From: Tomek Mrugalski Date: Sat, 4 Jul 2015 13:39:51 +0000 (+0200) Subject: humandate.c: X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5eaa74ceb249f759c3a05be5771c0eb5362f659b;p=thirdparty%2Fntp.git humandate.c: 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 --- diff --git a/tests/libntp/decodenetnum.c b/tests/libntp/decodenetnum.c index 681b7125a..22c1507a3 100644 --- a/tests/libntp/decodenetnum.c +++ b/tests/libntp/decodenetnum.c @@ -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. */ diff --git a/tests/libntp/hextolfp.c b/tests/libntp/hextolfp.c index a2f548f56..228242f6f 100644 --- a/tests/libntp/hextolfp.c +++ b/tests/libntp/hextolfp.c @@ -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)); } - diff --git a/tests/libntp/humandate.c b/tests/libntp/humandate.c index 071fa4159..561d28b9b 100644 --- a/tests/libntp/humandate.c +++ b/tests/libntp/humandate.c @@ -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)); } diff --git a/tests/libntp/run-decodenetnum.c b/tests/libntp/run-decodenetnum.c index 2e0a7e593..4f9c5d570 100644 --- a/tests/libntp/run-decodenetnum.c +++ b/tests/libntp/run-decodenetnum.c @@ -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()); } diff --git a/tests/libntp/run-hextolfp.c b/tests/libntp/run-hextolfp.c index 0ef9f63b8..abc775853 100644 --- a/tests/libntp/run-hextolfp.c +++ b/tests/libntp/run-hextolfp.c @@ -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()); } diff --git a/tests/libntp/run-humandate.c b/tests/libntp/run-humandate.c index 291415f53..4336bd996 100644 --- a/tests/libntp/run-humandate.c +++ b/tests/libntp/run-humandate.c @@ -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()); }