3 class hextolfpTest : public lfptest {
6 TEST_F(hextolfpTest, PositiveInteger) {
7 const char *str = "00001000.00000000";
10 l_fp expected = {4096, 0}; // 16^3, no fraction part.
12 ASSERT_TRUE(hextolfp(str, &actual));
13 EXPECT_TRUE(IsEqual(expected, actual));
16 TEST_F(hextolfpTest, NegativeInteger) {
17 const char *str = "ffffffff.00000000"; // -1 decimal
20 l_fp expected = {-1, 0};
22 ASSERT_TRUE(hextolfp(str, &actual));
23 EXPECT_TRUE(IsEqual(expected, actual));
26 TEST_F(hextolfpTest, PositiveFraction) {
27 const char *str = "00002000.80000000"; // 8196.5 decimal
30 l_fp expected = {8192, HALF};
32 ASSERT_TRUE(hextolfp(str, &actual));
33 EXPECT_TRUE(IsEqual(expected, actual));
36 TEST_F(hextolfpTest, NegativeFraction) {
37 const char *str = "ffffffff.40000000"; // -1 + 0.25 decimal
40 l_fp expected = {-1, QUARTER}; //-1 + 0.25
42 ASSERT_TRUE(hextolfp(str, &actual));
43 EXPECT_TRUE(IsEqual(expected, actual));
46 TEST_F(hextolfpTest, IllegalNumberOfInteger) {
47 const char *str = "1000000.00000000"; // Missing one digit in integral part.
50 ASSERT_FALSE(hextolfp(str, &actual));
53 TEST_F(hextolfpTest, IllegalChar) {
54 const char *str = "10000000.0000h000"; // Illegal character h.
57 ASSERT_FALSE(hextolfp(str, &actual));