-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
39 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
// A small test to show that ordered-float does allow us to "do stuff" Eq-wise | ||
// with values when we opt for an Eq-compatible representation of floats. | ||
// Easiest way is simply to construct a type that derives Eq and include | ||
// simd Values in it, construct it, and compare it! This won't even compile | ||
// simd Values in it, construct it, and compare it! This won't even compile | ||
// if we have got it wrong | ||
#[cfg(feature = "ordered-float")] | ||
use simd_json::{BorrowedValue, OwnedValue}; | ||
|
||
#[cfg(feature = "ordered-float")] | ||
#[test] | ||
fn test_values_as_hashmap_keys() { | ||
#[derive(Eq, PartialEq, Debug)] | ||
struct AnEqType { | ||
owned_value: OwnedValue, | ||
borrowed_value: BorrowedValue<'static> | ||
} | ||
let an_eq_type = AnEqType { | ||
owned_value: OwnedValue::from("an-owned-value"), | ||
borrowed_value: BorrowedValue::from("a-borrowed-value") | ||
}; | ||
#[derive(Eq, PartialEq, Debug)] | ||
struct AnEqType { | ||
owned_value: OwnedValue, | ||
borrowed_value: BorrowedValue<'static>, | ||
} | ||
let an_eq_type = AnEqType { | ||
owned_value: OwnedValue::from("an-owned-value"), | ||
borrowed_value: BorrowedValue::from("a-borrowed-value"), | ||
}; | ||
|
||
assert_eq!(an_eq_type, AnEqType { | ||
owned_value: OwnedValue::from("an-owned-value"), | ||
borrowed_value: BorrowedValue::from("a-borrowed-value") | ||
}); | ||
} | ||
assert_eq!( | ||
an_eq_type, | ||
AnEqType { | ||
owned_value: OwnedValue::from("an-owned-value"), | ||
borrowed_value: BorrowedValue::from("a-borrowed-value") | ||
} | ||
); | ||
} |