diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
commit | 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch) | |
tree | bdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/toml/tests/testsuite/spanned_impls.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff) | |
download | rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip |
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/toml/tests/testsuite/spanned_impls.rs')
-rw-r--r-- | vendor/toml/tests/testsuite/spanned_impls.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vendor/toml/tests/testsuite/spanned_impls.rs b/vendor/toml/tests/testsuite/spanned_impls.rs new file mode 100644 index 000000000..5e866f92a --- /dev/null +++ b/vendor/toml/tests/testsuite/spanned_impls.rs @@ -0,0 +1,41 @@ +use std::cmp::{Ord, Ordering, PartialOrd}; + +use serde::Deserialize; +use toml::{from_str, Spanned}; + +#[test] +fn test_spans_impls() { + #[derive(Deserialize)] + struct Foo { + bar: Spanned<bool>, + baz: Spanned<String>, + } + let f: Foo = from_str( + " + bar = true + baz = \"yes\" + ", + ) + .unwrap(); + let g: Foo = from_str( + " + baz = \"yes\" + bar = true + ", + ) + .unwrap(); + assert!(f.bar.span() != g.bar.span()); + assert!(f.baz.span() != g.baz.span()); + + // test that eq still holds + assert_eq!(f.bar, g.bar); + assert_eq!(f.baz, g.baz); + + // test that Ord returns equal order + assert_eq!(f.bar.cmp(&g.bar), Ordering::Equal); + assert_eq!(f.baz.cmp(&g.baz), Ordering::Equal); + + // test that PartialOrd returns equal order + assert_eq!(f.bar.partial_cmp(&g.bar), Some(Ordering::Equal)); + assert_eq!(f.baz.partial_cmp(&g.baz), Some(Ordering::Equal)); +} |