Skip to content

Commit

Permalink
Fix formatting in FloatUtilTest and BitStreamReader
Browse files Browse the repository at this point in the history
  • Loading branch information
mikir committed Jan 2, 2024
1 parent 77ed6a9 commit 9693f66
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace zserio

namespace
{

// max size calculated to prevent overflows in internal comparisons
const size_t MAX_BUFFER_SIZE = std::numeric_limits<size_t>::max() / 8 - 4;

Expand Down Expand Up @@ -343,6 +344,7 @@ inline uint64_t readBits64Impl(ReaderContext& ctx, uint8_t numBits)
return value;
}
#endif

} // namespace

BitStreamReader::ReaderContext::ReaderContext(Span<const uint8_t> readBuffer, size_t readBufferBitSize) :
Expand Down
41 changes: 24 additions & 17 deletions compiler/extensions/cpp/runtime/test/zserio/FloatUtilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,33 @@ class FloatUtilTest : public ::testing::Test
};

const std::array<FloatUtilTest::TestFloat32Element, 8> FloatUtilTest::TEST_FLOAT32_DATA = {
TestFloat32Element{0, 0, UINT32_C(0), 0.0F}, //
TestFloat32Element{1, 0, UINT32_C(0), -0.0F}, //
TestFloat32Element{0, 127, UINT32_C(0), +1.0F}, //
TestFloat32Element{1, 127, UINT32_C(0), -1.0F}, //
TestFloat32Element{0, 128, UINT32_C(0x600000), 3.5F}, // 2^1 (1 + 2^-1 + 2^-2)
TestFloat32Element{0, 126, UINT32_C(0x600000), 0.875F}, // 2^-1 (1 + 2^-1 + 2^-2)
TestFloat32Element{0, 130, UINT32_C(0x1E0000), 9.875F}, // 2^3 (1 + 2^-3 + 2^-4 + 2^-5 + 2^-6)
TestFloat32Element{0, 126, UINT32_C(0x1E0000), 0.6171875F} // 2^-3 (1 + 2^-3 + 2^-4 + 2^-5 + 2^-6)
TestFloat32Element{0, 0, UINT32_C(0), 0.0F},
TestFloat32Element{1, 0, UINT32_C(0), -0.0F},
TestFloat32Element{0, 127, UINT32_C(0), +1.0F},
TestFloat32Element{1, 127, UINT32_C(0), -1.0F},
// 2^1 (1 + 2^-1 + 2^-2)
TestFloat32Element{0, 128, UINT32_C(0x600000), 3.5F},
// 2^-1 (1 + 2^-1 + 2^-2)
TestFloat32Element{0, 126, UINT32_C(0x600000), 0.875F},
// 2^3 (1 + 2^-3 + 2^-4 + 2^-5 + 2^-6)
TestFloat32Element{0, 130, UINT32_C(0x1E0000), 9.875F},
// 2^-3 (1 + 2^-3 + 2^-4 + 2^-5 + 2^-6)
TestFloat32Element{0, 126, UINT32_C(0x1E0000), 0.6171875F},
};

const std::array<FloatUtilTest::TestFloat64Element, 8> FloatUtilTest::TEST_FLOAT64_DATA = {
TestFloat64Element{0, 0, UINT64_C(0), 0.0}, //
TestFloat64Element{1, 0, UINT64_C(0), -0.0}, //
TestFloat64Element{0, 1023, UINT64_C(0), +1.0}, //
TestFloat64Element{1, 1023, UINT64_C(0), -1.0}, //
TestFloat64Element{0, 1024, UINT64_C(0xC000000000000), 3.5}, // 2^1 (1 + 2^-1 + 2^-2)
TestFloat64Element{0, 1022, UINT64_C(0xC000000000000), 0.875}, // 2^-1 (1 + 2^-1 + 2^-2)
TestFloat64Element{0, 1026, UINT64_C(0x3C00000000000), 9.875}, // 2^3 (1 + 2^-3 + 2^-4 + 2^-5 + 2^-6)
TestFloat64Element{
0, 1022, UINT64_C(0x3C00000000000), 0.6171875} // 2^-3 (1 + 2^-3 + 2^-4 + 2^-5 + 2^-6)
TestFloat64Element{0, 0, UINT64_C(0), 0.0},
TestFloat64Element{1, 0, UINT64_C(0), -0.0},
TestFloat64Element{0, 1023, UINT64_C(0), +1.0},
TestFloat64Element{1, 1023, UINT64_C(0), -1.0},
// 2^1 (1 + 2^-1 + 2^-2)
TestFloat64Element{0, 1024, UINT64_C(0xC000000000000), 3.5},
// 2^-1 (1 + 2^-1 + 2^-2)
TestFloat64Element{0, 1022, UINT64_C(0xC000000000000), 0.875},
// 2^3 (1 + 2^-3 + 2^-4 + 2^-5 + 2^-6)
TestFloat64Element{0, 1026, UINT64_C(0x3C00000000000), 9.875},
// 2^-3 (1 + 2^-3 + 2^-4 + 2^-5 + 2^-6)
TestFloat64Element{0, 1022, UINT64_C(0x3C00000000000), 0.6171875},
};

const uint16_t FloatUtilTest::FLOAT16_SIGN_BIT_POSITION = UINT16_C(15);
Expand Down

0 comments on commit 9693f66

Please sign in to comment.