]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Changes wrt to <hextolfp> test
authorLokesh Walase <lokeshw24@ntp.org>
Mon, 15 Jun 2015 05:51:38 +0000 (11:21 +0530)
committerLokesh Walase <lokeshw24@ntp.org>
Mon, 15 Jun 2015 05:51:38 +0000 (11:21 +0530)
bk: 557e67eaeEVQBgJYjtGZbuf6Xt6Tjw

tests/libntp/c_lfptest.h [new file with mode: 0644]
tests/libntp/hextolfp.c
tests/libntp/lfptest.h

diff --git a/tests/libntp/c_lfptest.h b/tests/libntp/c_lfptest.h
new file mode 100644 (file)
index 0000000..a6e3627
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef NTP_TESTS_LFPTEST_H
+#define NTP_TESTS_LFPTEST_H
+
+#include "ntp_fp.h"
+
+int IsEqual(const l_fp expected, const l_fp actual) {
+       if (L_ISEQU(&expected, &actual)) {
+               return 1==1;
+       } else {
+               return 1==2;
+       }
+
+}
+
+#endif
+
+
index 04e96d1640e4575495bcbf127a4a599c13b4b675..f17642ef3f0afaff563fe1c88284e8fcafc153b3 100644 (file)
@@ -1,6 +1,15 @@
-#include "testcalshims.h"
+#include "config.h"
+#include "ntp_stdlib.h"
+#include "ntp_calendar.h"
 #include "unity.h"
-#include "lfptest.h"
+#include "c_lfptest.h"
+
+static const int32 HALF = -2147483647L - 1L;
+static const int32 HALF_PROMILLE_UP = 2147484; // slightly more than 0.0005
+static const int32 HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005
+static const int32 QUARTER = 1073741824L;
+static const int32 QUARTER_PROMILLE_APPRX = 1073742L;
+
 
 
 void test_PositiveInteger(void) {
@@ -13,49 +22,47 @@ void test_PositiveInteger(void) {
        TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-/*
-TEST_F(hextolfpTest, NegativeInteger) {
+void test_NegativeInteger(void) {
        const char *str = "ffffffff.00000000"; // -1 decimal
        l_fp actual;
 
        l_fp expected = {-1, 0};
 
-       ASSERT_TRUE(hextolfp(str, &actual));
-       EXPECT_TRUE(IsEqual(expected, actual));
+       TEST_ASSERT_TRUE(hextolfp(str, &actual));
+       TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-TEST_F(hextolfpTest, PositiveFraction) {
+void test_PositiveFraction(void) {
        const char *str = "00002000.80000000"; // 8196.5 decimal
        l_fp actual;
 
        l_fp expected = {8192, HALF};
 
-       ASSERT_TRUE(hextolfp(str, &actual));
-       EXPECT_TRUE(IsEqual(expected, actual));
+       TEST_ASSERT_TRUE(hextolfp(str, &actual));
+       TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-TEST_F(hextolfpTest, NegativeFraction) {
+void test_NegativeFraction(void) {
        const char *str = "ffffffff.40000000"; // -1 + 0.25 decimal
        l_fp actual;
 
        l_fp expected = {-1, QUARTER}; //-1 + 0.25
 
-       ASSERT_TRUE(hextolfp(str, &actual));
-       EXPECT_TRUE(IsEqual(expected, actual));
+       TEST_ASSERT_TRUE(hextolfp(str, &actual));
+       TEST_ASSERT_TRUE(IsEqual(expected, actual));
 }
 
-TEST_F(hextolfpTest, IllegalNumberOfInteger) {
+void test_IllegalNumberOfInteger(void) {
        const char *str = "1000000.00000000"; // Missing one digit in integral part.
        l_fp actual;
 
-       ASSERT_FALSE(hextolfp(str, &actual));
+       TEST_ASSERT_FALSE(hextolfp(str, &actual));
 }
 
-TEST_F(hextolfpTest, IllegalChar) {
+void test_IllegalChar(void) {
        const char *str = "10000000.0000h000"; // Illegal character h.
        l_fp actual;
 
-       ASSERT_FALSE(hextolfp(str, &actual));
+       TEST_ASSERT_FALSE(hextolfp(str, &actual));
 }
 
-*/
index 58857354e2edabd49cab579c0c67cb0a0cb731b0..85179b811c11f4aafeb11a02130ff94d945f008c 100644 (file)
@@ -1,28 +1,6 @@
 #ifndef NTP_TESTS_LFPTEST_H
 #define NTP_TESTS_LFPTEST_H
 
-//#include "libntptest.h"
-//Including this gives some error during compilation.
-//Hence right now commenting it out, as it is not required currently.
-
-#include "ntp_fp.h"
-
-int IsEqual(const l_fp expected, const l_fp actual) {
-       if (L_ISEQU(&expected, &actual)) {
-               return 1==1;
-       } else {
-               return 1==2;
-       }
-
-}
-
-#endif
-
-
-/*
-#ifndef NTP_TESTS_LFPTEST_H
-#define NTP_TESTS_LFPTEST_H
-
 #include "libntptest.h"
 
 extern "C" {
@@ -51,5 +29,4 @@ protected:
 };
 
 #endif
-*/
 /* NTP_TESTS_LFPTEST_H */