From: Lokesh Walase Date: Mon, 6 Jul 2015 15:00:39 +0000 (+0530) Subject: code review changes X-Git-Tag: NTP_4_3_65~7^2~11^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8e3a7c2fa110db36170e395d5525edae7665810;p=thirdparty%2Fntp.git code review changes bk: 559a9817BBqO65UinwZRvHMrtSaDyw --- diff --git a/tests/libntp/lfptest.h b/tests/libntp/lfptest.h index a830b37a4..ab815f5a0 100644 --- a/tests/libntp/lfptest.h +++ b/tests/libntp/lfptest.h @@ -3,6 +3,13 @@ #include "ntp_fp.h" +static const int32 HALF = -2147483647L - 1L; +static const int32 HALF_PROMILLE_UP = 2147484; // slightly more than 0.0005 +static const int32 HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005 +static const int32 QUARTER = 1073741824L; +static const int32 QUARTER_PROMILLE_APPRX = 1073742L; + + int IsEqual(const l_fp expected, const l_fp actual); int IsEqual(const l_fp expected, const l_fp actual) { @@ -21,12 +28,6 @@ int IsEqual(const l_fp expected, const l_fp actual) { } -static const int32 HALF = -2147483647L - 1L; -static const int32 HALF_PROMILLE_UP = 2147484; // slightly more than 0.0005 -static const int32 HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005 -static const int32 QUARTER = 1073741824L; -static const int32 QUARTER_PROMILLE_APPRX = 1073742L; - #endif diff --git a/tests/libntp/strtolfp.c b/tests/libntp/strtolfp.c index de9f1119c..1767f0be8 100644 --- a/tests/libntp/strtolfp.c +++ b/tests/libntp/strtolfp.c @@ -8,11 +8,12 @@ /* This file tests both atolfp and mstolfp */ -void test_PositiveInteger(void) { +void +test_PositiveInteger(void) { const char *str = "500"; const char *str_ms = "500000"; - l_fp expected = {500,0}; + const l_fp expected = {500,0}; l_fp actual, actual_ms; TEST_ASSERT_TRUE(atolfp(str, &actual)); @@ -22,13 +23,12 @@ void test_PositiveInteger(void) { TEST_ASSERT_TRUE(IsEqual(expected, actual_ms)); } -void test_NegativeInteger(void) { +void +test_NegativeInteger(void) { const char *str = "-300"; const char *str_ms = "-300000"; - l_fp expected; - expected.l_i = -300; - expected.l_uf = 0; + const l_fp expected = {-300,0}; l_fp actual, actual_ms; @@ -39,11 +39,12 @@ void test_NegativeInteger(void) { TEST_ASSERT_TRUE(IsEqual(expected, actual_ms)); } -void test_PositiveFraction(void) { +void +test_PositiveFraction(void) { const char *str = "+500.5"; const char *str_ms = "500500.0"; - l_fp expected = {500, HALF}; + const l_fp expected = {500, HALF}; l_fp actual, actual_ms; TEST_ASSERT_TRUE(atolfp(str, &actual)); @@ -53,13 +54,12 @@ void test_PositiveFraction(void) { TEST_ASSERT_TRUE(IsEqual(expected, actual_ms)); } -void test_NegativeFraction(void) { +void +test_NegativeFraction(void) { const char *str = "-300.75"; const char *str_ms = "-300750"; - l_fp expected; - expected.l_i = -301; - expected.l_uf = QUARTER; + const l_fp expected = {-301, QUARTER}; l_fp actual, actual_ms; @@ -70,11 +70,12 @@ void test_NegativeFraction(void) { TEST_ASSERT_TRUE(IsEqual(expected, actual_ms)); } -void test_PositiveMsFraction(void) { +void +test_PositiveMsFraction(void) { const char *str = "300.00025"; const char *str_ms = "300000.25"; - l_fp expected = {300, QUARTER_PROMILLE_APPRX}; + const l_fp expected = {300, QUARTER_PROMILLE_APPRX}; l_fp actual, actual_ms; @@ -86,13 +87,12 @@ void test_PositiveMsFraction(void) { } -void test_NegativeMsFraction(void) { +void +test_NegativeMsFraction(void) { const char *str = "-199.99975"; const char *str_ms = "-199999.75"; - l_fp expected; - expected.l_i = -200; - expected.l_uf = QUARTER_PROMILLE_APPRX; + const l_fp expected = {-200, QUARTER_PROMILLE_APPRX} ; l_fp actual, actual_ms; @@ -104,7 +104,8 @@ void test_NegativeMsFraction(void) { } -void test_InvalidChars(void) { +void +test_InvalidChars(void) { const char *str = "500.4a2"; l_fp actual, actual_ms;