#include "config.h"
#include "ntp_stdlib.h"
+ #include "ntp_calendar.h"
#include "sockaddrtest.h"
-
#include "unity.h"
-
- 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);
+
+ void
test_IPv4AddressOnly(void) {
const char *str = "192.0.2.1";
sockaddr_u actual;
#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
-
-
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
+
+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
test_PositiveInteger(void) {
l_fp test = {200, 0}; // exact 200.0000000000
#include "sockaddrtest.h"
- void test_ClassBAddress(void) {
+
+void test_ClassBAddress(void);
+void test_ClassCAddress(void);
+void test_ClassAAddress(void);
+void test_IPv6Address(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);
#include "unity.h"
- void test_SingleDigit(void) {
+
+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) {
const char* str = "5";
u_long actual;
#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));
/* This file tests both atolfp and mstolfp */
- void test_PositiveInteger(void) {
+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) {
const char *str = "500";
const char *str_ms = "500000";