@@ -136,6 +136,83 @@ macro_rules! impl_binary_checked_op_test {
136136 } ;
137137}
138138
139+ #[ macro_export]
140+ macro_rules! impl_common_integer_tests {
141+ { $vector: ident, $scalar: ident } => {
142+ test_helpers:: test_lanes! {
143+ fn wrapping_sum<const LANES : usize >( ) {
144+ test_helpers:: test_1( & |x| {
145+ test_helpers:: prop_assert_biteq! (
146+ $vector:: <LANES >:: from_array( x) . wrapping_sum( ) ,
147+ x. iter( ) . copied( ) . fold( 0 as $scalar, $scalar:: wrapping_add) ,
148+ ) ;
149+ Ok ( ( ) )
150+ } ) ;
151+ }
152+
153+ fn wrapping_product<const LANES : usize >( ) {
154+ test_helpers:: test_1( & |x| {
155+ test_helpers:: prop_assert_biteq! (
156+ $vector:: <LANES >:: from_array( x) . wrapping_product( ) ,
157+ x. iter( ) . copied( ) . fold( 1 as $scalar, $scalar:: wrapping_mul) ,
158+ ) ;
159+ Ok ( ( ) )
160+ } ) ;
161+ }
162+
163+ fn and_lanes<const LANES : usize >( ) {
164+ test_helpers:: test_1( & |x| {
165+ test_helpers:: prop_assert_biteq! (
166+ $vector:: <LANES >:: from_array( x) . and_lanes( ) ,
167+ x. iter( ) . copied( ) . fold( -1i8 as $scalar, <$scalar as core:: ops:: BitAnd >:: bitand) ,
168+ ) ;
169+ Ok ( ( ) )
170+ } ) ;
171+ }
172+
173+ fn or_lanes<const LANES : usize >( ) {
174+ test_helpers:: test_1( & |x| {
175+ test_helpers:: prop_assert_biteq! (
176+ $vector:: <LANES >:: from_array( x) . or_lanes( ) ,
177+ x. iter( ) . copied( ) . fold( 0 as $scalar, <$scalar as core:: ops:: BitOr >:: bitor) ,
178+ ) ;
179+ Ok ( ( ) )
180+ } ) ;
181+ }
182+
183+ fn xor_lanes<const LANES : usize >( ) {
184+ test_helpers:: test_1( & |x| {
185+ test_helpers:: prop_assert_biteq! (
186+ $vector:: <LANES >:: from_array( x) . xor_lanes( ) ,
187+ x. iter( ) . copied( ) . fold( 0 as $scalar, <$scalar as core:: ops:: BitXor >:: bitxor) ,
188+ ) ;
189+ Ok ( ( ) )
190+ } ) ;
191+ }
192+
193+ fn max_lane<const LANES : usize >( ) {
194+ test_helpers:: test_1( & |x| {
195+ test_helpers:: prop_assert_biteq! (
196+ $vector:: <LANES >:: from_array( x) . max_lane( ) ,
197+ x. iter( ) . copied( ) . max( ) . unwrap( ) ,
198+ ) ;
199+ Ok ( ( ) )
200+ } ) ;
201+ }
202+
203+ fn min_lane<const LANES : usize >( ) {
204+ test_helpers:: test_1( & |x| {
205+ test_helpers:: prop_assert_biteq! (
206+ $vector:: <LANES >:: from_array( x) . min_lane( ) ,
207+ x. iter( ) . copied( ) . min( ) . unwrap( ) ,
208+ ) ;
209+ Ok ( ( ) )
210+ } ) ;
211+ }
212+ }
213+ }
214+ }
215+
139216/// Implement tests for signed integers.
140217#[ macro_export]
141218macro_rules! impl_signed_tests {
@@ -144,6 +221,8 @@ macro_rules! impl_signed_tests {
144221 type Vector <const LANES : usize > = core_simd:: $vector<LANES >;
145222 type Scalar = $scalar;
146223
224+ impl_common_integer_tests! { Vector , Scalar }
225+
147226 test_helpers:: test_lanes! {
148227 fn neg<const LANES : usize >( ) {
149228 test_helpers:: test_unary_elementwise(
@@ -241,6 +320,8 @@ macro_rules! impl_unsigned_tests {
241320 type Vector <const LANES : usize > = core_simd:: $vector<LANES >;
242321 type Scalar = $scalar;
243322
323+ impl_common_integer_tests! { Vector , Scalar }
324+
244325 test_helpers:: test_lanes_panic! {
245326 fn rem_zero_panic<const LANES : usize >( ) {
246327 let a = Vector :: <LANES >:: splat( 42 ) ;
@@ -397,6 +478,46 @@ macro_rules! impl_float_tests {
397478 } ,
398479 ) . unwrap( ) ;
399480 }
481+
482+ fn sum<const LANES : usize >( ) {
483+ test_helpers:: test_1( & |x| {
484+ test_helpers:: prop_assert_biteq! (
485+ Vector :: <LANES >:: from_array( x) . sum( ) ,
486+ x. iter( ) . copied( ) . fold( 0 as Scalar , <Scalar as core:: ops:: Add >:: add) ,
487+ ) ;
488+ Ok ( ( ) )
489+ } ) ;
490+ }
491+
492+ fn product<const LANES : usize >( ) {
493+ test_helpers:: test_1( & |x| {
494+ test_helpers:: prop_assert_biteq! (
495+ Vector :: <LANES >:: from_array( x) . product( ) ,
496+ x. iter( ) . copied( ) . fold( 1. as Scalar , <Scalar as core:: ops:: Mul >:: mul) ,
497+ ) ;
498+ Ok ( ( ) )
499+ } ) ;
500+ }
501+
502+ fn max_lane<const LANES : usize >( ) {
503+ test_helpers:: test_1( & |x| {
504+ test_helpers:: prop_assert_biteq! (
505+ Vector :: <LANES >:: from_array( x) . max_lane( ) ,
506+ x. iter( ) . copied( ) . fold( Scalar :: NAN , Scalar :: max) ,
507+ ) ;
508+ Ok ( ( ) )
509+ } ) ;
510+ }
511+
512+ fn min_lane<const LANES : usize >( ) {
513+ test_helpers:: test_1( & |x| {
514+ test_helpers:: prop_assert_biteq! (
515+ Vector :: <LANES >:: from_array( x) . min_lane( ) ,
516+ x. iter( ) . copied( ) . fold( Scalar :: NAN , Scalar :: min) ,
517+ ) ;
518+ Ok ( ( ) )
519+ } ) ;
520+ }
400521 }
401522 }
402523 }
0 commit comments