From: Lokesh Walase Date: Mon, 15 Jun 2015 05:51:38 +0000 (+0530) Subject: Changes wrt to test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2dcbe9b4d01b2d2ce37ad96131ca9fa3b2bdc18;p=thirdparty%2Fntp.git Changes wrt to test bk: 557e67eaeEVQBgJYjtGZbuf6Xt6Tjw --- diff --git a/tests/libntp/c_lfptest.h b/tests/libntp/c_lfptest.h new file mode 100644 index 000000000..a6e3627e9 --- /dev/null +++ b/tests/libntp/c_lfptest.h @@ -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 + + diff --git a/tests/libntp/hextolfp.c b/tests/libntp/hextolfp.c index 04e96d164..f17642ef3 100644 --- a/tests/libntp/hextolfp.c +++ b/tests/libntp/hextolfp.c @@ -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)); } -*/ diff --git a/tests/libntp/lfptest.h b/tests/libntp/lfptest.h index 58857354e..85179b811 100644 --- a/tests/libntp/lfptest.h +++ b/tests/libntp/lfptest.h @@ -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 */