]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Unity test cleanup. Harlan Stenn.
authorHarlan Stenn <stenn@ntp.org>
Fri, 20 Nov 2015 07:27:27 +0000 (07:27 +0000)
committerHarlan Stenn <stenn@ntp.org>
Fri, 20 Nov 2015 07:27:27 +0000 (07:27 +0000)
bk: 564ecb5fCWb2w8ufbXtz8Mw17ErsOA

17 files changed:
tests/libntp/authkeys.c
tests/libntp/buftvtots.c
tests/libntp/calendar.c
tests/libntp/caljulian.c
tests/libntp/clocktime.c
tests/libntp/humandate.c
tests/libntp/lfpfunc.c
tests/libntp/netof.c
tests/libntp/numtohost.c
tests/libntp/octtoint.c
tests/libntp/refidsmear.c
tests/libntp/refnumtoa.c
tests/libntp/run-lfpfunc.c
tests/libntp/run-refidsmear.c
tests/libntp/timespecops.c
tests/libntp/timestructs.h
tests/libntp/timevalops.c

index 217016dd45fbfd9b4a6ca53e475f9a035920db55..2ddbce59703bcf5d27b28f2b37cccb4478c79362 100644 (file)
@@ -51,18 +51,21 @@ setUp(void)
        cache_flags = 0;
        cache_secret = NULL;
        cache_secretsize = 0;
+
+       return;
 }
 
 void
 tearDown(void)
 {
-
+       return;
 }
 
 static const int KEYTYPE = KEY_TYPE_MD5;
 
 void
