test cleanup

remove compile time "debug" flag from from tests.
use testDiag() instead
This commit is contained in:
Michael Davidsaver
2017-06-25 19:38:59 +02:00
parent 18283b44b2
commit 66633a7728
9 changed files with 138 additions and 309 deletions

View File

@@ -25,14 +25,12 @@
using namespace epics::pvData;
static bool debug = false;
void testTimeStampInternal()
{
testOk1(nanoSecPerSec==1000000000);
TimeStamp current;
current.getCurrent();
printf("current %lli %i milliSec %lli\n",
testDiag("current %lli %i milliSec %lli\n",
(long long)current.getSecondsPastEpoch(),
(int)current.getNanoseconds(),
(long long)current.getMilliseconds());
@@ -40,7 +38,7 @@ void testTimeStampInternal()
current.toTime_t(tt);
struct tm ctm;
memcpy(&ctm,localtime(&tt),sizeof(struct tm));
printf(
testDiag(
"%4.4d.%2.2d.%2.2d %2.2d:%2.2d:%2.2d %d isDst %s\n",
ctm.tm_year+1900,ctm.tm_mon + 1,ctm.tm_mday,
ctm.tm_hour,ctm.tm_min,ctm.tm_sec,
@@ -48,13 +46,13 @@ void testTimeStampInternal()
(ctm.tm_isdst==0) ? "false" : "true");
tt = time(&tt);
current.fromTime_t(tt);
printf("fromTime_t\ncurrent %lli %i milliSec %lli\n",
testDiag("fromTime_t\ncurrent %lli %i milliSec %lli\n",
(long long)current.getSecondsPastEpoch(),
(int)current.getNanoseconds(),
(long long)current.getMilliseconds());
current.toTime_t(tt);
memcpy(&ctm,localtime(&tt),sizeof(struct tm));
printf(
testDiag(
"%4.4d.%2.2d.%2.2d %2.2d:%2.2d:%2.2d %d isDst %s\n",
ctm.tm_year+1900,ctm.tm_mon + 1,ctm.tm_mday,
ctm.tm_hour,ctm.tm_min,ctm.tm_sec,
@@ -66,7 +64,7 @@ void testTimeStampInternal()
left.put(current.getSecondsPastEpoch(),current.getNanoseconds());
double diff;
diff = TimeStamp::diff(left,right);
if(debug) printf("diff %e\n",diff);
testDiag("diff %e\n",diff);
testOk1(diff==0.0);
testOk1((left==right));
testOk1(!(left!=right));
@@ -76,7 +74,7 @@ void testTimeStampInternal()
testOk1(!(left>right));
left.put(current.getSecondsPastEpoch()+1,current.getNanoseconds());
diff = TimeStamp::diff(left,right);
if(debug) printf("diff %e\n",diff);
testDiag("diff %e\n",diff);
testOk1(diff==1.0);
testOk1(!(left==right));
testOk1((left!=right));
@@ -86,7 +84,7 @@ void testTimeStampInternal()
testOk1((left>right));
left.put(current.getSecondsPastEpoch()-1,current.getNanoseconds());
diff = TimeStamp::diff(left,right);
if(debug) printf("diff %e\n",diff);
testDiag("diff %e\n",diff);
testOk1(diff==-1.0);
testOk1(!(left==right));
testOk1((left!=right));
@@ -96,7 +94,7 @@ void testTimeStampInternal()
testOk1(!(left>right));
left.put(current.getSecondsPastEpoch(),current.getNanoseconds()-nanoSecPerSec);
diff = TimeStamp::diff(left,right);
if(debug) printf("diff %e\n",diff);
testDiag("diff %e\n",diff);
testOk1(diff==-1.0);
testOk1(!(left==right));
testOk1((left!=right));
@@ -106,7 +104,7 @@ void testTimeStampInternal()
testOk1(!(left>right));
left.put(current.getSecondsPastEpoch(),current.getNanoseconds()-1);
diff = TimeStamp::diff(left,right);
if(debug) printf("diff %e\n",diff);
testDiag("diff %e\n",diff);
testOk1(diff<0.0);
testOk1(!(left==right));
testOk1((left!=right));
@@ -117,13 +115,12 @@ void testTimeStampInternal()
left.put(current.getSecondsPastEpoch(),current.getNanoseconds());
left += .1;
diff = TimeStamp::diff(left,right);
if(debug) printf("diff %e\n",diff);
testDiag("diff %e\n",diff);
left.put(current.getSecondsPastEpoch(),current.getNanoseconds());
int64 inc = -1;
left += inc;
diff = TimeStamp::diff(left,right);
testOk1(diff==-1.0);
printf("PASSED\n");
}
MAIN(testTimeStamp)