@@ -196,8 +196,8 @@ impl Dimensions {
196
196
let extended_rows = self . extended_rows ( ) ;
197
197
198
198
( start..end) . map ( move |cell| Position {
199
- row : cell % extended_rows,
200
- col : ( cell / extended_rows) as u16 ,
199
+ row : cell / extended_rows,
200
+ col : ( cell % extended_rows) as u16 ,
201
201
} )
202
202
}
203
203
}
@@ -209,6 +209,8 @@ mod tests {
209
209
210
210
use crate :: matrix:: { Dimensions , Position } ;
211
211
212
+ use super :: Partition ;
213
+
212
214
#[ test]
213
215
fn zero_dimensions ( ) {
214
216
assert ! ( Dimensions :: new( 0 , 0 ) . is_none( ) ) ;
@@ -243,4 +245,14 @@ mod tests {
243
245
. collect :: < Vec < _ > > ( ) ;
244
246
assert_eq ! ( cells, expected) ;
245
247
}
248
+
249
+ #[ test_case( 1 , 2 , & [ ( 0 , 0 ) , ( 0 , 1 ) ] ; "First partition" ) ]
250
+ #[ test_case( 2 , 2 , & [ ( 1 , 0 ) , ( 1 , 1 ) ] ; "Second partition" ) ]
251
+ fn iter_extended_partition_positions ( number : u8 , fraction : u8 , expected : & [ ( u32 , u16 ) ] ) {
252
+ Dimensions :: new ( 1 , 2 )
253
+ . unwrap ( )
254
+ . iter_extended_partition_positions ( & Partition { number, fraction } )
255
+ . zip ( expected. iter ( ) . map ( |& ( row, col) | Position { row, col } ) )
256
+ . for_each ( |( p1, p2) | assert ! ( p1 == p2) ) ;
257
+ }
246
258
}
0 commit comments