mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 07:50:04 +00:00
Float utility
This commit is contained in:
parent
711993362c
commit
3fc6837f2a
5 changed files with 132 additions and 3 deletions
50
test/source/scwx/util/float.test.cpp
Normal file
50
test/source/scwx/util/float.test.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include <scwx/util/float.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
TEST(FloatTest, Decode32Positive1)
|
||||
{
|
||||
uint16_t msw = 0x3f80;
|
||||
uint16_t lsw = 0x0000;
|
||||
|
||||
float x = DecodeFloat32(msw, lsw);
|
||||
|
||||
EXPECT_FLOAT_EQ(x, 1.0f);
|
||||
}
|
||||
|
||||
TEST(FloatTest, Decode32Negative1)
|
||||
{
|
||||
uint16_t msw = 0xbf80;
|
||||
uint16_t lsw = 0x0000;
|
||||
|
||||
float x = DecodeFloat32(msw, lsw);
|
||||
|
||||
EXPECT_FLOAT_EQ(x, -1.0f);
|
||||
}
|
||||
|
||||
TEST(FloatTest, Decode32Positive12345678)
|
||||
{
|
||||
uint16_t msw = 0x4b3c;
|
||||
uint16_t lsw = 0x614e;
|
||||
|
||||
float x = DecodeFloat32(msw, lsw);
|
||||
|
||||
EXPECT_FLOAT_EQ(x, 12345678.0f);
|
||||
}
|
||||
|
||||
TEST(FloatTest, Decode16h0x5bb4)
|
||||
{
|
||||
uint16_t hex = 0x5bb4;
|
||||
|
||||
float x = DecodeFloat16(hex);
|
||||
|
||||
EXPECT_FLOAT_EQ(x, 123.25f);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace scwx
|
||||
|
|
@ -15,7 +15,8 @@ set(SRC_AWIPS_TESTS source/scwx/awips/coded_location.test.cpp
|
|||
set(SRC_COMMON_TESTS source/scwx/common/color_table.test.cpp)
|
||||
set(SRC_QT_CONFIG_TESTS source/scwx/qt/config/radar_site.test.cpp)
|
||||
set(SRC_QT_MANAGER_TESTS source/scwx/qt/manager/settings_manager.test.cpp)
|
||||
set(SRC_UTIL_TESTS source/scwx/util/rangebuf.test.cpp
|
||||
set(SRC_UTIL_TESTS source/scwx/util/float.test.cpp
|
||||
source/scwx/util/rangebuf.test.cpp
|
||||
source/scwx/util/streams.test.cpp
|
||||
source/scwx/util/vectorbuf.test.cpp)
|
||||
set(SRC_WSR88D_TESTS source/scwx/wsr88d/ar2v_file.test.cpp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue