u_long current_time = 4;
-void setUp(void)
-{
-}
-
-void tearDown(void)
-{
-}
-
/*
* Example packet with MD5 hash calculated manually.
*/
const char *key = "abcdefgh";
const u_short keyLength = 8;
const char *packet = "ijklmnopqrstuvwx";
-#define packetLength 16 //const int packetLength = 16;
-#define keyIdLength 4 //const int keyIdLength = 4;
-#define digestLength 16 //const int digestLength = 16;
+#define packetLength 16
+#define keyIdLength 4
+#define digestLength 16
const int totalLength = packetLength + keyIdLength + digestLength;
const char *expectedPacket = "ijklmnopqrstuvwx\0\0\0\0\x0c\x0e\x84\xcf\x0b\xb7\xa8\x68\x8e\x52\x38\xdb\xbc\x1c\x39\x53";
-void test_Encrypt() {
- char *packetPtr = malloc(totalLength*sizeof(*packetPtr)); //new char[totalLength];
+void
+test_Encrypt(void) {
+ char *packetPtr;
+ int length;
+
+ packetPtr = malloc(totalLength * sizeof(*packetPtr));
- memset(packetPtr+packetLength, 0, keyIdLength);
+ memset(packetPtr + packetLength, 0, keyIdLength);
memcpy(packetPtr, packet, packetLength);
cache_secretsize = keyLength;
- int length = MD5authencrypt(keytype, (u_char*)key, (u_int32*)packetPtr, packetLength);
+ length = MD5authencrypt(keytype, (u_char*)key, (u_int32*)packetPtr, packetLength);
TEST_ASSERT_TRUE(MD5authdecrypt(keytype, (u_char*)key, (u_int32*)packetPtr, packetLength, length));
TEST_ASSERT_EQUAL(20, length);
- //TEST_ASSERT_TRUE(memcmp(expectedPacket, packetPtr, totalLength) == 0);
TEST_ASSERT_EQUAL_MEMORY(expectedPacket, packetPtr, totalLength);
- free(packetPtr); //delete[] packetPtr;
+ free(packetPtr);
}
-void test_DecryptValid() {
+void
+test_DecryptValid(void) {
cache_secretsize = keyLength;
TEST_ASSERT_TRUE(MD5authdecrypt(keytype, (u_char*)key, (u_int32*)expectedPacket, packetLength, 20));
}
-void test_DecryptInvalid() {
+void
+test_DecryptInvalid(void) {
cache_secretsize = keyLength;
const char *invalidPacket = "ijklmnopqrstuvwx\0\0\0\0\x0c\x0e\x84\xcf\x0b\xb7\xa8\x68\x8e\x52\x38\xdb\xbc\x1c\x39\x54";
TEST_ASSERT_FALSE(MD5authdecrypt(keytype, (u_char*)key, (u_int32*)invalidPacket, packetLength, 20));
}
-void test_IPv4AddressToRefId() {
+void
+test_IPv4AddressToRefId(void) {
sockaddr_u addr;
addr.sa4.sin_family = AF_INET;
+ u_int32 address;
+
addr.sa4.sin_port = htons(80);
- u_int32 address = inet_addr("192.0.2.1");
+ address = inet_addr("192.0.2.1");
addr.sa4.sin_addr.s_addr = address;
TEST_ASSERT_EQUAL(address, addr2refid(&addr));
}
-void test_IPv6AddressToRefId() {
+void
+test_IPv6AddressToRefId(void) {
const struct in6_addr address = {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
int counter = 0;
-// old code from google test framework, moved to SetUp() for unity
-void setUp(void)
+void
+setUp(void)
{
-// init_lib();
- if(counter ==0){
- counter++;
- init_auth(); //causes segfault if called more than once
+ if (counter == 0) {
+ counter++;
+ init_auth(); // causes segfault if called more than once
}
-/*
+ /*
* init_auth() is called by tests_main.cpp earlier. It
* does not initialize global variables like
* authnumkeys, so let's reset them to zero here.
cache_flags = 0;
cache_secret = NULL;
cache_secretsize = 0;
-
}
-void tearDown(void)
+void
+tearDown(void)
{
-}
+}
static const int KEYTYPE = KEY_TYPE_MD5;
-
-
-
-void AddTrustedKey(keyid_t keyno) {
+void
+AddTrustedKey(keyid_t keyno) {
/*
* We need to add a MD5-key in addition to setting the
* trust, because authhavekey() requires type != 0.
authtrust(keyno, TRUE);
}
-void AddUntrustedKey(keyid_t keyno) {
+void
+AddUntrustedKey(keyid_t keyno) {
authtrust(keyno, FALSE);
}
-void test_AddTrustedKeys() {
+void
+test_AddTrustedKeys() {
const keyid_t KEYNO1 = 5;
const keyid_t KEYNO2 = 8;
TEST_ASSERT_TRUE(authistrusted(KEYNO2));
}
-void test_AddUntrustedKey() {
+void
+test_AddUntrustedKey() {
const keyid_t KEYNO = 3;
AddUntrustedKey(KEYNO);
TEST_ASSERT_FALSE(authistrusted(KEYNO));
}
-void test_HaveKeyCorrect() {
+void
+test_HaveKeyCorrect() {
const keyid_t KEYNO = 3;
AddTrustedKey(KEYNO);
TEST_ASSERT_TRUE(authhavekey(KEYNO));
}
-void test_HaveKeyIncorrect() {
+void
+test_HaveKeyIncorrect() {
const keyid_t KEYNO = 2;
TEST_ASSERT_FALSE(auth_havekey(KEYNO));
TEST_ASSERT_FALSE(authhavekey(KEYNO));
}
-void test_AddWithAuthUseKey() {
+void
+test_AddWithAuthUseKey() {
const keyid_t KEYNO = 5;
const char* KEY = "52a";
TEST_ASSERT_TRUE(authusekey(KEYNO, KEYTYPE, (u_char*)KEY));
}
-void test_EmptyKey() {
+void
+test_EmptyKey() {
const keyid_t KEYNO = 3;
const char* KEY = "";
-void test_ZeroBuffer() {
+void
+test_ZeroBuffer(void) {
#ifndef SYS_WINNT
const struct timeval input = {0, 0};
const l_fp expected = {0 + JAN_1970, 0};
#endif
}
-void test_IntegerAndFractionalBuffer() {
+void
+test_IntegerAndFractionalBuffer(void) {
#ifndef SYS_WINNT
const struct timeval input = {5, 500000}; // 5.5
const l_fp expected = {5 + JAN_1970, HALF};
-
+ double expectedDouble, actualDouble;
l_fp actual;
TEST_ASSERT_TRUE(buftvtots((const char*)(&input), &actual));
// Compare the fractional part with an absolute error given.
TEST_ASSERT_EQUAL(expected.l_ui, actual.l_ui);
- double expectedDouble, actualDouble;
M_LFPTOD(0, expected.l_uf, expectedDouble);
M_LFPTOD(0, actual.l_uf, actualDouble);
// The error should be less than 0.5 us
- TEST_ASSERT_DOUBLE_WITHIN(0.0000005,expectedDouble,actualDouble); //delta,epected,actual //_EXPECT_NEAR(expectedDouble, actualDouble, 0.0000005);
+ TEST_ASSERT_DOUBLE_WITHIN(0.0000005, expectedDouble, actualDouble);
#else
TEST_IGNORE_MESSAGE("Test only for Windows, skipping...");
#endif
}
-void test_IllegalMicroseconds() {
+void
+test_IllegalMicroseconds(void) {
#ifndef SYS_WINNT
const struct timeval input = {0, 1100000}; // > 999 999 microseconds.
}
-void test_AlwaysFalseOnWindows() {
+void
+test_AlwaysFalseOnWindows(void) {
#ifdef SYS_WINNT
/*
* Under Windows, buftvtots will just return
#include "ntp_calendar.h"
#include "unity.h"
-//#include "test-libntp.h"
-
-
#include <string.h>
-//#include <sstream>
static int leapdays(int year);
char * CalendarFromCalToString(const struct calendar cal); //&
char * CalendarFromIsoToString(const struct isodate iso); //&
-//tehnically, booleans
+// technically, booleans
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); //&
-//tehnically, booleans
+// technically, booleans
int sEqualDateCal(const struct calendar expected, const struct calendar actual); //&&
int IsEqualDateIso(const struct isodate expected, const struct isodate actual); //&&
// test support stuff
// ---------------------------------------------------------------------
-//function which, in combination with TEST_ASSERT_TRUE replaces google test framework's EXPECT_GT(a,b); -> GT means Greather Than
-//boolean
-int isGT(int first,int second){
- if(first > second){
-
- return TRUE;
+int
+isGT(int first, int second){
+ if(first > second) {
+ return TRUE;
+ } else {
+ return FALSE;
}
-
- else return FALSE;
}
-
-int leapdays(int year)
+int
+leapdays(int year)
{
if (year % 400 == 0)
return 1;
return 0;
}
-char * CalendarFromCalToString(const struct calendar cal) { //&
- char * ss = malloc (sizeof (char) * 100);
+char *
+CalendarFromCalToString(const struct calendar cal) { //&
+ char * str = malloc (sizeof (char) * 100);
char buffer[100] ="";
- sprintf(buffer, "%u", cal.year);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)cal.month);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)cal.monthday);
- strcat(ss,buffer);
- strcat(ss," (");
- sprintf(buffer, "%u", cal.yearday);
- strcat(ss,buffer);
- strcat(ss,") ");
- sprintf(buffer, "%u", (u_int)cal.hour);
- strcat(ss,buffer);
- strcat(ss,":");
- sprintf(buffer, "%u", (u_int)cal.minute);
- strcat(ss,buffer);
- strcat(ss,":");
- sprintf(buffer, "%u", (u_int)cal.second);
- strcat(ss,buffer);
- //ss << cal.year << "-" << (u_int)cal.month << "-" << (u_int)cal.monthday << " (" << cal.yearday << ") " << (u_int)cal.hour << ":" << (u_int)cal.minute << ":" << (u_int)cal.second;
- return ss;
-
+ snprintf(buffer, 100, "%u", cal.year);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)cal.month);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)cal.monthday);
+ strcat(str, buffer);
+ strcat(str, " (");
+ snprintf(buffer, 100, "%u", cal.yearday);
+ strcat(str, buffer);
+ strcat(str, ") ");
+ snprintf(buffer, 100, "%u", (u_int)cal.hour);
+ strcat(str, buffer);
+ strcat(str, ":");
+ snprintf(buffer, 100, "%u", (u_int)cal.minute);
+ strcat(str, buffer);
+ strcat(str, ":");
+ snprintf(buffer, 100, "%u", (u_int)cal.second);
+ strcat(str, buffer);
+
+ return str;
}
-char * CalendarFromIsoToString(const struct isodate iso) { //&
+char *
+CalendarFromIsoToString(const struct isodate iso) { //&
- char * ss = malloc (sizeof (char) * 100);
+ char * str = malloc (sizeof (char) * 100);
char buffer[100] ="";
- sprintf(buffer, "%u", iso.year);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)iso.week);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)iso.weekday);
- strcat(ss,buffer);
- sprintf(buffer, "%u", (u_int)iso.hour);
- strcat(ss,buffer);
- strcat(ss,":");
- sprintf(buffer, "%u", (u_int)iso.minute);
- strcat(ss,buffer);
- strcat(ss,":");
- sprintf(buffer, "%u", (u_int)iso.second);
- strcat(ss,buffer);
- //ss << iso.year << "-" << (u_int)iso.week << "-" << (u_int)iso.weekday << (u_int)iso.hour << ":" << (u_int)iso.minute << ":" << (u_int)iso.second;
- return ss;
-
+ snprintf(buffer, 100, "%u", iso.year);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)iso.week);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)iso.weekday);
+ strcat(str, buffer);
+ snprintf(buffer, 100, "%u", (u_int)iso.hour);
+ strcat(str, buffer);
+ strcat(str, ":");
+ snprintf(buffer, 100, "%u", (u_int)iso.minute);
+ strcat(str, buffer);
+ strcat(str, ":");
+ snprintf(buffer, 100, "%u", (u_int)iso.second);
+ strcat(str, buffer);
+
+ return str;
}
-int IsEqualCal(const struct calendar expected, const struct calendar actual) { //&&
+int
+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) { //&&
+int
+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) { //&
+char *
+DateFromCalToString(const struct calendar cal) { //&
- char * ss = malloc (sizeof (char) * 100);
+ char * str = malloc (sizeof (char) * 100);
char buffer[100] ="";
- sprintf(buffer, "%u", cal.year);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)cal.month);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)cal.monthday);
- strcat(ss,buffer);
- strcat(ss," (");
- sprintf(buffer, "%u", cal.yearday);
- strcat(ss,buffer);
- strcat(ss,")");
+ snprintf(buffer, 100, "%u", cal.year);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)cal.month);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)cal.monthday);
+ strcat(str, buffer);
+ strcat(str, " (");
+ snprintf(buffer, 100, "%u", cal.yearday);
+ strcat(str, buffer);
+ strcat(str, ")");
- return ss;
- //ss << cal.year << "-" << (u_int)cal.month << "-" << (u_int)cal.monthday << " (" << cal.yearday << ")";
+ return str;
}
-char * DateFromIsoToString(const struct isodate iso) { //&
+char *
+DateFromIsoToString(const struct isodate iso) { //&
- char * ss = malloc (sizeof (char) * 100);
+ char * str = malloc (sizeof (char) * 100);
char buffer[100] ="";
- sprintf(buffer, "%u", iso.year);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)iso.week);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)iso.weekday);
- strcat(ss,buffer);
-
- return ss;
- //ss << iso.year << "-" << (u_int)iso.week << "-" << (u_int)iso.weekday;
-
+ snprintf(buffer, 100, "%u", iso.year);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)iso.week);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)iso.weekday);
+ strcat(str, buffer);
+
+ return str;
}
-//boolean
-int IsEqualDateCal(const struct calendar expected, const struct calendar actual) { //&&
+// boolean
+int
+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) { //&&
+// boolean
+int
+IsEqualDateIso(const struct isodate expected, const struct isodate actual) { //&&
if (expected.year == actual.year &&
expected.week == actual.week &&
expected.weekday == actual.weekday) {
// test the day/sec join & split ops, making sure that 32bit
// intermediate results would definitely overflow and the hi DWORD of
// the 'vint64' is definitely needed.
-void test_DaySplitMerge() {
+void
+test_DaySplitMerge(void) {
int32 day,sec;
for (day = -1000000; day <= 1000000; day += 100) {
for (sec = -100000; sec <= 186400; sec += 10000) {
- vint64 merge = ntpcal_dayjoin(day, sec);
- ntpcal_split split = ntpcal_daysplit(&merge);
- int32 eday = day;
- int32 esec = sec;
+ vint64 merge;
+ ntpcal_split split;
+ int32 eday;
+ int32 esec;
+
+ merge = ntpcal_dayjoin(day, sec);
+ split = ntpcal_daysplit(&merge);
+ eday = day;
+ esec = sec;
while (esec >= 86400) {
eday += 1;
}
}
-void test_SplitYearDays1() {
+void
+test_SplitYearDays1(void) {
int32 eyd;
for (eyd = -1; eyd <= 365; eyd++) {
ntpcal_split split = ntpcal_split_yeardays(eyd, 0);
if (split.lo >= 0 && split.hi >= 0) {
- TEST_ASSERT_TRUE(isGT(12,split.hi));//EXPECT_GT(12, split.hi);
- TEST_ASSERT_TRUE(isGT(real_month_days[0][split.hi+1], split.lo));//EXPECT_GT(real_month_days[0][split.hi+1], split.lo);
+ TEST_ASSERT_TRUE(isGT(12,split.hi));
+ TEST_ASSERT_TRUE(isGT(real_month_days[0][split.hi+1], split.lo));
int32 tyd = real_month_table[0][split.hi] + split.lo;
TEST_ASSERT_EQUAL(eyd, tyd);
} else
}
}
-void test_SplitYearDays2() {
+void
+test_SplitYearDays2(void) {
int32 eyd;
for (eyd = -1; eyd <= 366; eyd++) {
ntpcal_split split = ntpcal_split_yeardays(eyd, 1);
}
}
-void test_RataDie1() {
+void
+test_RataDie1(void) {
int32 testDate = 1; // 0001-01-01 (proleptic date)
struct calendar expected = { 1, 1, 1, 1 };
struct calendar actual;
}
// check last day of february for first 10000 years
-void test_LeapYears1() {
+void
+test_LeapYears1(void) {
struct calendar dateIn, dateOut;
for (dateIn.year = 1; dateIn.year < 10000; ++dateIn.year) {
}
// check first day of march for first 10000 years
-void test_LeapYears2() {
+void
+test_LeapYears2(void) {
struct calendar dateIn, dateOut;
for (dateIn.year = 1; dateIn.year < 10000; ++dateIn.year) {
// (since the input is all nominal days of the calendar in that range
// and the result of the inverse calculation must match the input no
// invalid output can occur.)
-void test_RoundTripDate() {
+void
+test_RoundTripDate(void) {
struct calendar truDate, expDate = { 1600, 0, 12, 31 };;
- int32 truRdn, expRdn = ntpcal_date_to_rd(&expDate);
int leaps;
+ int32 truRdn, expRdn = ntpcal_date_to_rd(&expDate);
while (expDate.year < 2400) {
expDate.year++;
}
// Roundtrip testing on calyearstart
-void test_RoundTripYearStart() {
+void
+test_RoundTripYearStart(void) {
static const time_t pivot = 0;
u_int32 ntp, expys, truys;
struct calendar date;
}
// Roundtrip testing on calymonthstart
-void test_RoundTripMonthStart() {
+void
+test_RoundTripMonthStart(void) {
static const time_t pivot = 0;
u_int32 ntp, expms, trums;
struct calendar date;
}
// Roundtrip testing on calweekstart
-void test_RoundTripWeekStart() {
+void
+test_RoundTripWeekStart(void) {
static const time_t pivot = 0;
u_int32 ntp, expws, truws;
struct isodate date;
}
// Roundtrip testing on caldaystart
-void test_RoundTripDayStart() {
+void
+test_RoundTripDayStart(void) {
static const time_t pivot = 0;
u_int32 ntp, expds, truds;
struct calendar date;
TEST_ASSERT_EQUAL(expds, truds);
}
}
-
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
-#include "unity.h"
+#include "unity.h"
#include "test-libntp.h"
-
#include <string.h>
-//#include <stdlib.h>
-//added struct to calendar!
-char * CalendarToString(const struct calendar cal) {
- char * ss = malloc (sizeof (char) * 100);
+char *
+CalendarToString(const struct calendar cal) {
+ char * str = malloc (sizeof (char) * 100);
char buffer[100] ="";
- sprintf(buffer, "%u", cal.year);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)cal.month);
- strcat(ss,buffer);
- strcat(ss,"-");
- sprintf(buffer, "%u", (u_int)cal.monthday);
- strcat(ss,buffer);
- strcat(ss," (");
- sprintf(buffer, "%u", (u_int) cal.yearday);
- strcat(ss,buffer);
- strcat(ss,") ");
- sprintf(buffer, "%u", (u_int)cal.hour);
- strcat(ss,buffer);
- strcat(ss,":");
- sprintf(buffer, "%u", (u_int)cal.minute);
- strcat(ss,buffer);
- strcat(ss,":");
- sprintf(buffer, "%u", (u_int)cal.second);
- strcat(ss,buffer);
- //ss << cal.year << "-" << (u_int)cal.month << "-" << (u_int)cal.monthday << " (" << cal.yearday << ") " << (u_int)cal.hour << ":" << (u_int)cal.minute << ":" << (u_int)cal.second;
- return ss;
+ snprintf(buffer, 100, "%u", cal.year);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)cal.month);
+ strcat(str, buffer);
+ strcat(str, "-");
+ snprintf(buffer, 100, "%u", (u_int)cal.monthday);
+ strcat(str, buffer);
+ strcat(str, " (");
+ snprintf(buffer, 100, "%u", (u_int) cal.yearday);
+ strcat(str, buffer);
+ strcat(str, ") ");
+ snprintf(buffer, 100, "%u", (u_int)cal.hour);
+ strcat(str, buffer);
+ strcat(str, ":");
+ snprintf(buffer, 100, "%u", (u_int)cal.minute);
+ strcat(str, buffer);
+ strcat(str, ":");
+ snprintf(buffer, 100, "%u", (u_int)cal.second);
+ strcat(str, buffer);
+ return str;
}
-//tehnically boolean
-int IsEqual(const struct calendar expected, const struct calendar actual) {
+int // technically boolean
+IsEqual(const struct calendar expected, const struct calendar actual) {
if (expected.year == actual.year &&
(expected.yearday == actual.yearday ||
(expected.month == actual.month &&
}
-void setUp()
+void
+setUp()
{
-
ntpcal_set_timefunc(timefunc);
settime(1970, 1, 1, 0, 0, 0);
}
-void tearDown()
+void
+tearDown()
{
ntpcal_set_timefunc(NULL);
}
-void test_RegularTime() {
+void
+test_RegularTime(void) {
u_long testDate = 3485080800UL; // 2010-06-09 14:00:00
struct calendar expected = {2010,160,6,9,14,0,0};
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_LeapYear() {
+void
+test_LeapYear(void) {
u_long input = 3549902400UL; // 2012-06-28 20:00:00Z
struct calendar expected = {2012, 179, 6, 28, 20, 0, 0};
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_uLongBoundary() {
+void
+test_uLongBoundary(void) {
u_long time = 4294967295UL; // 2036-02-07 6:28:15
struct calendar expected = {2036,0,2,7,6,28,15};
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_uLongWrapped() {
+void
+test_uLongWrapped(void) {
u_long time = 0;
struct calendar expected = {2036,0,2,7,6,28,16};
#include "config.h"
-#include "unity.h"
#include "ntp_calendar.h"
+#include "unity.h"
void
test_DateGivenMonthDay(void) {
// dependent on the actual system time.
-void setUp()
+void
+setUp()
{
ntpcal_set_timefunc(timefunc);
settime(2000, 1, 1, 0, 0, 0);
}
-void tearDown()
+void
+tearDown()
{
ntpcal_set_timefunc(NULL);
}
// ---------------------------------------------------------------------
// test cases
-void test_CurrentYear() {
+void
+test_CurrentYear(void) {
// Timestamp: 2010-06-24 12:50:00Z
const u_int32 timestamp = 3486372600UL;
const u_int32 expected = timestamp; // exactly the same.
TEST_ASSERT_EQUAL(expected, actual);
}
-void test_CurrentYearFuzz() {
+void
+test_CurrentYearFuzz(void) {
/*
* Timestamp (rec_ui) is: 2010-06-24 12:50:00
* Time sent into function is 12:00:00.
TEST_ASSERT_EQUAL(expected, actual);
}
-void test_TimeZoneOffset() {
+void
+test_TimeZoneOffset(void) {
/*
* Timestamp (rec_ui) is: 2010-06-24 12:00:00 +0800
* (which is 2010-06-24 04:00:00Z)
TEST_ASSERT_EQUAL(expected, actual);
}
-void test_WrongYearStart() {
+void
+test_WrongYearStart(void) {
/*
* Timestamp (rec_ui) is: 2010-01-02 11:00:00Z
* Time sent into function is 11:00:00.
TEST_ASSERT_EQUAL(expected, actual);
}
-void test_PreviousYear() {
+void
+test_PreviousYear(void) {
/*
* Timestamp is: 2010-01-01 01:00:00Z
* Time sent into function is 23:00:00
TEST_ASSERT_EQUAL(expected, actual);
}
-void test_NextYear() {
+void
+test_NextYear(void) {
/*
* Timestamp is: 2009-12-31 23:00:00Z
* Time sent into function is 01:00:00
TEST_ASSERT_EQUAL(expected, actual);
}
-void test_NoReasonableConversion() {
+void
+test_NoReasonableConversion(void) {
/* Timestamp is: 2010-01-02 11:00:00Z */
const u_int32 timestamp = 3471418800UL;
&yearstart, &actual));
}
-// *** FUNCTION isLE, to simulate gtest's ASSERT_LE using Unity's TEST_ASSERT_TRUE
-//tehnically boolean
-int isLE(u_int32 diff,u_int32 actual){
+
+int // technically boolean
+isLE(u_int32 diff,u_int32 actual){
if(diff <= actual){
return TRUE;
}
}
-void test_AlwaysInLimit() {
+void
+test_AlwaysInLimit(void) {
/* Timestamp is: 2010-01-02 11:00:00Z */
const u_int32 timestamp = 3471418800UL;
const u_short prime_incs[] = { 127, 151, 163, 179 };
diff = actual - timestamp;
if (diff >= 0x80000000UL)
diff = ~diff + 1;
- TEST_ASSERT_TRUE(isLE(diff, (183u * SECSPERDAY))); // adding new function to return TRUE if first number is less or equal the second
- //TEST_ASSERT_LE(diff, (183u * SECSPERDAY));
+ TEST_ASSERT_TRUE(isLE(diff, (183u * SECSPERDAY)));
}
}
}
extern void setUp(void);
extern void tearDown(void);
void resetTest(void);
-extern void test_Encrypt();
-extern void test_DecryptValid();
-extern void test_DecryptInvalid();
-extern void test_IPv4AddressToRefId();
-extern void test_IPv6AddressToRefId();
+extern void test_Encrypt(void);
+extern void test_DecryptValid(void);
+extern void test_DecryptInvalid(void);
+extern void test_IPv4AddressToRefId(void);
+extern void test_IPv6AddressToRefId(void);
//=======Test Reset Option=====
progname = argv[0];
Unity.TestFile = "a_md5encrypt.c";
UnityBegin("a_md5encrypt.c");
- RUN_TEST(test_Encrypt, 36);
- RUN_TEST(test_DecryptValid, 55);
- RUN_TEST(test_DecryptInvalid, 61);
- RUN_TEST(test_IPv4AddressToRefId, 69);
- RUN_TEST(test_IPv6AddressToRefId, 80);
+ RUN_TEST(test_Encrypt, 29);
+ RUN_TEST(test_DecryptValid, 51);
+ RUN_TEST(test_DecryptInvalid, 58);
+ RUN_TEST(test_IPv4AddressToRefId, 67);
+ RUN_TEST(test_IPv6AddressToRefId, 81);
return (UnityEnd());
}
//=======External Functions This Runner Calls=====
extern void setUp(void);
extern void tearDown(void);
+void resetTest(void);
extern void test_AddTrustedKeys();
extern void test_AddUntrustedKey();
extern void test_HaveKeyCorrect();
progname = argv[0];
Unity.TestFile = "authkeys.c";
UnityBegin("authkeys.c");
- RUN_TEST(test_AddTrustedKeys, 71);
+ RUN_TEST(test_AddTrustedKeys, 70);
RUN_TEST(test_AddUntrustedKey, 82);
- RUN_TEST(test_HaveKeyCorrect, 90);
- RUN_TEST(test_HaveKeyIncorrect, 99);
- RUN_TEST(test_AddWithAuthUseKey, 106);
- RUN_TEST(test_EmptyKey, 113);
+ RUN_TEST(test_HaveKeyCorrect, 91);
+ RUN_TEST(test_HaveKeyIncorrect, 101);
+ RUN_TEST(test_AddWithAuthUseKey, 109);
+ RUN_TEST(test_EmptyKey, 117);
return (UnityEnd());
}
//=======External Functions This Runner Calls=====
extern void setUp(void);
extern void tearDown(void);
-extern void test_ZeroBuffer();
-extern void test_IntegerAndFractionalBuffer();
-extern void test_IllegalMicroseconds();
-extern void test_AlwaysFalseOnWindows();
+void resetTest(void);
+extern void test_ZeroBuffer(void);
+extern void test_IntegerAndFractionalBuffer(void);
+extern void test_IllegalMicroseconds(void);
+extern void test_AlwaysFalseOnWindows(void);
//=======Test Reset Option=====
progname = argv[0];
Unity.TestFile = "buftvtots.c";
UnityBegin("buftvtots.c");
- RUN_TEST(test_ZeroBuffer, 16);
- RUN_TEST(test_IntegerAndFractionalBuffer, 30);
- RUN_TEST(test_IllegalMicroseconds, 53);
- RUN_TEST(test_AlwaysFalseOnWindows, 66);
+ RUN_TEST(test_ZeroBuffer, 17);
+ RUN_TEST(test_IntegerAndFractionalBuffer, 32);
+ RUN_TEST(test_IllegalMicroseconds, 55);
+ RUN_TEST(test_AlwaysFalseOnWindows, 69);
return (UnityEnd());
}
//=======External Functions This Runner Calls=====
extern void setUp(void);
extern void tearDown(void);
-extern void test_DaySplitMerge();
-extern void test_SplitYearDays1();
-extern void test_SplitYearDays2();
-extern void test_RataDie1();
-extern void test_LeapYears1();
-extern void test_LeapYears2();
-extern void test_RoundTripDate();
-extern void test_RoundTripYearStart();
-extern void test_RoundTripMonthStart();
-extern void test_RoundTripWeekStart();
-extern void test_RoundTripDayStart();
+void resetTest(void);
+extern void test_DaySplitMerge(void);
+extern void test_SplitYearDays1(void);
+extern void test_SplitYearDays2(void);
+extern void test_RataDie1(void);
+extern void test_LeapYears1(void);
+extern void test_LeapYears2(void);
+extern void test_RoundTripDate(void);
+extern void test_RoundTripYearStart(void);
+extern void test_RoundTripMonthStart(void);
+extern void test_RoundTripWeekStart(void);
+extern void test_RoundTripDayStart(void);
//=======Test Reset Option=====
progname = argv[0];
Unity.TestFile = "calendar.c";
UnityBegin("calendar.c");
- RUN_TEST(test_DaySplitMerge, 230);
- RUN_TEST(test_SplitYearDays1, 254);
- RUN_TEST(test_SplitYearDays2, 268);
- RUN_TEST(test_RataDie1, 283);
- RUN_TEST(test_LeapYears1, 293);
- RUN_TEST(test_LeapYears2, 308);
- RUN_TEST(test_RoundTripDate, 326);
- RUN_TEST(test_RoundTripYearStart, 355);
- RUN_TEST(test_RoundTripMonthStart, 371);
- RUN_TEST(test_RoundTripWeekStart, 387);
- RUN_TEST(test_RoundTripDayStart, 403);
+ 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);
return (UnityEnd());
}
extern void setUp(void);
extern void tearDown(void);
void resetTest(void);
-extern void test_RegularTime();
-extern void test_LeapYear();
-extern void test_uLongBoundary();
-extern void test_uLongWrapped();
+extern void test_RegularTime(void);
+extern void test_LeapYear(void);
+extern void test_uLongBoundary(void);
+extern void test_uLongWrapped(void);
//=======Test Reset Option=====
progname = argv[0];
Unity.TestFile = "caljulian.c";
UnityBegin("caljulian.c");
- RUN_TEST(test_RegularTime, 74);
+ RUN_TEST(test_RegularTime, 73);
RUN_TEST(test_LeapYear, 85);
- RUN_TEST(test_uLongBoundary, 96);
- RUN_TEST(test_uLongWrapped, 107);
+ RUN_TEST(test_uLongBoundary, 97);
+ RUN_TEST(test_uLongWrapped, 109);
return (UnityEnd());
}
//=======External Functions This Runner Calls=====
extern void setUp(void);
extern void tearDown(void);
+void resetTest(void);
extern void test_DateGivenMonthDay(void);
extern void test_DateGivenYearDay(void);
extern void test_DateLeapYear(void);
//=======External Functions This Runner Calls=====
extern void setUp(void);
extern void tearDown(void);
-extern void test_CurrentYear();
-extern void test_CurrentYearFuzz();
-extern void test_TimeZoneOffset();
-extern void test_WrongYearStart();
-extern void test_PreviousYear();
-extern void test_NextYear();
-extern void test_NoReasonableConversion();
-extern void test_AlwaysInLimit();
+void resetTest(void);
+extern void test_CurrentYear(void);
+extern void test_CurrentYearFuzz(void);
+extern void test_TimeZoneOffset(void);
+extern void test_WrongYearStart(void);
+extern void test_PreviousYear(void);
+extern void test_NextYear(void);
+extern void test_NoReasonableConversion(void);
+extern void test_AlwaysInLimit(void);
//=======Test Reset Option=====
progname = argv[0];
Unity.TestFile = "clocktime.c";
UnityBegin("clocktime.c");
- 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);
+ 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);
return (UnityEnd());
}