feat: Add hash term function

This commit is contained in:
2023-10-25 22:20:43 +02:00
parent ad2af90692
commit 1589fdb6b1
4 changed files with 84 additions and 12 deletions

View File

@@ -78,6 +78,24 @@ mod tests {
assert_eq!(terms["hel"].len(), 1);
}
#[test]
fn test_hash_name(){
let search = Rustysearch::new("/tmp/rustysearch_hashname");
search.setup();
let hash = search.hash_name("hello", 6);
assert_eq!(hash, "5d4140");
}
#[test]
fn test_make_segment_name(){
let search = Rustysearch::new("/tmp/rustysearch_makesegmentname");
search.setup();
let segment_name = search.make_segment_name("hello");
assert_eq!(segment_name, "/tmp/rustysearch_makesegmentname/index/5d4140.index");
}
// Helper function to clean up the stats file
fn clean_stats(tmp_path: &str){
let search = Rustysearch::new(tmp_path);