4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE FloatRawDataTest
6 #include <boost/test/unit_test.hpp>
7 using namespace boost::unit_test_framework;
18 d.
open(
"(dummy?map=floatRawTest.map)");
21 auto scalarInfo = registerCatalogue.
getRegister(
"FLOAT_TEST/SCALAR");
23 BOOST_CHECK_EQUAL(scalarInfo.getRegisterName(),
"FLOAT_TEST/SCALAR");
24 BOOST_CHECK_EQUAL(scalarInfo.getNumberOfElements(), 1);
25 BOOST_CHECK_EQUAL(scalarInfo.getNumberOfChannels(), 1);
26 BOOST_CHECK_EQUAL(scalarInfo.getNumberOfDimensions(), 0);
27 BOOST_CHECK(scalarInfo.isReadable());
28 BOOST_CHECK(scalarInfo.isWriteable());
30 BOOST_CHECK(scalarInfo.getSupportedAccessModes() ==
AccessModeFlags({AccessMode::raw}));
32 auto dataDescriptor = scalarInfo.getDataDescriptor();
33 BOOST_CHECK(dataDescriptor.fundamentalType() == DataDescriptor::FundamentalType::numeric);
34 BOOST_CHECK(dataDescriptor.isSigned());
35 BOOST_CHECK(dataDescriptor.isIntegral() ==
false);
36 BOOST_CHECK_EQUAL(dataDescriptor.nDigits(), 48);
37 BOOST_CHECK_EQUAL(dataDescriptor.nFractionalDigits(), 45);
38 BOOST_CHECK_EQUAL(dataDescriptor.rawDataType(), DataType::int32);
40 BOOST_CHECK_EQUAL(dataDescriptor.transportLayerDataType(), DataType::none);
45 d.
open(
"(dummy?map=floatRawTest.map)");
53 rawIntAccessor = 0x40700000;
54 rawIntAccessor.write();
58 BOOST_CHECK_CLOSE(
float(floatAccessor), 3.75, 0.0001);
61 doubleAccessor.read();
62 BOOST_CHECK_CLOSE(
double(doubleAccessor), 3.75, 0.0001);
66 BOOST_CHECK_EQUAL(int32_t(intAccessor), 4);
69 stringAccessor.read();
70 BOOST_CHECK_EQUAL(std::string(stringAccessor),
std::to_string(3.75));
74 BOOST_CHECK_EQUAL(int32_t(rawAccessor), 0x40700000);
75 BOOST_CHECK_CLOSE(rawAccessor.getAsCooked<
float>(), 3.75, 0.0001);
79 void* warningAvoider = &rawValue;
80 float testValue = *(
reinterpret_cast<float*
>(warningAvoider));
82 BOOST_CHECK_CLOSE(testValue, expectedValue, 0.0001);
87 d.
open(
"(dummy?map=floatRawTest.map)");
90 floatAccessor[0] = 1.23;
91 floatAccessor[1] = 2.23;
92 floatAccessor[2] = 3.23;
93 floatAccessor[3] = 4.23;
94 floatAccessor.write();
97 rawIntAccessor.read();
104 doubleAccessor[0] = 11.23;
105 doubleAccessor[1] = 22.23;
106 doubleAccessor[2] = 33.23;
107 doubleAccessor[3] = 44.23;
108 doubleAccessor.write();
110 rawIntAccessor.read();
123 rawIntAccessor.read();
130 stringAccessor[0] =
"17.4";
131 stringAccessor[1] =
"17.5";
132 stringAccessor[2] =
"17.6";
133 stringAccessor[3] =
"17.7";
134 stringAccessor.write();
136 rawIntAccessor.read();