input: add two_in_one

This commit is contained in:
Peter McGoron 2021-07-10 16:16:57 -04:00
parent 7e8cb24a90
commit 03c7601f22
1 changed files with 26 additions and 0 deletions

View File

@ -101,6 +101,31 @@ TEST too_many_arg(void) {
PASS();
}
TEST two_in_one(void) {
struct libscomm_input in;
struct libscomm_line l;
char s[] = "Arg 1\tArg 2\tArg 3\nArg 4\tArg 5\tArg 6\tArg 7\n";
char *p = s;
libscomm_reset(&in);
ASSERT_EQ(libscomm_read(&in, &p, &l), LIBSCOMM_COMPLETE);
ASSERT_EQ(l.name, 0);
ASSERT_EQ(l.len, 3);
ASSERT_STR_EQ(l.buf[0], "Arg 1");
ASSERT_STR_EQ(l.buf[1], "Arg 2");
ASSERT_STR_EQ(l.buf[2], "Arg 3");
ASSERT_EQ(libscomm_read(&in, &p, &l), LIBSCOMM_COMPLETE);
ASSERT_EQ(l.name, 0);
ASSERT_EQ(l.len, 4);
ASSERT_STR_EQ(l.buf[0], "Arg 4");
ASSERT_STR_EQ(l.buf[1], "Arg 5");
ASSERT_STR_EQ(l.buf[2], "Arg 6");
ASSERT_STR_EQ(l.buf[3], "Arg 7");
PASS();
}
GREATEST_MAIN_DEFS();
int main(int argc, char *argv[]) {
@ -111,6 +136,7 @@ int main(int argc, char *argv[]) {
RUN_TEST(single_arg_too_large);
RUN_TEST(arg_limit);
RUN_TEST(too_many_arg);
RUN_TEST(two_in_one);
GREATEST_MAIN_END();
}