From 5ce988c8de8c80037fb55cbadcb960accdd0af30 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Sat, 10 Jul 2021 16:06:19 -0400 Subject: [PATCH] input: add line_limit test --- test/input.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/input.c b/test/input.c index a0af325..61649ee 100644 --- a/test/input.c +++ b/test/input.c @@ -21,6 +21,27 @@ TEST one_pass(void) { PASS(); } +TEST line_limit(void) { + struct libscomm_input in; + struct libscomm_line l; + char s[LIBSCOMM_MAXBUF + 1]; + char *p = s; + int i; + + for (i = 0; i < LIBSCOMM_MAXBUF - 1; i++) { + s[i] = (i + 1) % 64 ? 'a' : '\t'; + } + s[LIBSCOMM_MAXBUF - 1] = '\n'; + s[LIBSCOMM_MAXBUF] = 0; + + if (GREATEST_IS_VERBOSE()) + fprintf(stderr, "%s", s); + + libscomm_reset(&in); + ASSERT_EQ(libscomm_read(&in, &p, &l), LIBSCOMM_COMPLETE); + PASS(); +} + TEST single_arg_too_large(void) { struct libscomm_input in; struct libscomm_line l; @@ -72,6 +93,7 @@ GREATEST_MAIN_DEFS(); int main(int argc, char *argv[]) { GREATEST_MAIN_BEGIN(); RUN_TEST(one_pass); + RUN_TEST(line_limit); RUN_TEST(single_arg_too_large); RUN_TEST(arg_limit); GREATEST_MAIN_END();