-#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) {
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));
}
-*/
#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" {
};
#endif
-*/
/* NTP_TESTS_LFPTEST_H */