removed stuff like 1==1 with TRUE. Also added cin cout stuff, should be replaced b
Many files:
new file
Makefile.am:
fixes to Lokesh-Damir merge, added new .h to noinst_SOURCES
c_lfptest.h:
put the static vars back in here, removed them from hextolfp.c, because more files will need them.
hextolfp.c:
removed static consts, placed them in c_lpftest.h
octtoint.c:
removed outdates testcalshims.h, replaced with required includes
bk: 557f57b2AUMb_7zs3jaMY7oj3giHSg
test-hextolfp \
test-netof \
test-socktoa \
+ test-decodenetnum \
$(NULL)
-#test-decodenetnum
if GTEST_AVAILABLE
check_PROGRAMS += tests
noinst_HEADERS = \
lfptest.h \
+ c_lfptest.h \
libntptest.h \
sockaddrtest.h \
+ c_sockaddrtest.h \
timestructs.h \
test-libntp.h \
$(NULL)
$(unity_tests_LDADD)
$(NULL)
-test_octtoint_CFLAGS = \
- -I$(top_srcdir)/sntp/unity \
+test_octtoint_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
$(NULL)
-test_octtoint_LDADD = \
- $(unity_tests_LDADD)
+test_octtoint_LDADD = \
+ $(unity_tests_LDADD) \
$(NULL)
-test_hextolfp_CFLAGS = \
- -I$(top_srcdir)/sntp/unity \
+test_hextolfp_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
$(NULL)
-test_hextolfp_LDADD = \
- $(unity_tests_LDADD)
+test_hextolfp_LDADD = \
+ $(unity_tests_LDADD) \
$(NULL)
-test_netof_CFLAGS = \
- -I$(top_srcdir)/sntp/unity \
+test_netof_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
$(NULL)
-test_netof_LDADD = \
- $(unity_tests_LDADD)
+test_netof_LDADD = \
+ $(unity_tests_LDADD) \
$(NULL)
-#test_decodenetnum_CFLAGS = \
-# -I$(top_srcdir)/sntp/unity \
-# $(NULL)
-#
-#test_decodenetnum_LDADD = \
-# $(unity_tests_LDADD)
-# $(NULL)
+test_decodenetnum_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
+ $(NULL)
+
+test_decodenetnum_LDADD = \
+ $(unity_tests_LDADD) \
+ $(NULL)
+
+test_socktoa_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
+ $(NULL)
-test_socktoa_CFLAGS = \
- -I$(top_srcdir)/sntp/unity \
+test_socktoa_LDADD = \
+ $(unity_tests_LDADD) \
$(NULL)
+test_a_md5encrypt_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
$(NULL)
test_a_md5encrypt_LDADD = \
$(NULL)
-
test_modetoa_SOURCES = \
modetoa.c \
run-test-modetoa.c \
run-test-atoint.c \
$(NULL)
-test_octtoint_SOURCES = \
- octtoint.c \
- run-test-octtoint.c \
+test_a_md5encrypt_SOURCES = \
+ a_md5encrypt.c \
+ run-test-a_md5encrypt.c \
$(NULL)
-test_hextolfp_SOURCES = \
- hextolfp.c \
- run-test-hextolfp.c \
+test_octtoint_SOURCES = \
+ octtoint.c \
+ run-test-octtoint.c \
$(NULL)
-test_netof_SOURCES = \
- netof.c \
- run-test-netof.c \
+test_hextolfp_SOURCES = \
+ hextolfp.c \
+ run-test-hextolfp.c \
$(NULL)
-#test_decodenetnum_SOURCES = \
-# decodenetnum.c \
-# run-test-decodenetnum.c \
-# $(NULL)
+test_netof_SOURCES = \
+ netof.c \
+ run-test-netof.c \
+ $(NULL)
-test_socktoa_SOURCES = \
- socktoa.c \
- run-test-socktoa.c \
+test_decodenetnum_SOURCES = \
+ decodenetnum.c \
+ run-test-decodenetnum.c \
+ $(NULL)
+
+test_socktoa_SOURCES = \
+ socktoa.c \
+ run-test-socktoa.c \
$(NULL)
test_atouint_SOURCES = \
test-libntp.c \
$(NULL)
-test_calendar_SOURCES = \
- calendar.c \
- run-test-calendar.c \
- test-libntp.c \
+test_calendar_SOURCES = \
+ calendar.c \
+ run-test-calendar.c \
+ test-libntp.c \
$(NULL)
$(srcdir)/run-test-caljulian.c \
$(srcdir)/run-test-calyearstart.c \
$(srcdir)/run-test-clocktime.c \
+ $(srcdir)/run-test-decodenetnum.c \
$(srcdir)/run-test-hextoint.c \
+ $(srcdir)/run-test-hextolfp.c \
$(srcdir)/run-test-lfpfunc.c \
$(srcdir)/run-test-modetoa.c \
+ $(srcdir)/run-test-netof.c \
$(srcdir)/run-test-numtoa.c \
$(srcdir)/run-test-numtohost.c \
+ $(srcdir)/run-test-octtoint.c \
$(srcdir)/run-test-refnumtoa.c \
+ $(srcdir)/run-test-socktoa.c \
$(srcdir)/run-test-statestr.c \
$(srcdir)/run-test-uglydate.c \
$(srcdir)/run-test-vi64ops.c \
$(srcdir)/run-test-netof.c: $(srcdir)/netof.c $(std_unity_list)
$(run_unity) netof.c run-test-netof.c
-#$(srcdir)/run-test-decodenetnum.c: $(srcdir)/decodenetnum.c $(std_unity_list)
-# $(run_unity) decodenetnum.c run-test-decodenetnum.c
+$(srcdir)/run-test-decodenetnum.c: $(srcdir)/decodenetnum.c $(std_unity_list)
+ $(run_unity) decodenetnum.c run-test-decodenetnum.c
$(srcdir)/run-test-socktoa.c: $(srcdir)/socktoa.c $(std_unity_list)
$(run_unity) socktoa.c run-test-socktoa.c
int IsEqual(const l_fp expected, const l_fp actual) {
if (L_ISEQU(&expected, &actual)) {
- return 1==1;
+ return TRUE;
} else {
- return 1==2;
+ //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
struct in6_addr in6;
if (expected.sa.sa_family != actual.sa.sa_family) {
- return 1==2;
+ //<< "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 1==1;
+ return TRUE;
} else {
- return 1==2;
+ //<< "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 1==1;
+ return TRUE;
} else {
- return 1==2;
+ printf("IPv6 comparision failed");
+ return FALSE;
}
} else { // Unknown family
- return 1==2;
+ printf("Unknown sa_family: ");// << actual.sa.sa_family;
+ return FALSE;
}
}
#include "unity.h"
#include "c_lfptest.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;
-
-
void test_PositiveInteger(void) {
const char *str = "00001000.00000000";
-#include "testcalshims.h"
+#include "config.h"
+
+#include "ntp_stdlib.h"
+//#include "ntp_calendar.h"
//#include "ntp_fp.h"
#include "unity.h"
--- /dev/null
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+ Unity.CurrentTestName = #TestFunc; \
+ Unity.CurrentTestLineNumber = TestLineNum; \
+ Unity.NumberOfTests++; \
+ if (TEST_PROTECT()) \
+ { \
+ setUp(); \
+ TestFunc(); \
+ } \
+ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+ { \
+ tearDown(); \
+ } \
+ UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+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);
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+ tearDown();
+ setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+ progname = argv[0];
+ 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);
+
+ return (UnityEnd());
+}
--- /dev/null
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+ Unity.CurrentTestName = #TestFunc; \
+ Unity.CurrentTestLineNumber = TestLineNum; \
+ Unity.NumberOfTests++; \
+ if (TEST_PROTECT()) \
+ { \
+ setUp(); \
+ TestFunc(); \
+ } \
+ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+ { \
+ tearDown(); \
+ } \
+ UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void test_PositiveInteger(void);
+extern void test_NegativeInteger(void);
+extern void test_PositiveFraction(void);
+extern void test_NegativeFraction(void);
+extern void test_IllegalNumberOfInteger(void);
+extern void test_IllegalChar(void);
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+ tearDown();
+ setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+ 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);
+
+ return (UnityEnd());
+}
--- /dev/null
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+ Unity.CurrentTestName = #TestFunc; \
+ Unity.CurrentTestLineNumber = TestLineNum; \
+ Unity.NumberOfTests++; \
+ if (TEST_PROTECT()) \
+ { \
+ setUp(); \
+ TestFunc(); \
+ } \
+ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+ { \
+ tearDown(); \
+ } \
+ UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void test_ClassBAddress(void);
+extern void test_ClassCAddress(void);
+extern void test_ClassAAddress(void);
+extern void test_IPv6Address(void);
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+ tearDown();
+ setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+ progname = argv[0];
+ Unity.TestFile = "netof.c";
+ UnityBegin("netof.c");
+ RUN_TEST(test_ClassBAddress, 10);
+ RUN_TEST(test_ClassCAddress, 20);
+ RUN_TEST(test_ClassAAddress, 30);
+ RUN_TEST(test_IPv6Address, 43);
+
+ return (UnityEnd());
+}
setUp();
}
+char *progname;
+
//=======MAIN=====
-int main(void)
+int main(int argc, char *argv[])
{
+ progname = argv[0];
Unity.TestFile = "octtoint.c";
UnityBegin("octtoint.c");
- RUN_TEST(test_SingleDigit, 5);
- RUN_TEST(test_MultipleDigits, 14);
- RUN_TEST(test_Zero, 23);
- RUN_TEST(test_MaximumUnsigned32bit, 32);
- RUN_TEST(test_Overflow, 41);
- RUN_TEST(test_IllegalCharacter, 49);
- RUN_TEST(test_IllegalDigit, 57);
+ 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);
return (UnityEnd());
}
--- /dev/null
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+ Unity.CurrentTestName = #TestFunc; \
+ Unity.CurrentTestLineNumber = TestLineNum; \
+ Unity.NumberOfTests++; \
+ if (TEST_PROTECT()) \
+ { \
+ setUp(); \
+ TestFunc(); \
+ } \
+ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+ { \
+ tearDown(); \
+ } \
+ UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void test_IPv4AddressWithPort(void);
+extern void test_IPv6AddressWithPort(void);
+extern void test_ScopedIPv6AddressWithPort(void);
+extern void test_HashEqual(void);
+extern void test_HashNotEqual(void);
+extern void test_IgnoreIPv6Fields(void);
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+ tearDown();
+ setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+ 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, 82);
+
+ return (UnityEnd());
+}