]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
code review changes
authorLokesh Walase <lokeshw24@ntp.org>
Mon, 6 Jul 2015 15:00:39 +0000 (20:30 +0530)
committerLokesh Walase <lokeshw24@ntp.org>
Mon, 6 Jul 2015 15:00:39 +0000 (20:30 +0530)
bk: 559a9817BBqO65UinwZRvHMrtSaDyw

tests/libntp/lfptest.h
tests/libntp/strtolfp.c

index a830b37a4cece0aa7e37c853fe0a8b4d1d12c88a..ab815f5a0bce6c2cfa7d4b8354a1a300682ed87b 100644 (file)
@@ -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
 
 
index de9f1119c6a10fcfb06849afb55d9816341e8ca1..1767f0be844ae9b92fbedc0d1f7a1ede8c0127e6 100644 (file)
@@ -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;