File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,24 @@ fn test_iterator_step_by() {
161161 assert_eq ! ( it. next( ) , None ) ;
162162}
163163
164+ #[ test]
165+ fn test_iterator_step_by_nth ( ) {
166+ let mut it = ( 0 ..16 ) . step_by ( 5 ) ;
167+ assert_eq ! ( it. nth( 0 ) , Some ( 0 ) ) ;
168+ assert_eq ! ( it. nth( 0 ) , Some ( 5 ) ) ;
169+ assert_eq ! ( it. nth( 0 ) , Some ( 10 ) ) ;
170+ assert_eq ! ( it. nth( 0 ) , Some ( 15 ) ) ;
171+ assert_eq ! ( it. nth( 0 ) , None ) ;
172+
173+ let it = ( 0 ..18 ) . step_by ( 5 ) ;
174+ assert_eq ! ( it. clone( ) . nth( 0 ) , Some ( 0 ) ) ;
175+ assert_eq ! ( it. clone( ) . nth( 1 ) , Some ( 5 ) ) ;
176+ assert_eq ! ( it. clone( ) . nth( 2 ) , Some ( 10 ) ) ;
177+ assert_eq ! ( it. clone( ) . nth( 3 ) , Some ( 15 ) ) ;
178+ assert_eq ! ( it. clone( ) . nth( 4 ) , None ) ;
179+ assert_eq ! ( it. clone( ) . nth( 42 ) , None ) ;
180+ }
181+
164182#[ test]
165183#[ should_panic]
166184fn test_iterator_step_by_zero ( ) {
You can’t perform that action at this time.
0 commit comments