input: add arg_limit

This commit is contained in:
Peter McGoron 2021-07-10 15:43:39 -04:00
parent 6454c63441
commit bbb7bb181a
2 changed files with 23 additions and 1 deletions

View File

@ -1,7 +1,7 @@
TESTS=test/input
tests: $(TESTS)
for i in $(TESTS); do ./$$i; done
for i in $(TESTS); do ./$$i -v; done
TEST_INPUT=test/input.o input.o
test/input: $(TEST_INPUT)

View File

@ -46,11 +46,33 @@ TEST single_arg_too_large(void) {
PASS();
}
TEST arg_limit(void) {
struct libscomm_input in;
struct libscomm_line l;
char s[] = " 1\t 2\t 3\t 4\t 5\t 6\t 7\t 8\t 9\t 10\t 11\t 12\t 13\t 14\t 15\t 16\t 17\t 18\t 19\t 20\t 21\t 22\t 23\t 24\t 25\t 26\t 27\t 28\t 29\t 30\t 31\t 32\n";
char *p = s;
char tbuf[10];
int i;
libscomm_reset(&in);
ASSERT_EQ(libscomm_read(&in, &p, &l), LIBSCOMM_COMPLETE);
ASSERT_EQ(l.name, 0);
ASSERT_EQ(l.len, LIBSCOMM_MAXARG);
for (i = 1; i <= l.len; i++) {
sprintf(tbuf, " %d", i);
ASSERT_STR_EQ(l.buf[i-1], tbuf);
}
PASS();
}
GREATEST_MAIN_DEFS();
int main(int argc, char *argv[]) {
GREATEST_MAIN_BEGIN();
RUN_TEST(one_pass);
RUN_TEST(single_arg_too_large);
RUN_TEST(arg_limit);
GREATEST_MAIN_END();
}