From: Lokesh Walase Date: Sun, 12 Jul 2015 17:29:46 +0000 (+0530) Subject: rc_cmdlength test X-Git-Tag: NTP_4_3_65~7^2~11^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=172be31f15615d48aeb8b03186481ee2f0088cd9;p=thirdparty%2Fntp.git rc_cmdlength test bk: 55a2a40amF8GcI1KEJZVu9uRHkhJig --- diff --git a/tests/ntpd/rc_cmdlength.c b/tests/ntpd/rc_cmdlength.c index bd1ed5e86..e3d599faf 100644 --- a/tests/ntpd/rc_cmdlength.c +++ b/tests/ntpd/rc_cmdlength.c @@ -13,10 +13,26 @@ 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 index 000000000..17de146ae --- /dev/null +++ b/tests/ntpd/run-rc_cmdlength.c @@ -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 +#include + +//=======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()); +}