24 #include <cppunit/ui/text/TestRunner.h> 25 #include <cppunit/ui/text/TestRunner.h> 26 #include <cppunit/TextOutputter.h> 27 #include <cppunit/extensions/TestFactoryRegistry.h> 28 #include <cppunit/extensions/HelperMacros.h> 29 #include <cppunit/TestAssert.h> 32 #include <coil/TimeValue.h> 41 :
public CppUnit::TestFixture
99 typedef struct data_struct {
105 DATA_STRUCT datatable[] = {
107 { 3.5 , 3 , 500000 },
108 { 3.555555 , 3 , 555555 },
109 { 3.5999994 , 3 , 599999 },
110 { 3.5999995 , 3 , 600000 },
111 { 0.999999 , 0 , 999999 },
112 { 1.000000 , 1 , 0 },
113 { 1.000001 , 1 , 1 },
115 { -0.3 , 0 , -300000 },
124 for (ic=0; ic < (
sizeof datatable/
sizeof datatable[0]); ic++)
126 dbsec = datatable[ic].indouble;
128 lsec = datatable[ic].outlong1;
129 lusec = datatable[ic].outlong2;
131 ltvusec = tv->
usec();
132 sprintf(cstr,
"loop counter:%d in:%f sec():%ld usec():%ld", ic, dbsec, ltvsec, ltvusec);
133 CPPUNIT_ASSERT_MESSAGE(cstr, (ltvsec == lsec) & (ltvusec ==lusec) );
145 typedef struct data_struct {
151 DATA_STRUCT datatable[] = {
154 { 3.555555 , 3 , 555555},
155 { 3.5999994 , 3 , 599999},
156 { 3.5999995 , 3 , 600000},
157 { -3.555555 , -3 , -555555},
158 { -3.5999994 , -3 , -599999},
159 { -3.5999995 , -3 , -600000},
168 for (ic=0; ic < (
sizeof datatable/
sizeof datatable[0]); ic++)
170 dbsec = datatable[ic].indouble;
172 lsec = datatable[ic].outlong1;
173 lusec = datatable[ic].outlong2;
176 sprintf(cstr,
"loop counter:%d in:%f sec():%ld usec():%ld ", ic, dbsec, ltvsec, ltvusec);
177 CPPUNIT_ASSERT_MESSAGE(cstr, (ltvsec == lsec) & (ltvusec ==lusec));
188 typedef struct data_struct {
195 DATA_STRUCT datatable[] = {
196 { 0.0 , 0.0 , 0 , 0},
197 { 3.5 , 0.5 , 4 , 0},
198 { 3.599999 , 0.000001 , 3 , 600000},
199 { 3.5999994 , 0.0000001 , 3 , 599999},
200 { 3.5999995 , 0.0000001 , 3 , 600000},
201 { -3.5 , -0.5 , -4 , 0},
202 { -3.599999 , -0.000001 , -3 , -600000},
203 { -3.5999994 ,-0.0000001 ,-3 , -599999},
204 { -3.5999995 ,-0.0000001 ,-3 , -600000},
205 { -3.5 , 3.5 , 0 , 0},
206 { -3.5 , 3.499999 , 0 , -1},
207 { -3.5 , 3.500001 , 0 , 1},
208 { 3.5 , -3.5 , 0 , 0},
209 { 3.5 , -3.499999 , 0 , 1},
210 { 3.5 , -3.500001 , 0 , -1},
217 double dbsec1, dbsec2;
220 for (ic=0; ic < (
sizeof datatable/
sizeof datatable[0]); ic++)
222 dbsec1 = datatable[ic].indouble1;
224 dbsec2 = datatable[ic].indouble2;
226 lsec = datatable[ic].outlong1;
227 lusec = datatable[ic].outlong2;
230 ltvusec = tv1.
usec();
231 sprintf(cstr,
"loop counter:%d in1:%f in2:%f sec():%ld usec():%ld ", ic, dbsec1, dbsec2, ltvsec, ltvusec);
232 CPPUNIT_ASSERT_MESSAGE(cstr, (ltvsec == lsec) & (ltvusec ==lusec));
243 typedef struct data_struct {
250 DATA_STRUCT datatable[] = {
251 { 0.0 , 0.0 , 0 , 0},
252 { 3.5 , 0.5 , 3 , 0},
253 { 3.6 , 0.000001 , 3 , 599999},
254 { 3.6 , 0.0000001 , 3 , 600000},
255 { 3.5999995 , 0.0000001 , 3 , 600000},
256 { 0.5 , 3.5 , -3 , 0},
257 { -3.6 , -0.000001 , -3 , -599999},
258 { -3.6 , -0.0000001 , -3 , -600000},
259 { -3.5999995 , -0.0000001 , -3 , -600000},
260 { -3.5 , 3.5 , -7 , 0},
261 { -3.5 , 3.499999 , -6 , -999999},
262 { -3.5 , 3.500001 , -7 , -1},
263 { 3.5 , -3.5 , 7 , 0},
264 { 3.5 , -3.499999 , 6 , 999999},
265 { 3.5 , -3.500001 , 7 , 1},
272 double dbsec1, dbsec2;
275 for (ic=0; ic < (
sizeof datatable/
sizeof datatable[0]); ic++)
277 dbsec1 = datatable[ic].indouble1;
279 dbsec2 = datatable[ic].indouble2;
281 lsec = datatable[ic].outlong1;
282 lusec = datatable[ic].outlong2;
285 ltvusec = tv1.
usec();
286 sprintf(cstr,
"loop counter:%d in1:%f in2:%f sec():%ld usec():%ld ", ic, dbsec1, dbsec2, ltvsec, ltvusec);
287 CPPUNIT_ASSERT_MESSAGE(cstr, (ltvsec == lsec) & (ltvusec ==lusec));
298 typedef struct data_struct {
303 DATA_STRUCT datatable[] = {
317 for (ic=0; ic < (
sizeof datatable/
sizeof datatable[0]); ic++)
319 dbsec = datatable[ic].indouble;
321 isign= datatable[ic].outint;
323 sprintf(cstr,
"loop counter:%d in:%f sgin():%d", ic, dbsec, itvsign);
324 CPPUNIT_ASSERT_MESSAGE(cstr, (isign == itvsign) );
335 typedef struct data_struct {
340 DATA_STRUCT datatable[] = {
343 { 3.555555 , 3.555555},
344 { 3.5999994 , 3.599999},
346 { -3.555555 , -3.555555},
347 { -3.5999994 , -3.599999},
348 { -3.5999995 , -3.600000},
357 for (ic=0; ic < (
sizeof datatable/
sizeof datatable[0]); ic++)
359 dbinsec = datatable[ic].indouble;
361 dboutsec = datatable[ic].outdouble;
362 dbtvsec = (double)tv;
363 sprintf(cstr,
"loop counter:%d in:%f sec:%f ", ic, dbinsec, dbtvsec);
364 CPPUNIT_ASSERT_MESSAGE(cstr, (dbtvsec == dboutsec) );
376 int main(
int argc,
char* argv[])
378 CppUnit::TextUi::TestRunner runner;
379 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
380 CppUnit::Outputter* outputter =
381 new CppUnit::TextOutputter(&runner.result(), std::cout);
382 runner.setOutputter(outputter);
387 #endif // TimeValue_cpp int main(int argc, char **argv)
TimeValueTests()
Constructor.
long int sec() const
Get value of second time scale.
virtual void setUp()
Test initialization.
virtual void tearDown()
Test finalization.
CPPUNIT_TEST_SUITE(TimeValueTests)
~TimeValueTests()
Destructor.
int sign() const
Sign judgment.
std::string sprintf(char const *__restrict fmt,...)
Convert it into a format given with an argumen.
void test_operatorMINUS()
CPPUNIT_TEST_SUITE_REGISTRATION(TimeValue::TimeValueTests)
long int usec() const
Get value of micro second time scale.
void test_operatordouble()