mirror of
https://github.com/storytold/designcraft.git
synced 2026-12-03 20:44:01 -05:00
address review: make the suggestion length-cap test deterministic
This commit is contained in:
1 parent
bdd3c50d5a
commit
6ac6637726
1 file changed
+6
-5
@@ -337,11 +337,12 @@ mod tests {
|
||||
/// fifty copies of it per character.
|
||||
#[test]
|
||||
fn very_long_words_get_no_suggestions() {
|
||||
let d = Dictionary::en_us();
|
||||
let long = "a".repeat(MAX_SUGGEST_CHARS + 1);
|
||||
let t = std::time::Instant::now();
|
||||
assert!(suggest(d, &long).is_empty());
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(1));
|
||||
// The dictionary holds the longest allowed word, so deleting one letter of the 41-letter
|
||||
// input would be a hit if the length cap were not applied.
|
||||
let d = Dictionary::from_entries(vec![("a".repeat(MAX_SUGGEST_CHARS), 0)]);
|
||||
assert_eq!(suggest(&d, &"a".repeat(MAX_SUGGEST_CHARS)), Vec::<String>::new());
|
||||
assert_eq!(suggest(&d, &"a".repeat(MAX_SUGGEST_CHARS - 1)), vec!["a".repeat(MAX_SUGGEST_CHARS)]);
|
||||
assert!(suggest(&d, &"a".repeat(MAX_SUGGEST_CHARS + 1)).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user