diff --git a/Makefile b/Makefile index e9161f3..cc76595 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/test/input.c b/test/input.c index 7437962..a0af325 100644 --- a/test/input.c +++ b/test/input.c @@ -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(); }