@@ -50,38 +50,25 @@ class BitsFxTest : public LIBC_NAMESPACE::testing::Test {
5050 func (negative_zero_point_six_eight_seven_five_t ));
5151
5252 if constexpr (FXRep::INTEGRAL_LEN > 0 ) {
53- if (static_cast <int >(max) >= 11 )
54- switch (FXRep::FRACTION_LEN) {
55- case 7 :
56- EXPECT_EQ (static_cast <XType>(1372 ), func (special_num_t ));
57- break ;
58- case 15 :
59- EXPECT_EQ (static_cast <XType>(351232 ), func (special_num_t ));
60- break ;
61- case 23 :
62- EXPECT_EQ (static_cast <XType>(89915392 ), func (special_num_t ));
63- break ;
64- default :
65- break ;
66- }
67- }
53+ constexpr size_t kMinFbits = 7 ;
54+
55+ if (max >= 11 && FXRep::FRACTION_LEN >= kMinFbits ) {
56+ // (10.71875)_10 = (1010.1011100)_2
57+ constexpr long long kExpected = 1372 ;
58+ EXPECT_EQ (
59+ static_cast <XType>(kExpected << (FXRep::FRACTION_LEN - kMinFbits )),
60+ func (special_num_t ));
61+ }
6862
69- if constexpr (FXRep::SIGN_LEN > 0 && FXRep::INTEGRAL_LEN > 0 ) {
70- if (static_cast <int >(min) <= -11 )
71- switch (FXRep::FRACTION_LEN) {
72- case 7 :
73- EXPECT_EQ (static_cast <XType>(-1372 ), func (negative_special_num_t ));
74- break ;
75- case 15 :
76- EXPECT_EQ (static_cast <XType>(-351232 ), func (negative_special_num_t ));
77- break ;
78- case 23 :
79- EXPECT_EQ (static_cast <XType>(-89915392 ),
63+ if constexpr (FXRep::SIGN_LEN > 0 ) {
64+ if (min <= -11 && FXRep::FRACTION_LEN >= kMinFbits ) {
65+ // (-10.71875)_10 = (-1010.1011100)_2
66+ constexpr long long kExpected = -1372 ;
67+ EXPECT_EQ (static_cast <XType>(kExpected
68+ << (FXRep::FRACTION_LEN - kMinFbits )),
8069 func (negative_special_num_t ));
81- break ;
82- default :
83- break ;
8470 }
71+ }
8572 }
8673 }
8774};
0 commit comments