]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
humandate.c:
authorTomek Mrugalski <tomasz@isc.org>
Sat, 4 Jul 2015 13:39:51 +0000 (15:39 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Sat, 4 Jul 2015 13:39:51 +0000 (15:39 +0200)
  reordered code so that it is C90-compilant, renamed variables so that they are different that function names, fixed formatting to match NTP's convention
hextolfp.c:
  removed a trailing endline, changed formatting to match NTP's convention,
decodenetnum.c:
  changed the order of imports, removed an unnecessary import, removed a trailing space, changed the return type from a function to be in a new line
run-humandate.c, run-hextolfp.c, run-decodenetnum.c:
  autogenerated

bk: 5597e227acs3bFvp8m1Ag6w4DKuorA

tests/libntp/decodenetnum.c
tests/libntp/hextolfp.c
tests/libntp/humandate.c
tests/libntp/run-decodenetnum.c
tests/libntp/run-hextolfp.c
tests/libntp/run-humandate.c

index 681b7125a017a06a0762cc055b99347d08f0d207..22c1507a30e092053233b9eab6002f378e0b43ec 100644 (file)
@@ -1,12 +1,12 @@
 #include "config.h"
 #include "ntp_stdlib.h"
-#include "ntp_calendar.h"
-#include "unity.h"
-
 #include "sockaddrtest.h"
 
+#include "unity.h"
+
 
-void test_IPv4AddressOnly(void) {
+void
+test_IPv4AddressOnly(void) {
        const char *str = "192.0.2.1";
        sockaddr_u actual;
 
@@ -19,7 +19,8 @@ void test_IPv4AddressOnly(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-void test_IPv4AddressWithPort(void) {
+void
+test_IPv4AddressWithPort(void) {
        const char *str = "192.0.2.2:2000";
        sockaddr_u actual;
 
@@ -32,10 +33,11 @@ void test_IPv4AddressWithPort(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-void test_IPv6AddressOnly(void) {
+void
+test_IPv6AddressOnly(void) {
        const struct in6_addr address = {
                0x20, 0x01, 0x0d, 0xb8,
-        0x85, 0xa3, 0x08, 0xd3, 
+        0x85, 0xa3, 0x08, 0xd3,
         0x13, 0x19, 0x8a, 0x2e,
         0x03, 0x70, 0x73, 0x34
        };
@@ -52,10 +54,11 @@ void test_IPv6AddressOnly(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-void test_IPv6AddressWithPort(void) {
+void
+test_IPv6AddressWithPort(void) {
        const struct in6_addr address = {
                0x20, 0x01, 0x0d, 0xb8,
-        0x85, 0xa3, 0x08, 0xd3, 
+        0x85, 0xa3, 0x08, 0xd3,
         0x13, 0x19, 0x8a, 0x2e,
         0x03, 0x70, 0x73, 0x34
        };
@@ -72,14 +75,16 @@ void test_IPv6AddressWithPort(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-void test_IllegalAddress(void) {
+void
+test_IllegalAddress(void) {
        const char *str = "192.0.2.270:2000";
        sockaddr_u actual;
 
        TEST_ASSERT_FALSE(decodenetnum(str, &actual));
 }
 
-void test_IllegalCharInPort(void) {
+void
+test_IllegalCharInPort(void) {
        /* An illegal port does not make the decodenetnum fail, but instead
         * makes it use the standard port.
         */
index a2f548f5664483bc88e753fe8a7f8cba0f5b1e6f..228242f6fe9b38ca660969b0ece7b6cf807f2466 100644 (file)
@@ -7,7 +7,8 @@
 #include "lfptest.h"
 
 
-void test_PositiveInteger(void) {
+void
+test_PositiveInteger(void) {
        const char *str = "00001000.00000000";
        l_fp actual;
 
@@ -17,7 +18,8 @@ void test_PositiveInteger(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-void test_NegativeInteger(void) {
+void
+test_NegativeInteger(void) {
        const char *str = "ffffffff.00000000"; // -1 decimal
        l_fp actual;
 
@@ -27,7 +29,8 @@ void test_NegativeInteger(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-void test_PositiveFraction(void) {
+void
+test_PositiveFraction(void) {
        const char *str = "00002000.80000000"; // 8196.5 decimal
        l_fp actual;
 
@@ -37,7 +40,8 @@ void test_PositiveFraction(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-void test_NegativeFraction(void) {
+void
+test_NegativeFraction(void) {
        const char *str = "ffffffff.40000000"; // -1 + 0.25 decimal
        l_fp actual;
 
@@ -47,17 +51,18 @@ void test_NegativeFraction(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-void test_IllegalNumberOfInteger(void) {
+void
+test_IllegalNumberOfInteger(void) {
        const char *str = "1000000.00000000"; // Missing one digit in integral part.
        l_fp actual;
 
        TEST_ASSERT_FALSE(hextolfp(str, &actual));
 }
 
-void test_IllegalChar(void) {
+void
+test_IllegalChar(void) {
        const char *str = "10000000.0000h000"; // Illegal character h.
        l_fp actual;
 
        TEST_ASSERT_FALSE(hextolfp(str, &actual));
 }
-
index 071fa415990029e2b1bc4333a93771b92fedcb0d..561d28b9bbb61a779324561dc9daa92dec78e1be 100644 (file)
@@ -5,32 +5,34 @@
 
 #include "unity.h"
 
-void test_RegularTime(void)
+void
+test_RegularTime(void)
 {
        time_t sample = 1276601278;
        char expected[15];
+       struct tm* tm;
 
-       struct tm* time;
-       time = localtime(&sample);
+       tm = localtime(&sample);
        TEST_ASSERT_TRUE(time != NULL);
 
-       snprintf(expected, 15, "%02d:%02d:%02d", time->tm_hour, time->tm_min, time->tm_sec);
+       snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
 
        TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
 }
 
-void test_CurrentTime(void)
+void
+test_CurrentTime(void)
 {
        time_t sample;
        char expected[15];
+       struct tm* tm;
 
        time(&sample);
 
-       struct tm* time;
-       time = localtime(&sample);
+       tm = localtime(&sample);
        TEST_ASSERT_TRUE(time != NULL);
 
-       snprintf(expected, 15, "%02d:%02d:%02d", time->tm_hour, time->tm_min, time->tm_sec);
+       snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
 
        TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
 }
index 2e0a7e593214f00986d66b52af5351ab754b7e73..4f9c5d5702c7ec0b885cd5a52adffcdf2f9006fe 100644 (file)
@@ -52,11 +52,11 @@ int main(int argc, char *argv[])
   Unity.TestFile = "decodenetnum.c";
   UnityBegin("decodenetnum.c");
   RUN_TEST(test_IPv4AddressOnly, 9);
-  RUN_TEST(test_IPv4AddressWithPort, 22);
-  RUN_TEST(test_IPv6AddressOnly, 35);
-  RUN_TEST(test_IPv6AddressWithPort, 55);
-  RUN_TEST(test_IllegalAddress, 75);
-  RUN_TEST(test_IllegalCharInPort, 82);
+  RUN_TEST(test_IPv4AddressWithPort, 23);
+  RUN_TEST(test_IPv6AddressOnly, 37);
+  RUN_TEST(test_IPv6AddressWithPort, 58);
+  RUN_TEST(test_IllegalAddress, 79);
+  RUN_TEST(test_IllegalCharInPort, 87);
 
   return (UnityEnd());
 }
index 0ef9f63b863fae8175ceda60dd5aeed6f8c303d0..abc775853086c0315d75b8e43cf27d3319c182d8 100644 (file)
@@ -51,12 +51,12 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "hextolfp.c";
   UnityBegin("hextolfp.c");
-  RUN_TEST(test_PositiveInteger, 10);
-  RUN_TEST(test_NegativeInteger, 20);
-  RUN_TEST(test_PositiveFraction, 30);
-  RUN_TEST(test_NegativeFraction, 40);
-  RUN_TEST(test_IllegalNumberOfInteger, 50);
-  RUN_TEST(test_IllegalChar, 57);
+  RUN_TEST(test_PositiveInteger, 11);
+  RUN_TEST(test_NegativeInteger, 22);
+  RUN_TEST(test_PositiveFraction, 33);
+  RUN_TEST(test_NegativeFraction, 44);
+  RUN_TEST(test_IllegalNumberOfInteger, 55);
+  RUN_TEST(test_IllegalChar, 63);
 
   return (UnityEnd());
 }
index 291415f532e47225e22c45d9eb14e540da8a64df..4336bd9961630cd34a95372fbc01beffb294ac86 100644 (file)
@@ -26,6 +26,7 @@
 //=======External Functions This Runner Calls=====
 extern void setUp(void);
 extern void tearDown(void);
+void resetTest(void);
 extern void test_RegularTime(void);
 extern void test_CurrentTime(void);
 
@@ -46,8 +47,8 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "humandate.c";
   UnityBegin("humandate.c");
-  RUN_TEST(test_RegularTime, 8);
-  RUN_TEST(test_CurrentTime, 22);
+  RUN_TEST(test_RegularTime, 9);
+  RUN_TEST(test_CurrentTime, 24);
 
   return (UnityEnd());
 }