4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE LMapMathPluginTest
6 #include <boost/test/unit_test.hpp>
7 using namespace boost::unit_test_framework;
13 BOOST_AUTO_TEST_SUITE(LMapMathPluginTestSuite)
19 device.
open(
"(logicalNameMap?map=mathPlugin.xlmap)");
28 BOOST_CHECK_CLOSE(
double(accMathRead), 45. / 7. + 13., 0.00001);
33 BOOST_CHECK_CLOSE(
double(accMathRead), -666. / 7. + 13., 0.00001);
38 BOOST_CHECK_EQUAL(
int(accTarget), 24);
43 BOOST_CHECK_EQUAL(
int(accTarget), -7);
50 device.
open(
"(logicalNameMap?map=mathPlugin.xlmap)");
60 BOOST_CHECK_CLOSE(
double(accMathRead), 45. / 7. + 13., 0.00001);
65 BOOST_CHECK_CLOSE(
double(accMathRead), -666. / 7. + 13., 0.00001);
70 BOOST_CHECK_EQUAL(
int(accTarget), 24);
75 BOOST_CHECK_EQUAL(
int(accTarget), -7);
82 device.
open(
"(logicalNameMap?map=mathPlugin.xlmap)");
87 BOOST_CHECK_EQUAL(accMathRead.getNElements(), 6);
88 BOOST_CHECK_EQUAL(accMathWrite.getNElements(), 6);
90 accTarget = {11, 22, 33, 44, 55, 66};
93 for(
size_t i = 0; i < 6; ++i) BOOST_CHECK_CLOSE(
double(accMathRead[i]), accTarget[i] / 7. + 13., 0.00001);
95 accTarget = {-120, 123456, -18, 9999, -999999999, 0};
98 for(
size_t i = 0; i < 6; ++i) BOOST_CHECK_CLOSE(
double(accMathRead[i]), accTarget[i] / 7. + 13., 0.00001);
100 accMathWrite = {-120, 123456, -18, 9999, -999999999, 0};
101 accMathWrite.write();
103 for(
size_t i = 0; i < 6; ++i) BOOST_CHECK_EQUAL(
double(accTarget[i]), std::round(accMathWrite[i] / 7. + 13.));
105 accMathWrite = {0, 1, 2, 3, 4, 5};
106 accMathWrite.write();
108 for(
size_t i = 0; i < 6; ++i) BOOST_CHECK_EQUAL(
double(accTarget[i]), std::round(accMathWrite[i] / 7. + 13.));
115 device.
open(
"(logicalNameMap?map=mathPlugin.xlmap)");
127 arrayPar = {2, 3, 4, 5, 6, 7};
130 BOOST_CHECK_CLOSE(
double(accMathRead), 42. / 6. + (2 + 3 + 4 + 5 + 6 + 7), 0.00001);
134 arrayPar = {1, -1, 1, -1, 1, -1};
137 BOOST_CHECK_CLOSE(
double(accMathRead), 42. / 7., 0.00001);
140 accMathWrite.write();
142 BOOST_CHECK_EQUAL(
int(accTarget), 8);
146 accMathWrite.write();
148 BOOST_CHECK_EQUAL(
int(accTarget), 14);
162 BOOST_CHECK_THROW(
device.
open(
"(logicalNameMap?map=mathPlugin-broken2.xlmap)");
166 device.
open(
"(logicalNameMap?map=mathPlugin.xlmap)");
191 device.
open(
"(logicalNameMap?map=mathPlugin.xlmap)");
195 BOOST_TEST(
int(acc) == 24);
200 BOOST_AUTO_TEST_SUITE_END()