@@ -4,21 +4,21 @@ use pipe_trait::Pipe;
44use pretty_assertions:: { assert_eq, assert_ne} ;
55
66const TABLE : & [ ( u64 , u64 , u64 , u64 , & str ) ] = & [
7- // dev, ino , size, links, path
8- ( 0 , 241 , 3652 , 1 , "a" ) ,
9- ( 0 , 569 , 2210 , 1 , "b" ) ,
10- ( 0 , 110 , 2350 , 3 , "c" ) ,
11- ( 0 , 110 , 2350 , 3 , "c1" ) ,
12- ( 0 , 778 , 1110 , 1 , "d" ) ,
13- ( 0 , 274 , 6060 , 2 , "e" ) ,
14- ( 0 , 274 , 6060 , 2 , "e1" ) ,
15- ( 0 , 883 , 4530 , 1 , "f" ) ,
7+ // ino, dev , size, links, path
8+ ( 241 , 0 , 3652 , 1 , "a" ) ,
9+ ( 569 , 0 , 2210 , 1 , "b" ) ,
10+ ( 110 , 0 , 2350 , 3 , "c" ) ,
11+ ( 110 , 0 , 2350 , 3 , "c1" ) ,
12+ ( 778 , 0 , 1110 , 1 , "d" ) ,
13+ ( 274 , 0 , 6060 , 2 , "e" ) ,
14+ ( 274 , 0 , 6060 , 2 , "e1" ) ,
15+ ( 883 , 0 , 4530 , 1 , "f" ) ,
1616] ;
1717
1818fn add < const ROW : usize > ( list : HardlinkList < Bytes > ) -> HardlinkList < Bytes > {
1919 let values = TABLE [ ROW ] ;
20- let ( dev , ino , size, links, path) = values;
21- if let Err ( error) = list. add ( ino. into ( ) , dev, size. into ( ) , links, path. as_ref ( ) ) {
20+ let ( ino , dev , size, links, path) = values;
21+ if let Err ( error) = list. add ( ino. into ( ) , dev. into ( ) , size. into ( ) , links, path. as_ref ( ) ) {
2222 panic ! ( "Failed to add {values:?} (index: {ROW}) to the list: {error}" ) ;
2323 }
2424 list
@@ -120,10 +120,10 @@ fn insertion_difference_cause_inequality() {
120120#[ test]
121121fn detect_size_change ( ) {
122122 let list = HardlinkList :: < Bytes > :: new ( ) ;
123- list. add ( 123 . into ( ) , 0 , 100 . into ( ) , 1 , "a" . as_ref ( ) )
123+ list. add ( 123 . into ( ) , 0 . into ( ) , 100 . into ( ) , 1 , "a" . as_ref ( ) )
124124 . expect ( "add the first path" ) ;
125125 let actual = list
126- . add ( 123 . into ( ) , 0 , 110 . into ( ) , 1 , "b" . as_ref ( ) )
126+ . add ( 123 . into ( ) , 0 . into ( ) , 110 . into ( ) , 1 , "b" . as_ref ( ) )
127127 . expect_err ( "add the second path" ) ;
128128 let expected = AddError :: SizeConflict ( SizeConflictError {
129129 ino : 123 . into ( ) ,
@@ -136,10 +136,10 @@ fn detect_size_change() {
136136#[ test]
137137fn detect_number_of_links_change ( ) {
138138 let list = HardlinkList :: < Bytes > :: new ( ) ;
139- list. add ( 123 . into ( ) , 0 , 100 . into ( ) , 1 , "a" . as_ref ( ) )
139+ list. add ( 123 . into ( ) , 0 . into ( ) , 100 . into ( ) , 1 , "a" . as_ref ( ) )
140140 . expect ( "add the first path" ) ;
141141 let actual = list
142- . add ( 123 . into ( ) , 0 , 100 . into ( ) , 2 , "b" . as_ref ( ) )
142+ . add ( 123 . into ( ) , 0 . into ( ) , 100 . into ( ) , 2 , "b" . as_ref ( ) )
143143 . expect_err ( "add the second path" ) ;
144144 let expected = AddError :: NumberOfLinksConflict ( NumberOfLinksConflictError {
145145 ino : 123 . into ( ) ,
@@ -159,29 +159,29 @@ fn same_ino_on_different_devices_are_treated_separately() {
159159 let list = HardlinkList :: < Bytes > :: new ( ) ;
160160
161161 // dev=1, ino=100 — first filesystem
162- list. add ( 100 . into ( ) , 1 , 50 . into ( ) , 2 , "dev1/file_a" . as_ref ( ) )
162+ list. add ( 100 . into ( ) , 1 . into ( ) , 50 . into ( ) , 2 , "dev1/file_a" . as_ref ( ) )
163163 . expect ( "add dev1/file_a" ) ;
164- list. add ( 100 . into ( ) , 1 , 50 . into ( ) , 2 , "dev1/file_b" . as_ref ( ) )
164+ list. add ( 100 . into ( ) , 1 . into ( ) , 50 . into ( ) , 2 , "dev1/file_b" . as_ref ( ) )
165165 . expect ( "add dev1/file_b (same dev+ino → same inode group)" ) ;
166166
167167 // dev=2, ino=100 — second filesystem, coincidentally same inode number
168- list. add ( 100 . into ( ) , 2 , 80 . into ( ) , 2 , "dev2/file_c" . as_ref ( ) )
168+ list. add ( 100 . into ( ) , 2 . into ( ) , 80 . into ( ) , 2 , "dev2/file_c" . as_ref ( ) )
169169 . expect ( "add dev2/file_c (different dev → separate inode group)" ) ;
170- list. add ( 100 . into ( ) , 2 , 80 . into ( ) , 2 , "dev2/file_d" . as_ref ( ) )
170+ list. add ( 100 . into ( ) , 2 . into ( ) , 80 . into ( ) , 2 , "dev2/file_d" . as_ref ( ) )
171171 . expect ( "add dev2/file_d (same dev+ino → same inode group as file_c)" ) ;
172172
173173 // Each device should produce its own entry, so the list should have 2 entries.
174- assert_eq ! ( list. len( ) , 2 , "expected one entry per (dev, ino ) pair" ) ;
174+ assert_eq ! ( list. len( ) , 2 , "expected one entry per (ino, dev ) pair" ) ;
175175
176176 let reflection = list. into_reflection ( ) ;
177177 assert_eq ! ( reflection. len( ) , 2 ) ;
178178
179179 // Sorted by (ino, dev), so dev=1 comes first.
180180 let entries: Vec < _ > = reflection. iter ( ) . collect ( ) ;
181- assert_eq ! ( entries[ 0 ] . dev, 1 ) ;
181+ assert_eq ! ( entries[ 0 ] . dev, 1 . into ( ) ) ;
182182 assert_eq ! ( entries[ 0 ] . ino, 100 . into( ) ) ;
183183 assert_eq ! ( entries[ 0 ] . paths. len( ) , 2 ) ;
184- assert_eq ! ( entries[ 1 ] . dev, 2 ) ;
184+ assert_eq ! ( entries[ 1 ] . dev, 2 . into ( ) ) ;
185185 assert_eq ! ( entries[ 1 ] . ino, 100 . into( ) ) ;
186186 assert_eq ! ( entries[ 1 ] . paths. len( ) , 2 ) ;
187187}
0 commit comments