<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>Amar Takhar pushed to branch master at <a href="https://gitlab.com/NTPsec/ntpsec">NTPsec / ntpsec</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/01600c3a9ce9cb863092c4a6233eb16e217fa90e">01600c3a</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Add packetProcessing.c (not converted)

  This requires some changes to ntpdig/main.c to allow for injecting options
  outside of main().</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/016739ee9bb368301e324ba899e8add235be1368">016739ee</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Remove unused networking.(c|cpp)</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/fed253a2e6dc34c303c1164f15105fe9a435b09a">fed253a2</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Cleanup headers.

  * Remove libntptest.h
  * Move sockaddrtest.h to common/</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/78eff93d90bd88fd7c9bfa3e72268f0679703c8a">78eff93d</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Remove libntptest.h reference in sockaddrtest.h</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/4a3c1ff85bba83e33377a51635ec326609dc8796">4a3c1ff8</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Convert ntpdig/utilities.c.

  * Also fix typo in CompareFileContent()</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/09aff7f39bae75e58b49ec96922bb5664b2c5efe">09aff7f3</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Convert libntp/clocktime.c.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/6e719472b7c218cf1638c5da29f96b73f54fa78b">6e719472</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Convert libntp/clocktime.c.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/24046bbb0a98f196a32fb5e3b59936ea9349df30">24046bbb</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Move IsEqualS to it's own C file.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/6fe6aea4bd828b4077e32a38dd9ece6e4d941454">6fe6aea4</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Convert libntp/netof.c.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/02bbab3b4091b546abc9ee0773dee670a5aa4937">02bbab3b</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Convert libntp/refnumtoa.c.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/965fde1f9b9057a9016826b3512f33ddbee7c776">965fde1f</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Enable decodenetnum.c now that sockaddrtest.h has been fixed.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/6165a2926fe5b02e7a9966518c86f64b942bc781">6165a292</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Convert libntp/caltontp.c.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/06a07c56f61049ad2634ece0c1eb5d524b981250">06a07c56</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Convert libntp/caljulian.c.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/769b057241c175409457e2e63ed422f50ed58db5">769b0572</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Move some functions from caljulian.c and calendar.c to caltime.c.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/c0ef5549f227759a99ebae150e7f0e97a263301c">c0ef5549</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2015-12-04T13:40:40Z</i>
</div>
<pre class='commit-message'>Convert libntp/caljulian.c.</pre>
</li>
</ul>
<h4>44 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
tests/common/caltime.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
tests/common/caltime.h
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
tests/common/file_handling.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-3'>
tests/libntp/sockaddrtest.h

tests/common/sockaddrtest.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-4'>
<span class='new-file'>
+
tests/common/sockaddrtest.h
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-5'>
tests/common/tests_main.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-6'>
tests/libntp/a_md5encrypt.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-7'>
tests/libntp/authkeys.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-8'>
tests/libntp/calendar.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-9'>
tests/libntp/caljulian.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-10'>
tests/libntp/caltontp.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-11'>
tests/libntp/calyearstart.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-12'>
tests/libntp/clocktime.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-13'>
tests/libntp/decodenetnum.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-14'>
tests/libntp/hextolfp.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-15'>
tests/libntp/humandate.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-16'>
tests/libntp/lfpfunc.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-17'>
tests/libntp/lfptest.h
</a>
</li>
<li class='file-stats'>
<a href='#diff-18'>
tests/libntp/lfptostr.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-19'>
<span class='deleted-file'>

tests/libntp/libntptest.h
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-20'>
tests/libntp/modetoa.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-21'>
tests/libntp/msyslog.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-22'>
tests/libntp/netof.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-23'>
tests/libntp/numtoa.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-24'>
tests/libntp/numtohost.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-25'>
tests/libntp/prettydate.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-26'>
tests/libntp/recvbuff.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-27'>
tests/libntp/refnumtoa.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-28'>
tests/libntp/sfptostr.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-29'>
tests/libntp/socktoa.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-30'>
tests/libntp/ssl_init.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-31'>
tests/libntp/statestr.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-32'>
tests/libntp/strtolfp.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-33'>
tests/libntp/timespecops.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-34'>
tests/libntp/timevalops.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-35'>
tests/libntp/tstotv.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-36'>
tests/libntp/tvtots.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-37'>
tests/libntp/vi64ops.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-38'>
tests/libntp/ymd2yd.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-39'>
<span class='deleted-file'>

tests/ntpdig/networking.c
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-40'>
<span class='deleted-file'>

tests/ntpdig/networking.cpp
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-41'>
<span class='new-file'>
+
tests/ntpdig/packetProcessing.c
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-42'>
<span class='new-file'>
+
tests/ntpdig/utilities.c
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-43'>
tests/wscript
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-0'>
<strong>
tests/common/caltime.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/common/caltime.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/common/caltime.c
</span><span style="color: #aaaaaa">@@ -23,3 +23,18 @@ void settime(int y, int m, int d, int H, int M, int S) {
</span>   nowtime = days * SECSPERDAY + secs;
 }
 
<span style="color: #000000;background-color: #ddffdd">+
+const char *CalendarToString(const struct calendar *cal) {
+       char *str = malloc(255);
+       snprintf(str, 255, "%hu-%u-%u (%u) %u:%u:%u\n", 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 str;
+}
+
+
+const char *CalendarToStringISO(const struct isodate *iso) {
+       char *str = malloc(255);
+       snprintf(str, 255, "%hu-%u-%u %u:%u:%u\n", iso->year, (u_int)iso->week, (u_int)iso->weekday, (u_int)iso->hour, (u_int)iso->minute, (u_int)iso->second);
+       return str;
+}
+
</span></code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-1'>
<strong>
tests/common/caltime.h
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/common/caltime.h
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/common/caltime.h
</span><span style="color: #aaaaaa">@@ -1,5 +1,8 @@
</span> #include <time.h>
 
<span style="color: #000000;background-color: #ddffdd">+#include "ntp_calendar.h"
+
</span> time_t timefunc(time_t*);
 void   settime(int y, int m, int d, int H, int M, int S);
<span style="color: #000000;background-color: #ffdddd">-
</span><span style="color: #000000;background-color: #ddffdd">+const char *CalendarToString(const struct calendar *cal);
+const char *CalendarToStringISO(const struct isodate *iso);
</span></code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-2'>
<strong>
tests/common/file_handling.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/common/file_handling.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/common/file_handling.c
</span><span style="color: #aaaaaa">@@ -52,7 +52,7 @@ void CompareFileContent(FILE* expected, FILE* actual) {
</span>           TEST_ASSERT_FALSE(ferror(expected));
                TEST_ASSERT_FALSE(ferror(actual));
                if (fgets(e_line, sizeof(e_line), expected) != NULL &&
<span style="color: #000000;background-color: #ffdddd">-                    fgets(e_line, sizeof(e_line), expected) != NULL) {
</span><span style="color: #000000;background-color: #ddffdd">+               fgets(a_line, sizeof(a_line), actual) != NULL) {
</span>                   TEST_ASSERT_EQUAL_STRING(e_line, a_line);
                }
        }
</code></pre>

<br>
</li>
<li id='diff-3'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-3'>
<strong>
tests/libntp/sockaddrtest.h
</strong>

<strong>
tests/common/sockaddrtest.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/sockaddrtest.h
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/common/sockaddrtest.c
</span><span style="color: #aaaaaa">@@ -1,7 +1,7 @@
</span> #ifndef GUARD_TESTS_SOCKADDRTEST_H
 #define GUARD_TESTS_SOCKADDRTEST_H
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
</span> 
 #include "ntp.h"
 
</code></pre>

<br>
</li>
<li id='diff-4'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-4'>
<strong>
tests/common/sockaddrtest.h
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- /dev/null
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/common/sockaddrtest.h
</span><span style="color: #aaaaaa">@@ -0,0 +1,10 @@
</span><span style="color: #000000;background-color: #ddffdd">+#ifndef GUARD_TESTS_SOCKADDRTEST_H
+#define GUARD_TESTS_SOCKADDRTEST_H
+
+#include "ntp.h"
+
+bool IsEqualS(const sockaddr_u *expected, const sockaddr_u *actual);
+sockaddr_u CreateSockaddr4(const char* address, unsigned int port);
+
+
+#endif // GUARD_TESTS_SOCKADDRTEST_H
</span></code></pre>

<br>
</li>
<li id='diff-5'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-5'>
<strong>
tests/common/tests_main.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/common/tests_main.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/common/tests_main.c
</span><span style="color: #aaaaaa">@@ -34,31 +34,35 @@ static void RunAllTests(void)
</span>   RUN_TEST_GROUP(kodDatabase);
        RUN_TEST_GROUP(kodFile);
        RUN_TEST_GROUP(packetHandling);
<span style="color: #000000;background-color: #ddffdd">+//      RUN_TEST_GROUP(packetProcessing);
+       RUN_TEST_GROUP(utilities);
</span> #endif
 
 #ifdef TEST_LIBNTP
        RUN_TEST_GROUP(a_md5encrypt);
        RUN_TEST_GROUP(authkeys);
<span style="color: #000000;background-color: #ffdddd">-//      RUN_TEST_GROUP(calendar);
-//     RUN_TEST_GROUP(caljulian);
-//     RUN_TEST_GROUP(caltontp);
</span><span style="color: #000000;background-color: #ddffdd">+   RUN_TEST_GROUP(calendar);
+       RUN_TEST_GROUP(caljulian);
+       RUN_TEST_GROUP(caltontp);
</span>   RUN_TEST_GROUP(calyearstart);
<span style="color: #000000;background-color: #ffdddd">-//      RUN_TEST_GROUP(clocktime);
-//     RUN_TEST_GROUP(decodenetnum);
</span><span style="color: #000000;background-color: #ddffdd">+   RUN_TEST_GROUP(clocktime);
+       RUN_TEST_GROUP(decodenetnum);
</span>   RUN_TEST_GROUP(hextolfp);
 //     RUN_TEST_GROUP(humandate);
 //     RUN_TEST_GROUP(lfp);
 //     RUN_TEST_GROUP(lfptostr);
        RUN_TEST_GROUP(modetoa);
 //     RUN_TEST_GROUP(msyslog);
<span style="color: #000000;background-color: #ffdddd">-//      RUN_TEST_GROUP(netof);
</span><span style="color: #000000;background-color: #ddffdd">+   RUN_TEST_GROUP(netof);
</span>   RUN_TEST_GROUP(numtoa);
        RUN_TEST_GROUP(numtohost);
        RUN_TEST_GROUP(prettydate);
        RUN_TEST_GROUP(recvbuff);
<span style="color: #000000;background-color: #ffdddd">-//      RUN_TEST_GROUP(refnumtoa);
</span><span style="color: #000000;background-color: #ddffdd">+#ifdef REFCLOCK
+       RUN_TEST_GROUP(refnumtoa);
+#endif
</span>   RUN_TEST_GROUP(sfptostr);
<span style="color: #000000;background-color: #ffdddd">-//      RUN_TEST_GROUP(socktoa);
</span><span style="color: #000000;background-color: #ddffdd">+   RUN_TEST_GROUP(socktoa);
</span>   RUN_TEST_GROUP(ssl_init);
        RUN_TEST_GROUP(statestr);
        RUN_TEST_GROUP(strtolfp);
</code></pre>

<br>
</li>
<li id='diff-6'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-6'>
<strong>
tests/libntp/a_md5encrypt.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/a_md5encrypt.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/a_md5encrypt.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -7,7 +10,6 @@ TEST_SETUP(a_md5encrypt) {}
</span> 
 TEST_TEAR_DOWN(a_md5encrypt) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 #ifdef HAVE_OPENSSL
 # include "openssl/err.h"
</code></pre>

<br>
</li>
<li id='diff-7'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-7'>
<strong>
tests/libntp/authkeys.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/authkeys.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/authkeys.c
</span><span style="color: #aaaaaa">@@ -1,7 +1,9 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 #ifdef HAVE_OPENSSL
 # include "openssl/err.h"
</code></pre>

<br>
</li>
<li id='diff-8'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-8'>
<strong>
tests/libntp/calendar.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/calendar.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/calendar.c
</span><span style="color: #aaaaaa">@@ -1,7 +1,10 @@
</span><span style="color: #000000;background-color: #ffdddd">-extern "C" {
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #000000;background-color: #ffdddd">-}
</span><span style="color: #000000;background-color: #ddffdd">+
+#include "caltime.h"
</span> 
 TEST_GROUP(calendar);
 
<span style="color: #aaaaaa">@@ -9,37 +12,12 @@ TEST_SETUP(calendar) {}
</span> 
 TEST_TEAR_DOWN(calendar) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
<span style="color: #000000;background-color: #ffdddd">-extern "C" {
</span> #include "ntp_calendar.h"
<span style="color: #000000;background-color: #ffdddd">-}
-
-#include <string>
-#include <sstream>
</span> 
<span style="color: #000000;background-color: #ffdddd">-class calendarTest : public libntptest {
-protected:
-       static int leapdays(int year);
</span><span style="color: #000000;background-color: #ddffdd">+#define TEST_ASSERT_GREATER_THAN(a, b) TEST_ASSERT_TRUE(a > b)
</span> 
<span style="color: #000000;background-color: #ffdddd">-        std::string CalendarToString(const calendar &cal);
-       std::string CalendarToString(const isodate &iso);
-       bool IsEqual(const calendar &expected, const calendar &actual);
-       bool IsEqual(const isodate &expected, const isodate &actual);
-
-       std::string DateToString(const calendar &cal);
-       std::string DateToString(const isodate &iso);
-       bool IsEqualDate(const calendar &expected, const calendar &actual);
-       bool IsEqualDate(const isodate &expected, const isodate &actual);
-};
-
-
-// ---------------------------------------------------------------------
-// test support stuff
-// ---------------------------------------------------------------------
-int
-calendarTest::leapdays(int year)
-{
</span><span style="color: #000000;background-color: #ddffdd">+int leapdays(int year) {
</span>   if (year % 400 == 0)
                return 1;
        if (year % 100 == 0)
<span style="color: #aaaaaa">@@ -49,95 +27,73 @@ calendarTest::leapdays(int year)
</span>   return 0;
 }
 
<span style="color: #000000;background-color: #ffdddd">-std::string 
-calendarTest::CalendarToString(const calendar &cal) {
-       std::ostringstream ss;
-       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.str();
-}
</span> 
<span style="color: #000000;background-color: #ffdddd">-std::string
-calendarTest:: CalendarToString(const isodate &iso) {
-       std::ostringstream ss;
-       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.str();
-}
-
-bool
-calendarTest:: IsEqual(const calendar &expected, const calendar &actual) {
-       if (expected.year == actual.year &&
-           (!expected.yearday || expected.yearday == actual.yearday) &&
-           expected.month == actual.month &&
-           expected.monthday == actual.monthday &&
-           expected.hour == actual.hour &&
-           expected.minute == actual.minute &&
-           expected.second == actual.second) {
</span><span style="color: #000000;background-color: #ddffdd">+bool IsEqualCA(const struct calendar *expected, const struct calendar *actual) {
+       if (expected->year == actual->year &&
+           (!expected->yearday || expected->yearday == actual->yearday) &&
+           expected->month == actual->month &&
+           expected->monthday == actual->monthday &&
+           expected->hour == actual->hour &&
+           expected->minute == actual->minute &&
+           expected->second == actual->second) {
</span>           return true;
        } else {
<span style="color: #000000;background-color: #ffdddd">-                return false
-                   << "expected: " << CalendarToString(expected) << " but was "
-                   << CalendarToString(actual);
</span><span style="color: #000000;background-color: #ddffdd">+           printf("Expected: %s but was %s\n", CalendarToString(expected), CalendarToString(actual));
+               return false;
</span>   }
 }
 
<span style="color: #000000;background-color: #ffdddd">-bool
-calendarTest:: IsEqual(const isodate &expected, const isodate &actual) {
-       if (expected.year == actual.year &&
-           expected.week == actual.week &&
-           expected.weekday == actual.weekday &&
-           expected.hour == actual.hour &&
-           expected.minute == actual.minute &&
-           expected.second == actual.second) {
</span><span style="color: #000000;background-color: #ddffdd">+
+bool IsEqualISO(const struct isodate *expected, const struct isodate *actual) {
+       if (expected->year == actual->year &&
+           expected->week == actual->week &&
+           expected->weekday == actual->weekday &&
+           expected->hour == actual->hour &&
+           expected->minute == actual->minute &&
+           expected->second == actual->second) {
</span>           return true;
        } else {
<span style="color: #000000;background-color: #ffdddd">-                return false
-                   << "expected: " << CalendarToString(expected) << " but was "
-                   << CalendarToString(actual);
</span><span style="color: #000000;background-color: #ddffdd">+           printf("Expected: %s but was %s\n", CalendarToStringISO(expected), CalendarToStringISO(actual));
+               return false;
</span>   }
 }
 
<span style="color: #000000;background-color: #ffdddd">-std::string
-calendarTest:: DateToString(const calendar &cal) {
-       std::ostringstream ss;
-       ss << cal.year << "-" << (u_int)cal.month << "-" << (u_int)cal.monthday
-          << " (" << cal.yearday << ")";
-       return ss.str();
</span><span style="color: #000000;background-color: #ddffdd">+
+const char *DateToString(const struct calendar *cal) {
+       char *str = malloc(255);
+       snprintf(str, 255, "%hu-%u-%u(%u)\n", cal->year, (u_int)cal->month, (u_int)cal->monthday, cal->yearday);
+       return str;
</span> }
 
<span style="color: #000000;background-color: #ffdddd">-std::string
-calendarTest:: DateToString(const isodate &iso) {
-       std::ostringstream ss;
-       ss << iso.year << "-" << (u_int)iso.week << "-" << (u_int)iso.weekday;
-       return ss.str();
</span><span style="color: #000000;background-color: #ddffdd">+
+const char *DateToStringISO(const struct isodate *iso) {
+       char *str = malloc(255);
+       snprintf(str, 255, "%hu-%u-%u\n", iso->year, (u_int)iso->week, (u_int)iso->weekday);
+       return str;
+
</span> }
 
<span style="color: #000000;background-color: #ffdddd">-bool
-calendarTest:: IsEqualDate(const calendar &expected, const calendar &actual) {
-       if (expected.year == actual.year &&
-           (!expected.yearday || expected.yearday == actual.yearday) &&
-           expected.month == actual.month &&
-           expected.monthday == actual.monthday) {
-               return true;
</span><span style="color: #000000;background-color: #ddffdd">+bool IsEqualDate(const struct calendar *expected, const struct calendar *actual) {
+       if (expected->year == actual->year &&
+           (!expected->yearday || expected->yearday == actual->yearday) &&
+           expected->month == actual->month &&
+           expected->monthday == actual->monthday) {
+                       return true;
</span>   } else {
<span style="color: #000000;background-color: #ffdddd">-                return false
-                   << "expected: " << DateToString(expected) << " but was "
-                   << DateToString(actual);
</span><span style="color: #000000;background-color: #ddffdd">+           printf("Expected: %s but was %s\n", DateToString(expected), DateToString(actual));
+               return false;
</span>   }
 }
 
<span style="color: #000000;background-color: #ffdddd">-bool
-calendarTest:: IsEqualDate(const isodate &expected, const isodate &actual) {
-       if (expected.year == actual.year &&
-           expected.week == actual.week &&
-           expected.weekday == actual.weekday) {
</span><span style="color: #000000;background-color: #ddffdd">+
+bool IsEqualDateISO(const struct isodate *expected, const struct isodate *actual) {
+       if (expected->year == actual->year &&
+           expected->week == actual->week &&
+           expected->weekday == actual->weekday) {
</span>           return true;
        } else {
<span style="color: #000000;background-color: #ffdddd">-                return false
-                   << "expected: " << DateToString(expected) << " but was "
-                   << DateToString(actual);
</span><span style="color: #000000;background-color: #ddffdd">+           printf("Expected: %s but was %s\n", DateToStringISO(expected), DateToStringISO(actual));
+               return false;
</span>   }
 }
 
<span style="color: #aaaaaa">@@ -164,12 +120,12 @@ static const u_short real_month_days[2][14] = {
</span> // intermediate results would definitely overflow and the hi DWORD of
 // the 'vint64' is definitely needed.
 TEST(calendar, DaySplitMerge) {
<span style="color: #000000;background-color: #ffdddd">-        for (int32 day = -1000000; day <= 1000000; day += 100) {
-               for (int32 sec = -100000; sec <= 186400; sec += 10000) {
</span><span style="color: #000000;background-color: #ddffdd">+   for (int32_t day = -1000000; day <= 1000000; day += 100) {
+               for (int32_t sec = -100000; sec <= 186400; sec += 10000) {
</span>                   vint64       merge = ntpcal_dayjoin(day, sec);
                        ntpcal_split split = ntpcal_daysplit(&merge);
<span style="color: #000000;background-color: #ffdddd">-                        int32        eday  = day;
-                       int32        esec  = sec;
</span><span style="color: #000000;background-color: #ddffdd">+                   int32_t      eday  = day;
+                       int32_t      esec  = sec;
</span> 
                        while (esec >= 86400) {
                                eday += 1;
<span style="color: #aaaaaa">@@ -187,12 +143,12 @@ TEST(calendar, DaySplitMerge) {
</span> }
 
 TEST(calendar, SplitYearDays1) {
<span style="color: #000000;background-color: #ffdddd">-        for (int32 eyd = -1; eyd <= 365; eyd++) {
</span><span style="color: #000000;background-color: #ddffdd">+   for (int32_t eyd = -1; eyd <= 365; eyd++) {
</span>           ntpcal_split split = ntpcal_split_yeardays(eyd, 0);
                if (split.lo >= 0 && split.hi >= 0) {
                        TEST_ASSERT_GREATER_THAN(12, split.hi);
                        TEST_ASSERT_GREATER_THAN(real_month_days[0][split.hi+1], split.lo);
<span style="color: #000000;background-color: #ffdddd">-                        int32 tyd = real_month_table[0][split.hi] + split.lo;
</span><span style="color: #000000;background-color: #ddffdd">+                   int32_t tyd = real_month_table[0][split.hi] + split.lo;
</span>                   TEST_ASSERT_EQUAL(eyd, tyd);
                } else
                        TEST_ASSERT_TRUE(eyd < 0 || eyd > 364);
<span style="color: #aaaaaa">@@ -200,12 +156,12 @@ TEST(calendar, SplitYearDays1) {
</span> }
 
 TEST(calendar, SplitYearDays2) {
<span style="color: #000000;background-color: #ffdddd">-        for (int32 eyd = -1; eyd <= 366; eyd++) {
</span><span style="color: #000000;background-color: #ddffdd">+   for (int32_t eyd = -1; eyd <= 366; eyd++) {
</span>           ntpcal_split split = ntpcal_split_yeardays(eyd, 1);
                if (split.lo >= 0 && split.hi >= 0) {
                        TEST_ASSERT_GREATER_THAN(12, split.hi);
                        TEST_ASSERT_GREATER_THAN(real_month_days[1][split.hi+1], split.lo);
<span style="color: #000000;background-color: #ffdddd">-                        int32 tyd = real_month_table[1][split.hi] + split.lo;
</span><span style="color: #000000;background-color: #ddffdd">+                   int32_t tyd = real_month_table[1][split.hi] + split.lo;
</span>                   TEST_ASSERT_EQUAL(eyd, tyd);
                } else
                        TEST_ASSERT_TRUE(eyd < 0 || eyd > 365);
<span style="color: #aaaaaa">@@ -213,17 +169,17 @@ TEST(calendar, SplitYearDays2) {
</span> }
 
 TEST(calendar, RataDie1) {
<span style="color: #000000;background-color: #ffdddd">-        int32    testDate = 1; // 0001-01-01 (proleptic date)
-       calendar expected = { 1, 1, 1, 1 };
-       calendar actual;
</span><span style="color: #000000;background-color: #ddffdd">+   int32_t  testDate = 1; // 0001-01-01 (proleptic date)
+       struct calendar expected = { 1, 1, 1, 1, 0, 0, 0, 0};
+       struct calendar actual;
</span> 
        ntpcal_rd_to_date(&actual, testDate);
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqualDate(expected, actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualDate(&expected, &actual));
</span> }
 
 // check last day of february for first 10000 years
 TEST(calendar, LeapYears1) {
<span style="color: #000000;background-color: #ffdddd">-        calendar dateIn, dateOut;
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar dateIn, dateOut;
</span> 
        for (dateIn.year = 1; dateIn.year < 10000; ++dateIn.year) {
                dateIn.month    = 2;
<span style="color: #aaaaaa">@@ -232,13 +188,13 @@ TEST(calendar, LeapYears1) {
</span> 
                ntpcal_rd_to_date(&dateOut, ntpcal_date_to_rd(&dateIn));
 
<span style="color: #000000;background-color: #ffdddd">-                TEST_ASSERT_TRUE(IsEqualDate(dateIn, dateOut));
</span><span style="color: #000000;background-color: #ddffdd">+           TEST_ASSERT_TRUE(IsEqualDate(&dateIn, &dateOut));
</span>   }
 }
 
 // check first day of march for first 10000 years
 TEST(calendar, LeapYears2) {
<span style="color: #000000;background-color: #ffdddd">-        calendar dateIn, dateOut;
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar dateIn, dateOut;
</span> 
        for (dateIn.year = 1; dateIn.year < 10000; ++dateIn.year) {
                dateIn.month    = 3;
<span style="color: #aaaaaa">@@ -246,7 +202,7 @@ TEST(calendar, LeapYears2) {
</span>           dateIn.yearday  = 60 + leapdays(dateIn.year);
 
                ntpcal_rd_to_date(&dateOut, ntpcal_date_to_rd(&dateIn));
<span style="color: #000000;background-color: #ffdddd">-                TEST_ASSERT_TRUE(IsEqualDate(dateIn, dateOut));
</span><span style="color: #000000;background-color: #ddffdd">+           TEST_ASSERT_TRUE(IsEqualDate(&dateIn, &dateOut));
</span>   }
 }
 
<span style="color: #aaaaaa">@@ -256,8 +212,8 @@ TEST(calendar, LeapYears2) {
</span> // and the result of the inverse calculation must match the input no
 // invalid output can occur.)
 TEST(calendar, RoundTripDate) {
<span style="color: #000000;background-color: #ffdddd">-        calendar truDate, expDate = { 1600, 0, 12, 31 };;
-       int32    truRdn, expRdn = ntpcal_date_to_rd(&expDate);
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar truDate, expDate = { 1600, 0, 12, 31, 0, 0, 0, 0};
+       int32_t  truRdn, expRdn = ntpcal_date_to_rd(&expDate);
</span>   int      leaps;
 
        while (expDate.year < 2400) {
<span style="color: #aaaaaa">@@ -277,7 +233,7 @@ TEST(calendar, RoundTripDate) {
</span>                           TEST_ASSERT_EQUAL(expRdn, truRdn);
 
                                ntpcal_rd_to_date(&truDate, truRdn);
<span style="color: #000000;background-color: #ffdddd">-                                TEST_ASSERT_TRUE(IsEqualDate(expDate, truDate));
</span><span style="color: #000000;background-color: #ddffdd">+                           TEST_ASSERT_TRUE(IsEqualDate(&expDate, &truDate));
</span>                   }
                }
        }
<span style="color: #aaaaaa">@@ -286,8 +242,8 @@ TEST(calendar, RoundTripDate) {
</span> // Roundtrip testing on calyearstart
 TEST(calendar, RoundTripYearStart) {
        static const time_t pivot = 0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 ntp, expys, truys;
-       calendar date;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t ntp, expys, truys;
+       struct calendar date;
</span> 
        for (ntp = 0; ntp < 0xFFFFFFFFu - 30000000u; ntp += 30000000u) {
                truys = calyearstart(ntp, &pivot);
<span style="color: #aaaaaa">@@ -302,8 +258,8 @@ TEST(calendar, RoundTripYearStart) {
</span> // Roundtrip testing on calymonthstart
 TEST(calendar, RoundTripMonthStart) {
        static const time_t pivot = 0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 ntp, expms, trums;
-       calendar date;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t ntp, expms, trums;
+       struct calendar date;
</span> 
        for (ntp = 0; ntp < 0xFFFFFFFFu - 2000000u; ntp += 2000000u) {
                trums = calmonthstart(ntp, &pivot);
<span style="color: #aaaaaa">@@ -318,8 +274,8 @@ TEST(calendar, RoundTripMonthStart) {
</span> // Roundtrip testing on calweekstart
 TEST(calendar, RoundTripWeekStart) {
        static const time_t pivot = 0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 ntp, expws, truws;
-       isodate date;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t ntp, expws, truws;
+       struct isodate date;
</span> 
        for (ntp = 0; ntp < 0xFFFFFFFFu - 600000u; ntp += 600000u) {
                truws = calweekstart(ntp, &pivot);
<span style="color: #aaaaaa">@@ -334,8 +290,8 @@ TEST(calendar, RoundTripWeekStart) {
</span> // Roundtrip testing on caldaystart
 TEST(calendar, RoundTripDayStart) {
        static const time_t pivot = 0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 ntp, expds, truds;
-       calendar date;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t ntp, expds, truds;
+       struct calendar date;
</span> 
        for (ntp = 0; ntp < 0xFFFFFFFFu - 80000u; ntp += 80000u) {
                truds = caldaystart(ntp, &pivot);
</code></pre>

<br>
</li>
<li id='diff-9'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-9'>
<strong>
tests/libntp/caljulian.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/caljulian.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/caljulian.c
</span><span style="color: #aaaaaa">@@ -1,108 +1,84 @@
</span><span style="color: #000000;background-color: #ffdddd">-extern "C" {
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #000000;background-color: #ffdddd">-}
-
-TEST_GROUP(caljulian);
</span> 
<span style="color: #000000;background-color: #ffdddd">-TEST_SETUP(caljulian) {}
</span><span style="color: #000000;background-color: #ddffdd">+#include "ntp_calendar.h"
</span> 
<span style="color: #000000;background-color: #ffdddd">-TEST_TEAR_DOWN(caljulian) {}
</span><span style="color: #000000;background-color: #ddffdd">+#include <string.h>
+#include "caltime.h"
</span> 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span><span style="color: #000000;background-color: #ddffdd">+TEST_GROUP(caljulian);
</span> 
<span style="color: #000000;background-color: #ffdddd">-extern "C" {
-#include "ntp_calendar.h"
</span><span style="color: #000000;background-color: #ddffdd">+TEST_SETUP(caljulian) {
+       ntpcal_set_timefunc(timefunc);
+       settime(1970, 1, 1, 0, 0, 0);
</span> }
 
<span style="color: #000000;background-color: #ffdddd">-#include "cal.h"
-#include <string>
-#include <sstream>
-
-class caljulianTest : public libntptest {
-protected:
-       virtual void SetUp();
-       virtual void TearDown();
-
-       std::string CalendarToString(const calendar &cal) {
-               std::ostringstream ss;
-               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.str();
-       }
-
-       bool IsEqual(const calendar &expected, const calendar &actual) {
-               if (expected.year == actual.year &&
-                       (expected.yearday == actual.yearday ||
-                        (expected.month == actual.month &&
-                         expected.monthday == actual.monthday)) &&
-                       expected.hour == actual.hour &&
-                       expected.minute == actual.minute &&
-                       expected.second == actual.second) {
-                       return true;
-               } else {
-                       return false
-                               << "expected: " << CalendarToString(expected) << " but was "
-                               << CalendarToString(actual);
-               }
-       }
-};
-
-void caljulianTest::SetUp()
-{
-    ntpcal_set_timefunc(timefunc);
-    settime(1970, 1, 1, 0, 0, 0);
</span><span style="color: #000000;background-color: #ddffdd">+TEST_TEAR_DOWN(caljulian) {
+       ntpcal_set_timefunc(NULL);
</span> }
 
<span style="color: #000000;background-color: #ffdddd">-void caljulianTest::TearDown()
-{
-    ntpcal_set_timefunc(NULL);
</span><span style="color: #000000;background-color: #ddffdd">+bool IsEqualC(const struct calendar *expected, const struct calendar *actual) {
+       if (expected->year == actual->year &&
+               (expected->yearday == actual->yearday ||
+                (expected->month == actual->month &&
+                 expected->monthday == actual->monthday)) &&
+               expected->hour == actual->hour &&
+               expected->minute == actual->minute &&
+               expected->second == actual->second) {
+               return true;
+       } else {
+               printf("expected: %s but was %s", CalendarToString(expected), CalendarToString(actual));
+
+               return false;
+       }
</span> }
 
 
 TEST(caljulian, RegularTime) {
        u_long testDate = 3485080800UL; // 2010-06-09 14:00:00
<span style="color: #000000;background-color: #ffdddd">-        calendar expected = {2010,160,6,9,14,0,0};
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar expected = {2010, 160, 6, 9, 14, 0, 0, 0};
</span> 
<span style="color: #000000;background-color: #ffdddd">-        calendar actual;
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar actual;
</span> 
        caljulian(testDate, &actual);
 
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(expected, actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualC(&expected, &actual));
</span> }
 
 TEST(caljulian, LeapYear) {
        u_long input = 3549902400UL; // 2012-06-28 20:00:00Z
<span style="color: #000000;background-color: #ffdddd">-        calendar expected = {2012, 179, 6, 28, 20, 0, 0};
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar expected = {2012, 179, 6, 28, 20, 0, 0, 0};
</span> 
<span style="color: #000000;background-color: #ffdddd">-        calendar actual;
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar actual;
</span> 
        caljulian(input, &actual);
 
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(expected, actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualC(&expected, &actual));
</span> }
 
 TEST(caljulian, uLongBoundary) {
        u_long time = 4294967295UL; // 2036-02-07 6:28:15
<span style="color: #000000;background-color: #ffdddd">-        calendar expected = {2036,0,2,7,6,28,15};
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar expected = {2036, 0, 2, 7, 6, 28, 15, 0};
</span> 
<span style="color: #000000;background-color: #ffdddd">-        calendar actual;
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar actual;
</span> 
        caljulian(time, &actual);
 
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(expected, actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualC(&expected, &actual));
</span> }
 
 TEST(caljulian, uLongWrapped) {
        u_long time = 0;
<span style="color: #000000;background-color: #ffdddd">-        calendar expected = {2036,0,2,7,6,28,16};
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar expected = {2036,0,2,7,6,28,16, 0};
</span> 
<span style="color: #000000;background-color: #ffdddd">-        calendar actual;
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar actual;
</span> 
        caljulian(time, &actual);
 
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(expected, actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualC(&expected, &actual));
</span> }
 
 TEST_GROUP_RUNNER(caljulian) {
</code></pre>

<br>
</li>
<li id='diff-10'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-10'>
<strong>
tests/libntp/caltontp.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/caltontp.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/caltontp.c
</span><span style="color: #aaaaaa">@@ -1,7 +1,10 @@
</span><span style="color: #000000;background-color: #ffdddd">-extern "C" {
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #000000;background-color: #ffdddd">-}
</span><span style="color: #000000;background-color: #ddffdd">+
+#include "ntp_calendar.h"
</span> 
 TEST_GROUP(caltontp);
 
<span style="color: #aaaaaa">@@ -9,18 +12,12 @@ TEST_SETUP(caltontp) {}
</span> 
 TEST_TEAR_DOWN(caltontp) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
<span style="color: #000000;background-color: #ffdddd">-extern "C" {
-#include "ntp_calendar.h"
-}
</span> 
<span style="color: #000000;background-color: #ffdddd">-class caltontpTest : public libntptest {
-};
</span> 
 TEST(caltontp, DateGivenMonthDay) {
        // 2010-06-24 12:50:00
<span style="color: #000000;background-color: #ffdddd">-        calendar input = {2010, 0, 6, 24, 12, 50, 0};
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar input = {2010, 0, 6, 24, 12, 50, 0, 0};
</span> 
        u_long expected = 3486372600UL; // This is the timestamp above.
 
<span style="color: #aaaaaa">@@ -30,7 +27,7 @@ TEST(caltontp, DateGivenMonthDay) {
</span> TEST(caltontp, DateGivenYearDay) {
        // 2010-06-24 12:50:00
        // This is the 175th day of 2010.
<span style="color: #000000;background-color: #ffdddd">-        calendar input = {2010, 175, 0, 0, 12, 50, 0};
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar input = {2010, 175, 0, 0, 12, 50, 0, 0};
</span> 
        u_long expected = 3486372600UL; // This is the timestamp above.
 
<span style="color: #aaaaaa">@@ -40,8 +37,8 @@ TEST(caltontp, DateGivenYearDay) {
</span> TEST(caltontp, DateLeapYear) {
        // 2012-06-24 12:00:00
        // This is the 176th day of 2012 (since 2012 is a leap year).
<span style="color: #000000;background-color: #ffdddd">-        calendar inputYd = {2012, 176, 0, 0, 12, 00, 00};
-       calendar inputMd = {2012, 0, 6, 24, 12, 00, 00};
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar inputYd = {2012, 176, 0, 0, 12, 00, 00, 0};
+       struct calendar inputMd = {2012, 0, 6, 24, 12, 00, 00, 0};
</span> 
        u_long expected = 3549528000UL;
 
<span style="color: #aaaaaa">@@ -52,7 +49,7 @@ TEST(caltontp, DateLeapYear) {
</span> TEST(caltontp, WraparoundDateIn2036) {
        // 2036-02-07 06:28:16
        // This is (one) wrapping boundary where we go from ULONG_MAX to 0.
<span style="color: #000000;background-color: #ffdddd">-        calendar input = {2036, 0, 2, 7, 6, 28, 16};
</span><span style="color: #000000;background-color: #ddffdd">+   struct calendar input = {2036, 0, 2, 7, 6, 28, 16, 0};
</span> 
        u_long expected = 0UL;
 
</code></pre>

<br>
</li>
<li id='diff-11'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-11'>
<strong>
tests/libntp/calyearstart.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/calyearstart.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/calyearstart.c
</span><span style="color: #aaaaaa">@@ -1,4 +1,7 @@
</span> #include "config.h"
<span style="color: #000000;background-color: #ddffdd">+#include "ntp_stdlib.h"
+
+#include "config.h"
</span> 
 #include "unity.h"
 #include "unity_fixture.h"
</code></pre>

<br>
</li>
<li id='diff-12'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-12'>
<strong>
tests/libntp/clocktime.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/clocktime.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/clocktime.c
</span><span style="color: #aaaaaa">@@ -1,16 +1,13 @@
</span><span style="color: #000000;background-color: #ffdddd">-extern "C" {
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #000000;background-color: #ffdddd">-}
-
-TEST_GROUP(clocktime);
-
-TEST_SETUP(clocktime) {}
</span> 
<span style="color: #000000;background-color: #ffdddd">-TEST_TEAR_DOWN(clocktime) {}
</span><span style="color: #000000;background-color: #ddffdd">+#include "ntp_calendar.h"
+#include "caltime.h"
</span> 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
-#include "cal.h"
</span><span style="color: #000000;background-color: #ddffdd">+TEST_GROUP(clocktime);
</span> 
 // ---------------------------------------------------------------------
 // test fixture
<span style="color: #aaaaaa">@@ -19,20 +16,13 @@ TEST_TEAR_DOWN(clocktime) {}
</span> // function for getting the current system time, so the tests are not
 // dependent on the actual system time.
 
<span style="color: #000000;background-color: #ffdddd">-class clocktimeTest : public libntptest {
-       virtual void SetUp();
-       virtual void TearDown();
-};
-
-void clocktimeTest::SetUp()
-{
-    ntpcal_set_timefunc(timefunc);
-    settime(2000, 1, 1, 0, 0, 0);
</span><span style="color: #000000;background-color: #ddffdd">+TEST_SETUP(clocktime) {
+       ntpcal_set_timefunc(timefunc);
+       settime(2000, 1, 1, 0, 0, 0);
</span> }
 
<span style="color: #000000;background-color: #ffdddd">-void clocktimeTest::TearDown()
-{
-    ntpcal_set_timefunc(NULL);
</span><span style="color: #000000;background-color: #ddffdd">+TEST_TEAR_DOWN(clocktime) {
+       ntpcal_set_timefunc(NULL);
</span> }
 
 // ---------------------------------------------------------------------
<span style="color: #aaaaaa">@@ -40,13 +30,13 @@ void clocktimeTest::TearDown()
</span> 
 TEST(clocktime, CurrentYear) {
        // Timestamp: 2010-06-24 12:50:00Z
<span style="color: #000000;background-color: #ffdddd">-        const u_int32 timestamp = 3486372600UL;
-       const u_int32 expected  = timestamp; // exactly the same.
</span><span style="color: #000000;background-color: #ddffdd">+   const u_int32_t timestamp = 3486372600UL;
+       const u_int32_t expected        = timestamp; // exactly the same.
</span> 
        const int yday=175, hour=12, minute=50, second=0, tzoff=0;
 
        u_long yearstart=0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 actual;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t actual;
</span> 
        TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
                                                  &yearstart, &actual));
<span style="color: #aaaaaa">@@ -54,7 +44,7 @@ TEST(clocktime, CurrentYear) {
</span> }
 
 TEST(clocktime, CurrentYearFuzz) {
<span style="color: #000000;background-color: #ffdddd">-        /* 
</span><span style="color: #000000;background-color: #ddffdd">+   /*
</span>    * Timestamp (rec_ui) is: 2010-06-24 12:50:00
         * Time sent into function is 12:00:00.
         *
<span style="color: #aaaaaa">@@ -62,13 +52,13 @@ TEST(clocktime, CurrentYearFuzz) {
</span>    * timestamp for the 12:00:00 time.
         */
 
<span style="color: #000000;background-color: #ffdddd">-        const u_int32 timestamp = 3486372600UL; // 2010-06-24 12:50:00Z
-       const u_int32 expected  = 3486369600UL; // 2010-06-24 12:00:00Z
</span><span style="color: #000000;background-color: #ddffdd">+   const u_int32_t timestamp = 3486372600UL; // 2010-06-24 12:50:00Z
+       const u_int32_t expected        = 3486369600UL; // 2010-06-24 12:00:00Z
</span> 
        const int yday=175, hour=12, minute=0, second=0, tzoff=0;
 
        u_long yearstart=0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 actual;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t actual;
</span> 
        TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
                                                  &yearstart, &actual));
<span style="color: #aaaaaa">@@ -82,13 +72,13 @@ TEST(clocktime, TimeZoneOffset) {
</span>    *
         * Time sent into function is 04:00:00 +0800
         */
<span style="color: #000000;background-color: #ffdddd">-        const u_int32 timestamp = 3486369600UL;
-       const u_int32 expected  = timestamp;
</span><span style="color: #000000;background-color: #ddffdd">+   const u_int32_t timestamp = 3486369600UL;
+       const u_int32_t expected        = timestamp;
</span> 
        const int yday=175, hour=4, minute=0, second=0, tzoff=8;
 
        u_long yearstart=0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 actual;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t actual;
</span> 
        TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
                                                  &yearstart, &actual));
<span style="color: #aaaaaa">@@ -101,13 +91,13 @@ TEST(clocktime, WrongYearStart) {
</span>    * Time sent into function is 11:00:00.
         * Yearstart sent into function is the yearstart of 2009!
         */
<span style="color: #000000;background-color: #ffdddd">-        const u_int32 timestamp = 3471418800UL;
-       const u_int32 expected  = timestamp;
</span><span style="color: #000000;background-color: #ddffdd">+   const u_int32_t timestamp = 3471418800UL;
+       const u_int32_t expected        = timestamp;
</span> 
        const int yday=2, hour=11, minute=0, second=0, tzoff=0;
 
        u_long yearstart = 302024100UL; // Yearstart of 2009.
<span style="color: #000000;background-color: #ffdddd">-        u_int32 actual;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t actual;
</span> 
        TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
                                                  &yearstart, &actual));
<span style="color: #aaaaaa">@@ -120,13 +110,13 @@ TEST(clocktime, PreviousYear) {
</span>    * Time sent into function is 23:00:00
         * (which is meant to be 2009-12-31 23:00:00Z)
         */
<span style="color: #000000;background-color: #ffdddd">-        const u_int32 timestamp = 3471296400UL;
-       const u_int32 expected  = 3471289200UL;
</span><span style="color: #000000;background-color: #ddffdd">+   const u_int32_t timestamp = 3471296400UL;
+       const u_int32_t expected        = 3471289200UL;
</span> 
        const int yday=365, hour=23, minute=0, second=0, tzoff=0;
 
        u_long yearstart = 0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 actual;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t actual;
</span> 
        TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
                                                  &yearstart, &actual));
<span style="color: #aaaaaa">@@ -139,12 +129,12 @@ TEST(clocktime, NextYear) {
</span>    * Time sent into function is 01:00:00
         * (which is meant to be 2010-01-01 01:00:00Z)
         */
<span style="color: #000000;background-color: #ffdddd">-        const u_int32 timestamp = 3471289200UL;
-       const u_int32 expected  = 3471296400UL;
</span><span style="color: #000000;background-color: #ddffdd">+   const u_int32_t timestamp = 3471289200UL;
+       const u_int32_t expected        = 3471296400UL;
</span> 
        const int yday=1, hour=1, minute=0, second=0, tzoff=0;
        u_long yearstart = 0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 actual;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t actual;
</span> 
        TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
                                                  &yearstart, &actual));
<span style="color: #aaaaaa">@@ -153,11 +143,11 @@ TEST(clocktime, NextYear) {
</span> 
 TEST(clocktime, NoReasonableConversion) {
        /* Timestamp is: 2010-01-02 11:00:00Z */
<span style="color: #000000;background-color: #ffdddd">-        const u_int32 timestamp = 3471418800UL;
</span><span style="color: #000000;background-color: #ddffdd">+   const u_int32_t timestamp = 3471418800UL;
</span> 
        const int yday=100, hour=12, minute=0, second=0, tzoff=0;
        u_long yearstart = 0;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 actual;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t actual;
</span> 
        TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff, timestamp,
                                                   &yearstart, &actual));
<span style="color: #aaaaaa">@@ -165,7 +155,7 @@ TEST(clocktime, NoReasonableConversion) {
</span> 
 TEST(clocktime, AlwaysInLimit) {
        /* Timestamp is: 2010-01-02 11:00:00Z */
<span style="color: #000000;background-color: #ffdddd">-        const u_int32 timestamp = 3471418800UL;
</span><span style="color: #000000;background-color: #ddffdd">+   const u_int32_t timestamp = 3471418800UL;
</span>   const u_short prime_incs[] = { 127, 151, 163, 179 };
        int     cyc;
        int     yday;
<span style="color: #aaaaaa">@@ -173,10 +163,9 @@ TEST(clocktime, AlwaysInLimit) {
</span>   u_short ydayinc;
        int     hour;
        int     minute;
<span style="color: #000000;background-color: #ffdddd">-        int     second;
</span>   u_long  yearstart;
<span style="color: #000000;background-color: #ffdddd">-        u_int32 actual;
-       u_int32 diff;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t       actual;
+       u_int32_t       diff;
</span> 
        yearstart = 0;
        for (cyc = 0; cyc < 5; cyc++) {
<span style="color: #aaaaaa">@@ -189,9 +178,10 @@ TEST(clocktime, AlwaysInLimit) {
</span>                                   clocktime(yday, hour, minute, 30, 0,
                                                  timestamp, &yearstart, &actual);
                                        diff = actual - timestamp;
<span style="color: #000000;background-color: #ffdddd">-                                        if (diff >= 0x80000000UL)
</span><span style="color: #000000;background-color: #ddffdd">+                                   if (diff >= 0x80000000UL) {
</span>                                           diff = ~diff + 1;
<span style="color: #000000;background-color: #ffdddd">-                                        TEST_ASSERT_LESS_THAN_OR_EQUAL(diff, (183u * SECSPERDAY));
</span><span style="color: #000000;background-color: #ddffdd">+                                   }
+                                       TEST_ASSERT_TRUE(diff <= (183u * SECSPERDAY));
</span>                           }
                        }
                }
</code></pre>

<br>
</li>
<li id='diff-13'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-13'>
<strong>
tests/libntp/decodenetnum.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/decodenetnum.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/decodenetnum.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
</code></pre>

<br>
</li>
<li id='diff-14'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-14'>
<strong>
tests/libntp/hextolfp.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/hextolfp.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/hextolfp.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
</code></pre>

<br>
</li>
<li id='diff-15'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-15'>
<strong>
tests/libntp/humandate.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/humandate.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/humandate.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> extern "C" {
 #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #aaaaaa">@@ -9,7 +12,6 @@ TEST_SETUP(humandate) {}
</span> 
 TEST_TEAR_DOWN(humandate) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 #include <sstream>
 #include <string>
</code></pre>

<br>
</li>
<li id='diff-16'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-16'>
<strong>
tests/libntp/lfpfunc.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/lfpfunc.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/lfpfunc.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> extern "C" {
 #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #aaaaaa">@@ -9,7 +12,6 @@ TEST_SETUP(lfpfunc) {}
</span> 
 TEST_TEAR_DOWN(lfpfunc) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> #include "timestructs.h"
 
 extern "C" {
</code></pre>

<br>
</li>
<li id='diff-17'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-17'>
<strong>
tests/libntp/lfptest.h
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/lfptest.h
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/lfptest.h
</span><span style="color: #aaaaaa">@@ -1,7 +1,6 @@
</span> #ifndef GUARD_NTP_TESTS_LFPTEST_H
 #define GUARD_NTP_TESTS_LFPTEST_H
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> #include "ntp_fp.h"
 
 static bool IsEqual(const l_fp *expected, const l_fp *actual) {
</code></pre>

<br>
</li>
<li id='diff-18'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-18'>
<strong>
tests/libntp/lfptostr.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/lfptostr.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/lfptostr.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> extern "C" {
 #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #aaaaaa">@@ -15,7 +18,6 @@ TEST_TEAR_DOWN(lfptostr) {}
</span>  * a macro.
  */
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 extern "C" {
 #include "ntp_fp.h"
</code></pre>

<br>
</li>
<li id='diff-19'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-19'>
<strong>
tests/libntp/libntptest.h
</strong>
deleted
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/libntptest.h
</span><span style="color: #000000;background-color: #ddffdd">+++ /dev/null
</span><span style="color: #aaaaaa">@@ -1,4 +0,0 @@
</span><span style="color: #000000;background-color: #ffdddd">-#include "tests_main.h"
-
-#include "ntp_stdlib.h"
-
</span></code></pre>

<br>
</li>
<li id='diff-20'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-20'>
<strong>
tests/libntp/modetoa.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/modetoa.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/modetoa.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -7,7 +10,6 @@ TEST_SETUP(modetoa) {}
</span> 
 TEST_TEAR_DOWN(modetoa) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 
 TEST(modetoa, KnownMode) {
</code></pre>

<br>
</li>
<li id='diff-21'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-21'>
<strong>
tests/libntp/msyslog.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/msyslog.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/msyslog.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> extern "C" {
 #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #aaaaaa">@@ -9,7 +12,6 @@ TEST_SETUP(msyslog) {}
</span> 
 TEST_TEAR_DOWN(msyslog) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 extern "C" {
 #include <stdio.h>
</code></pre>

<br>
</li>
<li id='diff-22'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-22'>
<strong>
tests/libntp/netof.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/netof.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/netof.c
</span><span style="color: #aaaaaa">@@ -1,7 +1,8 @@
</span><span style="color: #000000;background-color: #ffdddd">-extern "C" {
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #000000;background-color: #ffdddd">-}
</span> 
 TEST_GROUP(netof);
 
<span style="color: #aaaaaa">@@ -11,8 +12,6 @@ TEST_TEAR_DOWN(netof) {}
</span> 
 #include "sockaddrtest.h"
 
<span style="color: #000000;background-color: #ffdddd">-class netofTest : public sockaddrtest  {
-};
</span> 
 TEST(netof, ClassBAddress) {
        sockaddr_u input = CreateSockaddr4("172.16.2.1", NTP_PORT);
<span style="color: #aaaaaa">@@ -21,7 +20,7 @@ TEST(netof, ClassBAddress) {
</span>   sockaddr_u* actual = netof(&input);
 
        TEST_ASSERT_TRUE(actual != NULL);
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(expected, *actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualS(&expected, actual));
</span> }
 
 TEST(netof, ClassCAddress) {
<span style="color: #aaaaaa">@@ -31,7 +30,7 @@ TEST(netof, ClassCAddress) {
</span>   sockaddr_u* actual = netof(&input);
 
        TEST_ASSERT_TRUE(actual != NULL);
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(expected, *actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualS(&expected, actual));
</span> }
 
 TEST(netof, ClassAAddress) {
<span style="color: #aaaaaa">@@ -44,24 +43,24 @@ TEST(netof, ClassAAddress) {
</span>   sockaddr_u* actual = netof(&input);
 
        TEST_ASSERT_TRUE(actual != NULL);
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(expected, *actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualS(&expected, actual));
</span> }
 
 TEST(netof, IPv6Address) {
        /* IPv6 addresses are assumed to have 64-bit host- and 64-bit network parts. */
<span style="color: #000000;background-color: #ffdddd">-        const struct in6_addr input_address = {
</span><span style="color: #000000;background-color: #ddffdd">+   const struct in6_addr input_address = {{{
</span>           0x20, 0x01, 0x0d, 0xb8,
<span style="color: #000000;background-color: #ffdddd">-        0x85, 0xa3, 0x08, 0xd3, 
</span><span style="color: #000000;background-color: #ddffdd">+        0x85, 0xa3, 0x08, 0xd3,
</span>         0x13, 0x19, 0x8a, 0x2e,
         0x03, 0x70, 0x73, 0x34
<span style="color: #000000;background-color: #ffdddd">-        }; // 2001:0db8:85a3:08d3:1319:8a2e:0370:7334
</span><span style="color: #000000;background-color: #ddffdd">+   }}}; // 2001:0db8:85a3:08d3:1319:8a2e:0370:7334
</span> 
<span style="color: #000000;background-color: #ffdddd">-        const struct in6_addr expected_address = {
</span><span style="color: #000000;background-color: #ddffdd">+   const struct in6_addr expected_address = {{{
</span>           0x20, 0x01, 0x0d, 0xb8,
<span style="color: #000000;background-color: #ffdddd">-        0x85, 0xa3, 0x08, 0xd3, 
</span><span style="color: #000000;background-color: #ddffdd">+        0x85, 0xa3, 0x08, 0xd3,
</span>         0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00
<span style="color: #000000;background-color: #ffdddd">-        }; // 2001:0db8:85a3:08d3:0000:0000:0000:0000
</span><span style="color: #000000;background-color: #ddffdd">+   }}}; // 2001:0db8:85a3:08d3:0000:0000:0000:0000
</span> 
        sockaddr_u input;
        input.sa6.sin6_family = AF_INET6;
<span style="color: #aaaaaa">@@ -76,7 +75,7 @@ TEST(netof, IPv6Address) {
</span>   sockaddr_u* actual = netof(&input);
 
        TEST_ASSERT_TRUE(actual != NULL);
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(expected, *actual));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualS(&expected, actual));
</span> }
 
 TEST_GROUP_RUNNER(netof) {
</code></pre>

<br>
</li>
<li id='diff-23'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-23'>
<strong>
tests/libntp/numtoa.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/numtoa.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/numtoa.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -7,7 +10,6 @@ TEST_SETUP(numtoa) {}
</span> 
 TEST_TEAR_DOWN(numtoa) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 TEST(numtoa, Address) {
        u_int32_t input = htonl(3221225472UL+512UL+1UL); // 192.0.2.1
</code></pre>

<br>
</li>
<li id='diff-24'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-24'>
<strong>
tests/libntp/numtohost.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/numtohost.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/numtohost.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -8,7 +11,6 @@ TEST_SETUP(numtohost) {}
</span> 
 TEST_TEAR_DOWN(numtohost) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 
 TEST(numtohost, LoopbackNetNonResolve) {
</code></pre>

<br>
</li>
<li id='diff-25'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-25'>
<strong>
tests/libntp/prettydate.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/prettydate.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/prettydate.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -7,7 +10,6 @@ TEST_SETUP(prettydate) {}
</span> 
 TEST_TEAR_DOWN(prettydate) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 #include "ntp_fp.h"
 
</code></pre>

<br>
</li>
<li id='diff-26'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-26'>
<strong>
tests/libntp/recvbuff.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/recvbuff.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/recvbuff.c
</span><span style="color: #aaaaaa">@@ -1,6 +1,8 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> #include "recvbuff.h"
 
 
</code></pre>

<br>
</li>
<li id='diff-27'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-27'>
<strong>
tests/libntp/refnumtoa.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/refnumtoa.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/refnumtoa.c
</span><span style="color: #aaaaaa">@@ -1,7 +1,11 @@
</span><span style="color: #000000;background-color: #ffdddd">-extern "C" {
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #000000;background-color: #ffdddd">-}
</span><span style="color: #000000;background-color: #ddffdd">+
+#include "ntp_net.h"
+#include "ntp_refclock.h"
</span> 
 TEST_GROUP(refnumtoa);
 
<span style="color: #aaaaaa">@@ -9,25 +13,16 @@ TEST_SETUP(refnumtoa) {}
</span> 
 TEST_TEAR_DOWN(refnumtoa) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
<span style="color: #000000;background-color: #ffdddd">-#include "ntp_net.h"
-#include "ntp_refclock.h"
</span><span style="color: #000000;background-color: #ddffdd">+/* Might need to be updated if a new refclock gets this id. */
+static const int UNUSED_REFCLOCK_ID = 250;
</span> 
<span style="color: #000000;background-color: #ffdddd">-#include <sstream>
</span> 
<span style="color: #000000;background-color: #ffdddd">-class refnumtoaTest : public libntptest {
-protected:
-       /* Might need to be updated if a new refclock gets this id. */
-       static const int UNUSED_REFCLOCK_ID = 250;
-};
-
-#ifdef REFCLOCK                /* clockname() is useless otherwise */
</span> TEST(refnumtoa, LocalClock) {
        /* We test with a refclock address of type LOCALCLOCK.
         * with id 8
         */
<span style="color: #000000;background-color: #ffdddd">-        u_int32 addr = REFCLOCK_ADDR;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t addr = REFCLOCK_ADDR;
</span>   addr |= REFCLK_LOCALCLOCK << 8;
        addr |= 0x8;
 
<span style="color: #aaaaaa">@@ -35,18 +30,15 @@ TEST(refnumtoa, LocalClock) {
</span>   address.sa4.sin_family = AF_INET;
        address.sa4.sin_addr.s_addr = htonl(addr);
 
<span style="color: #000000;background-color: #ffdddd">-        std::ostringstream expected;
-       expected << clockname(REFCLK_LOCALCLOCK)
-                        << "(8)";
</span><span style="color: #000000;background-color: #ddffdd">+   char expected[255];
+       snprintf(expected, sizeof(expected), "%s(8)", clockname(REFCLK_LOCALCLOCK));
</span> 
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_EQUAL_STRING(expected.str().c_str(), refnumtoa(&address));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
</span> }
<span style="color: #000000;background-color: #ffdddd">-#endif  /* REFCLOCK */
</span> 
<span style="color: #000000;background-color: #ffdddd">-#ifdef REFCLOCK         /* refnumtoa() is useless otherwise */
</span> TEST(refnumtoa, UnknownId) {
        /* We test with a currently unused refclock ID */
<span style="color: #000000;background-color: #ffdddd">-        u_int32 addr = REFCLOCK_ADDR;
</span><span style="color: #000000;background-color: #ddffdd">+   u_int32_t addr = REFCLOCK_ADDR;
</span>   addr |= UNUSED_REFCLOCK_ID << 8;
        addr |= 0x4;
 
<span style="color: #aaaaaa">@@ -54,13 +46,12 @@ TEST(refnumtoa, UnknownId) {
</span>   address.sa4.sin_family = AF_INET;
        address.sa4.sin_addr.s_addr = htonl(addr);
 
<span style="color: #000000;background-color: #ffdddd">-        std::ostringstream expected;
-       expected << "REFCLK(" << UNUSED_REFCLOCK_ID
-                        << ",4)";
</span><span style="color: #000000;background-color: #ddffdd">+   char expected[255];
+       snprintf(expected, sizeof(expected), "REFCLK(%d,4)", UNUSED_REFCLOCK_ID);
</span> 
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_EQUAL_STRING(expected.str().c_str(), refnumtoa(&address));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_EQUAL_STRING(expected, refnumtoa(&address));
</span> }
<span style="color: #000000;background-color: #ffdddd">-#endif  /* REFCLOCK */
</span><span style="color: #000000;background-color: #ddffdd">+
</span> 
 TEST_GROUP_RUNNER(refnumtoa) {
        RUN_TEST_CASE(refnumtoa, LocalClock);
</code></pre>

<br>
</li>
<li id='diff-28'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-28'>
<strong>
tests/libntp/sfptostr.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/sfptostr.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/sfptostr.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -12,7 +15,6 @@ TEST_TEAR_DOWN(sfptostr) {}
</span>  * since all these functions are very similar.
  */
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 #include "ntp_fp.h"
 
</code></pre>

<br>
</li>
<li id='diff-29'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-29'>
<strong>
tests/libntp/socktoa.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/socktoa.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/socktoa.c
</span><span style="color: #aaaaaa">@@ -1,7 +1,8 @@
</span><span style="color: #000000;background-color: #ffdddd">-extern "C" {
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #000000;background-color: #ffdddd">-}
</span> 
 TEST_GROUP(socktoa);
 
<span style="color: #aaaaaa">@@ -11,8 +12,6 @@ TEST_TEAR_DOWN(socktoa) {}
</span> 
 #include "sockaddrtest.h"
 
<span style="color: #000000;background-color: #ffdddd">-class socktoaTest : public sockaddrtest {
-};
</span> 
 TEST(socktoa, IPv4AddressWithPort) {
        sockaddr_u input = CreateSockaddr4("192.0.2.10", 123);
<span style="color: #aaaaaa">@@ -22,12 +21,12 @@ TEST(socktoa, IPv4AddressWithPort) {
</span> }
 
 TEST(socktoa, IPv6AddressWithPort) {
<span style="color: #000000;background-color: #ffdddd">-        const struct in6_addr address = {
</span><span style="color: #000000;background-color: #ddffdd">+   const struct in6_addr address = {{{
</span>           0x20, 0x01, 0x0d, 0xb8,
<span style="color: #000000;background-color: #ffdddd">-                0x85, 0xa3, 0x08, 0xd3, 
</span><span style="color: #000000;background-color: #ddffdd">+           0x85, 0xa3, 0x08, 0xd3,
</span>           0x13, 0x19, 0x8a, 0x2e,
                0x03, 0x70, 0x73, 0x34
<span style="color: #000000;background-color: #ffdddd">-        };
</span><span style="color: #000000;background-color: #ddffdd">+   }}};
</span> 
        const char* expected =
                "2001:db8:85a3:8d3:1319:8a2e:370:7334";
<span style="color: #aaaaaa">@@ -46,16 +45,16 @@ TEST(socktoa, IPv6AddressWithPort) {
</span> 
 #ifdef ISC_PLATFORM_HAVESCOPEID
 TEST(socktoa, ScopedIPv6AddressWithPort) {
<span style="color: #000000;background-color: #ffdddd">-        const struct in6_addr address = {
</span><span style="color: #000000;background-color: #ddffdd">+   const struct in6_addr address = {{{
</span>           0xfe, 0x80, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
<span style="color: #000000;background-color: #ffdddd">-                0x02, 0x12, 0x3f, 0xff, 
</span><span style="color: #000000;background-color: #ddffdd">+           0x02, 0x12, 0x3f, 0xff,
</span>           0xfe, 0x29, 0xff, 0xfa
<span style="color: #000000;background-color: #ffdddd">-        };
</span><span style="color: #000000;background-color: #ddffdd">+   }}};
</span> 
        const char* expected =
                "fe80::212:3fff:fe29:fffa%5";
<span style="color: #000000;background-color: #ffdddd">-        const char* expected_port = 
</span><span style="color: #000000;background-color: #ddffdd">+   const char* expected_port =
</span>           "[fe80::212:3fff:fe29:fffa%5]:123";
 
        sockaddr_u input;
<span style="color: #aaaaaa">@@ -74,7 +73,7 @@ TEST(socktoa, HashEqual) {
</span>   sockaddr_u input1 = CreateSockaddr4("192.00.2.2", 123);
        sockaddr_u input2 = CreateSockaddr4("192.0.2.2", 123);
 
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_TRUE(IsEqual(input1, input2));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_TRUE(IsEqualS(&input1, &input2));
</span>   TEST_ASSERT_EQUAL(sock_hash(&input1), sock_hash(&input2));
 }
 
<span style="color: #aaaaaa">@@ -83,17 +82,17 @@ TEST(socktoa, HashNotEqual) {
</span>   sockaddr_u input1 = CreateSockaddr4("192.0.2.1", 123);
        sockaddr_u input2 = CreateSockaddr4("192.0.2.2", 123);
 
<span style="color: #000000;background-color: #ffdddd">-        TEST_ASSERT_FALSE(IsEqual(input1, input2));
</span><span style="color: #000000;background-color: #ddffdd">+   TEST_ASSERT_FALSE(IsEqualS(&input1, &input2));
</span>   TEST_ASSERT_NOT_EQUAL(sock_hash(&input1), sock_hash(&input2));
 }
 
 TEST(socktoa, IgnoreIPv6Fields) {
<span style="color: #000000;background-color: #ffdddd">-        const struct in6_addr address = {
</span><span style="color: #000000;background-color: #ddffdd">+   const struct in6_addr address = {{{
</span>           0x20, 0x01, 0x0d, 0xb8,
<span style="color: #000000;background-color: #ffdddd">-        0x85, 0xa3, 0x08, 0xd3, 
</span><span style="color: #000000;background-color: #ddffdd">+        0x85, 0xa3, 0x08, 0xd3,
</span>         0x13, 0x19, 0x8a, 0x2e,
         0x03, 0x70, 0x73, 0x34
<span style="color: #000000;background-color: #ffdddd">-        };
</span><span style="color: #000000;background-color: #ddffdd">+   }}};
</span> 
        sockaddr_u input1, input2;
 
</code></pre>

<br>
</li>
<li id='diff-30'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-30'>
<strong>
tests/libntp/ssl_init.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/ssl_init.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/ssl_init.c
</span><span style="color: #aaaaaa">@@ -1,4 +1,7 @@
</span> #include "config.h"
<span style="color: #000000;background-color: #ddffdd">+#include "ntp_stdlib.h"
+
+#include "config.h"
</span> 
 #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #aaaaaa">@@ -9,7 +12,6 @@ TEST_SETUP(ssl_init) {}
</span> 
 TEST_TEAR_DOWN(ssl_init) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 #ifdef HAVE_OPENSSL
 # include "openssl/err.h"
</code></pre>

<br>
</li>
<li id='diff-31'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-31'>
<strong>
tests/libntp/statestr.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/statestr.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/statestr.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -7,7 +10,6 @@ TEST_SETUP(statestr) {}
</span> 
 TEST_TEAR_DOWN(statestr) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 #include "ntp.h" // Needed for MAX_MAC_LEN used in ntp_control.h
 #include "ntp_control.h"
</code></pre>

<br>
</li>
<li id='diff-32'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-32'>
<strong>
tests/libntp/strtolfp.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/strtolfp.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/strtolfp.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
</code></pre>

<br>
</li>
<li id='diff-33'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-33'>
<strong>
tests/libntp/timespecops.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/timespecops.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/timespecops.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> extern "C" {
 #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #aaaaaa">@@ -9,7 +12,6 @@ TEST_SETUP(timespecops) {}
</span> 
 TEST_TEAR_DOWN(timespecops) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> #include "timestructs.h"
 
 extern "C" {
</code></pre>

<br>
</li>
<li id='diff-34'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-34'>
<strong>
tests/libntp/timevalops.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/timevalops.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/timevalops.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> extern "C" {
 #include "unity.h"
 #include "unity_fixture.h"
<span style="color: #aaaaaa">@@ -9,7 +12,6 @@ TEST_SETUP(timevalops) {}
</span> 
 TEST_TEAR_DOWN(timevalops) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> #include "timestructs.h"
 
 extern "C" {
</code></pre>

<br>
</li>
<li id='diff-35'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-35'>
<strong>
tests/libntp/tstotv.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/tstotv.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/tstotv.c
</span><span style="color: #aaaaaa">@@ -1,4 +1,7 @@
</span> #include "config.h"
<span style="color: #000000;background-color: #ddffdd">+#include "ntp_stdlib.h"
+
+#include "config.h"
</span> 
 #include "unity.h"
 #include "unity_fixture.h"
</code></pre>

<br>
</li>
<li id='diff-36'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-36'>
<strong>
tests/libntp/tvtots.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/tvtots.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/tvtots.c
</span><span style="color: #aaaaaa">@@ -1,4 +1,7 @@
</span> #include "config.h"
<span style="color: #000000;background-color: #ddffdd">+#include "ntp_stdlib.h"
+
+#include "config.h"
</span> 
 #include "unity.h"
 #include "unity_fixture.h"
</code></pre>

<br>
</li>
<li id='diff-37'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-37'>
<strong>
tests/libntp/vi64ops.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/vi64ops.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/vi64ops.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -7,7 +10,6 @@ TEST_SETUP(vi64ops) {}
</span> 
 TEST_TEAR_DOWN(vi64ops) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 #include "vint64ops.h"
 
</code></pre>

<br>
</li>
<li id='diff-38'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-38'>
<strong>
tests/libntp/ymd2yd.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/libntp/ymd2yd.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/libntp/ymd2yd.c
</span><span style="color: #aaaaaa">@@ -1,3 +1,6 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "config.h"
+#include "ntp_stdlib.h"
+
</span> #include "unity.h"
 #include "unity_fixture.h"
 
<span style="color: #aaaaaa">@@ -7,7 +10,6 @@ TEST_SETUP(ymd2yd) {}
</span> 
 TEST_TEAR_DOWN(ymd2yd) {}
 
<span style="color: #000000;background-color: #ffdddd">-#include "libntptest.h"
</span> 
 
 TEST(ymd2yd, NonLeapYearFebruary) {
</code></pre>

<br>
</li>
<li id='diff-39'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-39'>
<strong>
tests/ntpdig/networking.c
</strong>
deleted
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/ntpdig/networking.c
</span><span style="color: #000000;background-color: #ddffdd">+++ /dev/null
</span><span style="color: #aaaaaa">@@ -1,3 +0,0 @@
</span><span style="color: #000000;background-color: #ffdddd">-#include "ntpdigtest.h"
-
-#include "networking.h"
</span></code></pre>

<br>
</li>
<li id='diff-40'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-40'>
<strong>
tests/ntpdig/networking.cpp
</strong>
deleted
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/ntpdig/networking.cpp
</span><span style="color: #000000;background-color: #ddffdd">+++ /dev/null
</span><span style="color: #aaaaaa">@@ -1,5 +0,0 @@
</span><span style="color: #000000;background-color: #ffdddd">-#include "ntpdigtest.h"
-
-extern "C" {
-#include "networking.h"
-};
</span></code></pre>

<br>
</li>
<li id='diff-41'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-41'>
<strong>
tests/ntpdig/packetProcessing.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- /dev/null
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/ntpdig/packetProcessing.c
</span><span style="color: #aaaaaa">@@ -0,0 +1,359 @@
</span><span style="color: #000000;background-color: #ddffdd">+extern "C" {
+#include "unity.h"
+#include "unity_fixture.h"
+}
+
+TEST_GROUP(packetProcessing);
+
+TEST_SETUP(packetProcessing) {}
+
+TEST_TEAR_DOWN(packetProcessing) {}
+
+#include "ntpdigtest.h"
+
+extern "C" {
+#include "networking.h"
+#include "ntp_stdlib.h"
+};
+
+#include <sstream>
+#include <string>
+
+// Hacks into the key database.
+extern key* key_ptr;
+extern int key_cnt;
+
+class packetProcessingTest : public ntpdigtest {
+protected:
+       pkt testpkt;
+       pkt testspkt;
+       sockaddr_u testsock;
+       bool restoreKeyDb;
+
+       void PrepareAuthenticationTest(int key_id,
+                                                                  int key_len,
+                                                                  const char* type,
+                                                                  const void* key_seq) {
+               std::stringstream ss;
+               ss << key_id;
+
+               ActivateOption("-a", ss.str().c_str());
+
+               key_cnt = 1;
+               key_ptr = new key;
+               key_ptr->next = NULL;
+               key_ptr->key_id = key_id;
+               key_ptr->key_len = key_len;
+               memcpy(key_ptr->type, "MD5", 3);
+
+               TEST_ASSERT_TRUE(key_len < sizeof(key_ptr->key_seq));
+
+               memcpy(key_ptr->key_seq, key_seq, key_ptr->key_len);
+               restoreKeyDb = true;
+       }
+
+       void PrepareAuthenticationTest(int key_id,
+                                                                  int key_len,
+                                                                  const void* key_seq) {
+               PrepareAuthenticationTest(key_id, key_len, "MD5", key_seq);
+       }
+
+       virtual void SetUp() {
+               restoreKeyDb = false;
+
+               /* Initialize the test packet and socket,
+                * so they contain at least some valid data. */
+               testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING, NTP_VERSION,
+                                                                                       MODE_SERVER);
+               testpkt.stratum = STRATUM_REFCLOCK;
+               memcpy(&testpkt.refid, "GPS\0", 4);
+
+               /* Set the origin timestamp of the received packet to the
+                * same value as the transmit timestamp of the sent packet. */
+               l_fp tmp;
+               tmp.l_ui = 1000UL;
+               tmp.l_uf = 0UL;
+
+               HTONL_FP(&tmp, &testpkt.org);
+               HTONL_FP(&tmp, &testspkt.xmt);
+       }
+
+       virtual void TearDown() {
+               if (restoreKeyDb) {
+                       key_cnt = 0;
+                       delete key_ptr;
+                       key_ptr = NULL;
+               }
+       }
+};
+
+TEST(packetProcessing, TooShortLength) {
+       TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC - 1,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+       TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC - 1,
+                                                 MODE_BROADCAST, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, LengthNotMultipleOfFour) {
+       TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC + 6,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+       TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC + 3,
+                                                 MODE_BROADCAST, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, TooShortExtensionFieldLength) {
+       /* The lower 16-bits are the length of the extension field.
+        * This lengths must be multiples of 4 bytes, which gives
+        * a minimum of 4 byte extension field length. */
+       testpkt.exten[7] = htonl(3); // 3 bytes is too short.
+
+       /* We send in a pkt_len of header size + 4 byte extension
+        * header + 24 byte MAC, this prevents the length error to
+        * be caught at an earlier stage */
+       int pkt_len = LEN_PKT_NOMAC + 4 + 24;
+
+       TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, UnauthenticatedPacketReject) {
+       // Activate authentication option
+       ActivateOption("-a", "123");
+       TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
+
+       int pkt_len = LEN_PKT_NOMAC;
+
+       // We demand authentication, but no MAC header is present.
+       TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, CryptoNAKPacketReject) {
+       // Activate authentication option
+       ActivateOption("-a", "123");
+       TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
+
+       int pkt_len = LEN_PKT_NOMAC + 4; // + 4 byte MAC = Crypto-NAK
+
+       TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, AuthenticatedPacketInvalid) {
+       // Activate authentication option
+       PrepareAuthenticationTest(50, 9, "123456789");
+       TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
+
+       // Prepare the packet.
+       int pkt_len = LEN_PKT_NOMAC;
+
+       testpkt.exten[0] = htonl(50);
+       int mac_len = make_mac((char*)&testpkt, pkt_len,
+                                                  MAX_MD5_LEN, key_ptr,
+                                                  (char*)&testpkt.exten[1]);
+
+       pkt_len += 4 + mac_len;
+
+       // Now, alter the MAC so it becomes invalid.
+       testpkt.exten[1] += 1;
+
+       TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, AuthenticatedPacketUnknownKey) {
+       // Activate authentication option
+       PrepareAuthenticationTest(30, 9, "123456789");
+       TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
+
+       // Prepare the packet. Observe that the Key-ID expected is 30,
+       // but the packet has a key id of 50.
+       int pkt_len = LEN_PKT_NOMAC;
+
+       testpkt.exten[0] = htonl(50);
+       int mac_len = make_mac((char*)&testpkt, pkt_len,
+                                                  MAX_MD5_LEN, key_ptr,
+                                                  (char*)&testpkt.exten[1]);
+       pkt_len += 4 + mac_len;
+
+       TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, ServerVersionTooOld) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                                                                               NTP_OLDVERSION - 1,
+                                                                               MODE_CLIENT);
+       TEST_ASSERT_LESS_THAN(PKT_VERSION(testpkt.li_vn_mode), NTP_OLDVERSION);
+
+       int pkt_len = LEN_PKT_NOMAC;
+
+       TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, ServerVersionTooNew) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                                                                               NTP_VERSION + 1,
+                                                                               MODE_CLIENT);
+       TEST_ASSERT_GREATER_THAN(PKT_VERSION(testpkt.li_vn_mode), NTP_VERSION);
+
+       int pkt_len = LEN_PKT_NOMAC;
+
+       TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, NonWantedMode) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                                                                               NTP_VERSION,
+                                                                               MODE_CLIENT);
+
+       // The packet has a mode of MODE_CLIENT, but process_pkt expects MODE_SERVER
+
+       TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+/* Tests bug 1597 */
+TEST(packetProcessing, KoDRate) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       testpkt.stratum = STRATUM_PKT_UNSPEC;
+       memcpy(&testpkt.refid, "RATE", 4);
+
+       TEST_ASSERT_EQUAL(KOD_RATE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, KoDDeny) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       testpkt.stratum = STRATUM_PKT_UNSPEC;
+       memcpy(&testpkt.refid, "DENY", 4);
+
+       TEST_ASSERT_EQUAL(KOD_DEMOBILIZE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, RejectUnsyncedServer) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
+                                                                               NTP_VERSION,
+                                                                               MODE_SERVER);
+
+       TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, RejectWrongResponseServerMode) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       l_fp tmp;
+       tmp.l_ui = 1000UL;
+       tmp.l_uf = 0UL;
+       HTONL_FP(&tmp, &testpkt.org);
+
+       tmp.l_ui = 2000UL;
+       tmp.l_uf = 0UL;
+       HTONL_FP(&tmp, &testspkt.xmt);
+
+       TEST_ASSERT_EQUAL(PACKET_UNUSEABLE,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, AcceptNoSentPacketBroadcastMode) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                                           NTP_VERSION,
+                                           MODE_BROADCAST);
+
+       TEST_ASSERT_EQUAL(LEN_PKT_NOMAC,
+                 process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
+                             MODE_BROADCAST, NULL, "UnitTest", true));
+}
+
+TEST(packetProcessing, CorrectUnauthenticatedPacket) {
+       TEST_ASSERT_FALSE(ENABLED_OPT(AUTHENTICATION));
+
+       TEST_ASSERT_EQUAL(LEN_PKT_NOMAC,
+                         process_pkt(&testpkt, &testsock, LEN_PKT_NOMAC,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST(packetProcessing, CorrectAuthenticatedPacketMD5) {
+       PrepareAuthenticationTest(10, 15, "123456789abcdef");
+       TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
+
+       int pkt_len = LEN_PKT_NOMAC;
+
+       // Prepare the packet.
+       testpkt.exten[0] = htonl(10);
+       int mac_len = make_mac((char*)&testpkt, pkt_len,
+                                                  MAX_MD5_LEN, key_ptr,
+                                                  (char*)&testpkt.exten[1]);
+
+       pkt_len += 4 + mac_len;
+
+       TEST_ASSERT_EQUAL(pkt_len,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+
+}
+
+TEST(packetProcessing, CorrectAuthenticatedPacketSHA1) {
+       PrepareAuthenticationTest(20, 15, "SHA1", "abcdefghijklmno");
+       TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
+
+       int pkt_len = LEN_PKT_NOMAC;
+
+       // Prepare the packet.
+       testpkt.exten[0] = htonl(20);
+       int mac_len = make_mac((char*)&testpkt, pkt_len,
+                                                  MAX_MAC_LEN, key_ptr,
+                                                  (char*)&testpkt.exten[1]);
+
+       pkt_len += 4 + mac_len;
+
+       TEST_ASSERT_EQUAL(pkt_len,
+                         process_pkt(&testpkt, &testsock, pkt_len,
+                                                 MODE_SERVER, &testspkt, "UnitTest", true));
+}
+
+TEST_GROUP_RUNNER(packetProcessing) {
+       RUN_TEST_CASE(packetProcessing, GenerateUnauthenticatedPacket);
+       RUN_TEST_CASE(packetProcessing, GenerateAuthenticatedPacket);
+       RUN_TEST_CASE(packetProcessing, OffsetCalculationPositiveOffset);
+       RUN_TEST_CASE(packetProcessing, OffsetCalculationNegativeOffset);
+       RUN_TEST_CASE(packetProcessing, HandleUnusableServer);
+       RUN_TEST_CASE(packetProcessing, HandleUnusablePacket);
+       RUN_TEST_CASE(packetProcessing, HandleServerAuthenticationFailure);
+       RUN_TEST_CASE(packetProcessing, HandleKodDemobilize);
+       RUN_TEST_CASE(packetProcessing, HandleKodRate);
+       RUN_TEST_CASE(packetProcessing, HandleCorrectPacket);
+}
+
</span></code></pre>

<br>
</li>
<li id='diff-42'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-42'>
<strong>
tests/ntpdig/utilities.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- /dev/null
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/ntpdig/utilities.c
</span><span style="color: #aaaaaa">@@ -0,0 +1,190 @@
</span><span style="color: #000000;background-color: #ddffdd">+#include "unity.h"
+#include "unity_fixture.h"
+
+TEST_GROUP(utilities);
+
+TEST_SETUP(utilities) {}
+
+TEST_TEAR_DOWN(utilities) {}
+
+#include "ntpdigtest.h"
+#include "file_handling.h"
+
+#include "main.h"
+#include "utilities.h"
+
+#include "sockaddrtest.h"
+
+const char * Version = "stub unit test Version string";
+
+
+struct addrinfo CreateAddrinfo(sockaddr_u* sock) {
+       struct addrinfo a;
+       a.ai_family = sock->sa.sa_family;
+       a.ai_addrlen = SIZEOF_SOCKADDR(a.ai_family);
+       a.ai_addr = &sock->sa;
+       return a;
+}
+
+
+bool outputFileOpened;
+FILE* outputFile;
+
+//     debugUtilitiesTest() : outputFileOpened(false) {}
+
+void InitDebugTest(const char *filename) {
+       // Clear the contents of the current file.
+       // Open the output file
+       outputFile = fopen(filename, "w+");
+       TEST_ASSERT_TRUE(outputFile != NULL);
+       outputFileOpened = true;
+}
+
+// Closes outputFile, and compare contents.
+void FinishDebugTest(const char *expected,
+                                        const char *actual) {
+       FILE* fp_a;
+       FILE* fp_e;
+
+       if (outputFileOpened) {
+               fclose(outputFile);
+       }
+
+       fp_a = fopen(actual, "rb");
+       fp_e = fopen(expected, "rb");
+
+       CompareFileContent(fp_e, fp_a);
+
+       fclose(fp_a);
+       fclose(fp_e);
+
+       free((void*) expected);
+       free((void*) actual);
+}
+
+
+/*
+ * These tests are essentially a copy of the tests for socktoa()
+ * in libntp. If ntpdig switches to using that functions, these
+ * tests can be removed.
+ */
+
+TEST(utilities, IPv4Address) {
+       const char* ADDR = "192.0.2.10";
+
+       sockaddr_u input = CreateSockaddr4(ADDR, 123);
+       struct addrinfo inputA = CreateAddrinfo(&input);
+
+       TEST_ASSERT_EQUAL_STRING(ADDR, ss_to_str(&input));
+       TEST_ASSERT_EQUAL_STRING(ADDR, addrinfo_to_str(&inputA));
+}
+
+TEST(utilities, IPv6Address) {
+       const struct in6_addr address = {{{
+                                               0x20, 0x01, 0x0d, 0xb8,
+                                               0x85, 0xa3, 0x08, 0xd3,
+                                               0x13, 0x19, 0x8a, 0x2e,
+                                               0x03, 0x70, 0x73, 0x34
+                                       }}};
+       const char *expected = "2001:db8:85a3:8d3:1319:8a2e:370:7334";
+       sockaddr_u      input;
+       struct addrinfo inputA;
+
+       memset(&input, 0, sizeof(input));
+       input.sa6.sin6_family = AF_INET6;
+       input.sa6.sin6_addr = address;
+       TEST_ASSERT_EQUAL_STRING(expected, ss_to_str(&input));
+
+       inputA = CreateAddrinfo(&input);
+       TEST_ASSERT_EQUAL_STRING(expected, addrinfo_to_str(&inputA));
+}
+
+TEST(utilities, SetLiVnMode1) {
+       struct pkt expected;
+       expected.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                                            NTP_VERSION,
+                                            MODE_SERVER);
+
+       struct pkt actual;
+       set_li_vn_mode(&actual, LEAP_NOWARNING, NTP_VERSION,
+                                  MODE_SERVER);
+
+       TEST_ASSERT_EQUAL(expected.li_vn_mode, actual.li_vn_mode);
+}
+
+TEST(utilities, SetLiVnMode2) {
+       struct pkt expected;
+       expected.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
+                                                                                NTP_OLDVERSION,
+                                                                                MODE_BROADCAST);
+
+       struct pkt actual;
+       set_li_vn_mode(&actual, LEAP_NOTINSYNC, NTP_OLDVERSION,
+                                  MODE_BROADCAST);
+
+       TEST_ASSERT_EQUAL(expected.li_vn_mode, actual.li_vn_mode);
+}
+
+/* Debug utilities tests */
+
+TEST(utilities, DebugPktOutput) {
+       const char *filename = CreatePath("debug-output-pkt", OUTPUT_DIR);
+       InitDebugTest(filename);
+
+       struct pkt testpkt;
+       memset(&testpkt, 0, sizeof(struct pkt));
+       testpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                                                                               NTP_VERSION,
+                                                                               MODE_SERVER);
+
+       l_fp test;
+       test.l_ui = 8;
+       test.l_uf = 2147483647; // Lots of ones.
+       HTONL_FP(&test, &testpkt.xmt);
+
+       pkt_output(&testpkt, LEN_PKT_NOMAC, outputFile);
+
+       FinishDebugTest(CreatePath("debug-input-pkt", INPUT_DIR), filename);
+}
+
+TEST(utilities, DebugLfpOutputBinaryFormat) {
+       const char *filename = CreatePath("debug-output-lfp-bin", OUTPUT_DIR);
+       InitDebugTest(filename);
+
+       l_fp test;
+       test.l_ui = 63;  // 00000000 00000000 00000000 00111111
+       test.l_uf = 127; // 00000000 00000000 00000000 01111111
+
+       l_fp network;
+       HTONL_FP(&test, &network);
+
+       l_fp_output_bin(&network, outputFile);
+
+       FinishDebugTest(CreatePath("debug-input-lfp-bin", INPUT_DIR), filename);
+}
+
+TEST(utilities, DebugLfpOutputDecimalFormat) {
+       const char *filename = CreatePath("debug-output-lfp-dec", OUTPUT_DIR);
+       InitDebugTest(filename);
+
+       l_fp test;
+       test.l_ui = 6310; // 0x000018A6
+       test.l_uf = 308502; // 0x00004B516
+
+       l_fp network;
+       HTONL_FP(&test, &network);
+
+       l_fp_output_dec(&network, outputFile);
+
+       FinishDebugTest(CreatePath("debug-input-lfp-dec", INPUT_DIR), filename);
+}
+
+TEST_GROUP_RUNNER(utilities) {
+       RUN_TEST_CASE(utilities, IPv4Address);
+       RUN_TEST_CASE(utilities, IPv6Address);
+       RUN_TEST_CASE(utilities, SetLiVnMode1);
+       RUN_TEST_CASE(utilities, SetLiVnMode2);
+       RUN_TEST_CASE(utilities, DebugPktOutput);
+       RUN_TEST_CASE(utilities, DebugLfpOutputBinaryFormat);
+       RUN_TEST_CASE(utilities, DebugLfpOutputDecimalFormat);
+}
</span></code></pre>

<br>
</li>
<li id='diff-43'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c#diff-43'>
<strong>
tests/wscript
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/tests/wscript
</span><span style="color: #000000;background-color: #ddffdd">+++ b/tests/wscript
</span><span style="color: #aaaaaa">@@ -18,6 +18,8 @@ def build(ctx):
</span>   # Test main.
        common_source = [
                "common/tests_main.c",
<span style="color: #000000;background-color: #ddffdd">+                "common/caltime.c",
+               "common/sockaddrtest.c"
</span>   ]
 
 
<span style="color: #aaaaaa">@@ -27,8 +29,9 @@ def build(ctx):
</span>           "ntpdig/keyFile.c",
                "ntpdig/kodDatabase.c",
                "ntpdig/kodFile.c",
<span style="color: #000000;background-color: #ffdddd">-#               "ntpdig/networking.c",
</span>           "ntpdig/packetHandling.c",
<span style="color: #000000;background-color: #ddffdd">+#               "ntpdig/packetProcessing.c",
+               "ntpdig/utilities.c",
</span>   ] + common_source
 
 
<span style="color: #aaaaaa">@@ -53,26 +56,25 @@ def build(ctx):
</span>   libntp_source = [
                "libntp/a_md5encrypt.c",
                "libntp/authkeys.c",
<span style="color: #000000;background-color: #ffdddd">-#               "libntp/calendar.c",
-#              "libntp/caljulian.c",
-#              "libntp/caltontp.c",
</span><span style="color: #000000;background-color: #ddffdd">+           "libntp/calendar.c",
+               "libntp/caljulian.c",
+               "libntp/caltontp.c",
</span>           "libntp/calyearstart.c",
<span style="color: #000000;background-color: #ffdddd">-#               "libntp/clocktime.c",
-#              "libntp/decodenetnum.c",
</span><span style="color: #000000;background-color: #ddffdd">+           "libntp/clocktime.c",
+               "libntp/decodenetnum.c",
</span>           "libntp/hextolfp.c",
 #              "libntp/humandate.c",
 #              "libntp/lfpfunc.c",
 #              "libntp/lfptostr.c",
                "libntp/modetoa.c",
 #              "libntp/msyslog.c",
<span style="color: #000000;background-color: #ffdddd">-#               "libntp/netof.c",
</span><span style="color: #000000;background-color: #ddffdd">+           "libntp/netof.c",
</span>           "libntp/numtoa.c",
                "libntp/numtohost.c",
                "libntp/prettydate.c",
                "libntp/recvbuff.c",
<span style="color: #000000;background-color: #ffdddd">-#               "libntp/refnumtoa.c",
</span>           "libntp/sfptostr.c",
<span style="color: #000000;background-color: #ffdddd">-#               "libntp/socktoa.c",
</span><span style="color: #000000;background-color: #ddffdd">+           "libntp/socktoa.c",
</span>           "libntp/ssl_init.c",
                "libntp/statestr.c",
                "libntp/strtolfp.c",
<span style="color: #aaaaaa">@@ -82,7 +84,10 @@ def build(ctx):
</span>           "libntp/tvtots.c",
                "libntp/vi64ops.c",
                "libntp/ymd2yd.c"
<span style="color: #000000;background-color: #ffdddd">-        ] + common_source + ["common/caltime.c"]
</span><span style="color: #000000;background-color: #ddffdd">+   ] + common_source
+
+       if ctx.env.REFCLOCK_ENABLE:
+               libntp_source += ["libntp/refnumtoa.c"]
</span> 
        ctx.ntp_test(
                features    = "c cprogram bld_include src_include libisc_include test",
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/compare/e108e3c68b024202dded95a96d0063b12b9f181e...c0ef5549f227759a99ebae150e7f0e97a263301c">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.

</p>
</div>
</body>
</html>