Caught a bug where the order of entries to map::TrieBuilder exposed a bug. Namely a long entry like "apple" if it came before a shorter entry "app" then it would not be found.
#[test]
fn value_overwrite_long_first() {
let mut builder = TrieBuilder::new();
builder.push("apple", 2);
builder.push("app", 1);
let trie = builder.build();
assert_eq!(trie.exact_match("apple"), Some(2));
assert_eq!(trie.exact_match("app"), Some(1)); // This one fails.
}
#[test]
fn value_overwrite_short() {
let mut builder = TrieBuilder::new();
builder.push("app", 1);
builder.push("apple", 2);
let trie = builder.build();
assert_eq!(trie.exact_match("apple"), Some(2));
assert_eq!(trie.exact_match("app"), Some(1)); // This one is fine.
}
Caught a bug where the order of entries to
map::TrieBuilder
exposed a bug. Namely a long entry like "apple" if it came before a shorter entry "app" then it would not be found.