Skip to content

Commit

Permalink
add a test for sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Oct 8, 2022
1 parent 8df6494 commit 2e3245f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ mod tests {
assert_eq!(uuid.get_variant(), Variant::RFC4122);
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn test_sorting() {
let time1: u64 = 1_496_854_535;
let time_fraction1: u32 = 812_000_000;

let time2 = time1 + 4000;
let time_fraction2 = time_fraction1;

let uuid1 = Uuid::new_v7(Timestamp::from_unix(NoContext, time1, time_fraction1));
let uuid2 = Uuid::new_v7(Timestamp::from_unix(NoContext, time2, time_fraction2));

assert!(uuid1.as_bytes() < uuid2.as_bytes());
assert!(uuid1.to_string() < uuid2.to_string());
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn test_new_timestamp_roundtrip() {
Expand Down

0 comments on commit 2e3245f

Please sign in to comment.