@@ -19,3 +19,44 @@ fn is_null() {
19
19
assert ! ( gix_hash:: Kind :: Sha1 . null( ) . is_null( ) ) ;
20
20
assert ! ( gix_hash:: Kind :: Sha1 . null( ) . as_ref( ) . is_null( ) ) ;
21
21
}
22
+
23
+ #[ test]
24
+ fn is_empty_blob ( ) {
25
+ // Test with ObjectId::empty_blob
26
+ let empty_blob = gix_hash:: ObjectId :: empty_blob ( gix_hash:: Kind :: Sha1 ) ;
27
+ assert ! ( empty_blob. is_empty_blob( ) ) ;
28
+ assert ! ( empty_blob. as_ref( ) . is_empty_blob( ) ) ;
29
+
30
+ // Test that non-empty blob hash returns false
31
+ let non_empty = gix_hash:: Kind :: Sha1 . null ( ) ;
32
+ assert ! ( !non_empty. is_empty_blob( ) ) ;
33
+ assert ! ( !non_empty. as_ref( ) . is_empty_blob( ) ) ;
34
+ }
35
+
36
+ #[ test]
37
+ fn is_empty_tree ( ) {
38
+ // Test with ObjectId::empty_tree
39
+ let empty_tree = gix_hash:: ObjectId :: empty_tree ( gix_hash:: Kind :: Sha1 ) ;
40
+ assert ! ( empty_tree. is_empty_tree( ) ) ;
41
+ assert ! ( empty_tree. as_ref( ) . is_empty_tree( ) ) ;
42
+
43
+ // Test that non-empty tree hash returns false
44
+ let non_empty = gix_hash:: Kind :: Sha1 . null ( ) ;
45
+ assert ! ( !non_empty. is_empty_tree( ) ) ;
46
+ assert ! ( !non_empty. as_ref( ) . is_empty_tree( ) ) ;
47
+ }
48
+
49
+ #[ test]
50
+ fn oid_methods_are_consistent_with_objectid ( ) {
51
+ // Verify that the oid methods return the same results as ObjectId methods
52
+ let empty_blob = gix_hash:: ObjectId :: empty_blob ( gix_hash:: Kind :: Sha1 ) ;
53
+ let empty_tree = gix_hash:: ObjectId :: empty_tree ( gix_hash:: Kind :: Sha1 ) ;
54
+
55
+ // Check that ObjectId and oid versions give same results
56
+ assert_eq ! ( empty_blob. is_empty_blob( ) , empty_blob. as_ref( ) . is_empty_blob( ) ) ;
57
+ assert_eq ! ( empty_tree. is_empty_tree( ) , empty_tree. as_ref( ) . is_empty_tree( ) ) ;
58
+
59
+ // Check cross-validation (empty blob is not empty tree and vice versa)
60
+ assert ! ( !empty_blob. as_ref( ) . is_empty_tree( ) ) ;
61
+ assert ! ( !empty_tree. as_ref( ) . is_empty_blob( ) ) ;
62
+ }
0 commit comments