tests_SOURCES = \
$(top_srcdir)/sntp/tests_main.cpp \
- libntptest.cpp \
+ g_libntptest.cpp \
g_a_md5encrypt.cpp \
g_atoint.cpp \
g_atouint.cpp \
g_authkeys.cpp \
- buftvtots.cpp \
+ g_buftvtots.cpp \
g_calendar.cpp \
g_caljulian.cpp \
g_caltontp.cpp \
g_statestr.cpp \
g_strtolfp.cpp \
g_timespecops.cpp \
- timestructs.cpp \
+ g_timestructs.cpp \
g_timevalops.cpp \
g_tstotv.cpp \
g_tvtots.cpp \
$(NULL)
noinst_HEADERS = \
+ g_lfptest.h \
lfptest.h \
- c_lfptest.h \
- libntptest.h \
+ g_libntptest.h \
+ g_sockaddrtest.h \
sockaddrtest.h \
- c_sockaddrtest.h\
- timestructs.h \
+ g_timestructs.h \
test-libntp.h \
$(NULL)
+++ /dev/null
-#ifndef NTP_TESTS_LFPTEST_H
-#define NTP_TESTS_LFPTEST_H
-
-#include "ntp_fp.h"
-
-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;
- }
-
-}
-
-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
-
-
+++ /dev/null
-#ifndef TESTS_SOCKADDRTEST_H
-#define TESTS_SOCKADDRTEST_H
-
-#include "ntp.h"
-#include "ntp_stdlib.h"
-
-sockaddr_u CreateSockaddr4(const char* address, unsigned int port) {
- sockaddr_u s;
- s.sa4.sin_family = AF_INET;
- s.sa4.sin_addr.s_addr = inet_addr(address);
- SET_PORT(&s, port);
-
- return s;
-}
-
-int IsEqual(const sockaddr_u expected, const sockaddr_u actual) {
- struct in_addr in;
- struct in6_addr in6;
-
- if (expected.sa.sa_family != actual.sa.sa_family) {
- //<< "Expected sa_family: " << expected.sa.sa_family
- //<< " but got: " << actual.sa.sa_family;
- return FALSE;
- }
-
- if (actual.sa.sa_family == AF_INET) { // IPv4
- if (expected.sa4.sin_port == actual.sa4.sin_port &&
- memcmp(&expected.sa4.sin_addr, &actual.sa4.sin_addr,
- sizeof( in )) == 0) {
- return TRUE;
- } else {
- //<< "IPv4 comparision failed, expected: "
- //<< expected.sa4.sin_addr.s_addr
- //<< "(" << socktoa(&expected) << ") but was: "
- //<< actual.sa4.sin_addr.s_addr "(" << socktoa(&actual) << ")";
- return FALSE;
- }
- } else if (actual.sa.sa_family == AF_INET6) { //IPv6
- if (expected.sa6.sin6_port == actual.sa6.sin6_port &&
- memcmp(&expected.sa6.sin6_addr, &actual.sa6.sin6_addr,
- sizeof(in6)) == 0) {
- return TRUE;
- } else {
- printf("IPv6 comparision failed");
- return FALSE;
- }
- } else { // Unknown family
- printf("Unknown sa_family: ");// << actual.sa.sa_family;
- return FALSE;
- }
-}
-
-
-#endif // TESTS_SOCKADDRTEST_H
-
-
-
#include "config.h"
-#include <stdlib.h>
-
#include "ntp_calendar.h"
-#include "unity.h"
#include "ntp_stdlib.h"
-
+#include "unity.h"
#include "test-libntp.h"
-
// ---------------------------------------------------------------------
// test fixture
//
#include "ntp_calendar.h"
#include "unity.h"
-#include "c_sockaddrtest.h"
+#include "sockaddrtest.h"
void test_IPv4AddressOnly(void) {
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#ifdef OPENSSL
-#include "libntptest.h"
+#include "g_libntptest.h"
class atointTest : public libntptest {
};
-#include "libntptest.h"
+#include "g_libntptest.h"
class atouintTest : public libntptest {
};
/* This file contains test for both libntp/authkeys.c and libntp/authusekey.c */
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#ifdef OPENSSL
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp_calendar.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp_calendar.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp_calendar.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
class calyearstartTest : public libntptest {
protected:
-#include "libntptest.h"
+#include "g_libntptest.h"
// ---------------------------------------------------------------------
// test fixture
-#include "libntptest.h"
+#include "g_libntptest.h"
class hextointTest : public libntptest {
};
-#include "libntptest.h"
+#include "g_libntptest.h"
#include <sstream>
#include <string>
-#include "libntptest.h"
-#include "timestructs.h"
+#include "g_libntptest.h"
+#include "g_timestructs.h"
extern "C" {
#include "ntp_fp.h"
--- /dev/null
+#ifndef NTP_TESTS_LFPTEST_H
+#define NTP_TESTS_LFPTEST_H
+
+#include "g_libntptest.h"
+
+extern "C" {
+#include "ntp_fp.h"
+};
+
+class lfptest : public libntptest {
+protected:
+ ::testing::AssertionResult IsEqual(const l_fp &expected, const l_fp &actual) {
+ if (L_ISEQU(&expected, &actual)) {
+ return ::testing::AssertionSuccess();
+ } else {
+ return ::testing::AssertionFailure()
+ << " expected: " << lfptoa(&expected, FRACTION_PREC)
+ << " (" << expected.l_ui << "." << expected.l_uf << ")"
+ << " but was: " << lfptoa(&actual, FRACTION_PREC)
+ << " (" << actual.l_ui << "." << actual.l_uf << ")";
+ }
+ }
+
+ 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
+/* NTP_TESTS_LFPTEST_H */
* a macro.
*/
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp_fp.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
/* This file contains various constants that libntp needs to be set
* and that is normally defined in ntpd/ntpq/...
-#include "libntptest.h"
+#include "g_libntptest.h"
class modetoaTest : public libntptest {
};
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include <stdio.h>
-#include "libntptest.h"
+#include "g_libntptest.h"
class numtoaTest : public libntptest {
};
-#include "libntptest.h"
+#include "g_libntptest.h"
class numtohostTest : public libntptest {
};
-#include "libntptest.h"
+#include "g_libntptest.h"
class octtointTest : public libntptest {
};
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp_fp.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "recvbuff.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
#include "ntp_net.h"
#include "ntp_refclock.h"
* since all these functions are very similar.
*/
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp_fp.h"
--- /dev/null
+#ifndef TESTS_SOCKADDRTEST_H
+#define TESTS_SOCKADDRTEST_H
+
+#include "g_libntptest.h"
+
+extern "C" {
+#include "ntp.h"
+};
+
+class sockaddrtest : public libntptest {
+protected:
+ ::testing::AssertionResult IsEqual(const sockaddr_u &expected, const sockaddr_u &actual) {
+ if (expected.sa.sa_family != actual.sa.sa_family) {
+ return ::testing::AssertionFailure()
+ << "Expected sa_family: " << expected.sa.sa_family
+ << " but got: " << actual.sa.sa_family;
+ }
+
+ if (actual.sa.sa_family == AF_INET) { // IPv4
+ if (expected.sa4.sin_port == actual.sa4.sin_port &&
+ memcmp(&expected.sa4.sin_addr, &actual.sa4.sin_addr,
+ sizeof(in_addr)) == 0) {
+ return ::testing::AssertionSuccess();
+ } else {
+ return ::testing::AssertionFailure()
+ << "IPv4 comparision failed, expected: "
+ << expected.sa4.sin_addr.s_addr
+ << "(" << socktoa(&expected) << ")"
+ << " but was: "
+ << actual.sa4.sin_addr.s_addr
+ << "(" << socktoa(&actual) << ")";
+ }
+ } else if (actual.sa.sa_family == AF_INET6) { //IPv6
+ if (expected.sa6.sin6_port == actual.sa6.sin6_port &&
+ memcmp(&expected.sa6.sin6_addr, &actual.sa6.sin6_addr,
+ sizeof(in6_addr)) == 0) {
+ return ::testing::AssertionSuccess();
+ } else {
+ return ::testing::AssertionFailure()
+ << "IPv6 comparision failed";
+ }
+ } else { // Unknown family
+ return ::testing::AssertionFailure()
+ << "Unknown sa_family: " << actual.sa.sa_family;
+ }
+ }
+
+ sockaddr_u CreateSockaddr4(const char* address, unsigned int port) {
+ sockaddr_u s;
+ s.sa4.sin_family = AF_INET;
+ s.sa4.sin_addr.s_addr = inet_addr(address);
+ SET_PORT(&s, port);
+
+ return s;
+ }
+};
+
+#endif // TESTS_SOCKADDRTEST_H
+
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#ifdef OPENSSL
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp.h" // Needed for MAX_MAC_LEN used in ntp_control.h
-#include "libntptest.h"
-#include "timestructs.h"
+#include "g_libntptest.h"
+#include "g_timestructs.h"
extern "C" {
#include <math.h>
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*/
-#include "libntptest.h"
-#include "timestructs.h"
+#include "g_libntptest.h"
+#include "g_timestructs.h"
extern "C" {
#include "timetoa.h"
* HRVs (human readable values) but we might also be interested in the
* machine representation for diagnostic purposes.
*/
-
-
-//#ifndef TESTCALSHIMS_H
-#include "testcalshims.h"
-//#endif
-
-
#ifndef TIMESTRUCTS_H
#define TIMESTRUCTS_H
+extern "C" {
#include "ntp_fp.h"
+}
-
-l_fp test ;
-//namespace timeStruct {
+namespace timeStruct {
// wrap a l_fp struct with common operations
-struct l_fp_wrap {
-
+class l_fp_wrap {
+ public:
l_fp V;
-
- //bool operator == (const l_fp_wrap& rhs) const
- // { return L_ISEQU(&V, &rhs.V); }
-
-//---------------THIS HAS TO BE MANUALLY CONVERTED IN CODE!!!
- //operator l_fp* ()
- // { return &V; }
- //operator l_fp& ()
- // { return V; }
-//-----------------------------------------
-/*
+ l_fp_wrap()
+ { ZERO(V); }
+ l_fp_wrap(u_int32 hi, u_int32 lo)
+ { V.l_ui = hi; V.l_uf = lo; }
+ l_fp_wrap(const l_fp &rhs)
+ { V = rhs; }
+ bool operator == (const l_fp_wrap& rhs) const
+ { return L_ISEQU(&V, &rhs.V); }
+ operator l_fp* ()
+ { return &V; }
+ operator l_fp& ()
+ { return V; }
l_fp_wrap & operator = (const l_fp_wrap& rhs)
{ V = rhs.V; return *this; }
l_fp_wrap& operator = (const l_fp& rhs)
{ V = rhs; return *this; }
-*/
-};
-
-l_fp_wrap(l_fp V){
- ZERO(V); }
-l_fp_wrap(l_fp V, u_int32 hi, u_int32 lo){
- V.l_ui = hi; V.l_uf = lo; }
-l_fp_wrap(l_fp V, const l_fp &rhs){
- V = rhs; }
-
-l_fp_wrap_equals(const l_fp_wrap& current, const l_fp_wrap& rhs) const // operator ==
- { return L_ISEQU(¤t.V, &rhs.V); }
-
-l_fp_wrap_and(const l_fp_wrap& current, const l_fp_wrap& rhs){
- V = rhs.V;
- return current//*this;
-}
-l_fp_wrap_and(const l_fp& current, const l_fp& rhs){
- V = rhs;
- return current//*this;
-}
-
+ };
-
// wrap a 'struct timeval' with common operations
-struct timeval_wrap {
-
+class timeval_wrap {
+public:
struct timeval V;
timeval_wrap()
};
// wrap a 'struct timespec' with common operations
-struct timespec_wrap {
-
+class timespec_wrap {
+public:
struct timespec V;
timespec_wrap()
extern std::ostream& operator << (std::ostream& os,
const timeStruct::timespec_wrap& val);
-//} // namespace timeStruct
+} // namespace timeStruct
#endif // TIMESTRUCTS_H
-#include "libntptest.h"
-#include "timestructs.h"
+#include "g_libntptest.h"
+#include "g_timestructs.h"
extern "C" {
#include <math.h>
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp_fp.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "ntp_fp.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
extern "C" {
#include "vint64ops.h"
-#include "libntptest.h"
+#include "g_libntptest.h"
class ymd2ydTest : public libntptest {
};
#include "config.h"
+
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
+
#include "unity.h"
-#include "c_lfptest.h"
+#include "lfptest.h"
void test_PositiveInteger(void) {
#include "config.h"
-#include "unity.h"
+
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
-#include <stdio.h>
+
+#include "unity.h"
void test_RegularTime(void)
{
#include <float.h>
#include <math.h>
-#include <string.h>
-
typedef struct {
uint32_t h, l;
#ifndef NTP_TESTS_LFPTEST_H
#define NTP_TESTS_LFPTEST_H
-#include "libntptest.h"
-
-extern "C" {
#include "ntp_fp.h"
-};
-class lfptest : public libntptest {
-protected:
- ::testing::AssertionResult IsEqual(const l_fp &expected, const l_fp &actual) {
- if (L_ISEQU(&expected, &actual)) {
- return ::testing::AssertionSuccess();
- } else {
- return ::testing::AssertionFailure()
- << " expected: " << lfptoa(&expected, FRACTION_PREC)
+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;
}
- 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;
-};
+}
+
+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
-/* NTP_TESTS_LFPTEST_H */
+
+
#include "config.h"
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
-#include "unity.h"
#include "ntp_fp.h"
+#include "unity.h"
+
static const int LFP_MAX_PRECISION = 10;
static const int LFP_MAX_PRECISION_MS = 7;
#include "config.h"
+
#include "ntp_stdlib.h"
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
+
#include "unity.h"
#ifndef VSNPRINTF_PERCENT_M
#include "config.h"
+
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
+
#include "unity.h"
-//#include "ntp.h"
-//#include "ntp_net.h"
-#include "c_sockaddrtest.h"
+#include "sockaddrtest.h"
void test_ClassBAddress(void) {
sockaddr_u input = CreateSockaddr4("172.16.2.1", NTP_PORT);
#include "config.h"
#include "ntp_stdlib.h"
-//#include "ntp_calendar.h"
-//#include "ntp_fp.h"
+
#include "unity.h"
void test_SingleDigit(void) {
TEST_ASSERT_TRUE(octtoint(str, &actual) );
TEST_ASSERT_EQUAL(5, actual);
-
}
void test_MultipleDigits(void){
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
#include "ntp_fp.h"
+
#include "unity.h"
void
TEST_ASSERT_EQUAL_STRING("cfba1ce0.80000000 Wed, Jun 9 2010 14:00:00.500",
gmprettydate(&time));
-}
\ No newline at end of file
+}
-//#include "testcalshims.h"
#include "config.h"
+
#include "recvbuff.h"
+
#include "unity.h"
-//#include "ntp_stdlib.h"
-//#include "libntptest.h"
void
setUp(void)
TEST_ASSERT_EQUAL_UINT(1, full_recvbuffs());
TEST_ASSERT_TRUE(has_full_recv_buffer());
TEST_ASSERT_EQUAL_PTR(buf, get_full_recv_buffer());
-}
\ No newline at end of file
+}
#include "config.h"
+
#include "ntp_net.h"
#include "ntp_refclock.h"
progname = argv[0];
Unity.TestFile = "clocktime.c";
UnityBegin("clocktime.c");
- RUN_TEST(test_CurrentYear, 36);
- RUN_TEST(test_CurrentYearFuzz, 51);
- RUN_TEST(test_TimeZoneOffset, 73);
- RUN_TEST(test_WrongYearStart, 93);
- RUN_TEST(test_PreviousYear, 112);
- RUN_TEST(test_NextYear, 131);
- RUN_TEST(test_NoReasonableConversion, 149);
- RUN_TEST(test_AlwaysInLimit, 171);
+ RUN_TEST(test_CurrentYear, 32);
+ RUN_TEST(test_CurrentYearFuzz, 47);
+ RUN_TEST(test_TimeZoneOffset, 69);
+ RUN_TEST(test_WrongYearStart, 89);
+ RUN_TEST(test_PreviousYear, 108);
+ RUN_TEST(test_NextYear, 127);
+ RUN_TEST(test_NoReasonableConversion, 145);
+ RUN_TEST(test_AlwaysInLimit, 167);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "hextolfp.c";
UnityBegin("hextolfp.c");
- RUN_TEST(test_PositiveInteger, 8);
- RUN_TEST(test_NegativeInteger, 18);
- RUN_TEST(test_PositiveFraction, 28);
- RUN_TEST(test_NegativeFraction, 38);
- RUN_TEST(test_IllegalNumberOfInteger, 48);
- RUN_TEST(test_IllegalChar, 55);
+ 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);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "humandate.c";
UnityBegin("humandate.c");
- RUN_TEST(test_RegularTime, 7);
- RUN_TEST(test_CurrentTime, 21);
+ RUN_TEST(test_RegularTime, 8);
+ RUN_TEST(test_CurrentTime, 22);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "lfpfunc.c";
UnityBegin("lfpfunc.c");
- RUN_TEST(test_AdditionLR, 317);
- RUN_TEST(test_AdditionRL, 335);
- RUN_TEST(test_SubtractionLR, 353);
- RUN_TEST(test_SubtractionRL, 367);
- RUN_TEST(test_Negation, 384);
- RUN_TEST(test_Absolute, 403);
- RUN_TEST(test_FDF_RoundTrip, 434);
- RUN_TEST(test_SignedRelOps, 465);
- RUN_TEST(test_UnsignedRelOps, 508);
+ RUN_TEST(test_AdditionLR, 315);
+ RUN_TEST(test_AdditionRL, 333);
+ RUN_TEST(test_SubtractionLR, 351);
+ RUN_TEST(test_SubtractionRL, 365);
+ RUN_TEST(test_Negation, 382);
+ RUN_TEST(test_Absolute, 401);
+ RUN_TEST(test_FDF_RoundTrip, 432);
+ RUN_TEST(test_SignedRelOps, 463);
+ RUN_TEST(test_UnsignedRelOps, 506);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "lfptostr.c";
UnityBegin("lfptostr.c");
- RUN_TEST(test_PositiveInteger, 22);
- RUN_TEST(test_NegativeInteger, 29);
- RUN_TEST(test_PositiveIntegerWithFraction, 36);
- RUN_TEST(test_NegativeIntegerWithFraction, 43);
- RUN_TEST(test_RoundingDownToInteger, 50);
- RUN_TEST(test_RoundingMiddleToInteger, 57);
- RUN_TEST(test_RoundingUpToInteger, 64);
- RUN_TEST(test_SingleDecimal, 71);
- RUN_TEST(test_MillisecondsRoundingUp, 78);
- RUN_TEST(test_MillisecondsRoundingDown, 87);
- RUN_TEST(test_UnsignedInteger, 96);
+ RUN_TEST(test_PositiveInteger, 23);
+ RUN_TEST(test_NegativeInteger, 30);
+ RUN_TEST(test_PositiveIntegerWithFraction, 37);
+ RUN_TEST(test_NegativeIntegerWithFraction, 44);
+ RUN_TEST(test_RoundingDownToInteger, 51);
+ RUN_TEST(test_RoundingMiddleToInteger, 58);
+ RUN_TEST(test_RoundingUpToInteger, 65);
+ RUN_TEST(test_SingleDecimal, 72);
+ RUN_TEST(test_MillisecondsRoundingUp, 79);
+ RUN_TEST(test_MillisecondsRoundingDown, 88);
+ RUN_TEST(test_UnsignedInteger, 97);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "msyslog.c";
UnityBegin("msyslog.c");
- RUN_TEST(test_msnprintf, 15);
- RUN_TEST(test_msnprintfLiteralPercentm, 31);
- RUN_TEST(test_msnprintfBackslashLiteralPercentm, 46);
- RUN_TEST(test_msnprintfBackslashPercent, 60);
- RUN_TEST(test_msnprintfHangingPercent, 75);
- RUN_TEST(test_format_errmsgHangingPercent, 92);
- RUN_TEST(test_msnprintfNullTarget, 107);
- RUN_TEST(test_msnprintfTruncate, 118);
+ RUN_TEST(test_msnprintf, 14);
+ RUN_TEST(test_msnprintfLiteralPercentm, 30);
+ RUN_TEST(test_msnprintfBackslashLiteralPercentm, 45);
+ RUN_TEST(test_msnprintfBackslashPercent, 59);
+ RUN_TEST(test_msnprintfHangingPercent, 74);
+ RUN_TEST(test_format_errmsgHangingPercent, 91);
+ RUN_TEST(test_msnprintfNullTarget, 106);
+ RUN_TEST(test_msnprintfTruncate, 117);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "octtoint.c";
UnityBegin("octtoint.c");
- RUN_TEST(test_SingleDigit, 8);
- RUN_TEST(test_MultipleDigits, 17);
- RUN_TEST(test_Zero, 26);
- RUN_TEST(test_MaximumUnsigned32bit, 35);
- RUN_TEST(test_Overflow, 44);
- RUN_TEST(test_IllegalCharacter, 52);
- RUN_TEST(test_IllegalDigit, 60);
+ RUN_TEST(test_SingleDigit, 7);
+ RUN_TEST(test_MultipleDigits, 15);
+ RUN_TEST(test_Zero, 24);
+ RUN_TEST(test_MaximumUnsigned32bit, 33);
+ RUN_TEST(test_Overflow, 42);
+ RUN_TEST(test_IllegalCharacter, 50);
+ RUN_TEST(test_IllegalDigit, 58);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "prettydate.c";
UnityBegin("prettydate.c");
- RUN_TEST(test_ConstantDate, 9);
+ RUN_TEST(test_ConstantDate, 10);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "recvbuff.c";
UnityBegin("recvbuff.c");
- RUN_TEST(test_Initialization, 16);
- RUN_TEST(test_GetAndFree, 24);
- RUN_TEST(test_GetAndFill, 35);
+ RUN_TEST(test_Initialization, 15);
+ RUN_TEST(test_GetAndFree, 23);
+ RUN_TEST(test_GetAndFill, 34);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "refnumtoa.c";
UnityBegin("refnumtoa.c");
- RUN_TEST(test_LocalClock, 12);
- RUN_TEST(test_UnknownId, 40);
+ RUN_TEST(test_LocalClock, 13);
+ RUN_TEST(test_UnknownId, 41);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "socktoa.c";
UnityBegin("socktoa.c");
- RUN_TEST(test_IPv4AddressWithPort, 9);
- RUN_TEST(test_IPv6AddressWithPort, 16);
- RUN_TEST(test_ScopedIPv6AddressWithPort, 40);
- RUN_TEST(test_HashEqual, 65);
- RUN_TEST(test_HashNotEqual, 73);
- RUN_TEST(test_IgnoreIPv6Fields, 86);
+ RUN_TEST(test_IPv4AddressWithPort, 11);
+ RUN_TEST(test_IPv6AddressWithPort, 18);
+ RUN_TEST(test_ScopedIPv6AddressWithPort, 42);
+ RUN_TEST(test_HashEqual, 67);
+ RUN_TEST(test_HashNotEqual, 75);
+ RUN_TEST(test_IgnoreIPv6Fields, 88);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "ssl_init.c";
UnityBegin("ssl_init.c");
- RUN_TEST(test_MD5KeyTypeWithoutDigestLength, 18);
- RUN_TEST(test_MD5KeyTypeWithDigestLength, 22);
- RUN_TEST(test_SHA1KeyTypeWithDigestLength, 31);
- RUN_TEST(test_MD5KeyName, 46);
- RUN_TEST(test_SHA1KeyName, 50);
+ RUN_TEST(test_MD5KeyTypeWithoutDigestLength, 19);
+ RUN_TEST(test_MD5KeyTypeWithDigestLength, 23);
+ RUN_TEST(test_SHA1KeyTypeWithDigestLength, 32);
+ RUN_TEST(test_MD5KeyName, 47);
+ RUN_TEST(test_SHA1KeyName, 51);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "strtolfp.c";
UnityBegin("strtolfp.c");
- RUN_TEST(test_PositiveInteger, 9);
- RUN_TEST(test_NegativeInteger, 23);
- RUN_TEST(test_PositiveFraction, 40);
- RUN_TEST(test_NegativeFraction, 54);
- RUN_TEST(test_PositiveMsFraction, 71);
- RUN_TEST(test_NegativeMsFraction, 87);
- RUN_TEST(test_InvalidChars, 105);
+ RUN_TEST(test_PositiveInteger, 11);
+ RUN_TEST(test_NegativeInteger, 25);
+ RUN_TEST(test_PositiveFraction, 42);
+ RUN_TEST(test_NegativeFraction, 56);
+ RUN_TEST(test_PositiveMsFraction, 73);
+ RUN_TEST(test_NegativeMsFraction, 89);
+ RUN_TEST(test_InvalidChars, 107);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "timespecops.c";
UnityBegin("timespecops.c");
- RUN_TEST(test_Helpers1, 156);
- RUN_TEST(test_Normalise, 176);
- RUN_TEST(test_SignNoFrac, 190);
- RUN_TEST(test_SignWithFrac, 202);
- RUN_TEST(test_CmpFracEQ, 216);
- RUN_TEST(test_CmpFracGT, 229);
- RUN_TEST(test_CmpFracLT, 242);
- RUN_TEST(test_AddFullNorm, 259);
- RUN_TEST(test_AddFullOflow1, 273);
- RUN_TEST(test_AddNsecNorm, 287);
- RUN_TEST(test_AddNsecOflow1, 299);
- RUN_TEST(test_SubFullNorm, 315);
- RUN_TEST(test_SubFullOflow, 329);
- RUN_TEST(test_SubNsecNorm, 343);
- RUN_TEST(test_SubNsecOflow, 355);
- RUN_TEST(test_Neg, 371);
- RUN_TEST(test_AbsNoFrac, 388);
- RUN_TEST(test_AbsWithFrac, 399);
- RUN_TEST(test_Helpers2, 414);
- RUN_TEST(test_ToLFPbittest, 446);
- RUN_TEST(test_ToLFPrelPos, 459);
- RUN_TEST(test_ToLFPrelNeg, 471);
- RUN_TEST(test_ToLFPabs, 483);
- RUN_TEST(test_FromLFPbittest, 498);
- RUN_TEST(test_FromLFPrelPos, 517);
- RUN_TEST(test_FromLFPrelNeg, 530);
- RUN_TEST(test_LFProundtrip, 545);
- RUN_TEST(test_ToString, 564);
+ RUN_TEST(test_Helpers1, 155);
+ RUN_TEST(test_Normalise, 175);
+ RUN_TEST(test_SignNoFrac, 189);
+ RUN_TEST(test_SignWithFrac, 201);
+ RUN_TEST(test_CmpFracEQ, 215);
+ RUN_TEST(test_CmpFracGT, 228);
+ RUN_TEST(test_CmpFracLT, 241);
+ RUN_TEST(test_AddFullNorm, 258);
+ RUN_TEST(test_AddFullOflow1, 272);
+ RUN_TEST(test_AddNsecNorm, 286);
+ RUN_TEST(test_AddNsecOflow1, 298);
+ RUN_TEST(test_SubFullNorm, 314);
+ RUN_TEST(test_SubFullOflow, 328);
+ RUN_TEST(test_SubNsecNorm, 342);
+ RUN_TEST(test_SubNsecOflow, 354);
+ RUN_TEST(test_Neg, 370);
+ RUN_TEST(test_AbsNoFrac, 387);
+ RUN_TEST(test_AbsWithFrac, 398);
+ RUN_TEST(test_Helpers2, 413);
+ RUN_TEST(test_ToLFPbittest, 445);
+ RUN_TEST(test_ToLFPrelPos, 458);
+ RUN_TEST(test_ToLFPrelNeg, 470);
+ RUN_TEST(test_ToLFPabs, 482);
+ RUN_TEST(test_FromLFPbittest, 497);
+ RUN_TEST(test_FromLFPrelPos, 516);
+ RUN_TEST(test_FromLFPrelNeg, 529);
+ RUN_TEST(test_LFProundtrip, 544);
+ RUN_TEST(test_ToString, 563);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "timevalops.c";
UnityBegin("timevalops.c");
- RUN_TEST(test_Helpers1, 155);
- RUN_TEST(test_Normalise, 175);
- RUN_TEST(test_SignNoFrac, 189);
- RUN_TEST(test_SignWithFrac, 201);
- RUN_TEST(test_CmpFracEQ, 216);
- RUN_TEST(test_CmpFracGT, 230);
- RUN_TEST(test_CmpFracLT, 244);
- RUN_TEST(test_AddFullNorm, 262);
- RUN_TEST(test_AddFullOflow1, 276);
- RUN_TEST(test_AddUsecNorm, 290);
- RUN_TEST(test_AddUsecOflow1, 302);
- RUN_TEST(test_SubFullNorm, 318);
- RUN_TEST(test_SubFullOflow, 332);
- RUN_TEST(test_SubUsecNorm, 346);
- RUN_TEST(test_SubUsecOflow, 358);
- RUN_TEST(test_Neg, 374);
- RUN_TEST(test_AbsNoFrac, 391);
- RUN_TEST(test_AbsWithFrac, 402);
- RUN_TEST(test_Helpers2, 418);
- RUN_TEST(test_ToLFPbittest, 451);
- RUN_TEST(test_ToLFPrelPos, 466);
- RUN_TEST(test_ToLFPrelNeg, 480);
- RUN_TEST(test_ToLFPabs, 493);
- RUN_TEST(test_FromLFPbittest, 511);
- RUN_TEST(test_FromLFPrelPos, 529);
- RUN_TEST(test_FromLFPrelNeg, 542);
- RUN_TEST(test_LFProundtrip, 556);
- RUN_TEST(test_ToString, 575);
+ RUN_TEST(test_Helpers1, 153);
+ RUN_TEST(test_Normalise, 173);
+ RUN_TEST(test_SignNoFrac, 187);
+ RUN_TEST(test_SignWithFrac, 199);
+ RUN_TEST(test_CmpFracEQ, 214);
+ RUN_TEST(test_CmpFracGT, 228);
+ RUN_TEST(test_CmpFracLT, 242);
+ RUN_TEST(test_AddFullNorm, 260);
+ RUN_TEST(test_AddFullOflow1, 274);
+ RUN_TEST(test_AddUsecNorm, 288);
+ RUN_TEST(test_AddUsecOflow1, 300);
+ RUN_TEST(test_SubFullNorm, 316);
+ RUN_TEST(test_SubFullOflow, 330);
+ RUN_TEST(test_SubUsecNorm, 344);
+ RUN_TEST(test_SubUsecOflow, 356);
+ RUN_TEST(test_Neg, 372);
+ RUN_TEST(test_AbsNoFrac, 389);
+ RUN_TEST(test_AbsWithFrac, 400);
+ RUN_TEST(test_Helpers2, 416);
+ RUN_TEST(test_ToLFPbittest, 449);
+ RUN_TEST(test_ToLFPrelPos, 464);
+ RUN_TEST(test_ToLFPrelNeg, 478);
+ RUN_TEST(test_ToLFPabs, 491);
+ RUN_TEST(test_FromLFPbittest, 509);
+ RUN_TEST(test_FromLFPrelPos, 527);
+ RUN_TEST(test_FromLFPrelNeg, 540);
+ RUN_TEST(test_LFProundtrip, 554);
+ RUN_TEST(test_ToString, 573);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "tstotv.c";
UnityBegin("tstotv.c");
- RUN_TEST(test_Seconds, 7);
- RUN_TEST(test_MicrosecondsExact, 19);
- RUN_TEST(test_MicrosecondsRounding, 33);
+ RUN_TEST(test_Seconds, 9);
+ RUN_TEST(test_MicrosecondsExact, 21);
+ RUN_TEST(test_MicrosecondsRounding, 35);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "tvtots.c";
UnityBegin("tvtots.c");
- RUN_TEST(test_Seconds, 9);
- RUN_TEST(test_MicrosecondsRounded, 20);
- RUN_TEST(test_MicrosecondsExact, 35);
+ RUN_TEST(test_Seconds, 10);
+ RUN_TEST(test_MicrosecondsRounded, 21);
+ RUN_TEST(test_MicrosecondsExact, 36);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "uglydate.c";
UnityBegin("uglydate.c");
- RUN_TEST(test_ConstantDateTime, 10);
+ RUN_TEST(test_ConstantDateTime, 11);
return (UnityEnd());
}
#ifndef TESTS_SOCKADDRTEST_H
#define TESTS_SOCKADDRTEST_H
-#include "libntptest.h"
-
-extern "C" {
#include "ntp.h"
-};
-
-class sockaddrtest : public libntptest {
-protected:
- ::testing::AssertionResult IsEqual(const sockaddr_u &expected, const sockaddr_u &actual) {
- if (expected.sa.sa_family != actual.sa.sa_family) {
- return ::testing::AssertionFailure()
- << "Expected sa_family: " << expected.sa.sa_family
- << " but got: " << actual.sa.sa_family;
- }
+#include "ntp_stdlib.h"
- if (actual.sa.sa_family == AF_INET) { // IPv4
- if (expected.sa4.sin_port == actual.sa4.sin_port &&
- memcmp(&expected.sa4.sin_addr, &actual.sa4.sin_addr,
- sizeof(in_addr)) == 0) {
- return ::testing::AssertionSuccess();
- } else {
- return ::testing::AssertionFailure()
- << "IPv4 comparision failed, expected: "
- << expected.sa4.sin_addr.s_addr
- << "(" << socktoa(&expected) << ")"
- << " but was: "
- << actual.sa4.sin_addr.s_addr
- << "(" << socktoa(&actual) << ")";
- }
- } else if (actual.sa.sa_family == AF_INET6) { //IPv6
- if (expected.sa6.sin6_port == actual.sa6.sin6_port &&
- memcmp(&expected.sa6.sin6_addr, &actual.sa6.sin6_addr,
- sizeof(in6_addr)) == 0) {
- return ::testing::AssertionSuccess();
- } else {
- return ::testing::AssertionFailure()
- << "IPv6 comparision failed";
- }
- } else { // Unknown family
- return ::testing::AssertionFailure()
- << "Unknown sa_family: " << actual.sa.sa_family;
- }
- }
+sockaddr_u CreateSockaddr4(const char* address, unsigned int port) {
+ sockaddr_u s;
+ s.sa4.sin_family = AF_INET;
+ s.sa4.sin_addr.s_addr = inet_addr(address);
+ SET_PORT(&s, port);
+
+ return s;
+}
+
+int IsEqual(const sockaddr_u expected, const sockaddr_u actual) {
+ struct in_addr in;
+ struct in6_addr in6;
- sockaddr_u CreateSockaddr4(const char* address, unsigned int port) {
- sockaddr_u s;
- s.sa4.sin_family = AF_INET;
- s.sa4.sin_addr.s_addr = inet_addr(address);
- SET_PORT(&s, port);
+ if (expected.sa.sa_family != actual.sa.sa_family) {
+ //<< "Expected sa_family: " << expected.sa.sa_family
+ //<< " but got: " << actual.sa.sa_family;
+ return FALSE;
+ }
- return s;
+ if (actual.sa.sa_family == AF_INET) { // IPv4
+ if (expected.sa4.sin_port == actual.sa4.sin_port &&
+ memcmp(&expected.sa4.sin_addr, &actual.sa4.sin_addr,
+ sizeof( in )) == 0) {
+ return TRUE;
+ } else {
+ //<< "IPv4 comparision failed, expected: "
+ //<< expected.sa4.sin_addr.s_addr
+ //<< "(" << socktoa(&expected) << ") but was: "
+ //<< actual.sa4.sin_addr.s_addr "(" << socktoa(&actual) << ")";
+ return FALSE;
+ }
+ } else if (actual.sa.sa_family == AF_INET6) { //IPv6
+ if (expected.sa6.sin6_port == actual.sa6.sin6_port &&
+ memcmp(&expected.sa6.sin6_addr, &actual.sa6.sin6_addr,
+ sizeof(in6)) == 0) {
+ return TRUE;
+ } else {
+ printf("IPv6 comparision failed");
+ return FALSE;
+ }
+ } else { // Unknown family
+ printf("Unknown sa_family: ");// << actual.sa.sa_family;
+ return FALSE;
}
-};
+}
+
#endif // TESTS_SOCKADDRTEST_H
+
+
#include "config.h"
+
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
+
#include "unity.h"
-#include "c_sockaddrtest.h"
+#include "sockaddrtest.h"
void test_IPv4AddressWithPort(void) {
#include "config.h"
+#include "ntp.h"
+
#ifdef OPENSSL
# include "openssl/err.h"
# include "openssl/rand.h"
# include "openssl/evp.h"
#endif
-#include "ntp.h"
#include "unity.h"
#include "config.h"
+
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
+
#include "unity.h"
-#include "c_lfptest.h"
+#include "lfptest.h"
/* This file tests both atolfp and mstolfp */
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
+
#include "test-libntp.h"
//const char *progname = "test-libntp";
-//#include "tests_main.h"
#include "config.h"
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
-//u_long current_time = 4; // needed by authkeys. Used only in to calculate lifetime.
-//const char *progname = "libntptest";
static time_t timefunc(time_t*);
static time_t nowtime;
#include "config.h"
-//#include "c_timestructs.h"
#include "ntp_types.h"
#include "ntp_fp.h"
* HRVs (human readable values) but we might also be interested in the
* machine representation for diagnostic purposes.
*/
+
+
+//#ifndef TESTCALSHIMS_H
+#include "testcalshims.h"
+//#endif
+
+
#ifndef TIMESTRUCTS_H
#define TIMESTRUCTS_H
-extern "C" {
#include "ntp_fp.h"
-}
-namespace timeStruct {
+
+l_fp test ;
+//namespace timeStruct {
// wrap a l_fp struct with common operations
-class l_fp_wrap {
- public:
+struct l_fp_wrap {
+
l_fp V;
- l_fp_wrap()
- { ZERO(V); }
- l_fp_wrap(u_int32 hi, u_int32 lo)
- { V.l_ui = hi; V.l_uf = lo; }
- l_fp_wrap(const l_fp &rhs)
- { V = rhs; }
- bool operator == (const l_fp_wrap& rhs) const
- { return L_ISEQU(&V, &rhs.V); }
- operator l_fp* ()
- { return &V; }
- operator l_fp& ()
- { return V; }
+
+ //bool operator == (const l_fp_wrap& rhs) const
+ // { return L_ISEQU(&V, &rhs.V); }
+
+//---------------THIS HAS TO BE MANUALLY CONVERTED IN CODE!!!
+ //operator l_fp* ()
+ // { return &V; }
+ //operator l_fp& ()
+ // { return V; }
+//-----------------------------------------
+/*
l_fp_wrap & operator = (const l_fp_wrap& rhs)
{ V = rhs.V; return *this; }
l_fp_wrap& operator = (const l_fp& rhs)
{ V = rhs; return *this; }
- };
+*/
+};
+
+l_fp_wrap(l_fp V){
+ ZERO(V); }
+l_fp_wrap(l_fp V, u_int32 hi, u_int32 lo){
+ V.l_ui = hi; V.l_uf = lo; }
+l_fp_wrap(l_fp V, const l_fp &rhs){
+ V = rhs; }
+
+l_fp_wrap_equals(const l_fp_wrap& current, const l_fp_wrap& rhs) const // operator ==
+ { return L_ISEQU(¤t.V, &rhs.V); }
+
+l_fp_wrap_and(const l_fp_wrap& current, const l_fp_wrap& rhs){
+ V = rhs.V;
+ return current//*this;
+}
+l_fp_wrap_and(const l_fp& current, const l_fp& rhs){
+ V = rhs;
+ return current//*this;
+}
+
+
// wrap a 'struct timeval' with common operations
-class timeval_wrap {
-public:
+struct timeval_wrap {
+
struct timeval V;
timeval_wrap()
};
// wrap a 'struct timespec' with common operations
-class timespec_wrap {
-public:
+struct timespec_wrap {
+
struct timespec V;
timespec_wrap()
extern std::ostream& operator << (std::ostream& os,
const timeStruct::timespec_wrap& val);
-} // namespace timeStruct
+//} // namespace timeStruct
#endif // TIMESTRUCTS_H
#include "config.h"
-//#include "c_timestructs.h" //functions removed from the wrapper and placed directly here!
//some unused features are still in the wrapper, unconverted
-#include "unity.h"
-
#include "ntp_types.h"
#include "ntp_fp.h"
#include <math.h>
#include "timevalops.h"
-#include <string.h>
+#include "unity.h"
+
//in unity_helper.h :
#define TEST_ASSERT_EQUAL_timeval(a, b) { \
#include "config.h"
+
#include "ntp_fp.h"
#include "timevalops.h"
+
#include "unity.h"
void
TEST_ASSERT_EQUAL(expected.tv_sec, actual.tv_sec);
TEST_ASSERT_EQUAL(expected.tv_usec, actual.tv_usec);
-}
\ No newline at end of file
+}
#include "config.h"
-#include "c_lfptest.h"
+
+#include "lfptest.h"
#include "timevalops.h"
+
#include "unity.h"
#include <math.h>// Required on Solaris for ldexp.
-
void test_Seconds(void)
{
struct timeval input = {500, 0}; // 500.0 s
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
#include "ntp_fp.h"
+
#include "unity.h"
#include "config.h"
#include "ntp_stdlib.h"
-//#include "ntp_calendar.h"
-#include "vint64ops.h"
#include "unity.h"
+#include "vint64ops.h"
+
//technically bool
//int IsEqual(const vint64 &expected, const vint64 &actual) {
int IsEqual(const vint64 expected, const vint64 actual) {