[Git][NTPsec/ntpsec][master] Convert strtolfp.c
Amar Takhar
gitlab at mg.gitlab.com
Tue Nov 24 03:51:07 UTC 2015
Amar Takhar pushed to branch master at NTPsec / ntpsec
Commits:
3d2ee8b4 by Amar Takhar at 2015-11-23T22:50:39Z
Convert strtolfp.c
- - - - -
3 changed files:
- tests/common/tests_main.c
- tests/libntp/strtolfp.c
- tests/wscript
Changes:
=====================================
tests/common/tests_main.c
=====================================
--- a/tests/common/tests_main.c
+++ b/tests/common/tests_main.c
@@ -60,7 +60,7 @@ static void RunAllTests(void)
// RUN_TEST_GROUP(socktoa);
// RUN_TEST_GROUP(ssl_init);
// RUN_TEST_GROUP(statestr);
-// RUN_TEST_GROUP(strtolfp);
+ RUN_TEST_GROUP(strtolfp);
// RUN_TEST_GROUP(timespec);
// RUN_TEST_GROUP(timevalops);
RUN_TEST_GROUP(tstotv);
=====================================
tests/libntp/strtolfp.c
=====================================
--- a/tests/libntp/strtolfp.c
+++ b/tests/libntp/strtolfp.c
@@ -1,7 +1,5 @@
-extern "C" {
#include "unity.h"
#include "unity_fixture.h"
-}
TEST_GROUP(strtolfp);
@@ -13,21 +11,19 @@ TEST_TEAR_DOWN(strtolfp) {}
/* This class tests both atolfp and mstolfp */
-class strtolfpTest : public lfptest {
-};
TEST(strtolfp, PositiveInteger) {
const char *str = "500";
const char *str_ms = "500000";
- l_fp expected = {500,0};
+ l_fp expected = {{500},0};
l_fp actual, actual_ms;
TEST_ASSERT_TRUE(atolfp(str, &actual));
TEST_ASSERT_TRUE(mstolfp(str_ms, &actual_ms));
- TEST_ASSERT_TRUE(IsEqual(expected, actual));
- TEST_ASSERT_TRUE(IsEqual(expected, actual_ms));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual_ms));
}
TEST(strtolfp, NegativeInteger) {
@@ -43,22 +39,22 @@ TEST(strtolfp, NegativeInteger) {
TEST_ASSERT_TRUE(atolfp(str, &actual));
TEST_ASSERT_TRUE(mstolfp(str_ms, &actual_ms));
- TEST_ASSERT_TRUE(IsEqual(expected, actual));
- TEST_ASSERT_TRUE(IsEqual(expected, actual_ms));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual_ms));
}
TEST(strtolfp, PositiveFraction) {
const char *str = "+500.5";
const char *str_ms = "500500.0";
- l_fp expected = {500, HALF};
+ l_fp expected = {{500}, HALF};
l_fp actual, actual_ms;
TEST_ASSERT_TRUE(atolfp(str, &actual));
TEST_ASSERT_TRUE(mstolfp(str_ms, &actual_ms));
- TEST_ASSERT_TRUE(IsEqual(expected, actual));
- TEST_ASSERT_TRUE(IsEqual(expected, actual_ms));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual_ms));
}
TEST(strtolfp, NegativeFraction) {
@@ -74,22 +70,22 @@ TEST(strtolfp, NegativeFraction) {
TEST_ASSERT_TRUE(atolfp(str, &actual));
TEST_ASSERT_TRUE(mstolfp(str_ms, &actual_ms));
- TEST_ASSERT_TRUE(IsEqual(expected, actual));
- TEST_ASSERT_TRUE(IsEqual(expected, actual_ms));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual_ms));
}
TEST(strtolfp, PositiveMsFraction) {
const char *str = "300.00025";
const char *str_ms = "300000.25";
- l_fp expected = {300, QUARTER_PROMILLE_APPRX};
+ l_fp expected = {{300}, QUARTER_PROMILLE_APPRX};
l_fp actual, actual_ms;
TEST_ASSERT_TRUE(atolfp(str, &actual));
TEST_ASSERT_TRUE(mstolfp(str_ms, &actual_ms));
- TEST_ASSERT_TRUE(IsEqual(expected, actual));
- TEST_ASSERT_TRUE(IsEqual(expected, actual_ms));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual_ms));
}
TEST(strtolfp, NegativeMsFraction) {
@@ -105,8 +101,8 @@ TEST(strtolfp, NegativeMsFraction) {
TEST_ASSERT_TRUE(atolfp(str, &actual));
TEST_ASSERT_TRUE(mstolfp(str_ms, &actual_ms));
- TEST_ASSERT_TRUE(IsEqual(expected, actual));
- TEST_ASSERT_TRUE(IsEqual(expected, actual_ms));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual));
+ TEST_ASSERT_TRUE(IsEqual(&expected, &actual_ms));
}
TEST(strtolfp, InvalidChars) {
=====================================
tests/wscript
=====================================
--- a/tests/wscript
+++ b/tests/wscript
@@ -75,7 +75,7 @@ def build(ctx):
# "libntp/socktoa.c",
# "libntp/ssl_init.c",
# "libntp/statestr.c",
-# "libntp/strtolfp.c",
+ "libntp/strtolfp.c",
# "libntp/timespecops.c",
# "libntp/timevalops.c",
"libntp/tstotv.c",
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3d2ee8b4e07e83d8480570cb3186b49100a239ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151124/46b527f2/attachment.html>
More information about the vc
mailing list