[Git][NTPsec/ntpsec][master] 2 commits: Dodge some unused func tests for now. This needs a lot of work.
Amar Takhar
gitlab at mg.gitlab.com
Tue Nov 24 03:43:49 UTC 2015
Amar Takhar pushed to branch master at NTPsec / ntpsec
Commits:
4ca43bda by Amar Takhar at 2015-11-23T22:37:58Z
Dodge some unused func tests for now. This needs a lot of work.
This is a temp measure until all tests are converted. There needs to be a huge
amount of header changes once it's all done I'll have a clear picture.
- - - - -
1096e3f7 by Amar Takhar at 2015-11-23T22:38:55Z
Convert tvtots.c
- - - - -
9 changed files:
- tests/common/tests_main.c
- + tests/libntp/cal.h
- tests/libntp/caljulian.c
- tests/libntp/calyearstart.c
- tests/libntp/clocktime.c
- tests/libntp/lfptest.h
- tests/libntp/libntptest.h
- tests/libntp/tvtots.c
- tests/wscript
Changes:
=====================================
tests/common/tests_main.c
=====================================
--- a/tests/common/tests_main.c
+++ b/tests/common/tests_main.c
@@ -64,7 +64,7 @@ static void RunAllTests(void)
// RUN_TEST_GROUP(timespec);
// RUN_TEST_GROUP(timevalops);
RUN_TEST_GROUP(tstotv);
-// RUN_TEST_GROUP(tvtots);
+ RUN_TEST_GROUP(tvtots);
// RUN_TEST_GROUP(vi64);
// RUN_TEST_GROUP(ymd2yd);
#endif
=====================================
tests/libntp/cal.h
=====================================
--- /dev/null
+++ b/tests/libntp/cal.h
@@ -0,0 +1,3 @@
+static time_t timefunc(time_t*);
+static void settime(int y, int m, int d, int H, int M, int S);
+
=====================================
tests/libntp/caljulian.c
=====================================
--- a/tests/libntp/caljulian.c
+++ b/tests/libntp/caljulian.c
@@ -15,6 +15,7 @@ extern "C" {
#include "ntp_calendar.h"
}
+#include "cal.h"
#include <string>
#include <sstream>
=====================================
tests/libntp/calyearstart.c
=====================================
--- a/tests/libntp/calyearstart.c
+++ b/tests/libntp/calyearstart.c
@@ -10,6 +10,7 @@ TEST_SETUP(calyearstart) {}
TEST_TEAR_DOWN(calyearstart) {}
#include "libntptest.h"
+#include "cal.h"
class calyearstartTest : public libntptest {
protected:
=====================================
tests/libntp/clocktime.c
=====================================
--- a/tests/libntp/clocktime.c
+++ b/tests/libntp/clocktime.c
@@ -10,6 +10,7 @@ TEST_SETUP(clocktime) {}
TEST_TEAR_DOWN(clocktime) {}
#include "libntptest.h"
+#include "cal.h"
// ---------------------------------------------------------------------
// test fixture
=====================================
tests/libntp/lfptest.h
=====================================
--- a/tests/libntp/lfptest.h
+++ b/tests/libntp/lfptest.h
@@ -4,11 +4,11 @@
#include "libntptest.h"
#include "ntp_fp.h"
-static bool IsEqual(const l_fp &expected, const l_fp &actual) {
- if (L_ISEQU(&expected, &actual)) {
+static bool IsEqual(const l_fp *expected, const l_fp *actual) {
+ if (L_ISEQU(expected, actual)) {
return true;
} else {
- printf("Expected: %d (%d.%d) but was: %d (%d.%d)\n", lfptoa(&expected, FRACTION_PREC), expected.l_ui, expected.l_uf, lfptoa(&actual, FRACTION_PREC), actual.l_ui, actual.l_uf);
+ printf("Expected: %s (%d.%d) but was: %s (%d.%d)\n", lfptoa(expected, FRACTION_PREC), expected->l_ui, expected->l_uf, lfptoa(actual, FRACTION_PREC), actual->l_ui, actual->l_uf);
return false;
}
}
=====================================
tests/libntp/libntptest.h
=====================================
--- a/tests/libntp/libntptest.h
+++ b/tests/libntp/libntptest.h
@@ -3,6 +3,4 @@
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
-static time_t timefunc(time_t*);
static time_t nowtime;
-static void settime(int y, int m, int d, int H, int M, int S);
=====================================
tests/libntp/tvtots.c
=====================================
--- a/tests/libntp/tvtots.c
+++ b/tests/libntp/tvtots.c
@@ -1,34 +1,30 @@
-extern "C" {
+#include "config.h"
+
#include "unity.h"
#include "unity_fixture.h"
-}
-
-TEST_GROUP(tvtots);
-
-TEST_SETUP(tvtots) {}
-
-TEST_TEAR_DOWN(tvtots) {}
#include "lfptest.h"
-
-extern "C" {
#include "timevalops.h"
-};
// Required on Solaris for ldexp.
#include <math.h>
-class tvtotsTest : public lfptest {
-};
+
+TEST_GROUP(tvtots);
+
+TEST_SETUP(tvtots) {}
+
+TEST_TEAR_DOWN(tvtots) {}
+
TEST(tvtots, Seconds) {
- timeval input = {500, 0}; // 500.0 s
- l_fp expected = {500, 0};
+ struct timeval input = {500, 0}; // 500.0 s
+ l_fp expected = {{500}, 0};
l_fp actual;
TVTOTS(&input, &actual);
- TEST_ASSERT_TRUE(IsEqual(expected, actual));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual));
}
TEST(tvtots, MicrosecondsRounded) {
@@ -37,18 +33,18 @@ TEST(tvtots, MicrosecondsRounded) {
* HALF_PROMILLE_UP (which is 2147484) should be
* the correct rounding. */
- timeval input = {0, 500}; // 0.0005 exact
- l_fp expected = {0, HALF_PROMILLE_UP};
+ struct timeval input = {0, 500}; // 0.0005 exact
+ l_fp expected = {{0}, HALF_PROMILLE_UP};
l_fp actual;
TVTOTS(&input, &actual);
- TEST_ASSERT_TRUE(IsEqual(expected, actual));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual));
}
TEST(tvtots, MicrosecondsExact) {
// 0.5 can be represented exact in both l_fp and timeval.
- const timeval input = {10, 500000}; // 0.5 exact
- const l_fp expected = {10, HALF}; // 0.5 exact
+ const struct timeval input = {10, 500000}; // 0.5 exact
+ const l_fp expected = {{10}, HALF}; // 0.5 exact
l_fp actual;
TVTOTS(&input, &actual);
=====================================
tests/wscript
=====================================
--- a/tests/wscript
+++ b/tests/wscript
@@ -79,7 +79,7 @@ def build(ctx):
# "libntp/timespecops.c",
# "libntp/timevalops.c",
"libntp/tstotv.c",
-# "libntp/tvtots.c",
+ "libntp/tvtots.c",
# "libntp/vi64ops.c",
# "libntp/ymd2yd.c"
] + common_source
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/32dd5e6b38dc0d6a1b541d835ab0740579c68462...1096e3f734b75998cd946edbd803227cb7888110
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151124/5c78f00c/attachment.html>
More information about the vc
mailing list