@@ -5,6 +5,7 @@ pub fn hash(input: &Vec<u8>) -> String {
55 xxh3_64 ( & input) . to_string ( )
66}
77
8+ // Converts the manifest to a string, and then hashes it
89pub fn hash_manifest ( input : & Vec < ( String , String , bool ) > ) -> String {
910 // Not a true hash. Just a temporary place to dump data, which can then be hashed
1011 let mut current_hash = "" . to_string ( ) ;
@@ -28,4 +29,34 @@ mod tests {
2829 let result = hash ( & vec ! [ 1 , 2 , 3 ] ) ;
2930 assert_eq ! ( result, "16991689376074199867" ) ;
3031 }
32+
33+ #[ test]
34+ fn hash_empty_vec ( ) {
35+ let result = hash ( & vec ! [ ] ) ;
36+ assert_eq ! ( result, "3244421341483603138" ) ;
37+ }
38+
39+ #[ test]
40+ fn hash_manifest_stable ( ) {
41+ let manifest = vec ! [
42+ ( "file1.txt" . to_string( ) , "hash1" . to_string( ) , false ) ,
43+ ( "file2.txt" . to_string( ) , "hash2" . to_string( ) , true ) ,
44+ ] ;
45+ let result = hash_manifest ( & manifest) ;
46+ assert_eq ! ( result, "1259801786371591190" ) ;
47+ }
48+
49+ #[ test]
50+ fn hash_manifest_empty ( ) {
51+ let manifest: Vec < ( String , String , bool ) > = vec ! [ ] ;
52+ let result = hash_manifest ( & manifest) ;
53+ assert_eq ! ( result, "3244421341483603138" ) ;
54+ }
55+
56+ #[ test]
57+ fn hash_manifest_single_entry ( ) {
58+ let manifest = vec ! [ ( "main.rs" . to_string( ) , "abc123" . to_string( ) , true ) ] ;
59+ let result = hash_manifest ( & manifest) ;
60+ assert_eq ! ( result, "9815591975043689442" ) ;
61+ }
3162}
0 commit comments