xref: /netbsd-src/external/bsd/ntp/dist/tests/ntpd/rc_cmdlength.c (revision cdfa2a7ef92791ba9db70a584a1d904730e6fb46)
1 /*	$NetBSD: rc_cmdlength.c,v 1.3 2020/05/25 20:47:36 christos Exp $	*/
2 
3 #include "config.h"
4 
5 #include "ntp.h"
6 #include "ntp_calendar.h"
7 #include "ntp_stdlib.h"
8 #include "rc_cmdlength.h"
9 
10 #include "unity.h"
11 
12 #include <string.h>
13 
14 #include "test-libntp.h"
15 
16 extern void test_EvaluateCommandLength(void);
test_EvaluateCommandLength(void)17 void test_EvaluateCommandLength(void)
18 {
19 	size_t length, commandLength;
20 	const char *command1 = "Random Command";
21 	const char *command2 = "Random Command\t\t\n\t";
22 	const char *command3 = "Random\nCommand\t\t\n\t";
23 	const char *command4 = "Random Command\t\t\n\t1 2 3";
24 
25 	length = strlen(command1);
26 	commandLength = remoteconfig_cmdlength(command1, command1+length);
27 	TEST_ASSERT_EQUAL(14, commandLength );
28 
29 	length = strlen(command2);
30 	commandLength = remoteconfig_cmdlength(command2, command2+length);
31 	TEST_ASSERT_EQUAL(14, commandLength );
32 
33 	length = strlen(command3);
34 	commandLength = remoteconfig_cmdlength(command3, command3+length);
35 	TEST_ASSERT_EQUAL(6, commandLength );
36 
37 	length = strlen(command4);
38 	commandLength = remoteconfig_cmdlength(command4, command4+length);
39 	TEST_ASSERT_EQUAL(16, commandLength );
40 }
41