forked from mirrors/jj
repo: move test_id_index()
into a tests
module
This is the usual convention (to save on compilation time when not running tests).
This commit is contained in:
parent
d3789cb28d
commit
0f8622dd5c
1 changed files with 25 additions and 20 deletions
|
@ -1237,26 +1237,31 @@ impl IdIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[cfg(test)]
|
||||||
fn test_id_index() {
|
mod tests {
|
||||||
let mut id_index = IdIndex::new();
|
use super::*;
|
||||||
id_index.insert(b"ab", ());
|
|
||||||
id_index.insert(b"acd", ());
|
|
||||||
assert_eq!(id_index.shortest_unique_prefix_len(b"acd"), 2);
|
|
||||||
assert_eq!(id_index.shortest_unique_prefix_len(b"ac"), 3);
|
|
||||||
|
|
||||||
let mut id_index = IdIndex::new();
|
#[test]
|
||||||
id_index.insert(b"ab", ());
|
fn test_id_index() {
|
||||||
id_index.insert(b"acd", ());
|
let mut id_index = IdIndex::new();
|
||||||
id_index.insert(b"acf", ());
|
id_index.insert(b"ab", ());
|
||||||
id_index.insert(b"a", ());
|
id_index.insert(b"acd", ());
|
||||||
id_index.insert(b"ba", ());
|
assert_eq!(id_index.shortest_unique_prefix_len(b"acd"), 2);
|
||||||
|
assert_eq!(id_index.shortest_unique_prefix_len(b"ac"), 3);
|
||||||
|
|
||||||
assert_eq!(id_index.shortest_unique_prefix_len(b"a"), 2); // Unlikely for hashes case: the entire length of the key is an insufficient
|
let mut id_index = IdIndex::new();
|
||||||
// prefix
|
id_index.insert(b"ab", ());
|
||||||
assert_eq!(id_index.shortest_unique_prefix_len(b"ba"), 1);
|
id_index.insert(b"acd", ());
|
||||||
assert_eq!(id_index.shortest_unique_prefix_len(b"ab"), 2);
|
id_index.insert(b"acf", ());
|
||||||
assert_eq!(id_index.shortest_unique_prefix_len(b"acd"), 3);
|
id_index.insert(b"a", ());
|
||||||
// If it were there, the length would be 1.
|
id_index.insert(b"ba", ());
|
||||||
assert_eq!(id_index.shortest_unique_prefix_len(b"c"), 1);
|
|
||||||
|
assert_eq!(id_index.shortest_unique_prefix_len(b"a"), 2); // Unlikely for hashes case: the entire length of the key is an insufficient
|
||||||
|
// prefix
|
||||||
|
assert_eq!(id_index.shortest_unique_prefix_len(b"ba"), 1);
|
||||||
|
assert_eq!(id_index.shortest_unique_prefix_len(b"ab"), 2);
|
||||||
|
assert_eq!(id_index.shortest_unique_prefix_len(b"acd"), 3);
|
||||||
|
// If it were there, the length would be 1.
|
||||||
|
assert_eq!(id_index.shortest_unique_prefix_len(b"c"), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue