]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
rc_cmdlength test
authorLokesh Walase <lokeshw24@ntp.org>
Sun, 12 Jul 2015 17:29:46 +0000 (22:59 +0530)
committerLokesh Walase <lokeshw24@ntp.org>
Sun, 12 Jul 2015 17:29:46 +0000 (22:59 +0530)
bk: 55a2a40amF8GcI1KEJZVu9uRHkhJig

tests/ntpd/rc_cmdlength.c
tests/ntpd/run-rc_cmdlength.c [new file with mode: 0644]

index bd1ed5e86e80052928b05f76f244400797af9a3a..e3d599faf0eac073a1102c32e5c694fb4c14c651 100644 (file)
 
 void
 test_EvaluateCommandLength(void){
-       const char *src_buf = "This is random command";
-       const char *src_end = "This is random command";
+       size_t length, commandLength;
+       const char *command1 = "Random Command";
+       const char *command2 = "Random Command\t\t\n\t";
+       const char *command3 = "Random\nCommand\t\t\n\t";
+       const char *command4 = "Random Command\t\t\n\t1 2 3";
+       
+       length = strlen(command1);
+       commandLength = remoteconfig_cmdlength(command1, command1+length);
+       TEST_ASSERT_EQUAL(14, commandLength );
+       
+       length = strlen(command2);
+       commandLength = remoteconfig_cmdlength(command2, command2+length);
+       TEST_ASSERT_EQUAL(14, commandLength );
+
+       length = strlen(command3);
+       commandLength = remoteconfig_cmdlength(command3, command3+length);
+       TEST_ASSERT_EQUAL(6, commandLength );
+       
+       length = strlen(command4);
+       commandLength = remoteconfig_cmdlength(command4, command4+length);
+       TEST_ASSERT_EQUAL(16, commandLength );
 
-       size_t commandLength = remoteconfig_cmdlength(src_buf, src_end);
-
-       TEST_ASSERT_EQUAL(strlen(src_buf), commandLength );
 }
diff --git a/tests/ntpd/run-rc_cmdlength.c b/tests/ntpd/run-rc_cmdlength.c
new file mode 100644 (file)
index 0000000..17de146
--- /dev/null
@@ -0,0 +1,52 @@
+/* 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);
+void resetTest(void);
+extern void test_EvaluateCommandLength(void);
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+  tearDown();
+  setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+  progname = argv[0];
+  Unity.TestFile = "rc_cmdlength.c";
+  UnityBegin("rc_cmdlength.c");
+  RUN_TEST(test_EvaluateCommandLength, 15);
+
+  return (UnityEnd());
+}