Skip to content

Commit

Permalink
Use deterministic Uuids in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ab22593k committed Jan 13, 2025
1 parent 818e55a commit ad9f15b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/non_nil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl From<NonNilUuid> for Uuid {
/// ```
/// use uuid::{non_nil::NonNilUuid, Uuid};
///
/// let uuid = Uuid::new_v4();
/// let uuid = Uuid::from_u128(0x0123456789abcdef0123456789abcdef);
/// let non_nil = NonNilUuid::from(uuid);
/// let uuid_again = Uuid::from(non_nil);
///
Expand All @@ -46,7 +46,7 @@ impl From<Uuid> for NonNilUuid {
/// ```
/// use uuid::{non_nil::NonNilUuid, Uuid};
///
/// let uuid = Uuid::new_v4();
/// let uuid = Uuid::from_u128(0x0123456789abcdef0123456789abcdef);
/// let non_nil = NonNilUuid::from(uuid);
/// ```
fn from(uuid: Uuid) -> Self {
Expand All @@ -70,15 +70,15 @@ mod tests {

#[test]
fn test_new_with_non_nil() {
let uuid = Uuid::new_v4();
let uuid = Uuid::from_u128(0x0123456789abcdef0123456789abcdef);
let nn_uuid = NonNilUuid::from(uuid);
assert_eq!(Uuid::from(nn_uuid), uuid);
}

#[test]
#[should_panic(expected = "Attempted to convert nil Uuid to NonNilUuid")]
fn test_new_with_nil() {
let nil_uuid = Uuid::nil();
let nil_uuid = Uuid::from_u128(0x0);
let _ = NonNilUuid::from(nil_uuid);
}
}

0 comments on commit ad9f15b

Please sign in to comment.