// Required for Solaris.
#include <math.h>
+void test_ZeroBuffer(void);
+void test_IntegerAndFractionalBuffer(void);
+void test_IllegalMicroseconds(void);
+void test_AlwaysFalseOnWindows(void);
void
static int leapdays(int year);
-char * CalendarFromCalToString(const struct calendar cal); //&
-char * CalendarFromIsoToString(const struct isodate iso); //&
+char * CalendarFromCalToString(const struct calendar cal);
+char * CalendarFromIsoToString(const struct isodate iso);
// technically, booleans
-int IsEqualCal(const struct calendar expected, const struct calendar actual); //&&
-int IsEqualIso(const struct isodate expected, const struct isodate actual); //&&
+int IsEqualCal(const struct calendar expected, const struct calendar actual);
+int IsEqualIso(const struct isodate expected, const struct isodate actual);
-char * DateFromCalToStringCal(const struct calendar cal); //&
-char * DateFromIsoToStringIso(const struct isodate iso); //&
+char * DateFromCalToStringCal(const struct calendar cal);
+char * DateFromIsoToStringIso(const struct isodate iso);
// technically, booleans
-int sEqualDateCal(const struct calendar expected, const struct calendar actual); //&&
-int IsEqualDateIso(const struct isodate expected, const struct isodate actual); //&&
+int sEqualDateCal(const struct calendar expected, const struct calendar actual);
+int IsEqualDateIso(const struct isodate expected, const struct isodate actual);
+
+
+int isGT(int first, int second);
+int leapdays(int year);
+char * CalendarFromCalToString(const struct calendar cal);
+char * CalendarFromIsoToString(const struct isodate iso);
+int IsEqualCal(const struct calendar expected, const struct calendar actual);
+int IsEqualIso(const struct isodate expected, const struct isodate actual);
+char * DateFromCalToString(const struct calendar cal);
+char * DateFromIsoToString(const struct isodate iso);
+int IsEqualDateCal(const struct calendar expected, const struct calendar actual);
+int IsEqualDateIso(const struct isodate expected, const struct isodate actual);
+void test_DaySplitMerge(void);
+void test_SplitYearDays1(void);
+void test_SplitYearDays2(void);
+void test_RataDie1(void);
+void test_LeapYears1(void);
+void test_LeapYears2(void);
+void test_RoundTripDate(void);
+void test_RoundTripYearStart(void);
+void test_RoundTripMonthStart(void);
+void test_RoundTripWeekStart(void);
+void test_RoundTripDayStart(void);
// ---------------------------------------------------------------------
int
-isGT(int first, int second){
+isGT(int first, int second)
+{
if(first > second) {
return TRUE;
} else {
}
char *
-CalendarFromCalToString(const struct calendar cal) { //&
+CalendarFromCalToString(const struct calendar cal) {
char * str = malloc (sizeof (char) * 100);
char buffer[100] ="";
}
char *
-CalendarFromIsoToString(const struct isodate iso) { //&
+CalendarFromIsoToString(const struct isodate iso) {
char * str = malloc (sizeof (char) * 100);
}
int
-IsEqualCal(const struct calendar expected, const struct calendar actual) { //&&
+IsEqualCal(const struct calendar expected, const struct calendar actual) {
if (expected.year == actual.year &&
(!expected.yearday || expected.yearday == actual.yearday) &&
expected.month == actual.month &&
}
int
-IsEqualIso(const struct isodate expected, const struct isodate actual) { //&&
+IsEqualIso(const struct isodate expected, const struct isodate actual) {
if (expected.year == actual.year &&
expected.week == actual.week &&
expected.weekday == actual.weekday &&
}
char *
-DateFromCalToString(const struct calendar cal) { //&
+DateFromCalToString(const struct calendar cal) {
char * str = malloc (sizeof (char) * 100);
}
char *
-DateFromIsoToString(const struct isodate iso) { //&
+DateFromIsoToString(const struct isodate iso) {
char * str = malloc (sizeof (char) * 100);
// boolean
int
-IsEqualDateCal(const struct calendar expected, const struct calendar actual) { //&&
+IsEqualDateCal(const struct calendar expected, const struct calendar actual) {
if (expected.year == actual.year &&
(!expected.yearday || expected.yearday == actual.yearday) &&
expected.month == actual.month &&
// boolean
int
-IsEqualDateIso(const struct isodate expected, const struct isodate actual) { //&&
+IsEqualDateIso(const struct isodate expected, const struct isodate actual) {
if (expected.year == actual.year &&
expected.week == actual.week &&
expected.weekday == actual.weekday) {
#include <string.h>
+char * CalendarToString(const struct calendar cal);
+int IsEqual(const struct calendar expected, const struct calendar actual);
+void setUp(void);
+void tearDown(void);
+void test_RegularTime(void);
+void test_LeapYear(void);
+void test_uLongBoundary(void);
+void test_uLongWrapped(void);
+
+
char *
CalendarToString(const struct calendar cal) {
char * str = malloc (sizeof (char) * 100);
#include "ntp_calendar.h"
#include "unity.h"
+void test_DateGivenMonthDay(void);
+void test_DateGivenYearDay(void);
+void test_DateLeapYear(void);
+void test_WraparoundDateIn2036(void);
+
void
test_DateGivenMonthDay(void) {
// 2010-06-24 12:50:00
#include "test-libntp.h"
+void setUp(void);
+void tearDown(void);
+void test_NoWrapInDateRange(void);
+void test_NoWrapInDateRangeLeapYear(void);
+void test_WrapInDateRange(void);
void setUp(void)
{
#include "unity.h"
#include "test-libntp.h"
+void setUp(void);
+void tearDown(void);
+void test_CurrentYear(void);
+void test_CurrentYearFuzz(void);
+void test_TimeZoneOffset(void);
+void test_WrongYearStart(void);
+void test_PreviousYear(void);
+void test_NextYear(void);
+void test_NoReasonableConversion(void);
+void test_AlwaysInLimit(void);
+
// ---------------------------------------------------------------------
// test fixture
#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
test_IPv4AddressOnly(void) {
#include "unity.h"
+void test_SingleDigit(void);
+void test_MultipleDigits(void);
+void test_MaxUnsigned(void);
+void test_Overflow(void);
+void test_IllegalChar(void);
+
void test_SingleDigit(void) {
const char *str = "a"; // 10 decimal
#include "unity.h"
#include "lfptest.h"
+void test_PositiveInteger(void);
+void test_NegativeInteger(void);
+void test_PositiveFraction(void);
+void test_NegativeFraction(void);
+void test_IllegalNumberOfInteger(void);
+void test_IllegalChar(void);
+
void
test_PositiveInteger(void) {
#include "unity.h"
+void test_RegularTime(void);
+void test_CurrentTime(void);
+
+
void
test_RegularTime(void)
{
TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf"); \
}
+
+void test_AdditionLR(void);
+void test_AdditionRL(void);
+void test_SubtractionLR(void);
+void test_SubtractionRL(void);
+void test_Negation(void);
+void test_Absolute(void);
+void test_FDF_RoundTrip(void);
+void test_SignedRelOps(void);
+void test_UnsignedRelOps(void);
+
+
+
typedef struct {
uint32_t h, l;
} lfp_hl;
#include "config.h"
#include "ntp_fp.h"
+#include "lfptest.h"
int IsEqual(const l_fp expected, const l_fp actual) {
if (L_ISEQU(&expected, &actual)) {
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
test_PositiveInteger(void) {
l_fp test = {200, 0}; // exact 200.0000000000
#include "unity.h"
+void test_KnownMode(void);
+void test_UnknownMode(void);
+
void
test_KnownMode(void) {
#endif
+void test_msnprintf(void);
+void test_msnprintfLiteralPercentm(void);
+void test_msnprintfBackslashLiteralPercentm(void);
+void test_msnprintfBackslashPercent(void);
+void test_msnprintfHangingPercent(void);
+void test_format_errmsgHangingPercent(void);
+void test_msnprintfNullTarget(void);
+void test_msnprintfTruncate(void);
+
+
void
test_msnprintf(void) {
#define FMT_PREFIX "msyslog.cpp ENOENT: "
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
-//#include "config.h"
-//#include "ntp_types.h"
-//#include "ntp_stdlib.h"
-//#include "lfptest.h"
-//#include "ntp_unixtime.h"
-//#include <math.h>
+#include "config.h"
+#include "ntp_types.h"
+#include "ntp_stdlib.h"
+#include "lfptest.h"
+#include "ntp_unixtime.h"
+#include <math.h>
//=======External Functions This Runner Calls=====
extern void setUp(void);
{
progname = argv[0];
UnityBegin("buftvtots.c");
- RUN_TEST(test_ZeroBuffer, 17);
- RUN_TEST(test_IntegerAndFractionalBuffer, 32);
- RUN_TEST(test_IllegalMicroseconds, 55);
- RUN_TEST(test_AlwaysFalseOnWindows, 69);
+ RUN_TEST(test_ZeroBuffer, 14);
+ RUN_TEST(test_IntegerAndFractionalBuffer, 15);
+ RUN_TEST(test_IllegalMicroseconds, 16);
+ RUN_TEST(test_AlwaysFalseOnWindows, 17);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("calendar.c");
- RUN_TEST(test_DaySplitMerge, 228);
- RUN_TEST(test_SplitYearDays1, 258);
- RUN_TEST(test_SplitYearDays2, 273);
- RUN_TEST(test_RataDie1, 289);
- RUN_TEST(test_LeapYears1, 300);
- RUN_TEST(test_LeapYears2, 316);
- RUN_TEST(test_RoundTripDate, 335);
- RUN_TEST(test_RoundTripYearStart, 365);
- RUN_TEST(test_RoundTripMonthStart, 382);
- RUN_TEST(test_RoundTripWeekStart, 399);
- RUN_TEST(test_RoundTripDayStart, 416);
+ RUN_TEST(test_DaySplitMerge, 36);
+ RUN_TEST(test_SplitYearDays1, 37);
+ RUN_TEST(test_SplitYearDays2, 38);
+ RUN_TEST(test_RataDie1, 39);
+ RUN_TEST(test_LeapYears1, 40);
+ RUN_TEST(test_LeapYears2, 41);
+ RUN_TEST(test_RoundTripDate, 42);
+ RUN_TEST(test_RoundTripYearStart, 43);
+ RUN_TEST(test_RoundTripMonthStart, 44);
+ RUN_TEST(test_RoundTripWeekStart, 45);
+ RUN_TEST(test_RoundTripDayStart, 46);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("caljulian.c");
- RUN_TEST(test_RegularTime, 73);
- RUN_TEST(test_LeapYear, 85);
- RUN_TEST(test_uLongBoundary, 97);
- RUN_TEST(test_uLongWrapped, 109);
+ RUN_TEST(test_RegularTime, 16);
+ RUN_TEST(test_LeapYear, 17);
+ RUN_TEST(test_uLongBoundary, 18);
+ RUN_TEST(test_uLongWrapped, 19);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("caltontp.c");
- RUN_TEST(test_DateGivenMonthDay, 6);
- RUN_TEST(test_DateGivenYearDay, 16);
- RUN_TEST(test_DateLeapYear, 27);
- RUN_TEST(test_WraparoundDateIn2036, 40);
+ RUN_TEST(test_DateGivenMonthDay, 5);
+ RUN_TEST(test_DateGivenYearDay, 6);
+ RUN_TEST(test_DateLeapYear, 7);
+ RUN_TEST(test_WraparoundDateIn2036, 8);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("calyearstart.c");
- RUN_TEST(test_NoWrapInDateRange, 22);
- RUN_TEST(test_NoWrapInDateRangeLeapYear, 30);
- RUN_TEST(test_WrapInDateRange, 38);
+ RUN_TEST(test_NoWrapInDateRange, 11);
+ RUN_TEST(test_NoWrapInDateRangeLeapYear, 12);
+ RUN_TEST(test_WrapInDateRange, 13);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("clocktime.c");
- RUN_TEST(test_CurrentYear, 35);
- RUN_TEST(test_CurrentYearFuzz, 51);
- RUN_TEST(test_TimeZoneOffset, 74);
- RUN_TEST(test_WrongYearStart, 95);
- RUN_TEST(test_PreviousYear, 115);
- RUN_TEST(test_NextYear, 135);
- RUN_TEST(test_NoReasonableConversion, 154);
- RUN_TEST(test_AlwaysInLimit, 177);
+ RUN_TEST(test_CurrentYear, 11);
+ RUN_TEST(test_CurrentYearFuzz, 12);
+ RUN_TEST(test_TimeZoneOffset, 13);
+ RUN_TEST(test_WrongYearStart, 14);
+ RUN_TEST(test_PreviousYear, 15);
+ RUN_TEST(test_NextYear, 16);
+ RUN_TEST(test_NoReasonableConversion, 17);
+ RUN_TEST(test_AlwaysInLimit, 18);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("decodenetnum.c");
- RUN_TEST(test_IPv4AddressOnly, 9);
- 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);
+ RUN_TEST(test_IPv4AddressOnly, 7);
+ RUN_TEST(test_IPv4AddressWithPort, 8);
+ RUN_TEST(test_IPv6AddressOnly, 9);
+ RUN_TEST(test_IPv6AddressWithPort, 10);
+ RUN_TEST(test_IllegalAddress, 11);
+ RUN_TEST(test_IllegalCharInPort, 12);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("hextoint.c");
- RUN_TEST(test_SingleDigit, 10);
- RUN_TEST(test_MultipleDigits, 18);
- RUN_TEST(test_MaxUnsigned, 26);
- RUN_TEST(test_Overflow, 34);
- RUN_TEST(test_IllegalChar, 41);
+ RUN_TEST(test_SingleDigit, 9);
+ RUN_TEST(test_MultipleDigits, 10);
+ RUN_TEST(test_MaxUnsigned, 11);
+ RUN_TEST(test_Overflow, 12);
+ RUN_TEST(test_IllegalChar, 13);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("hextolfp.c");
- 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);
+ RUN_TEST(test_PositiveInteger, 9);
+ RUN_TEST(test_NegativeInteger, 10);
+ RUN_TEST(test_PositiveFraction, 11);
+ RUN_TEST(test_NegativeFraction, 12);
+ RUN_TEST(test_IllegalNumberOfInteger, 13);
+ RUN_TEST(test_IllegalChar, 14);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("humandate.c");
- RUN_TEST(test_RegularTime, 9);
- RUN_TEST(test_CurrentTime, 24);
+ RUN_TEST(test_RegularTime, 8);
+ RUN_TEST(test_CurrentTime, 9);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("lfpfunc.c");
- RUN_TEST(test_AdditionLR, 251);
- RUN_TEST(test_AdditionRL, 265);
- RUN_TEST(test_SubtractionLR, 283);
- RUN_TEST(test_SubtractionRL, 296);
- RUN_TEST(test_Negation, 313);
- RUN_TEST(test_Absolute, 333);
- RUN_TEST(test_FDF_RoundTrip, 366);
- RUN_TEST(test_SignedRelOps, 393);
- RUN_TEST(test_UnsignedRelOps, 433);
+ RUN_TEST(test_AdditionLR, 22);
+ RUN_TEST(test_AdditionRL, 23);
+ RUN_TEST(test_SubtractionLR, 24);
+ RUN_TEST(test_SubtractionRL, 25);
+ RUN_TEST(test_Negation, 26);
+ RUN_TEST(test_Absolute, 27);
+ RUN_TEST(test_FDF_RoundTrip, 28);
+ RUN_TEST(test_SignedRelOps, 29);
+ RUN_TEST(test_UnsignedRelOps, 30);
return (UnityEnd());
}
progname = argv[0];
UnityBegin("lfptostr.c");
RUN_TEST(test_PositiveInteger, 23);
- RUN_TEST(test_NegativeInteger, 31);
- RUN_TEST(test_PositiveIntegerWithFraction, 39);
- RUN_TEST(test_NegativeIntegerWithFraction, 47);
- RUN_TEST(test_RoundingDownToInteger, 55);
- RUN_TEST(test_RoundingMiddleToInteger, 63);
- RUN_TEST(test_RoundingUpToInteger, 71);
- RUN_TEST(test_SingleDecimal, 79);
- RUN_TEST(test_MillisecondsRoundingUp, 87);
- RUN_TEST(test_MillisecondsRoundingDown, 97);
- RUN_TEST(test_UnsignedInteger, 106);
+ RUN_TEST(test_NegativeInteger, 24);
+ RUN_TEST(test_PositiveIntegerWithFraction, 25);
+ RUN_TEST(test_NegativeIntegerWithFraction, 26);
+ RUN_TEST(test_RoundingDownToInteger, 27);
+ RUN_TEST(test_RoundingMiddleToInteger, 28);
+ RUN_TEST(test_RoundingUpToInteger, 29);
+ RUN_TEST(test_SingleDecimal, 30);
+ RUN_TEST(test_MillisecondsRoundingUp, 31);
+ RUN_TEST(test_MillisecondsRoundingDown, 32);
+ RUN_TEST(test_UnsignedInteger, 33);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("modetoa.c");
- RUN_TEST(test_KnownMode, 9);
- RUN_TEST(test_UnknownMode, 16);
+ RUN_TEST(test_KnownMode, 7);
+ RUN_TEST(test_UnknownMode, 8);
return (UnityEnd());
}
{
progname = argv[0];
UnityBegin("msyslog.c");
- RUN_TEST(test_msnprintf, 14);
- RUN_TEST(test_msnprintfLiteralPercentm, 31);
- RUN_TEST(test_msnprintfBackslashLiteralPercentm, 47);
- RUN_TEST(test_msnprintfBackslashPercent, 62);
- RUN_TEST(test_msnprintfHangingPercent, 78);
- RUN_TEST(test_format_errmsgHangingPercent, 96);
- RUN_TEST(test_msnprintfNullTarget, 112);
- RUN_TEST(test_msnprintfTruncate, 124);
+ RUN_TEST(test_msnprintf, 13);
+ RUN_TEST(test_msnprintfLiteralPercentm, 14);
+ RUN_TEST(test_msnprintfBackslashLiteralPercentm, 15);
+ RUN_TEST(test_msnprintfBackslashPercent, 16);
+ RUN_TEST(test_msnprintfHangingPercent, 17);
+ RUN_TEST(test_format_errmsgHangingPercent, 18);
+ RUN_TEST(test_msnprintfNullTarget, 19);
+ RUN_TEST(test_msnprintfTruncate, 20);
return (UnityEnd());
}