-AddTrustedKey(keyid_t keyno) {
+AddTrustedKey(keyid_t keyno)
+{
        /*
         * We need to add a MD5-key in addition to setting the
         * trust, because authhavekey() requires type != 0.
@@ -70,15 +73,21 @@ AddTrustedKey(keyid_t keyno) {
        MD5auth_setkey(keyno, KEYTYPE, NULL, 0);
 
        authtrust(keyno, TRUE);
+
+       return;
 }
 
 void
-AddUntrustedKey(keyid_t keyno) {
+AddUntrustedKey(keyid_t keyno)
+{
        authtrust(keyno, FALSE);
+
+       return;
 }
 
 void
-test_AddTrustedKeys(void) {
+test_AddTrustedKeys(void)
+{
        const keyid_t KEYNO1 = 5;
        const keyid_t KEYNO2 = 8;
 
@@ -87,48 +96,65 @@ test_AddTrustedKeys(void) {
 
        TEST_ASSERT_TRUE(authistrusted(KEYNO1));
        TEST_ASSERT_TRUE(authistrusted(KEYNO2));
+
+       return;
 }
 
 void
-test_AddUntrustedKey(void) {
+test_AddUntrustedKey(void)
+{
        const keyid_t KEYNO = 3;
    
        AddUntrustedKey(KEYNO);
 
        TEST_ASSERT_FALSE(authistrusted(KEYNO));
+
+       return;
 }
 
 void
-test_HaveKeyCorrect(void) {
+test_HaveKeyCorrect(void)
+{
        const keyid_t KEYNO = 3;
 
        AddTrustedKey(KEYNO);
 
        TEST_ASSERT_TRUE(auth_havekey(KEYNO));
        TEST_ASSERT_TRUE(authhavekey(KEYNO));
+
+       return;
 }
 
 void
-test_HaveKeyIncorrect(void) {
+test_HaveKeyIncorrect(void)
+{
        const keyid_t KEYNO = 2;
 
        TEST_ASSERT_FALSE(auth_havekey(KEYNO));
        TEST_ASSERT_FALSE(authhavekey(KEYNO));
+
+       return;
 }
 
 void
-test_AddWithAuthUseKey(void) {
+test_AddWithAuthUseKey(void)
+{
        const keyid_t KEYNO = 5;
        const char* KEY = "52a";
 
-       TEST_ASSERT_TRUE(authusekey(KEYNO, KEYTYPE, (const u_char*)KEY));       
+       TEST_ASSERT_TRUE(authusekey(KEYNO, KEYTYPE, (const u_char*)KEY));
+
+       return;
 }
 
 void
-test_EmptyKey(void) {
+test_EmptyKey(void)
+{
        const keyid_t KEYNO = 3;
        const char* KEY = "";
 
 
        TEST_ASSERT_FALSE(authusekey(KEYNO, KEYTYPE, (const u_char*)KEY));
+
+       return;
 }
index efde0090440a0517c8a0fc4080c4a2da327dbfe2..b6b81a2298637fccca73e6384fba4e1dc8028769 100644 (file)
@@ -18,7 +18,8 @@ void test_AlwaysFalseOnWindows(void);
 
 
 void
-test_ZeroBuffer(void) {
+test_ZeroBuffer(void)
+{
 #ifndef SYS_WINNT
        const struct timeval input = {0, 0};
        const l_fp expected = {{0 + JAN_1970}, 0};
@@ -30,10 +31,14 @@ test_ZeroBuffer(void) {
 #else
        TEST_IGNORE_MESSAGE("Test only for Windows, skipping...");
 #endif
+
+       return;
 }
 
+
 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};
@@ -53,24 +58,30 @@ test_IntegerAndFractionalBuffer(void) {
 #else
        TEST_IGNORE_MESSAGE("Test only for Windows, skipping...");
 #endif
+
+       return;
 }
 
 void
-test_IllegalMicroseconds(void) {
+test_IllegalMicroseconds(void)
+{
 #ifndef SYS_WINNT
        const struct timeval input = {0, 1100000}; /* > 999 999 microseconds. */
-       
+
        l_fp actual;
 
        TEST_ASSERT_FALSE(buftvtots((const char*)(&input), &actual));
 #else
        TEST_IGNORE_MESSAGE("Test only for Windows, skipping...");
 #endif
+
+       return;
 }
 
 
 void
-test_AlwaysFalseOnWindows(void) {
+test_AlwaysFalseOnWindows(void)
+{
 #ifdef SYS_WINNT
        /*
         * Under Windows, buftvtots will just return
@@ -81,5 +92,6 @@ test_AlwaysFalseOnWindows(void) {
 #else
        TEST_IGNORE_MESSAGE("Non-Windows test, skipping...");
 #endif
-}
 
+       return;
+}
index 2c8a2d52afb06b12a73ad6126bca27506cebfd6d..87619802dffc207ab10c7d51c7c89258cf59ed86 100644 (file)
@@ -8,31 +8,31 @@
 
 static int leapdays(int year);
 
-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);
-void test_IsoCalYearsToWeeks(void);
-void test_IsoCalWeeksToYearStart(void);
-void test_IsoCalWeeksToYearEnd(void);
-void test_DaySecToDate(void);
+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);
+void   test_IsoCalYearsToWeeks(void);
+void   test_IsoCalWeeksToYearStart(void);
+void   test_IsoCalWeeksToYearEnd(void);
+void   test_DaySecToDate(void);
 
 /*
  * ---------------------------------------------------------------------
@@ -42,7 +42,7 @@ void test_DaySecToDate(void);
 int
 isGT(int first, int second)
 {
-       if(first > second) {    
+       if(first > second) {
                return TRUE;
        } else {
                return FALSE;
@@ -215,8 +215,10 @@ static const u_short real_month_days[2][14] = {
  * 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;
@@ -242,11 +244,15 @@ test_DaySplitMerge(void) {
                        TEST_ASSERT_EQUAL(esec, split.lo);
                }
        }
+
+       return;
 }
 
 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) {
@@ -257,11 +263,15 @@ test_SplitYearDays1(void) {
                } else
                        TEST_ASSERT_TRUE(eyd < 0 || eyd > 364);
        }
+
+       return;
 }
-               
+
 void
-test_SplitYearDays2(void) {
+test_SplitYearDays2(void)
+{
        int32 eyd;
+
        for (eyd = -1; eyd <= 366; eyd++) {
                ntpcal_split split = ntpcal_split_yeardays(eyd, 1);
                if (split.lo >= 0 && split.hi >= 0) {
@@ -274,21 +284,27 @@ test_SplitYearDays2(void) {
                } else
                        TEST_ASSERT_TRUE(eyd < 0 || eyd > 365);
                }
+
+       return;
 }
-               
+
 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;
 
        ntpcal_rd_to_date(&actual, testDate);
        TEST_ASSERT_TRUE(IsEqualDateCal(&expected, &actual));
+
+       return;
 }
 
 /* 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) {
@@ -300,11 +316,14 @@ test_LeapYears1(void) {
 
                TEST_ASSERT_TRUE(IsEqualDateCal(&dateIn, &dateOut));
        }
+
+       return;
 }
 
 /* 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) {
@@ -315,6 +334,8 @@ test_LeapYears2(void) {
                ntpcal_rd_to_date(&dateOut, ntpcal_date_to_rd(&dateIn));
                TEST_ASSERT_TRUE(IsEqualDateCal(&dateIn, &dateOut));
        }
+
+       return;
 }
 
 /* Full roundtrip from 1601-01-01 to 2400-12-31
@@ -324,7 +345,8 @@ test_LeapYears2(void) {
  * invalid output can occur.)
  */
 void
-test_RoundTripDate(void) {
+test_RoundTripDate(void)
+{
        struct calendar truDate, expDate = { 1600, 0, 12, 31 };;
        int      leaps;
        int32    truRdn, expRdn = ntpcal_date_to_rd(&expDate);
@@ -335,7 +357,7 @@ test_RoundTripDate(void) {
                expDate.yearday = 0;
                leaps = leapdays(expDate.year);
                while (expDate.month < 12) {
-                       expDate.month++;                        
+                       expDate.month++;
                        expDate.monthday = 0;
                        while (expDate.monthday < real_month_days[leaps][expDate.month]) {
                                expDate.monthday++;
@@ -350,11 +372,14 @@ test_RoundTripDate(void) {
                        }
                }
        }
+
+       return;
 }
 
 /* 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;
@@ -367,11 +392,14 @@ test_RoundTripYearStart(void) {
                expys = ntpcal_date_to_ntp(&date);
                TEST_ASSERT_EQUAL(expys, truys);
        }
-}      
+
+       return;
+}
 
 /* Roundtrip testing on calmonthstart */
 void
-test_RoundTripMonthStart(void) {
+test_RoundTripMonthStart(void)
+{
        static const time_t pivot = 0;
        u_int32 ntp, expms, trums;
        struct calendar date;
@@ -384,11 +412,14 @@ test_RoundTripMonthStart(void) {
                expms = ntpcal_date_to_ntp(&date);
                TEST_ASSERT_EQUAL(expms, trums);
        }
-}      
+
+       return;
+}
 
 /* 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;
@@ -401,11 +432,14 @@ test_RoundTripWeekStart(void) {
                expws = isocal_date_to_ntp(&date);
                TEST_ASSERT_EQUAL(expws, truws);
        }
-}      
+
+       return;
+}
 
 /* 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;
@@ -417,6 +451,8 @@ test_RoundTripDayStart(void) {
                expds = ntpcal_date_to_ntp(&date);
                TEST_ASSERT_EQUAL(expds, truds);
        }
+
+       return;
 }
 
 /* ---------------------------------------------------------------------
@@ -444,6 +480,7 @@ refimpl_WeeksInIsoYears(
        int32_t years)
 {
        int32_t days, weeks;
+
        days = ntpcal_weekday_close(
                ntpcal_days_in_years(years) + 1,
                CAL_MONDAY) - 1;
@@ -455,6 +492,7 @@ refimpl_WeeksInIsoYears(
        weeks = days / 7;
        days  = days % 7;
        TEST_ASSERT_EQUAL(0, days); /* paranoia check... */
+
        return weeks;
 }
 
@@ -462,9 +500,11 @@ refimpl_WeeksInIsoYears(
  * they are not, the calendar needs a better implementation...
  */
 void
-test_IsoCalYearsToWeeks(void) {
+test_IsoCalYearsToWeeks(void)
+{
        int32_t years;
        int32_t wref, wcal;
+
        for (years = -1000; years < 4000; ++years) {
                /* get number of weeks before years (reference) */
                wref = refimpl_WeeksInIsoYears(years);
@@ -472,13 +512,17 @@ test_IsoCalYearsToWeeks(void) {
                wcal = isocal_weeks_in_years(years);
                TEST_ASSERT_EQUAL(wref, wcal);
        }
+
+       return;
 }
 
 void
-test_IsoCalWeeksToYearStart(void) {
+test_IsoCalWeeksToYearStart(void)
+{
        int32_t years;
        int32_t wref;
        ntpcal_split ysplit;
+
        for (years = -1000; years < 4000; ++years) {
                /* get number of weeks before years (reference) */
                wref = refimpl_WeeksInIsoYears(years);
@@ -488,13 +532,17 @@ test_IsoCalWeeksToYearStart(void) {
                TEST_ASSERT_EQUAL(years, ysplit.hi);
                TEST_ASSERT_EQUAL(0, ysplit.lo);
        }
+
+       return;
 }
 
 void
-test_IsoCalWeeksToYearEnd(void) {
+test_IsoCalWeeksToYearEnd(void)
+{
        int32_t years;
        int32_t wref;
        ntpcal_split ysplit;
+
        for (years = -1000; years < 4000; ++years) {
                /* get last week of previous year */
                wref = refimpl_WeeksInIsoYears(years) - 1;
@@ -504,10 +552,13 @@ test_IsoCalWeeksToYearEnd(void) {
                TEST_ASSERT_EQUAL(years-1, ysplit.hi);
                TEST_ASSERT(ysplit.lo == 51 || ysplit.lo == 52);
        }
+
+       return;
 }
 
 void
-test_DaySecToDate(void) {
+test_DaySecToDate(void)
+{
        struct calendar cal;
        int32_t days;
 
@@ -538,4 +589,6 @@ test_DaySecToDate(void) {
        days = ntpcal_daysec_to_date(&cal, 86400);
        TEST_ASSERT_MESSAGE((days==1 && cal.hour==0 && cal.minute==0 && cal.second==0),
                "failed for 86400");
+
+       return;
 }
index ff35e1ab8173157554bbeabb19ca6287e53a3841..f1eb3538d5cc7d1845712874bb8be9dbb9158710 100644 (file)
@@ -20,9 +20,10 @@ void test_uLongWrapped(void);
 
 
 char *
-CalendarToString(const struct calendar cal) {
+CalendarToString(const struct calendar cal)
+{
        char * str = emalloc (sizeof (char) * 100);
-       
+
        char buffer[100] ="";
        snprintf(buffer, 100, "%u", cal.year);
        strcat(str, buffer);
@@ -48,7 +49,8 @@ CalendarToString(const struct calendar cal) {
 }
 
 int // technically boolean
-IsEqual(const struct calendar expected, const struct calendar actual) {
+IsEqual(const struct calendar expected, const struct calendar actual)
+{
        if (expected.year == actual.year &&
                (expected.yearday == actual.yearday ||
                 (expected.month == actual.month &&
@@ -58,9 +60,9 @@ IsEqual(const struct calendar expected, const struct calendar actual) {
                expected.second == actual.second) {
                return TRUE;
        } else {
-               printf("expected: %s but was %s", CalendarToString(expected) ,CalendarToString(actual));
+               printf("expected: %s but was %s", CalendarToString(expected),
+                       CalendarToString(actual));
                return FALSE;
-                       
        }
 }
 
@@ -70,17 +72,22 @@ setUp()
 {
     ntpcal_set_timefunc(timefunc);
     settime(1970, 1, 1, 0, 0, 0);
+
+    return;
 }
 
 void
 tearDown()
 {
     ntpcal_set_timefunc(NULL);
+
+    return;
 }
 
 
 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};
 
@@ -89,10 +96,13 @@ test_RegularTime(void) {
        caljulian(testDate, &actual);
 
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
+
+       return;
 }
 
 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};
 
@@ -101,10 +111,13 @@ test_LeapYear(void) {
        caljulian(input, &actual);
 
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
+
+       return;
 }
 
 void
-test_uLongBoundary(void) {
+test_uLongBoundary(void)
+{
        u_long enc_time = 4294967295UL; // 2036-02-07 6:28:15
        struct calendar expected = {2036,0,2,7,6,28,15};
 
@@ -113,10 +126,13 @@ test_uLongBoundary(void) {
        caljulian(enc_time, &actual);
 
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
+
+       return;
 }
 
 void
-test_uLongWrapped(void) {
+test_uLongWrapped(void)
+{
        u_long enc_time = 0;
        struct calendar expected = {2036,0,2,7,6,28,16};
 
@@ -125,4 +141,6 @@ test_uLongWrapped(void) {
        caljulian(enc_time, &actual);
 
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
+
+       return;
 }
index 67ca40180defee7a6dad3f405328dee4bc46567f..ed2d4b2b187d6a560984eb2dbb3ae41da3e13328 100644 (file)
@@ -30,14 +30,18 @@ void test_AlwaysInLimit(void);
 void
 setUp()
 {
-    ntpcal_set_timefunc(timefunc);
-    settime(2000, 1, 1, 0, 0, 0);
+       ntpcal_set_timefunc(timefunc);
+       settime(2000, 1, 1, 0, 0, 0);
+
+       return;
 }
 
 void
 tearDown()
 {
-    ntpcal_set_timefunc(NULL);
+       ntpcal_set_timefunc(NULL);
+
+       return;
 }
 
 /* ---------------------------------------------------------------------
@@ -45,23 +49,27 @@ tearDown()
  */
 
 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. */
 
        const int yday=175, hour=12, minute=50, second=0, tzoff=0;
 
-       u_long yearstart=0;
+       u_long yearstart = 0;
        u_int32 actual;
 
-       TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
-                                                 &yearstart, &actual));
+       TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff,
+                                  timestamp, &yearstart, &actual));
        TEST_ASSERT_EQUAL(expected, actual);
+
+       return;
 }
 
 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.
@@ -78,13 +86,16 @@ test_CurrentYearFuzz(void) {
        u_long yearstart=0;
        u_int32 actual;
 
-       TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
-                                                 &yearstart, &actual));
+       TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff,
+                                  timestamp, &yearstart, &actual));
        TEST_ASSERT_EQUAL(expected, actual);
+
+       return;
 }
 
 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)
@@ -105,7 +116,8 @@ test_TimeZoneOffset(void) {
 }
 
 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.
@@ -125,7 +137,8 @@ test_WrongYearStart(void) {
 }
 
 void
-test_PreviousYear(void) {
+test_PreviousYear(void)
+{
        /*
         * Timestamp is: 2010-01-01 01:00:00Z
         * Time sent into function is 23:00:00
@@ -145,7 +158,8 @@ test_PreviousYear(void) {
 }
 
 void
-test_NextYear(void) {
+test_NextYear(void)
+{
        /*
         * Timestamp is: 2009-12-31 23:00:00Z
         * Time sent into function is 01:00:00
@@ -158,28 +172,35 @@ test_NextYear(void) {
        u_long yearstart = 0;
        u_int32 actual;
 
-       TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
-                                                 &yearstart, &actual));
+       TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff,
+                                  timestamp, &yearstart, &actual));
        TEST_ASSERT_EQUAL(expected, actual);
+
+       return;
 }
 
 void
-test_NoReasonableConversion(void) {
+test_NoReasonableConversion(void)
+{
        /* Timestamp is: 2010-01-02 11:00:00Z */
        const u_int32 timestamp = 3471418800UL;
-       
+
        const int yday=100, hour=12, minute=0, second=0, tzoff=0;
        u_long yearstart = 0;
        u_int32 actual;
 
-       TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff, timestamp,
-                                                  &yearstart, &actual));
+       TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff,
+                                   timestamp, &yearstart, &actual));
+
+       return;
 }
 
 
 int/*BOOL*/
-isLE(u_int32 diff,u_int32 actual){
-       if(diff <= actual){
+isLE(u_int32 diff,u_int32 actual)
+{
+
+       if (diff <= actual) {
                return TRUE;
        }
        else return FALSE;
@@ -187,7 +208,8 @@ isLE(u_int32 diff,u_int32 actual){
 
 
 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 };
@@ -210,7 +232,8 @@ test_AlwaysInLimit(void) {
                        for (hour = -204; hour < 204; hour += 2) {
                                for (minute = -60; minute < 60; minute++) {
                                        clocktime(yday, hour, minute, 30, 0,
-                                                 timestamp, &yearstart, &actual);
+                                                 timestamp, &yearstart,
+                                                 &actual);
                                        diff = actual - timestamp;
                                        if (diff >= 0x80000000UL)
                                                diff = ~diff + 1;
@@ -219,4 +242,5 @@ test_AlwaysInLimit(void) {
                        }
                }
        }
+       return;
 }
index 3a28f59dc4b0ec8846c7a8a9b2e954650217f6b4..31758c187ec8f18f15f07f89fefa5a834af56eae 100644 (file)
@@ -17,11 +17,13 @@ test_RegularTime(void)
        struct tm* tm;
 
        tm = localtime(&sample);
-       TEST_ASSERT_TRUE(time != NULL);
+       TEST_ASSERT_TRUE(tm != NULL);
 
        snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
 
        TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
+
+       return;
 }
 
 void
@@ -34,9 +36,11 @@ test_CurrentTime(void)
        time(&sample);
 
        tm = localtime(&sample);
-       TEST_ASSERT_TRUE(time != NULL);
+       TEST_ASSERT_TRUE(tm != NULL);
 
        snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
 
        TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
+
+       return;
 }
index 1f92a84ad2513122263a3bcb0d706e5c5af76289..cedbb6082a4d63e27a315837825199f914ef18e5 100644 (file)
@@ -9,17 +9,18 @@
 #include <math.h>
 
 
-/* replaced TEST_ASSERT_EQUAL_MEMORY(&a, &b, sizeof(a)) with TEST_ASSERT_EQUAL_l_fp(a, b).
-   It's safer this way, because structs can be compared even if they aren't initiated
-   with memset (due to padding bytes).
+/*
+   replaced:   TEST_ASSERT_EQUAL_MEMORY(&a, &b, sizeof(a))
+   with:       TEST_ASSERT_EQUAL_l_fp(a, b).
+   It's safer this way, because structs can be compared even if they
+   aren't initiated with memset (due to padding bytes).
 */
-#define TEST_ASSERT_EQUAL_l_fp(a, b) { \
-    TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i"); \
-    TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf");      \
+#define TEST_ASSERT_EQUAL_l_fp(a, b) {                                 \
+       TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i");           \
+       TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf");   \
 }
 
 
-
 typedef int bool; // typedef enum { FALSE, TRUE } boolean; -> can't use this because TRUE and FALSE are already defined
 
 
@@ -28,23 +29,23 @@ typedef struct  {
 } lfp_hl;
 
 
-int l_fp_scmp(const l_fp first, const l_fp second);
-int l_fp_ucmp(const l_fp first, l_fp second );
-l_fp l_fp_init(int32 i, u_int32 f);
-l_fp l_fp_add(const l_fp first, const l_fp second);
-l_fp l_fp_subtract(const l_fp first, const l_fp second);
-l_fp l_fp_negate(const l_fp first);
-l_fp l_fp_abs(const l_fp first);
-int l_fp_signum(const l_fp first);
-double l_fp_convert_to_double(const l_fp first);
-l_fp l_fp_init_from_double( double rhs);
-void l_fp_swap(l_fp * first, l_fp *second);
-bool l_isgt(const l_fp first, const l_fp second);
-bool l_isgtu(const l_fp first, const l_fp second);
-bool l_ishis(const l_fp first, const l_fp second);
-bool l_isgeq(const l_fp first, const l_fp second);
-bool l_isequ(const l_fp first, const l_fp second);
-double eps(double d);
+int    l_fp_scmp(const l_fp first, const l_fp second);
+int    l_fp_ucmp(const l_fp first, l_fp second);
+l_fp   l_fp_init(int32 i, u_int32 f);
+l_fp   l_fp_add(const l_fp first, const l_fp second);
+l_fp   l_fp_subtract(const l_fp first, const l_fp second);
+l_fp   l_fp_negate(const l_fp first);
+l_fp   l_fp_abs(const l_fp first);
+int    l_fp_signum(const l_fp first);
+double l_fp_convert_to_double(const l_fp first);
+l_fp   l_fp_init_from_double( double rhs);
+void   l_fp_swap(l_fp * first, l_fp *second);
+bool   l_isgt(const l_fp first, const l_fp second);
+bool   l_isgtu(const l_fp first, const l_fp second);
+bool   l_ishis(const l_fp first, const l_fp second);
+bool   l_isgeq(const l_fp first, const l_fp second);
+bool   l_isequ(const l_fp first, const l_fp second);
+double eps(double d);
 
 
 void test_AdditionLR(void);
@@ -58,7 +59,6 @@ void test_SignedRelOps(void);
 void test_UnsignedRelOps(void);
 
 
-
 static int cmp_work(u_int32 a[3], u_int32 b[3]);
 
 //----------------------------------------------------------------------
@@ -72,10 +72,10 @@ int
 l_fp_scmp(const l_fp first, const l_fp second)
 {
        u_int32 a[3], b[3];
-       
+
        const l_fp op1 = first;
        const l_fp op2 = second;
-       
+
        a[0] = op1.l_uf; a[1] = op1.l_ui; a[2] = 0;
        b[0] = op2.l_uf; b[1] = op2.l_ui; b[2] = 0;
 
@@ -86,12 +86,12 @@ l_fp_scmp(const l_fp first, const l_fp second)
 }
 
 int
-l_fp_ucmp(const l_fp first, l_fp second )
+l_fp_ucmp(const l_fp first, l_fp second)
 {
        u_int32 a[3], b[3];
        const l_fp op1 = first; 
        const l_fp op2 = second;
-       
+
        a[0] = op1.l_uf; a[1] = op1.l_ui; a[2] = 0;
        b[0] = op2.l_uf; b[1] = op2.l_ui; b[2] = 0;
 
@@ -142,7 +142,7 @@ l_fp_subtract(const l_fp first, const l_fp second)
 {
        l_fp temp = first;
        L_SUB(&temp, &second);
-       
+
        return temp;
 }
 
@@ -151,7 +151,7 @@ l_fp_negate(const l_fp first)
 {
        l_fp temp = first;
        L_NEG(&temp);
-       
+
        return temp;
 }
 
@@ -189,11 +189,14 @@ l_fp_init_from_double( double rhs)
 }
 
 void
-l_fp_swap(l_fp * first, l_fp *second){
+l_fp_swap(l_fp * first, l_fp *second)
+{
        l_fp temp = *second;
 
        *second = *first;
        *first = temp;
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -204,27 +207,37 @@ l_fp_swap(l_fp * first, l_fp *second){
 
 
 bool
-l_isgt (const l_fp first, const l_fp second) {
+l_isgt (const l_fp first, const l_fp second)
+{
+
        return L_ISGT(&first, &second);
 }
 
 bool
-l_isgtu(const l_fp first, const l_fp second) {
+l_isgtu(const l_fp first, const l_fp second)
+{
+
        return L_ISGTU(&first, &second);
 }
 
 bool
-l_ishis(const l_fp first, const l_fp second) {
+l_ishis(const l_fp first, const l_fp second)
+{
+
        return L_ISHIS(&first, &second);
 }
 
 bool
-l_isgeq(const l_fp first, const l_fp second) {
+l_isgeq(const l_fp first, const l_fp second)
+{
+
        return L_ISGEQ(&first, &second);
 }
 
 bool
-l_isequ(const l_fp first, const l_fp second) {
+l_isequ(const l_fp first, const l_fp second)
+{
+
        return L_ISEQU(&first, &second);
 }
 
@@ -275,6 +288,7 @@ static const size_t addsub_tot = (sizeof(addsub_tab)/sizeof(addsub_tab[0][0]));
 double
 eps(double d)
 {
+
        return fmax(ldexp(1.0, -31), ldexp(fabs(d), -53));
 }
 
@@ -282,22 +296,26 @@ eps(double d)
 // test addition
 //----------------------------------------------------------------------
 void
-test_AdditionLR(void) {
+test_AdditionLR(void)
+{
        size_t idx = 0;
 
        for (idx = 0; idx < addsub_cnt; ++idx) {
                l_fp op1 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l);
                l_fp op2 = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l);
                l_fp e_res = l_fp_init(addsub_tab[idx][2].h, addsub_tab[idx][2].l);
-               l_fp res = l_fp_add(op1, op2);          
+               l_fp res = l_fp_add(op1, op2);
 
                TEST_ASSERT_EQUAL_l_fp(e_res, res);
-       }       
+       }
+       return;
 }
 
 void
-test_AdditionRL(void) {
+test_AdditionRL(void)
+{
        size_t idx = 0;
+
        for (idx = 0; idx < addsub_cnt; ++idx) {
                l_fp op2 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l);
                l_fp op1 = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l);
@@ -305,30 +323,35 @@ test_AdditionRL(void) {
                l_fp res = l_fp_add(op1, op2);
 
                TEST_ASSERT_EQUAL_l_fp(e_res, res);
-       }       
+       }
+       return;
 }
 
 
-
 //----------------------------------------------------------------------
 // test subtraction
 //----------------------------------------------------------------------
 void
-test_SubtractionLR(void) {
+test_SubtractionLR(void)
+{
        size_t idx = 0;
+
        for (idx = 0; idx < addsub_cnt; ++idx) {
                l_fp op2 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l);
                l_fp e_res = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l);
                l_fp op1 = l_fp_init(addsub_tab[idx][2].h, addsub_tab[idx][2].l);
                l_fp res = l_fp_subtract(op1, op2);
-               
-               TEST_ASSERT_EQUAL_l_fp(e_res, res);             
-       }       
+
+               TEST_ASSERT_EQUAL_l_fp(e_res, res);
+       }
+       return;
 }
 
 void
-test_SubtractionRL(void) {
+test_SubtractionRL(void)
+{
        size_t idx = 0;
+
        for (idx = 0; idx < addsub_cnt; ++idx) {
                l_fp e_res = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l);
                l_fp op2 = l_fp_init(addsub_tab[idx][1].h, addsub_tab[idx][1].l);
@@ -336,7 +359,8 @@ test_SubtractionRL(void) {
                l_fp res = l_fp_subtract(op1, op2);
 
                TEST_ASSERT_EQUAL_l_fp(e_res, res);
-       }       
+       }
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -344,18 +368,20 @@ test_SubtractionRL(void) {
 //----------------------------------------------------------------------
 
 void
-test_Negation(void) {
-
+test_Negation(void)
+{
        size_t idx = 0;
+
        for (idx = 0; idx < addsub_cnt; ++idx) {
                l_fp op1 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l);
                l_fp op2 = l_fp_negate(op1);
                l_fp sum = l_fp_add(op1, op2);
-               
+
                l_fp zero = l_fp_init(0, 0);
 
                TEST_ASSERT_EQUAL_l_fp(zero, sum);
-       }       
+       }
+       return;
 }
 
 
@@ -364,21 +390,23 @@ test_Negation(void) {
 // test absolute value
 //----------------------------------------------------------------------
 void
-test_Absolute(void) {
+test_Absolute(void)
+{
        size_t idx = 0;
+
        for (idx = 0; idx < addsub_cnt; ++idx) {
                l_fp op1 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l);
                l_fp op2 = l_fp_abs(op1);
 
-               TEST_ASSERT_TRUE(l_fp_signum(op2) >= 0);                
+               TEST_ASSERT_TRUE(l_fp_signum(op2) >= 0);
 
                if (l_fp_signum(op1) >= 0)
-                       op1 = l_fp_subtract(op1, op2);                  
+                       op1 = l_fp_subtract(op1, op2);
                else
                        op1 = l_fp_add(op1, op2);
-               
+
                l_fp zero = l_fp_init(0, 0);
-               
+
                TEST_ASSERT_EQUAL_l_fp(zero, op1);
        }
 
@@ -390,6 +418,8 @@ test_Absolute(void) {
        TEST_ASSERT_EQUAL(-1, l_fp_signum(minVal));
 
        TEST_ASSERT_EQUAL_l_fp(minVal, minAbs);
+
+       return;
 }
 
 
@@ -397,14 +427,17 @@ test_Absolute(void) {
 // fp -> double -> fp rountrip test
 //----------------------------------------------------------------------
 void
-test_FDF_RoundTrip(void) {
+test_FDF_RoundTrip(void)
+{
+       size_t idx = 0;
+
        // since a l_fp has 64 bits in it's mantissa and a double has
        // only 54 bits available (including the hidden '1') we have to
        // make a few concessions on the roundtrip precision. The 'eps()'
        // function makes an educated guess about the avilable precision
        // and checks the difference in the two 'l_fp' values against
        // that limit.
-       size_t idx = 0;
+
        for (idx = 0; idx < addsub_cnt; ++idx) {
                l_fp op1 = l_fp_init(addsub_tab[idx][0].h, addsub_tab[idx][0].l);
                double op2 = l_fp_convert_to_double(op1);
@@ -412,8 +445,10 @@ test_FDF_RoundTrip(void) {
 
                l_fp temp = l_fp_subtract(op1, op3);
                double d = l_fp_convert_to_double(temp);
-               TEST_ASSERT_DOUBLE_WITHIN(eps(op2), 0.0, fabs(d));                              
-       }       
+               TEST_ASSERT_DOUBLE_WITHIN(eps(op2), 0.0, fabs(d));
+       }
+
+       return;
 }
 
 
@@ -424,14 +459,16 @@ test_FDF_RoundTrip(void) {
 // macros in 'ntp_fp.h' produce mathing results.
 // ----------------------------------------------------------------------
 void
-test_SignedRelOps(void) {
+test_SignedRelOps(void)
+{
        const lfp_hl * tv = (&addsub_tab[0][0]);
        size_t lc ;
+
        for (lc = addsub_tot - 1; lc; --lc, ++tv) {
                l_fp op1 = l_fp_init(tv[0].h, tv[0].l);
                l_fp op2 = l_fp_init(tv[1].h, tv[1].l);
-               int cmp = l_fp_scmp(op1, op2);          
-               
+               int cmp = l_fp_scmp(op1, op2);
+
                switch (cmp) {
                case -1:
                        //printf("op1:%d %d, op2:%d %d\n",op1.l_uf,op1.l_ui,op2.l_uf,op2.l_ui);
@@ -458,15 +495,19 @@ test_SignedRelOps(void) {
                        TEST_ASSERT_TRUE (l_isequ(op2, op1));
                        break;
                default:
-                       TEST_FAIL_MESSAGE("unexpected UCMP result: " ); 
+                       TEST_FAIL_MESSAGE("unexpected UCMP result: ");
                }
        }
+
+       return;
 }
 
 void
-test_UnsignedRelOps(void) {
-       const lfp_hl * tv =(&addsub_tab[0][0]); 
+test_UnsignedRelOps(void)
+{
+       const lfp_hl * tv =(&addsub_tab[0][0]);
        size_t lc;
+
        for (lc = addsub_tot - 1; lc; --lc, ++tv) {
                l_fp op1 = l_fp_init(tv[0].h, tv[0].l);
                l_fp op2 = l_fp_init(tv[1].h, tv[1].l);
@@ -492,10 +533,13 @@ test_UnsignedRelOps(void) {
                        TEST_ASSERT_TRUE (l_ishis(op2, op1));
                        break;
                default:
-                       TEST_FAIL_MESSAGE("unexpected UCMP result: " ); 
+                       TEST_FAIL_MESSAGE("unexpected UCMP result: ");
                }
        }
+
+       return;
 }
+
 /*
 */
 
index b0fcc1b1d3c5683d033e8164946d37d679b87472..dc0e5a20096b9d0a9c2d41bdbc5750ea2f0b2b5d 100644 (file)
@@ -14,8 +14,9 @@ void test_ClassAAddress(void);
 void test_IPv6Address(void);
 
 
-
-void test_ClassBAddress(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);
 
@@ -23,9 +24,13 @@ void test_ClassBAddress(void) {
 
        TEST_ASSERT_TRUE(actual != NULL);
        TEST_ASSERT_TRUE(IsEqual(expected, *actual));
+
+       return;
 }
 
-void test_ClassCAddress(void) {
+void
+test_ClassCAddress(void)
+{
        sockaddr_u input = CreateSockaddr4("192.0.2.255", NTP_PORT);
        sockaddr_u expected = CreateSockaddr4("192.0.2.0", NTP_PORT);
 
@@ -33,9 +38,14 @@ void test_ClassCAddress(void) {
 
        TEST_ASSERT_TRUE(actual != NULL);
        TEST_ASSERT_TRUE(IsEqual(expected, *actual));
+
+       return;
 }
 
-void  test_ClassAAddress(void) {
+
+void
+test_ClassAAddress(void)
+{
        /* Class A addresses are assumed to be classless,
         * thus the same address should be returned.
         */
@@ -46,9 +56,13 @@ void  test_ClassAAddress(void) {
 
        TEST_ASSERT_TRUE(actual != NULL);
        TEST_ASSERT_TRUE(IsEqual(expected, *actual));
+
+       return;
 }
 
-void  test_IPv6Address(void) {
+void
+test_IPv6Address(void)
+{
        /* IPv6 addresses are assumed to have 64-bit host- and 64-bit network parts. */
        const struct in6_addr input_address = { { {
                0x20, 0x01, 0x0d, 0xb8,
@@ -63,7 +77,7 @@ void  test_IPv6Address(void) {
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00
        } } }; // 2001:0db8:85a3:08d3:0000:0000:0000:0000
-       
+
        sockaddr_u input;
        input.sa6.sin6_family = AF_INET6;
        input.sa6.sin6_addr = input_address;
@@ -78,5 +92,6 @@ void  test_IPv6Address(void) {
 
        TEST_ASSERT_TRUE(actual != NULL);
        TEST_ASSERT_TRUE(IsEqual(expected, *actual));
-}
 
+       return;
+}
index cfce2d8a309a777f0741e5f95c5904b18ded6767..4eb32eec58a5c1339c5ae190fe66e894c95b8c1f 100644 (file)
@@ -15,6 +15,6 @@ test_LoopbackNetNonResolve(void) {
         */
 
        const u_int32 input = 127*256*256*256 + 1*256 + 1; // 127.0.1.1
-       
+
        TEST_ASSERT_EQUAL_STRING("127.0.1.1", numtohost(htonl(input)));
 }
index 5c03d6d1b807d813b7c35931138d5a70a5c95b59..83a1c994aa46001be4cb177832191a135940ac0f 100644 (file)
@@ -14,61 +14,83 @@ void test_IllegalCharacter(void);
 void test_IllegalDigit(void);
 
 
-void test_SingleDigit(void) {
+void
+test_SingleDigit(void)
+{
        const char* str = "5";
        u_long actual;
 
-       TEST_ASSERT_TRUE(octtoint(str, &actual) );
+       TEST_ASSERT_TRUE(octtoint(str, &actual));
        TEST_ASSERT_EQUAL(5, actual);
+
+       return;
 }
 
-void test_MultipleDigits(void){
+void
+test_MultipleDigits(void)
+{
        const char* str = "271";
        u_long actual;
 
-       TEST_ASSERT_TRUE(octtoint(str, &actual) );
+       TEST_ASSERT_TRUE(octtoint(str, &actual));
        TEST_ASSERT_EQUAL(185, actual);
 
+       return;
 }
 
-void test_Zero(void){
+void
+test_Zero(void)
+{
        const char* str = "0";
        u_long actual;
 
-       TEST_ASSERT_TRUE(octtoint(str, &actual) );
+       TEST_ASSERT_TRUE(octtoint(str, &actual));
        TEST_ASSERT_EQUAL(0, actual);
 
+       return;
 }
 
-void test_MaximumUnsigned32bit(void){
+void
+test_MaximumUnsigned32bit(void)
+{
        const char* str = "37777777777";
        u_long actual;
 
-       TEST_ASSERT_TRUE(octtoint(str, &actual) );
+       TEST_ASSERT_TRUE(octtoint(str, &actual));
        TEST_ASSERT_EQUAL(4294967295UL, actual);
 
+       return;
 }
 
-void test_Overflow(void){
+void
+test_Overflow(void)
+{
        const char* str = "40000000000";
        u_long actual;
 
-       TEST_ASSERT_FALSE(octtoint(str, &actual) );
+       TEST_ASSERT_FALSE(octtoint(str, &actual));
 
+       return;
 }
 
-void test_IllegalCharacter(void){
+void
+test_IllegalCharacter(void)
+{
        const char* str = "5ac2";
        u_long actual;
 
-       TEST_ASSERT_FALSE(octtoint(str, &actual) );
+       TEST_ASSERT_FALSE(octtoint(str, &actual));
 
+       return;
 }
 
-void test_IllegalDigit(void){
+void
+test_IllegalDigit(void)
+{
        const char* str = "5283";
        u_long actual;
 
-       TEST_ASSERT_FALSE(octtoint(str, &actual) );
+       TEST_ASSERT_FALSE(octtoint(str, &actual));
 
+       return;
 }
index 04f396cb0a17b0de05f4beb3eba9771dd6bb9d39..ad431c1a1b213e254a64467f18b9914c9c21e5e4 100644 (file)
@@ -29,7 +29,6 @@
  */
 
 
-
 void rtol(uint32_t r, char *es);
 void rtoltor(uint32_t er, char *es);
 void ltor(l_fp l, char *er);
@@ -48,7 +47,7 @@ rtol(uint32_t r, char *es)
 
        l = convertRefIDToLFP(htonl(r));
        as = lfptoa(&l, 8);
-       
+
        //printf("refid %#x, smear %s\n", r, as);
 
        TEST_ASSERT_NOT_NULL_MESSAGE(as, msg);
@@ -58,8 +57,6 @@ rtol(uint32_t r, char *es)
 }
 
 
-
-
 void
 rtoltor(uint32_t er, char *es)
 {
index 33ad3aa48d16847ef476c4b52144743847bc2670..8fe71045ee1aac2ff15bbc9bec95b8db5d38b650 100644 (file)
@@ -26,7 +26,7 @@ test_LocalClock(void) {
        sockaddr_u address;
        address.sa4.sin_family = AF_INET;
        address.sa4.sin_addr.s_addr = htonl(addr);
-       
+
        char stringStart[100]= "";
 
        strcat(stringStart, clockname(REFCLK_LOCALCLOCK));
@@ -35,7 +35,7 @@ test_LocalClock(void) {
        char * expected = stringStart;
 
        TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
-#else  
+#else
        TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");
 #endif /* REFCLOCK */
 }
@@ -51,16 +51,16 @@ test_UnknownId(void) {
        sockaddr_u address;
        address.sa4.sin_family = AF_INET;
        address.sa4.sin_addr.s_addr = htonl(addr);
-       
+
        char stringStart[100]= "REFCLK(";
-       char value[100] ;       
+       char value[100] ;
        snprintf(value, sizeof(value), "%d", UNUSED_REFCLOCK_ID);
        strcat(stringStart,value);
        strcat(stringStart,",4)");
        char * expected = stringStart;
 
        TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
-#else  
+#else
        TEST_IGNORE_MESSAGE("REFCLOCK NOT DEFINED, SKIPPING TEST");
 #endif /* REFCLOCK */
 }
index ac6700f78987a803d75a73fc557ed13278abf292..83f966815a4729448759d97cc2d536516bb2ecc9 100644 (file)
@@ -58,15 +58,15 @@ int main(int argc, char *argv[])
 {
   progname = argv[0];
   UnityBegin("lfpfunc.c");
-  RUN_TEST(test_AdditionLR, 50);
-  RUN_TEST(test_AdditionRL, 51);
-  RUN_TEST(test_SubtractionLR, 52);
-  RUN_TEST(test_SubtractionRL, 53);
-  RUN_TEST(test_Negation, 54);
-  RUN_TEST(test_Absolute, 55);
-  RUN_TEST(test_FDF_RoundTrip, 56);
-  RUN_TEST(test_SignedRelOps, 57);
-  RUN_TEST(test_UnsignedRelOps, 58);
+  RUN_TEST(test_AdditionLR, 51);
+  RUN_TEST(test_AdditionRL, 52);
+  RUN_TEST(test_SubtractionLR, 53);
+  RUN_TEST(test_SubtractionRL, 54);
+  RUN_TEST(test_Negation, 55);
+  RUN_TEST(test_Absolute, 56);
+  RUN_TEST(test_FDF_RoundTrip, 57);
+  RUN_TEST(test_SignedRelOps, 58);
+  RUN_TEST(test_UnsignedRelOps, 59);
 
   return (UnityEnd());
 }
index 465690f763051fd4c904b7e5f1d47d26c4389efb..1c128e7823562454d672856f5b3ef9b65f36039a 100644 (file)
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
 {
   progname = argv[0];
   UnityBegin("refidsmear.c");
-  RUN_TEST(test_refidsmear, 36);
+  RUN_TEST(test_refidsmear, 35);
 
   return (UnityEnd());
 }
index 86df7a1767abc1f6243bd7bee9844d903c021531..676a358572455672fa0e18ff91ee9a3e113f3254 100644 (file)
 #include <string.h>
 
 
-#define TEST_ASSERT_EQUAL_timespec(a, b) { \
-    TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec"); \
+#define TEST_ASSERT_EQUAL_timespec(a, b) {                             \
+    TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec");     \
     TEST_ASSERT_EQUAL_MESSAGE(a.tv_nsec, b.tv_nsec, "Field tv_nsec");  \
 }
 
 
-#define TEST_ASSERT_EQUAL_l_fp(a, b) { \
-    TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i"); \
+#define TEST_ASSERT_EQUAL_l_fp(a, b) {                                 \
+    TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i");              \
     TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf");      \
 }
 
@@ -64,35 +64,43 @@ void test_ToString(void);
 
 typedef int bool;
 
-const bool timespec_isValid(struct timespec V);
+const bool     timespec_isValid(struct timespec V);
 struct timespec timespec_init(time_t hi, long lo);
-l_fp l_fp_init(int32 i, u_int32 f);
-bool AssertFpClose(const l_fp m, const l_fp n, const l_fp limit);
-bool AssertTimespecClose(const struct timespec m, const struct timespec n, const struct timespec limit);
+l_fp           l_fp_init(int32 i, u_int32 f);
+bool           AssertFpClose(const l_fp m, const l_fp n, const l_fp limit);
+bool           AssertTimespecClose(const struct timespec m,
+                                   const struct timespec n,
+                                   const struct timespec limit);
 
 
-//******************************************MY CUSTOM FUNCTIONS*******************************
-
+//***************************MY CUSTOM FUNCTIONS***************************
 
 
 const bool
-timespec_isValid(struct timespec V) {
+timespec_isValid(struct timespec V)
+{
+
        return V.tv_nsec >= 0 && V.tv_nsec < 1000000000;
 }
 
 
 struct timespec
-timespec_init(time_t hi, long lo) {
-       struct timespec V;      
+timespec_init(time_t hi, long lo)
+{
+       struct timespec V;
+
        V.tv_sec = hi;
        V.tv_nsec = lo;
+
        return V;
 }
 
 
 l_fp
-l_fp_init(int32 i, u_int32 f) {
+l_fp_init(int32 i, u_int32 f)
+{
        l_fp temp;
+
        temp.l_i  = i;
        temp.l_uf = f;
 
@@ -101,7 +109,8 @@ l_fp_init(int32 i, u_int32 f) {
 
 
 bool
-AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) {
+AssertFpClose(const l_fp m, const l_fp n, const l_fp limit)
+{
        l_fp diff;
 
        if (L_ISGEQ(&m, &n)) {
@@ -111,7 +120,7 @@ AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) {
                diff = n;
                L_SUB(&diff, &m);
        }
-       if (L_ISGEQ(&limit, &diff)){
+       if (L_ISGEQ(&limit, &diff)) {
                return TRUE;
        }
        else {
@@ -122,7 +131,9 @@ AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) {
 
 
 bool
-AssertTimespecClose(const struct timespec m, const struct timespec n, const struct timespec limit) {
+AssertTimespecClose(const struct timespec m, const struct timespec n,
+       const struct timespec limit)
+{
        struct timespec diff;
 
        diff = abs_tspec(sub_tspec(m, n));
@@ -156,11 +167,13 @@ static const struct lfpfracdata fdata[] = {
 
 
 u_int32
-my_tick_to_tsf(u_int32 ticks) {
+my_tick_to_tsf(u_int32 ticks)
+{
        // convert nanoseconds to l_fp fractional units, using double
        // precision float calculations or, if available, 64bit integer
        // arithmetic. This should give the precise fraction, rounded to
        // the nearest representation.
+
 #ifdef HAVE_U_INT64
        return (u_int32)((( ((u_int64)(ticks)) << 32) + 500000000) / 1000000000);
 #else
@@ -172,7 +185,9 @@ my_tick_to_tsf(u_int32 ticks) {
 
 
 u_int32
-my_tsf_to_tick(u_int32 tsf) {
+my_tsf_to_tick(u_int32 tsf)
+{
+
        // Inverse operation: converts fraction to microseconds.
 #ifdef HAVE_U_INT64
        return (u_int32)(( ((u_int64)(tsf)) * 1000000000 + 0x80000000) >> 32);
@@ -189,7 +204,8 @@ my_tsf_to_tick(u_int32 tsf) {
 // ---------------------------------------------------------------------
 
 void
-test_Helpers1(void) {
+test_Helpers1(void)
+{
        struct timespec x;
 
        for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++) {
@@ -202,6 +218,8 @@ test_Helpers1(void) {
                x.tv_nsec = 1000000000;
                TEST_ASSERT_FALSE(timespec_isValid(x));
        }
+
+       return;
 }
 
 
@@ -210,14 +228,18 @@ test_Helpers1(void) {
 //----------------------------------------------------------------------
 
 void
-test_Normalise(void) {
+test_Normalise(void)
+{
        long ns;
+
        for ( ns = -2000000000; ns <= 2000000000; ns += 10000000) {
                struct timespec x = timespec_init(0, ns);
 
                x = normalize_tspec(x);
                TEST_ASSERT_TRUE(timespec_isValid(x));
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -225,9 +247,11 @@ test_Normalise(void) {
 //----------------------------------------------------------------------
 
 void
-test_SignNoFrac(void) {
+test_SignNoFrac(void)
+{
        // sign test, no fraction
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 0);
                int E = (i > 0) - (i < 0);
@@ -235,26 +259,34 @@ test_SignNoFrac(void) {
 
                TEST_ASSERT_EQUAL(E, r);
        }
+
+       return;
 }
 
 
 void
-test_SignWithFrac(void) {
+test_SignWithFrac(void)
+{
        // sign test, with fraction
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 10);
                int E = (i >= 0) - (i < 0);
                int r = test_tspec(a);
+
                TEST_ASSERT_EQUAL(E, r);
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
 // test compare
 //----------------------------------------------------------------------
 void
-test_CmpFracEQ(void) {
+test_CmpFracEQ(void)
+{
        // fractions are equal
        int i, j;
        for (i = -4; i <= 4; ++i)
@@ -263,38 +295,51 @@ test_CmpFracEQ(void) {
                        struct timespec b = timespec_init( j , 200);
                        int   E = (i > j) - (i < j);
                        int   r = cmp_tspec_denorm(a, b);
+
                        TEST_ASSERT_EQUAL(E, r);
                }
+
+       return;
 }
 
 
 void
-test_CmpFracGT(void) {
+test_CmpFracGT(void)
+{
        // fraction a bigger fraction b
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 999999800);
                        struct timespec b = timespec_init(j, 200);
                        int   E = (i >= j) - (i < j);
                        int   r = cmp_tspec_denorm(a, b);
+
                        TEST_ASSERT_EQUAL(E, r);
                }
+
+       return;
 }
 
 
 void
-test_CmpFracLT(void) {
+test_CmpFracLT(void)
+{
        // fraction a less fraction b
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 200);
                        struct timespec b = timespec_init(j, 999999800);
                        int   E = (i > j) - (i <= j);
                        int   r = cmp_tspec_denorm(a, b);
+
                        TEST_ASSERT_EQUAL(E, r);
                }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -302,8 +347,10 @@ test_CmpFracLT(void) {
 //----------------------------------------------------------------------
 
 void
-test_AddFullNorm(void) {
+test_AddFullNorm(void)
+{
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 200);
@@ -314,12 +361,16 @@ test_AddFullNorm(void) {
                        c = add_tspec(a, b);
                        TEST_ASSERT_EQUAL_timespec(E, c);
                }
+
+       return;
 }
 
 
 void
-test_AddFullOflow1(void) {
+test_AddFullOflow1(void)
+{
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 200);
@@ -330,12 +381,15 @@ test_AddFullOflow1(void) {
                        c = add_tspec(a, b);
                        TEST_ASSERT_EQUAL_timespec(E, c);
                }
+
+       return;
 }
 
 
 void
 test_AddNsecNorm(void) {
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 200);
                struct timespec E = timespec_init(i, 600);
@@ -344,12 +398,16 @@ test_AddNsecNorm(void) {
                c = add_tspec_ns(a, 600 - 200);
                TEST_ASSERT_EQUAL_timespec(E, c);
        }
+
+       return;
 }
 
 
 void
-test_AddNsecOflow1(void) {
+test_AddNsecOflow1(void)
+{
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 200);
                struct timespec E = timespec_init(i + 1, 100);
@@ -358,6 +416,8 @@ test_AddNsecOflow1(void) {
                c = add_tspec_ns(a, NANOSECONDS - 100);
                TEST_ASSERT_EQUAL_timespec(E, c);
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -365,8 +425,10 @@ test_AddNsecOflow1(void) {
 //----------------------------------------------------------------------
 
 void
-test_SubFullNorm(void) {
+test_SubFullNorm(void)
+{
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init( i , 600);
@@ -377,12 +439,16 @@ test_SubFullNorm(void) {
                        c = sub_tspec(a, b);
                        TEST_ASSERT_EQUAL_timespec(E, c);
                }
+
+       return;
 }
 
 
 void
-test_SubFullOflow(void) {
+test_SubFullOflow(void)
+{
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timespec a = timespec_init(i, 100);
@@ -393,12 +459,16 @@ test_SubFullOflow(void) {
                        c = sub_tspec(a, b);
                        TEST_ASSERT_EQUAL_timespec(E, c);
                }
+
+       return;
 }
 
 
 void
-test_SubNsecNorm(void) {
+test_SubNsecNorm(void)
+{
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 600);
                struct timespec E = timespec_init(i, 200);
@@ -407,12 +477,16 @@ test_SubNsecNorm(void) {
                c = sub_tspec_ns(a, 600 - 200);
                TEST_ASSERT_EQUAL_timespec(E, c);
        }
+
+       return;
 }
 
 
 void
-test_SubNsecOflow(void) {
+test_SubNsecOflow(void)
+{
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init( i , 100);
                struct timespec E = timespec_init(i-1, 200);
@@ -421,6 +495,8 @@ test_SubNsecOflow(void) {
                c = sub_tspec_ns(a, NANOSECONDS - 100);
                TEST_ASSERT_EQUAL_timespec(E, c);
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -429,8 +505,10 @@ test_SubNsecOflow(void) {
 
 
 void
-test_Neg(void) {
+test_Neg(void)
+{
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 100);
                struct timespec b;
@@ -440,6 +518,8 @@ test_Neg(void) {
                c = add_tspec(a, b);
                TEST_ASSERT_EQUAL(0, test_tspec(c));
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -447,8 +527,10 @@ test_Neg(void) {
 //----------------------------------------------------------------------
 
 void
-test_AbsNoFrac(void) {
+test_AbsNoFrac(void)
+{
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i , 0);
                struct timespec b;
@@ -456,12 +538,16 @@ test_AbsNoFrac(void) {
                b = abs_tspec(a);
                TEST_ASSERT_EQUAL((i != 0), test_tspec(b));
        }
+
+       return;
 }
 
 
 void
-test_AbsWithFrac(void) {
+test_AbsWithFrac(void)
+{
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timespec a = timespec_init(i, 100);
                struct timespec b;
@@ -469,6 +555,8 @@ test_AbsWithFrac(void) {
                b = abs_tspec(a);
                TEST_ASSERT_EQUAL(1, test_tspec(b));
        }
+
+       return;
 }
 
 // ---------------------------------------------------------------------
@@ -476,9 +564,9 @@ test_AbsWithFrac(void) {
 // ---------------------------------------------------------------------
 
 void
-test_Helpers2(void) {
+test_Helpers2(void)
+{
        struct timespec limit = timespec_init(0, 2);
-       
        struct timespec x, y;
        long i;
 
@@ -489,7 +577,7 @@ test_Helpers2(void) {
                        for (i = -4; i < 5; ++i) {
                                y = x;
                                y.tv_nsec += i;
-                               if (i >= -2 && i <= 2){
+                               if (i >= -2 && i <= 2) {
                                        TEST_ASSERT_TRUE(AssertTimespecClose(x, y, limit));
                                }
                                else
@@ -498,6 +586,8 @@ test_Helpers2(void) {
                                }
                        }
                }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -505,9 +595,11 @@ test_Helpers2(void) {
 //----------------------------------------------------------------------
 
 void
-test_ToLFPbittest(void) {
+test_ToLFPbittest(void)
+{
        l_fp lfpClose =  l_fp_init(0, 1);
        u_int32 i;
+
        for (i = 0; i < 1000000000; i+=1000) {
                struct timespec a = timespec_init(1, i);
                l_fp E= l_fp_init(1, my_tick_to_tsf(i));
@@ -516,12 +608,16 @@ test_ToLFPbittest(void) {
                r = tspec_intv_to_lfp(a);
                TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));
        }
+
+       return;
 }
 
 
 void
-test_ToLFPrelPos(void) {
+test_ToLFPrelPos(void)
+{
        int i;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timespec a = timespec_init(1, fdata[i].nsec);
                l_fp E = l_fp_init(1, fdata[i].frac);
@@ -530,12 +626,16 @@ test_ToLFPrelPos(void) {
                r = tspec_intv_to_lfp(a);
                TEST_ASSERT_EQUAL_l_fp(E, r);
        }
+
+       return;
 }
 
 
 void
-test_ToLFPrelNeg(void) {
+test_ToLFPrelNeg(void)
+{
        int i;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timespec a = timespec_init(-1, fdata[i].nsec);
                l_fp E = l_fp_init(~0, fdata[i].frac);
@@ -544,12 +644,16 @@ test_ToLFPrelNeg(void) {
                r = tspec_intv_to_lfp(a);
                TEST_ASSERT_EQUAL_l_fp(E, r);
        }
+
+       return;
 }
 
 
 void
-test_ToLFPabs(void) {
+test_ToLFPabs(void)
+{
        int i;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timespec a = timespec_init(1, fdata[i].nsec);
                l_fp E = l_fp_init(1 + JAN_1970, fdata[i].frac);
@@ -558,6 +662,8 @@ test_ToLFPabs(void) {
                r = tspec_stamp_to_lfp(a);
                TEST_ASSERT_EQUAL_l_fp(E, r);
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -565,7 +671,8 @@ test_ToLFPabs(void) {
 //----------------------------------------------------------------------
 
 void
-test_FromLFPbittest(void) {
+test_FromLFPbittest(void)
+{
        struct timespec limit = timespec_init(0, 2);
 
        // Not *exactly* a bittest, because 2**32 tests would take a
@@ -582,13 +689,17 @@ test_FromLFPbittest(void) {
                // comparing to calculated value.
                TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit));
        }
+
+       return;
 }
 
 
 void
-test_FromLFPrelPos(void) {
+test_FromLFPrelPos(void)
+{
        struct timespec limit = timespec_init(0, 2);
        int i;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                l_fp a = l_fp_init(1, fdata[i].frac);
                struct timespec E = timespec_init(1, fdata[i].nsec);
@@ -597,13 +708,17 @@ test_FromLFPrelPos(void) {
                r = lfp_intv_to_tspec(a);
                TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit));
        }
+
+       return;
 }
 
 
 void
-test_FromLFPrelNeg(void) {
+test_FromLFPrelNeg(void)
+{
        struct timespec limit = timespec_init(0, 2);
        int i;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                l_fp a = l_fp_init(~0, fdata[i].frac);
                struct timespec E = timespec_init(-1, fdata[i].nsec);
@@ -612,14 +727,18 @@ test_FromLFPrelNeg(void) {
                r = lfp_intv_to_tspec(a);
                TEST_ASSERT_TRUE(AssertTimespecClose(E, r, limit));
        }
+
+       return;
 }
 
 
 // nsec -> frac -> nsec roundtrip, using a prime start and increment
 void
-test_LFProundtrip(void) {
+test_LFProundtrip(void)
+{
        int32_t t;
        u_int32 i;
+
        for (t = -1; t < 2; ++t)
                for (i = 4999; i < 1000000000; i += 10007) {
                        struct timespec E = timespec_init(t, i);
@@ -630,6 +749,8 @@ test_LFProundtrip(void) {
                        r = lfp_intv_to_tspec(a);
                        TEST_ASSERT_EQUAL_timespec(E, r);
                }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -637,7 +758,8 @@ test_LFProundtrip(void) {
 //----------------------------------------------------------------------
 
 void
-test_ToString(void) {
+test_ToString(void)
+{
        static const struct {
                time_t          sec;
                long            nsec;
@@ -653,12 +775,15 @@ test_ToString(void) {
                {-1,-1, "-1.000000001" },
        };
        int i;
+
        for (i = 0; i < COUNTOF(data); ++i) {
                struct timespec a = timespec_init(data[i].sec, data[i].nsec);
                const char * E = data[i].repr;
                const char * r = tspectoa(a);
                TEST_ASSERT_EQUAL_STRING(E, r);
        }
+
+       return;
 }
 
 // -*- EOF -*-
index 8cd59270d7939ede8dc2ccbd476c5ab7f4ce31a2..9aad649f8e82d0b4f6b57dbabae45ff5e1d088d4 100644 (file)
@@ -35,7 +35,7 @@ struct l_fp_wrap {
        l_fp V;
        
        
-       //bool operator == (const l_fp_wraprhs) const
+       //bool operator == (const l_fp_wrap &rhs) const
        //      { return L_ISEQU(&V, &rhs.V); }
 
 //---------------THIS HAS TO BE MANUALLY CONVERTED IN CODE!!!
@@ -45,28 +45,28 @@ struct l_fp_wrap {
        //      { return V; }
 //-----------------------------------------
 /*
-       l_fp_wrap & operator = (const l_fp_wrap& rhs)
+       l_fp_wrap &operator = (const l_fp_wrap &rhs)
                { V = rhs.V; return *this; }
-       l_fp_wrap& operator = (const l_fp& rhs)
+       l_fp_wrap &operator = (const l_fp &rhs)
                { V = rhs; return *this; }
 */
 };
 
-l_fp_wrap(l_fp V){
+l_fp_wrap(l_fp V) {
        ZERO(V); }
-l_fp_wrap(l_fp V, u_int32 hi, u_int32 lo){
+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){
+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 ==
+l_fp_wrap_equals(const l_fp_wrap &current, const l_fp_wrap &rhs) const // operator ==
        { return L_ISEQU(&current.V, &rhs.V); }
 
-l_fp_wrap_and(const l_fp_wrap& current, const l_fp_wrap& rhs){
+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)
+l_fp_wrap_and(const l_fp &current, const l_fp &rhs) 
        V = rhs; 
        return current//*this; 
 }
@@ -82,11 +82,11 @@ struct timeval_wrap {
                { ZERO(V); }
        timeval_wrap(time_t hi, long lo)
                { V.tv_sec = hi; V.tv_usec = lo; }
-       timeval_wrap(const struct timeval & rhs)
+       timeval_wrap(const struct timeval &rhs)
                { V = rhs; }
-       timeval_wrap(const timeval_wrap & rhs)
+       timeval_wrap(const timeval_wrap &rhs)
                { V = rhs.V; }
-       bool operator == (const timeval_wraprhs) const
+       bool operator == (const timeval_wrap &rhs) const
                { return V.tv_sec == rhs.V.tv_sec &&
                         V.tv_usec == rhs.V.tv_usec ; }
        bool valid() const
@@ -95,9 +95,9 @@ struct timeval_wrap {
                { return &V; }
        operator struct timeval& ()
                { return V; }
-       timeval_wrap& operator = (const timeval_wrap& rhs)
+       timeval_wrap &operator = (const timeval_wrap &rhs)
                { V = rhs.V; return *this; }
-       timeval_wrap& operator = (const struct timeval& rhs)
+       timeval_wrap &operator = (const struct timeval &rhs)
                { V = rhs; return *this; }
 };
 
@@ -110,11 +110,11 @@ struct timespec_wrap {
                { ZERO(V); }
        timespec_wrap(time_t hi, long lo)
                { V.tv_sec = hi; V.tv_nsec = lo; }
-       timespec_wrap(const struct timespec & rhs)
+       timespec_wrap(const struct timespec &rhs)
                { V = rhs; }
-       timespec_wrap(const timespec_wrap & rhs)
+       timespec_wrap(const timespec_wrap &rhs)
                { V = rhs.V; }
-       bool operator == (const timespec_wraprhs) const
+       bool operator == (const timespec_wrap &rhs) const
                { return V.tv_sec == rhs.V.tv_sec &&
                         V.tv_nsec == rhs.V.tv_nsec ; }
        bool valid() const
@@ -123,9 +123,9 @@ struct timespec_wrap {
                { return &V; }
        operator struct timespec& ()
                { return V;     }
-       timespec_wrap& operator = (const timespec_wrap& rhs)
+       timespec_wrap &operator = (const timespec_wrap &rhs)
                { V = rhs.V; return *this; }
-       timespec_wrap& operator = (const struct timespec& rhs)
+       timespec_wrap &operator = (const struct timespec &rhs)
                { V = rhs; return *this; }
 };
 
@@ -144,7 +144,7 @@ public:
 
        ::testing::AssertionResult
        operator()(const char* m_expr, const char* n_expr,
-                  const l_fp & m, const l_fp & n);
+                  const l_fp &m, const l_fp &n);
 };
 
 
@@ -170,7 +170,7 @@ public:
 
        ::testing::AssertionResult
        operator()(const char* m_expr, const char* n_expr,
-                  const struct timeval & m, const struct timeval & n);
+                  const struct timeval &m, const struct timeval &n);
 };
 
 
@@ -193,7 +193,7 @@ public:
 
        ::testing::AssertionResult
        operator()(const char* m_expr, const char* n_expr,
-                  const struct timespec & m, const struct timespec & n);
+                  const struct timespec &m, const struct timespec &n);
 };
 
 
index a2d9358f97bcab8568886e76a46dc082253c6ad3..32fe4fb01934783aa512e80959b9089a8a1370a8 100644 (file)
@@ -11,8 +11,8 @@
 #include "unity.h"
 
 
-#define TEST_ASSERT_EQUAL_timeval(a, b) { \
-    TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec"); \
+#define TEST_ASSERT_EQUAL_timeval(a, b) {                              \
+    TEST_ASSERT_EQUAL_MESSAGE(a.tv_sec, b.tv_sec, "Field tv_sec");     \
     TEST_ASSERT_EQUAL_MESSAGE(a.tv_usec, b.tv_usec, "Field tv_usec");  \
 }
 
@@ -65,28 +65,34 @@ void test_LFProundtrip(void);
 void test_ToString(void);
 
 
-//******************************************MY CUSTOM FUNCTIONS*******************************
-
+//**********************************MY CUSTOM FUNCTIONS***********************
 
 
 struct timeval
-timeval_init( time_t hi, long lo){
+timeval_init(time_t hi, long lo)
+{
        struct timeval V; 
+
        V.tv_sec = hi; 
        V.tv_usec = lo;
+
        return V;
 }
 
 
 const bool
-timeval_isValid(struct timeval V) {
+timeval_isValid(struct timeval V)
+{
+
        return V.tv_usec >= 0 && V.tv_usec < 1000000;
 }
 
 
 l_fp
-l_fp_init(int32 i, u_int32 f) {
+l_fp_init(int32 i, u_int32 f)
+{
        l_fp temp;
+
        temp.l_i  = i;
        temp.l_uf = f;
 
@@ -95,25 +101,26 @@ l_fp_init(int32 i, u_int32 f) {
 
 
 bool
-AssertTimevalClose(const struct timeval m, const struct timeval n, const struct timeval limit) {
+AssertTimevalClose(const struct timeval m, const struct timeval n, const struct timeval limit)
+{
        struct timeval diff;
 
        diff = abs_tval(sub_tval(m, n));
        if (cmp_tval(limit, diff) >= 0)
                return TRUE;
-       
        else 
        {
                printf("m_expr which is %ld.%lu \nand\nn_expr which is %ld.%lu\nare not close; diff=%ld.%luusec\n", m.tv_sec, m.tv_usec, n.tv_sec, n.tv_usec, diff.tv_sec, diff.tv_usec); 
                //I don't have variables m_expr and n_expr in unity, those are command line arguments which only getst has!!!
-               
+
                return FALSE;
        }
 }
 
 
 bool
-AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) {
+AssertFpClose(const l_fp m, const l_fp n, const l_fp limit)
+{
        l_fp diff;
 
        if (L_ISGEQ(&m, &n)) {
@@ -123,7 +130,7 @@ AssertFpClose(const l_fp m, const l_fp n, const l_fp limit) {
                diff = n;
                L_SUB(&diff, &m);
        }
-       if (L_ISGEQ(&limit, &diff)){
+       if (L_ISGEQ(&limit, &diff)) {
                return TRUE;
        }
        else {
@@ -155,11 +162,13 @@ static const lfpfracdata fdata[] = {
 
 
 u_int32
-my_tick_to_tsf(u_int32 ticks) {
+my_tick_to_tsf(u_int32 ticks)
+{
        // convert microseconds to l_fp fractional units, using double
        // precision float calculations or, if available, 64bit integer
        // arithmetic. This should give the precise fraction, rounded to
        // the nearest representation.
+
 #ifdef HAVE_U_INT64
        return (u_int32)((( ((u_int64)(ticks)) << 32) + 500000) / 1000000); //I put too much () when casting just to be safe
 #else
@@ -171,7 +180,8 @@ my_tick_to_tsf(u_int32 ticks) {
 
 
 u_int32
-my_tsf_to_tick(u_int32 tsf) {
+my_tsf_to_tick(u_int32 tsf)
+{
        // Inverse operation: converts fraction to microseconds.
 #ifdef HAVE_U_INT64
        return (u_int32)( ((u_int64)(tsf) * 1000000 + 0x80000000) >> 32); //CHECK ME!!!
@@ -182,7 +192,7 @@ my_tsf_to_tick(u_int32 tsf) {
 }
 
 
-//***************************************END OF CUSTOM FUNCTIONS*****************************
+//*******************************END OF CUSTOM FUNCTIONS*********************
 
 
 // ---------------------------------------------------------------------
@@ -190,7 +200,8 @@ my_tsf_to_tick(u_int32 tsf) {
 // ---------------------------------------------------------------------
 
 void
-test_Helpers1(void) {
+test_Helpers1(void)
+{
        struct timeval x;
 
        for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++) {
@@ -203,6 +214,8 @@ test_Helpers1(void) {
                x.tv_usec = 1000000;
                TEST_ASSERT_FALSE(timeval_isValid(x));
        }
+
+       return;
 }
 
 
@@ -211,14 +224,18 @@ test_Helpers1(void) {
 //----------------------------------------------------------------------
 
 void
-test_Normalise(void) {
+test_Normalise(void)
+{
        long ns;
+
        for (ns = -2000000000; ns <= 2000000000; ns += 10000000) {
                struct timeval x = timeval_init(0, ns);
-               
+
                x = normalize_tval(x);
                TEST_ASSERT_TRUE(timeval_isValid(x));
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -226,8 +243,10 @@ test_Normalise(void) {
 //----------------------------------------------------------------------
 
 void
-test_SignNoFrac(void) {
+test_SignNoFrac(void)
+{
        int i;
+
        // sign test, no fraction
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 0);
@@ -236,13 +255,17 @@ test_SignNoFrac(void) {
 
                TEST_ASSERT_EQUAL(E, r);
        }
+
+       return;
 }
 
 
 void
-test_SignWithFrac(void) {
+test_SignWithFrac(void)
+{
        // sign test, with fraction
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 10);
                int          E = (i >= 0) - (i < 0);
@@ -250,14 +273,18 @@ test_SignWithFrac(void) {
 
                TEST_ASSERT_EQUAL(E, r);
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
 // test compare
 //----------------------------------------------------------------------
 void
-test_CmpFracEQ(void) {
+test_CmpFracEQ(void)
+{
        int i, j;
+
        // fractions are equal
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
@@ -268,13 +295,17 @@ test_CmpFracEQ(void) {
 
                        TEST_ASSERT_EQUAL(E, r);
                }
+
+       return;
 }
 
 
 void
-test_CmpFracGT(void) {
+test_CmpFracGT(void)
+{
        // fraction a bigger fraction b
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init( i , 999800);
@@ -284,13 +315,17 @@ test_CmpFracGT(void) {
 
                        TEST_ASSERT_EQUAL(E, r);
                }
+
+       return;
 }
 
 
 void
-test_CmpFracLT(void) {
+test_CmpFracLT(void)
+{
        // fraction a less fraction b
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 200);
@@ -300,6 +335,8 @@ test_CmpFracLT(void) {
 
                        TEST_ASSERT_EQUAL(E, r);
                }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -307,8 +344,10 @@ test_CmpFracLT(void) {
 //----------------------------------------------------------------------
 
 void
-test_AddFullNorm(void) {
+test_AddFullNorm(void)
+{
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 200);
@@ -319,12 +358,16 @@ test_AddFullNorm(void) {
                        c = add_tval(a, b);
                        TEST_ASSERT_EQUAL_timeval(E, c);
                }
+
+       return;
 }
 
 
 void
-test_AddFullOflow1(void) {
+test_AddFullOflow1(void)
+{
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 200);
@@ -335,12 +378,16 @@ test_AddFullOflow1(void) {
                        c = add_tval(a, b);
                        TEST_ASSERT_EQUAL_timeval(E, c);
                }
+
+       return;
 }
 
 
 void
-test_AddUsecNorm(void) {
+test_AddUsecNorm(void)
+{
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 200);
                struct timeval E = timeval_init(i, 600);
@@ -349,12 +396,16 @@ test_AddUsecNorm(void) {
                c = add_tval_us(a, 600 - 200);
                TEST_ASSERT_EQUAL_timeval(E, c);
        }
+
+       return;
 }
 
 
 void
-test_AddUsecOflow1(void) {
+test_AddUsecOflow1(void)
+{
        int i;
+
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 200);
                struct timeval E = timeval_init(i + 1, 100);
@@ -363,6 +414,8 @@ test_AddUsecOflow1(void) {
                c = add_tval_us(a, MICROSECONDS - 100);
                TEST_ASSERT_EQUAL_timeval(E, c);
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -370,8 +423,10 @@ test_AddUsecOflow1(void) {
 //----------------------------------------------------------------------
 
 void
-test_SubFullNorm(void) {
+test_SubFullNorm(void)
+{
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 600);
@@ -382,12 +437,16 @@ test_SubFullNorm(void) {
                        c = sub_tval(a, b);
                        TEST_ASSERT_EQUAL_timeval(E, c);
                }
+
+       return;
 }
 
 
 void
-test_SubFullOflow(void) {
+test_SubFullOflow(void)
+{
        int i, j;
+
        for (i = -4; i <= 4; ++i)
                for (j = -4; j <= 4; ++j) {
                        struct timeval a = timeval_init(i, 100);
@@ -398,12 +457,16 @@ test_SubFullOflow(void) {
                        c = sub_tval(a, b);
                        TEST_ASSERT_EQUAL_timeval(E, c);
                }
+
+       return;
 }
 
 
 void
-test_SubUsecNorm(void) {
+test_SubUsecNorm(void)
+{
        int i = -4;
+
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 600);
                struct timeval E = timeval_init(i, 200);
@@ -412,12 +475,16 @@ test_SubUsecNorm(void) {
                c = sub_tval_us(a, 600 - 200);
                TEST_ASSERT_EQUAL_timeval(E, c);
        }
+
+       return;
 }
 
 
 void
-test_SubUsecOflow(void) {
+test_SubUsecOflow(void)
+{
        int i = -4;
+
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 100);
                struct timeval E = timeval_init(i - 1, 200);
@@ -426,6 +493,8 @@ test_SubUsecOflow(void) {
                c = sub_tval_us(a, MICROSECONDS - 100);
                TEST_ASSERT_EQUAL_timeval(E, c);
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -433,8 +502,10 @@ test_SubUsecOflow(void) {
 //----------------------------------------------------------------------
 
 void
-test_Neg(void) {
+test_Neg(void)
+{
        int i = -4;
+
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 100);
                struct timeval b;
@@ -444,6 +515,8 @@ test_Neg(void) {
                c = add_tval(a, b);
                TEST_ASSERT_EQUAL(0, test_tval(c));
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -451,8 +524,10 @@ test_Neg(void) {
 //----------------------------------------------------------------------
 
 void
-test_AbsNoFrac(void) {
+test_AbsNoFrac(void)
+{
        int i = -4;
+
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 0);
                struct timeval b;
@@ -460,12 +535,16 @@ test_AbsNoFrac(void) {
                b = abs_tval(a);
                TEST_ASSERT_EQUAL((i != 0), test_tval(b));
        }
+
+       return;
 }
 
 
 void
-test_AbsWithFrac(void) {
+test_AbsWithFrac(void)
+{
        int i = -4;
+
        for (i = -4; i <= 4; ++i) {
                struct timeval a = timeval_init(i, 100);
                struct timeval b;
@@ -473,6 +552,8 @@ test_AbsWithFrac(void) {
                b = abs_tval(a);
                TEST_ASSERT_EQUAL(1, test_tval(b));
        }
+
+       return;
 }
 
 // ---------------------------------------------------------------------
@@ -481,20 +562,20 @@ test_AbsWithFrac(void) {
 
 
 void
-test_Helpers2(void) {
-
+test_Helpers2(void)
+{
        struct timeval limit = timeval_init(0, 2);
        struct timeval x, y;
-       long i; 
+       long i;
 
-       for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++){
+       for (x.tv_sec = -2; x.tv_sec < 3; x.tv_sec++) {
                for (x.tv_usec = 1;
                     x.tv_usec < 1000000;
                     x.tv_usec += 499999) {
                        for (i = -4; i < 5; ++i) {
                                y = x;
                                y.tv_usec += i;
-                               if (i >= -2 && i <= 2){
+                               if (i >= -2 && i <= 2) {
                                        TEST_ASSERT_TRUE(AssertTimevalClose(x, y, limit));//ASSERT_PRED_FORMAT2(isClose, x, y);
                                }
                                else {
@@ -503,6 +584,8 @@ test_Helpers2(void) {
                        }
                }
        }
+
+       return;
 }
 
 // and the global predicate instances we're using here
@@ -515,8 +598,9 @@ test_Helpers2(void) {
 //----------------------------------------------------------------------
 
 void
-test_ToLFPbittest(void) {
-       l_fp lfpClose =  l_fp_init(0, 1);       
+test_ToLFPbittest(void)
+{
+       l_fp lfpClose =  l_fp_init(0, 1);
 
        u_int32 i = 0;
        for (i = 0; i < 1000000; ++i) {
@@ -527,14 +611,17 @@ test_ToLFPbittest(void) {
                r = tval_intv_to_lfp(a);
                TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));        //ASSERT_PRED_FORMAT2(FpClose, E, r);
        }
+
+       return;
 }
 
 
 void
-test_ToLFPrelPos(void) {
+test_ToLFPrelPos(void)
+{
        l_fp lfpClose =  l_fp_init(0, 1);
-
        int i = 0;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timeval a = timeval_init(1, fdata[i].usec);
                l_fp E = l_fp_init(1, fdata[i].frac);
@@ -543,13 +630,17 @@ test_ToLFPrelPos(void) {
                r = tval_intv_to_lfp(a);
                TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));
        }
+
+       return;
 }
 
 
 void
-test_ToLFPrelNeg(void) {
+test_ToLFPrelNeg(void)
+{
        l_fp lfpClose =  l_fp_init(0, 1);
        int i = 0;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timeval a = timeval_init(-1, fdata[i].usec);
                l_fp E = l_fp_init(~0, fdata[i].frac);
@@ -558,14 +649,17 @@ test_ToLFPrelNeg(void) {
                r = tval_intv_to_lfp(a);
                TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));
        }
+
+       return;
 }
 
 
 void
-test_ToLFPabs(void) {
+test_ToLFPabs(void)
+{
        l_fp lfpClose =  l_fp_init(0, 1);
-
        int i = 0;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                struct timeval a = timeval_init(1, fdata[i].usec);
                l_fp E = l_fp_init(1 + JAN_1970, fdata[i].frac);
@@ -574,6 +668,8 @@ test_ToLFPabs(void) {
                r = tval_stamp_to_lfp(a);
                TEST_ASSERT_TRUE(AssertFpClose(E, r, lfpClose));
        }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -581,12 +677,14 @@ test_ToLFPabs(void) {
 //----------------------------------------------------------------------
 
 void
-test_FromLFPbittest(void) {
+test_FromLFPbittest(void)
+{
        struct timeval timevalClose = timeval_init(0, 1);
        // Not *exactly* a bittest, because 2**32 tests would take a
        // really long time even on very fast machines! So we do test
        // every 1000 fractional units.
        u_int32 tsf = 0;
+
        for (tsf = 0; tsf < ~((u_int32)(1000)); tsf += 1000) {
                struct timeval E = timeval_init(1, my_tsf_to_tick(tsf));
                l_fp a = l_fp_init(1, tsf);
@@ -597,13 +695,17 @@ test_FromLFPbittest(void) {
                // comparing to calculated value.
                TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose));
        }
+
+       return;
 }
 
 
 void
-test_FromLFPrelPos(void) {
+test_FromLFPrelPos(void)
+{
        struct timeval timevalClose = timeval_init(0, 1);
-       int i = 0;      
+       int i = 0;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                l_fp a = l_fp_init(1, fdata[i].frac);
                struct timeval E = timeval_init(1, fdata[i].usec);
@@ -612,13 +714,17 @@ test_FromLFPrelPos(void) {
                r = lfp_intv_to_tval(a);
                TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose));
        }
+
+       return;
 }
 
 
 void
-test_FromLFPrelNeg(void) {
+test_FromLFPrelNeg(void)
+{
        struct timeval timevalClose = timeval_init(0, 1);
        int i = 0;
+
        for (i = 0; i < COUNTOF(fdata); ++i) {
                l_fp a = l_fp_init(~0, fdata[i].frac);
                struct timeval E = timeval_init(-1, fdata[i].usec);
@@ -627,14 +733,18 @@ test_FromLFPrelNeg(void) {
                r = lfp_intv_to_tval(a);
                TEST_ASSERT_TRUE(AssertTimevalClose(E, r, timevalClose));
        }
+
+       return;
 }
 
 
 // usec -> frac -> usec roundtrip, using a prime start and increment
 void
-test_LFProundtrip(void) {
+test_LFProundtrip(void)
+{
        int32_t t = -1;
        u_int32 i = 5;
+
        for (t = -1; t < 2; ++t)
                for (i = 5; i < 1000000; i += 11) {
                        struct timeval E = timeval_init(t, i);
@@ -645,6 +755,8 @@ test_LFProundtrip(void) {
                        r = lfp_intv_to_tval(a);
                        TEST_ASSERT_EQUAL_timeval(E, r);
                }
+
+       return;
 }
 
 //----------------------------------------------------------------------
@@ -652,7 +764,8 @@ test_LFProundtrip(void) {
 //----------------------------------------------------------------------
 
 void
-test_ToString(void) {
+test_ToString(void)
+{
        static const struct {
                time_t       sec;
                long         usec;
@@ -668,6 +781,7 @@ test_ToString(void) {
                {-1,-1, "-1.000001" },
        };
        int i;
+
        for (i = 0; i < COUNTOF(data); ++i) {
                struct timeval a = timeval_init(data[i].sec, data[i].usec);
                const char *  E = data[i].repr;
@@ -675,6 +789,8 @@ test_ToString(void) {
 
                TEST_ASSERT_EQUAL_STRING(E, r);
        }
+
+       return;
 }
 
 // -*- EOF -*-