From: Damir Tomic Date: Sun, 26 Jul 2015 19:00:42 +0000 (+0200) Subject: Merge psp-deb1.ntp.org:/home/lokeshw24/ntp-stable-unity X-Git-Tag: NTP_4_3_67~2^2~2^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2bbf51b0036d1606860741648c32ba2e453cc90;p=thirdparty%2Fntp.git Merge psp-deb1.ntp.org:/home/lokeshw24/ntp-stable-unity into ubuntu.(none):/home/viperus/Desktop/ntp-stable-unity bk: 55b52e5aok1pKPRiWQqsdgPSr5WsEw --- b2bbf51b0036d1606860741648c32ba2e453cc90 diff --cc tests/libntp/decodenetnum.c index 77491b8b3,3f0a066f0..15f4cabcd --- a/tests/libntp/decodenetnum.c +++ b/tests/libntp/decodenetnum.c @@@ -1,18 -1,10 +1,17 @@@ #include "config.h" #include "ntp_stdlib.h" + #include "ntp_calendar.h" #include "sockaddrtest.h" - #include "unity.h" +extern void test_IPv4AddressOnly(void); +extern void test_IPv4AddressWithPort(void); +extern void test_IPv6AddressOnly(void); +extern void test_IPv6AddressWithPort(void); +extern void test_IllegalAddress(void); +extern void test_IllegalCharInPort(void); + - - void + void test_IPv4AddressOnly(void) { const char *str = "192.0.2.1"; sockaddr_u actual; diff --cc tests/libntp/lfptest.h index 30a85f5b3,ab815f5a0..defbf5822 --- a/tests/libntp/lfptest.h +++ b/tests/libntp/lfptest.h @@@ -1,16 -1,33 +1,32 @@@ #ifndef NTP_TESTS_LFPTEST_H #define NTP_TESTS_LFPTEST_H +#include "config.h" #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) { + if (L_ISEQU(&expected, &actual)) { + return TRUE; + } else { + //printf(" expected: ..."); + /* + << " expected: " << lfptoa(&expected, FRACTION_PREC) + << " (" << expected.l_ui << "." << expected.l_uf << ")" + << " but was: " << lfptoa(&actual, FRACTION_PREC) + << " (" << actual.l_ui << "." << actual.l_uf << ")"; + */ + return FALSE; + } + + } + #endif - - diff --cc tests/libntp/lfptostr.c index 267c3021c,b185853e6..a9875133a --- a/tests/libntp/lfptostr.c +++ b/tests/libntp/lfptostr.c @@@ -19,22 -20,7 +20,22 @@@ static const int THREE_FOURTH = -107374 static const int HALF_PROMILLE_UP = 2147484; // slightly more than 0.0005 static const int HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005 + +void test_PositiveInteger(void); +void test_NegativeInteger(void); +void test_PositiveIntegerWithFraction(void); +void test_NegativeIntegerWithFraction(void); +void test_RoundingDownToInteger(void); +void test_RoundingMiddleToInteger(void); +void test_RoundingUpToInteger(void); +void test_SingleDecimal(void); +void test_MillisecondsRoundingUp(void); +void test_MillisecondsRoundingDown(void); +void test_UnsignedInteger(void); + + + - void + void test_PositiveInteger(void) { l_fp test = {200, 0}; // exact 200.0000000000 diff --cc tests/libntp/netof.c index 2fde6cc2e,6a3aa4233..1a8e52b23 --- a/tests/libntp/netof.c +++ b/tests/libntp/netof.c @@@ -7,15 -7,8 +7,16 @@@ #include "sockaddrtest.h" + +void test_ClassBAddress(void); +void test_ClassCAddress(void); +void test_ClassAAddress(void); +void test_IPv6Address(void); + + + - void test_ClassBAddress(void) { + void + test_ClassBAddress(void) { sockaddr_u input = CreateSockaddr4("172.16.2.1", NTP_PORT); sockaddr_u expected = CreateSockaddr4("172.16.0.0", NTP_PORT); diff --cc tests/libntp/octtoint.c index 5c03d6d1b,c069d6834..f72d529ca --- a/tests/libntp/octtoint.c +++ b/tests/libntp/octtoint.c @@@ -4,17 -4,8 +4,18 @@@ #include "unity.h" + +void test_SingleDigit(void); +void test_MultipleDigits(void); +void test_Zero(void); +void test_MaximumUnsigned32bit(void); +void test_Overflow(void); +void test_IllegalCharacter(void); +void test_IllegalDigit(void); + + - void test_SingleDigit(void) { + void + test_SingleDigit(void) { const char* str = "5"; u_long actual; diff --cc tests/libntp/socktoa.c index bd4e4286b,bd584d347..9ce3a1e99 --- a/tests/libntp/socktoa.c +++ b/tests/libntp/socktoa.c @@@ -4,17 -4,11 +4,17 @@@ #include "ntp_calendar.h" #include "unity.h" - #include "sockaddrtest.h" +void test_IPv4AddressWithPort(void); +void test_IPv6AddressWithPort(void); +void test_ScopedIPv6AddressWithPort(void); +void test_HashEqual(void); +void test_HashNotEqual(void); +void test_IgnoreIPv6Fields(void); - void test_IPv4AddressWithPort(void) { + void + test_IPv4AddressWithPort(void) { sockaddr_u input = CreateSockaddr4("192.0.2.10", 123); TEST_ASSERT_EQUAL_STRING("192.0.2.10", socktoa(&input)); diff --cc tests/libntp/strtolfp.c index ace04b0d1,1767f0be8..00dc27729 --- a/tests/libntp/strtolfp.c +++ b/tests/libntp/strtolfp.c @@@ -8,16 -8,8 +8,17 @@@ /* This file tests both atolfp and mstolfp */ +void test_PositiveInteger(void); +void test_NegativeInteger(void); +void test_PositiveFraction(void); +void test_NegativeFraction(void); +void test_PositiveMsFraction(void); +void test_NegativeMsFraction(void); +void test_InvalidChars(void); + + - void test_PositiveInteger(void) { + void + test_PositiveInteger(void) { const char *str = "500"; const char *str_ms = "500000";