@@ -81,6 +81,46 @@ fn test_binary_search_implementation_details() {
8181 assert_eq ! ( b. binary_search( & 3 ) , Ok ( 8 ) ) ;
8282}
8383
84+ #[ test]
85+ fn test_partition_point ( ) {
86+ let b: [ i32 ; 0 ] = [ ] ;
87+ assert_eq ! ( b. partition_point( |& x| x < 5 ) , 0 ) ;
88+
89+ let b = [ 4 ] ;
90+ assert_eq ! ( b. partition_point( |& x| x < 3 ) , 0 ) ;
91+ assert_eq ! ( b. partition_point( |& x| x < 4 ) , 0 ) ;
92+ assert_eq ! ( b. partition_point( |& x| x < 5 ) , 1 ) ;
93+
94+ let b = [ 1 , 2 , 4 , 6 , 8 , 9 ] ;
95+ assert_eq ! ( b. partition_point( |& x| x < 5 ) , 3 ) ;
96+ assert_eq ! ( b. partition_point( |& x| x < 6 ) , 3 ) ;
97+ assert_eq ! ( b. partition_point( |& x| x < 7 ) , 4 ) ;
98+ assert_eq ! ( b. partition_point( |& x| x < 8 ) , 4 ) ;
99+
100+ let b = [ 1 , 2 , 4 , 5 , 6 , 8 ] ;
101+ assert_eq ! ( b. partition_point( |& x| x < 9 ) , 6 ) ;
102+
103+ let b = [ 1 , 2 , 4 , 6 , 7 , 8 , 9 ] ;
104+ assert_eq ! ( b. partition_point( |& x| x < 6 ) , 3 ) ;
105+ assert_eq ! ( b. partition_point( |& x| x < 5 ) , 3 ) ;
106+ assert_eq ! ( b. partition_point( |& x| x < 8 ) , 5 ) ;
107+
108+ let b = [ 1 , 2 , 4 , 5 , 6 , 8 , 9 ] ;
109+ assert_eq ! ( b. partition_point( |& x| x < 7 ) , 5 ) ;
110+ assert_eq ! ( b. partition_point( |& x| x < 0 ) , 0 ) ;
111+
112+ let b = [ 1 , 3 , 3 , 3 , 7 ] ;
113+ assert_eq ! ( b. partition_point( |& x| x < 0 ) , 0 ) ;
114+ assert_eq ! ( b. partition_point( |& x| x < 1 ) , 0 ) ;
115+ assert_eq ! ( b. partition_point( |& x| x < 2 ) , 1 ) ;
116+ assert_eq ! ( b. partition_point( |& x| x < 3 ) , 1 ) ;
117+ assert_eq ! ( b. partition_point( |& x| x < 4 ) , 4 ) ;
118+ assert_eq ! ( b. partition_point( |& x| x < 5 ) , 4 ) ;
119+ assert_eq ! ( b. partition_point( |& x| x < 6 ) , 4 ) ;
120+ assert_eq ! ( b. partition_point( |& x| x < 7 ) , 4 ) ;
121+ assert_eq ! ( b. partition_point( |& x| x < 8 ) , 5 ) ;
122+ }
123+
84124#[ test]
85125fn test_iterator_nth ( ) {
86126 let v: & [ _ ] = & [ 0 , 1 , 2 , 3 , 4 ] ;
0 commit comments