summaryrefslogtreecommitdiff
path: root/test_timespec.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-06-05 12:45:15 -0700
committerGary E. Miller <gem@rellim.com>2015-06-05 12:45:15 -0700
commit357f4722dffe2705384572774929c7296bb3ea55 (patch)
treea566e581808d7fd584afb005978f761abc7dd18d /test_timespec.c
parent09f2659e61a0b73c05841dfe3c4da5d3311e0c92 (diff)
downloadgpsd-357f4722dffe2705384572774929c7296bb3ea55.tar.gz
Remove a duplicate array of tests.
Diffstat (limited to 'test_timespec.c')
-rw-r--r--test_timespec.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/test_timespec.c b/test_timespec.c
index 11834e61..f334a1f9 100644
--- a/test_timespec.c
+++ b/test_timespec.c
@@ -98,11 +98,11 @@ struct subtract_test subtract_tests[] = {
{ TS_ZERO, TS_2037_NINES, TS_N_2037_NINES, 1},
};
-struct format_test {
+typedef struct format_test {
struct timespec input;
char *expected;
bool last;
-};
+} format_test_t;
struct format_test format_tests[] = {
{ TS_ZERO, " 0.000000000", 0},
@@ -215,7 +215,7 @@ static int test_ns_subtract( int verbose )
static int test_format(int verbose )
{
- struct format_test *p = format_tests;
+ format_test_t *p = format_tests;
int fail_count = 0;
while ( 1 ) {
@@ -245,21 +245,6 @@ static int test_format(int verbose )
return fail_count;
}
-struct timespec exs[] = {
- TS_ZERO_ONE,
- TS_ZERO_TWO,
- TS_ZERO_NINES,
- TS_ONE,
- TS_ONE_ONE,
- TS_TWO,
- TS_2037,
- TS_2037_ONE,
- TS_2037_TWO,
- TS_2037_X,
- TS_2037_NINES,
- TS_ZERO,
-};
-
static int ex_subtract_float( void )
{
struct subtract_test *p = subtract_tests;
@@ -333,10 +318,14 @@ static int ex_subtract_float( void )
}
+/*
+ * show examples of how integers and floats fail
+ *
+ */
static void ex_precision(void)
{
char buf[TIMESPEC_LEN];
- struct timespec *v = exs;
+ format_test_t *p = format_tests;
puts( "\n\n Simple conversion examples\n\n"
"ts: timespec\n"
@@ -351,6 +340,10 @@ static void ex_precision(void)
int32_t l32;
int64_t l64;
+ struct timespec *v = &(p->input);
+
+ // timespec_str( &p->a, buf_a, sizeof(buf_a) );
+
l32 = (int32_t)(v->tv_sec * NS_IN_SEC)+(int32_t)v->tv_nsec;
l64 = (int64_t)(v->tv_sec * NS_IN_SEC)+(int64_t)v->tv_nsec;
f = (float)TSTONS( v );
@@ -363,11 +356,10 @@ static void ex_precision(void)
"d: %21.9f\n\n",
buf, (long long)l32, (long long)l64, f, d);
- if ( ( 0 == v->tv_sec ) && ( 0 == v->tv_nsec) ) {
- /* done */
- break;
+ if ( p->last ) {
+ break;
}
- v++;
+ p++;
}
printf( "\n\nSubtraction examples:\n");