-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
199f299
commit a4fca2f
Showing
3 changed files
with
53 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! Test that CUIDs are of a predictable length | ||
use cuid; | ||
|
||
use std::collections::HashSet; | ||
|
||
#[test] | ||
fn check_cuid_length() { | ||
let mut set = HashSet::new(); | ||
for _ in 0..100000 { | ||
let id = cuid::cuid().unwrap(); | ||
set.insert(id); | ||
} | ||
// all CUIDs are of the same length | ||
// NOTE: this will start failing in ~2059, at which poit this will need to | ||
// be updated to 26 | ||
assert!(set.iter().all(|i| i.len() == 25)); | ||
} | ||
|
||
#[test] | ||
fn check_cuid_slug_length() { | ||
let mut set = HashSet::new(); | ||
for _ in 0..100000 { | ||
let id = cuid::slug().unwrap(); | ||
set.insert(id); | ||
} | ||
// all slugs are of the same length | ||
// NOTE: this will start failing in ~2059, at which poit this will need to | ||
// be updated to 26 | ||
assert!(set.iter().all(|i| i.len() == 10)); | ||
} |