Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Datetime with fractional times are not equal #179

Closed
alanhdu opened this issue May 30, 2017 · 0 comments
Closed

Datetime with fractional times are not equal #179

alanhdu opened this issue May 30, 2017 · 0 comments

Comments

@alanhdu
Copy link
Contributor

alanhdu commented May 30, 2017

When I deserialize 06:00:00.0 and 06:00:00 into toml datetimes, they do not compare equal.

Even more confusingly, their Debug implementations are identical, so running

[test]
fn test_datetime_fraction() {
    let a = "key = 06:00:00.0";
    let b = "key = 06:00:00";


    let x: toml::Value = toml::from_str(a).unwrap();
    let y: toml::Value = toml::from_str(b).unwrap();

    assert_eq!(x.get("key").unwrap(), y.get("key").unwrap());
}

outputs

assertion failed: `(left == right)` (left: `Datetime(06:00:00)`, right: `Datetime(06:00:00)`)

I feel like either toml::datetime::Time's secfract field should be required (and default 0 when missing), or None should be equal to Some(0.0).

Found with rust-fuzz/targets#72

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant