[Git][NTPsec/ntpsec][master] 4 commits: Convert prettydate.c

Amar Takhar gitlab at mg.gitlab.com
Wed Nov 25 00:55:50 UTC 2015


Amar Takhar pushed to branch master at NTPsec / ntpsec


Commits:
8d4472ee by Amar Takhar at 2015-11-24T19:54:58Z
Convert prettydate.c

- - - - -
c2b06499 by Amar Takhar at 2015-11-24T19:54:58Z
octtoint was removed in d111c7c5.

- - - - -
c9f47a81 by Amar Takhar at 2015-11-24T19:54:58Z
Fix a bug in installing the icons.

This reverts some previous work.  I remember now why I did it the way I did.

- - - - -
8c989ef7 by Amar Takhar at 2015-11-24T19:54:58Z
Convert numtoa.c.

- - - - -


7 changed files:

- docs/wscript
- tests/common/tests_main.c
- tests/libntp/numtoa.c
- − tests/libntp/octtoint.c
- − tests/libntp/octtoint.cpp
- tests/libntp/prettydate.c
- tests/wscript


Changes:

=====================================
docs/wscript
=====================================
--- a/docs/wscript
+++ b/docs/wscript
@@ -17,13 +17,14 @@ def build(ctx):
 		ctx.path.get_bld().make_node(dir).mkdir() # create 'pic' directory
 		image_source += files
 
-	# Copy images
-	ctx(
-		features	= "subst",
-		is_copy		= True,
-		source		= image_source,
-		target		= [ctx.path.find_node(dir).get_bld().make_node(x.name) for x in image_source]
-	)
+		# Copy images
+		ctx(
+			features	= "subst",
+			is_copy		= True,
+			source		= files,
+			target		= [ctx.path.find_node(dir).get_bld().make_node(x.name) for x in files]
+		)
+
 
 	extra = ["asciidoc.js", "asciidoc.css"]
 


=====================================
tests/common/tests_main.c
=====================================
--- a/tests/common/tests_main.c
+++ b/tests/common/tests_main.c
@@ -52,10 +52,9 @@ static void RunAllTests(void)
 //	RUN_TEST_GROUP(modetoa);
 //	RUN_TEST_GROUP(msyslog);
 //	RUN_TEST_GROUP(netof);
-//	RUN_TEST_GROUP(numtoa);
+	RUN_TEST_GROUP(numtoa);
 //	RUN_TEST_GROUP(numtohost);
-//	RUN_TEST_GROUP(octtoint);
-//	RUN_TEST_GROUP(prettydate);
+	RUN_TEST_GROUP(prettydate);
 //	RUN_TEST_GROUP(recvbuff);
 //	RUN_TEST_GROUP(refnumtoa);
 	RUN_TEST_GROUP(sfptostr);


=====================================
tests/libntp/numtoa.c
=====================================
--- a/tests/libntp/numtoa.c
+++ b/tests/libntp/numtoa.c
@@ -1,7 +1,5 @@
-extern "C" {
 #include "unity.h"
 #include "unity_fixture.h"
-}
 
 TEST_GROUP(numtoa);
 
@@ -11,19 +9,16 @@ TEST_TEAR_DOWN(numtoa) {}
 
 #include "libntptest.h"
 
-class numtoaTest : public libntptest {
-};
-
 TEST(numtoa, Address) {
-	u_int32 input = htonl(3221225472UL+512UL+1UL); // 192.0.2.1
+	u_int32_t input = htonl(3221225472UL+512UL+1UL); // 192.0.2.1
 
 	TEST_ASSERT_EQUAL_STRING("192.0.2.1", numtoa(input));
 }
 
 TEST(numtoa, Netmask) {
 	// 255.255.255.0
-	u_int32 hostOrder = 255UL*256UL*256UL*256UL + 255UL*256UL*256UL + 255UL*256UL;
-	u_int32 input = htonl(hostOrder);
+	u_int32_t hostOrder = 255UL*256UL*256UL*256UL + 255UL*256UL*256UL + 255UL*256UL;
+	u_int32_t input = htonl(hostOrder);
 
 	TEST_ASSERT_EQUAL_STRING("255.255.255.0", numtoa(input));
 }


=====================================
tests/libntp/octtoint.c deleted
=====================================
--- a/tests/libntp/octtoint.c
+++ /dev/null
@@ -1,78 +0,0 @@
-extern "C" {
-#include "unity.h"
-#include "unity_fixture.h"
-}
-
-TEST_GROUP(octtoint);
-
-TEST_SETUP(octtoint) {}
-
-TEST_TEAR_DOWN(octtoint) {}
-
-#include "libntptest.h"
-
-class octtointTest : public libntptest {
-};
-
-TEST(octtoint, SingleDigit) {
-	const char* str = "5";
-	u_long actual;
-
-	TEST_ASSERT_TRUE(octtoint(str, &actual));
-	TEST_ASSERT_EQUAL(5, actual);
-}
-
-TEST(octtoint, MultipleDigits) {
-	const char* str = "271";
-	u_long actual;
-
-	TEST_ASSERT_TRUE(octtoint(str, &actual));
-	TEST_ASSERT_EQUAL(185, actual);
-}
-
-TEST(octtoint, Zero) {
-	const char* str = "0";
-	u_long actual;
-
-	TEST_ASSERT_TRUE(octtoint(str, &actual));
-	TEST_ASSERT_EQUAL(0, actual);
-}
-
-TEST(octtoint, MaximumUnsigned32bit) {
-	const char* str = "37777777777";
-	u_long actual;
-
-	TEST_ASSERT_TRUE(octtoint(str, &actual));
-	TEST_ASSERT_EQUAL(4294967295UL, actual);
-}
-
-TEST(octtoint, Overflow) {
-	const char* str = "40000000000";
-	u_long actual;
-
-	TEST_ASSERT_FALSE(octtoint(str, &actual));
-}
-
-TEST(octtoint, IllegalCharacter) {
-	const char* str = "5ac2";
-	u_long actual;
-
-	TEST_ASSERT_FALSE(octtoint(str, &actual));
-}
-
-TEST(octtoint, IllegalDigit) {
-	const char* str = "5283";
-	u_long actual;
-
-	TEST_ASSERT_FALSE(octtoint(str, &actual));
-}
-
-TEST_GROUP_RUNNER(octtoint) {
-	RUN_TEST_CASE(octtoint, SingleDigit);
-	RUN_TEST_CASE(octtoint, MultipleDigits);
-	RUN_TEST_CASE(octtoint, Zero);
-	RUN_TEST_CASE(octtoint, MaximumUnsigned32bit);
-	RUN_TEST_CASE(octtoint, Overflow);
-	RUN_TEST_CASE(octtoint, IllegalCharacter);
-	RUN_TEST_CASE(octtoint, IllegalDigit);
-}


=====================================
tests/libntp/octtoint.cpp deleted
=====================================
--- a/tests/libntp/octtoint.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-extern "C" {
-#include "unity.h"
-#include "unity_fixture.h"
-}
-
-TEST_GROUP(octtoint);
-
-TEST_SETUP(octtoint) {}
-
-TEST_TEAR_DOWN(octtoint) {}
-
-#include "libntptest.h"
-
-class octtointTest : public libntptest {
-};
-
-TEST(octtoint, SingleDigit) {
-	const char* str = "5";
-	u_long actual;
-
-	TEST_ASSERT_TRUE(octtoint(str, &actual));
-	TEST_ASSERT_EQUAL(5, actual);
-}
-
-TEST(octtoint, MultipleDigits) {
-	const char* str = "271";
-	u_long actual;
-
-	TEST_ASSERT_TRUE(octtoint(str, &actual));
-	TEST_ASSERT_EQUAL(185, actual);
-}
-
-TEST(octtoint, Zero) {
-	const char* str = "0";
-	u_long actual;
-
-	TEST_ASSERT_TRUE(octtoint(str, &actual));
-	TEST_ASSERT_EQUAL(0, actual);
-}
-
-TEST(octtoint, MaximumUnsigned32bit) {
-	const char* str = "37777777777";
-	u_long actual;
-
-	TEST_ASSERT_TRUE(octtoint(str, &actual));
-	TEST_ASSERT_EQUAL(4294967295UL, actual);
-}
-
-TEST(octtoint, Overflow) {
-	const char* str = "40000000000";
-	u_long actual;
-
-	TEST_ASSERT_FALSE(octtoint(str, &actual));
-}
-
-TEST(octtoint, IllegalCharacter) {
-	const char* str = "5ac2";
-	u_long actual;
-
-	TEST_ASSERT_FALSE(octtoint(str, &actual));
-}
-
-TEST(octtoint, IllegalDigit) {
-	const char* str = "5283";
-	u_long actual;
-
-	TEST_ASSERT_FALSE(octtoint(str, &actual));
-}


=====================================
tests/libntp/prettydate.c
=====================================
--- a/tests/libntp/prettydate.c
+++ b/tests/libntp/prettydate.c
@@ -1,7 +1,5 @@
-extern "C" {
 #include "unity.h"
 #include "unity_fixture.h"
-}
 
 TEST_GROUP(prettydate);
 
@@ -11,17 +9,12 @@ TEST_TEAR_DOWN(prettydate) {}
 
 #include "libntptest.h"
 
-extern "C" {
 #include "ntp_fp.h"
-};
 
-class prettydateTest : public libntptest {
-protected:
-	static const u_int32 HALF = 2147483648UL;
-};
+static const u_int32_t HALF = 2147483648UL;
 
 TEST(prettydate, ConstantDate) {
-	l_fp time = {3485080800UL, HALF}; // 2010-06-09 14:00:00.5
+	l_fp time = {{3485080800UL}, HALF}; // 2010-06-09 14:00:00.5
 
 	TEST_ASSERT_EQUAL_STRING("cfba1ce0.80000000  2010-06-09T14:00:00.500", gmprettydate(&time));
 }


=====================================
tests/wscript
=====================================
--- a/tests/wscript
+++ b/tests/wscript
@@ -65,10 +65,9 @@ def build(ctx):
 #		"libntp/modetoa.c",
 #		"libntp/msyslog.c",
 #		"libntp/netof.c",
-#		"libntp/numtoa.c",
+		"libntp/numtoa.c",
 #		"libntp/numtohost.c",
-#		"libntp/octtoint.c",
-#		"libntp/prettydate.c",
+		"libntp/prettydate.c",
 #		"libntp/recvbuff.c",
 #		"libntp/refnumtoa.c",
 		"libntp/sfptostr.c",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/bce7a4b7ddbd1998c367be12f19a5d73d27cb90e...8c989ef735e2e3a20b14ef39804ae0f91e1025db
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151125/169f7966/attachment.html>


More information about the vc mailing list