@@ -127,6 +127,52 @@ macro_rules! uint_module {
127127 assert_eq_const_safe!( $T: _1. swap_bytes( ) , _1) ;
128128 }
129129
130+ fn test_gather_bits( ) {
131+ assert_eq_const_safe!( $T: $T:: gather_bits( 0b1010_0101 , 0b0000_0011 ) , 0b_0001 ) ;
132+ assert_eq_const_safe!( $T: $T:: gather_bits( 0b1010_0101 , 0b0000_0110 ) , 0b_0010 ) ;
133+ assert_eq_const_safe!( $T: $T:: gather_bits( 0b1010_0101 , 0b0000_1100 ) , 0b_0001 ) ;
134+ assert_eq_const_safe!( $T: $T:: gather_bits( 0b1010_0101 , 0b0001_1000 ) , 0b_0000 ) ;
135+ assert_eq_const_safe!( $T: $T:: gather_bits( 0b1010_0101 , 0b0011_0000 ) , 0b_0010 ) ;
136+ assert_eq_const_safe!( $T: $T:: gather_bits( 0b1010_0101 , 0b0110_0000 ) , 0b_0001 ) ;
137+ assert_eq_const_safe!( $T: $T:: gather_bits( 0b1010_0101 , 0b1100_0000 ) , 0b_0010 ) ;
138+
139+ assert_eq_const_safe!( $T: A . gather_bits( _0) , 0 ) ;
140+ assert_eq_const_safe!( $T: B . gather_bits( _0) , 0 ) ;
141+ assert_eq_const_safe!( $T: C . gather_bits( _0) , 0 ) ;
142+ assert_eq_const_safe!( $T: _0. gather_bits( A ) , 0 ) ;
143+ assert_eq_const_safe!( $T: _0. gather_bits( B ) , 0 ) ;
144+ assert_eq_const_safe!( $T: _0. gather_bits( C ) , 0 ) ;
145+
146+ assert_eq_const_safe!( $T: A . gather_bits( _1) , A ) ;
147+ assert_eq_const_safe!( $T: B . gather_bits( _1) , B ) ;
148+ assert_eq_const_safe!( $T: C . gather_bits( _1) , C ) ;
149+ assert_eq_const_safe!( $T: _1. gather_bits( 0b0010_0001 ) , 0b0000_0011 ) ;
150+ assert_eq_const_safe!( $T: _1. gather_bits( 0b0010_1100 ) , 0b0000_0111 ) ;
151+ assert_eq_const_safe!( $T: _1. gather_bits( 0b0111_1001 ) , 0b0001_1111 ) ;
152+ }
153+
154+ fn test_scatter_bits( ) {
155+ assert_eq_const_safe!( $T: $T:: scatter_bits( 0b1111 , 0b1001_0110 ) , 0b1001_0110 ) ;
156+ assert_eq_const_safe!( $T: $T:: scatter_bits( 0b0001 , 0b1001_0110 ) , 0b0000_0010 ) ;
157+ assert_eq_const_safe!( $T: $T:: scatter_bits( 0b0010 , 0b1001_0110 ) , 0b0000_0100 ) ;
158+ assert_eq_const_safe!( $T: $T:: scatter_bits( 0b0100 , 0b1001_0110 ) , 0b0001_0000 ) ;
159+ assert_eq_const_safe!( $T: $T:: scatter_bits( 0b1000 , 0b1001_0110 ) , 0b1000_0000 ) ;
160+
161+ assert_eq_const_safe!( $T: A . scatter_bits( _0) , 0 ) ;
162+ assert_eq_const_safe!( $T: B . scatter_bits( _0) , 0 ) ;
163+ assert_eq_const_safe!( $T: C . scatter_bits( _0) , 0 ) ;
164+ assert_eq_const_safe!( $T: _0. scatter_bits( A ) , 0 ) ;
165+ assert_eq_const_safe!( $T: _0. scatter_bits( B ) , 0 ) ;
166+ assert_eq_const_safe!( $T: _0. scatter_bits( C ) , 0 ) ;
167+
168+ assert_eq_const_safe!( $T: A . scatter_bits( _1) , A ) ;
169+ assert_eq_const_safe!( $T: B . scatter_bits( _1) , B ) ;
170+ assert_eq_const_safe!( $T: C . scatter_bits( _1) , C ) ;
171+ assert_eq_const_safe!( $T: _1. scatter_bits( A ) , A ) ;
172+ assert_eq_const_safe!( $T: _1. scatter_bits( B ) , B ) ;
173+ assert_eq_const_safe!( $T: _1. scatter_bits( C ) , C ) ;
174+ }
175+
130176 fn test_reverse_bits( ) {
131177 assert_eq_const_safe!( $T: A . reverse_bits( ) . reverse_bits( ) , A ) ;
132178 assert_eq_const_safe!( $T: B . reverse_bits( ) . reverse_bits( ) , B ) ;
0 commit comments