]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
c_fileHandlingTest.h:
authorDamir Tomic <viperus@ntp.org>
Fri, 19 Jun 2015 15:51:30 +0000 (17:51 +0200)
committerDamir Tomic <viperus@ntp.org>
Fri, 19 Jun 2015 15:51:30 +0000 (17:51 +0200)
  added new cases with strcpy(path,....)
run-strtolfp.c, run-lfptostr.c:
  new file

bk: 55843a82TcA8kiy_MeZsvwBDpKmHow

sntp/tests/c_fileHandlingTest.h
tests/libntp/run-lfptostr.c [new file with mode: 0644]
tests/libntp/run-strtolfp.c [new file with mode: 0644]

index b9cb12ad61ab3fd61ac6b459d2b1cb0ad47b9a6a..e3f76d5707c47673d1e51b96dd36f81c159474d8 100644 (file)
@@ -35,7 +35,10 @@ const char * CreatePath(const char* filename, enum DirectoryType argument) {
        if (getcwd(cwd, sizeof(cwd)) != NULL)
                printf("Current working dir: %s\n", cwd);
        
-
+       if(strstr(cwd,"sub/") == NULL){
+               strcpy(path,"../../../sntp/tests/data/");
+       }
+       else
        if(strstr(cwd,"_build") == NULL){ //if it's run as make distcheck, it's in a different directory!
                strcpy(path,"../../../sntp/tests/data/");
        }
diff --git a/tests/libntp/run-lfptostr.c b/tests/libntp/run-lfptostr.c
new file mode 100644 (file)
index 0000000..491f7c0
--- /dev/null
@@ -0,0 +1,71 @@
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+  Unity.CurrentTestName = #TestFunc; \
+  Unity.CurrentTestLineNumber = TestLineNum; \
+  Unity.NumberOfTests++; \
+  if (TEST_PROTECT()) \
+  { \
+      setUp(); \
+      TestFunc(); \
+  } \
+  if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+  { \
+    tearDown(); \
+  } \
+  UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void test_PositiveInteger(void);
+extern void test_NegativeInteger(void);
+extern void test_PositiveIntegerWithFraction(void);
+extern void test_NegativeIntegerWithFraction(void);
+extern void test_RoundingDownToInteger(void);
+extern void test_RoundingMiddleToInteger(void);
+extern void test_RoundingUpToInteger(void);
+extern void test_SingleDecimal(void);
+extern void test_MillisecondsRoundingUp(void);
+extern void test_MillisecondsRoundingDown(void);
+extern void test_UnsignedInteger(void);
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+  tearDown();
+  setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+  progname = argv[0];
+  Unity.TestFile = "lfptostr.c";
+  UnityBegin("lfptostr.c");
+  RUN_TEST(test_PositiveInteger, 22);
+  RUN_TEST(test_NegativeInteger, 29);
+  RUN_TEST(test_PositiveIntegerWithFraction, 36);
+  RUN_TEST(test_NegativeIntegerWithFraction, 43);
+  RUN_TEST(test_RoundingDownToInteger, 50);
+  RUN_TEST(test_RoundingMiddleToInteger, 57);
+  RUN_TEST(test_RoundingUpToInteger, 64);
+  RUN_TEST(test_SingleDecimal, 71);
+  RUN_TEST(test_MillisecondsRoundingUp, 78);
+  RUN_TEST(test_MillisecondsRoundingDown, 87);
+  RUN_TEST(test_UnsignedInteger, 96);
+
+  return (UnityEnd());
+}
diff --git a/tests/libntp/run-strtolfp.c b/tests/libntp/run-strtolfp.c
new file mode 100644 (file)
index 0000000..c698800
--- /dev/null
@@ -0,0 +1,63 @@
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+  Unity.CurrentTestName = #TestFunc; \
+  Unity.CurrentTestLineNumber = TestLineNum; \
+  Unity.NumberOfTests++; \
+  if (TEST_PROTECT()) \
+  { \
+      setUp(); \
+      TestFunc(); \
+  } \
+  if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+  { \
+    tearDown(); \
+  } \
+  UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void test_PositiveInteger(void);
+extern void test_NegativeInteger(void);
+extern void test_PositiveFraction(void);
+extern void test_NegativeFraction(void);
+extern void test_PositiveMsFraction(void);
+extern void test_NegativeMsFraction(void);
+extern void test_InvalidChars(void);
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+  tearDown();
+  setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+  progname = argv[0];
+  Unity.TestFile = "strtolfp.c";
+  UnityBegin("strtolfp.c");
+  RUN_TEST(test_PositiveInteger, 9);
+  RUN_TEST(test_NegativeInteger, 23);
+  RUN_TEST(test_PositiveFraction, 40);
+  RUN_TEST(test_NegativeFraction, 54);
+  RUN_TEST(test_PositiveMsFraction, 71);
+  RUN_TEST(test_NegativeMsFraction, 87);
+  RUN_TEST(test_InvalidChars, 105);
+
+  return (UnityEnd());
+}