input: add split test

This commit is contained in:
Peter McGoron 2021-07-10 16:33:27 -04:00
parent ee5d0c1a67
commit 498c935304
1 changed files with 34 additions and 0 deletions

View File

@ -149,6 +149,39 @@ TEST label(void) {
PASS();
}
TEST split(void) {
struct libscomm_input in;
struct libscomm_line l;
char s1[] = ":123456\tArg 1\tArg 2\tAr";
char s2[] = "g 3\tArg 4\tArg 5\tArg 6";
char s3[] = "\n";
char *p = s1;
libscomm_reset(&in);
ASSERT_EQ(libscomm_read(&in, &p, &l), LIBSCOMM_MORE);
ASSERT_EQ(p, &s1[sizeof s1 - 1]);
p = s2;
ASSERT_EQ(libscomm_read(&in, &p, &l), LIBSCOMM_MORE);
ASSERT_EQ(p, &s2[sizeof s2 - 1]);
p = s3;
ASSERT_EQ(libscomm_read(&in, &p, &l), LIBSCOMM_COMPLETE);
ASSERT_EQ(p, &s3[sizeof s3 - 1]);
ASSERT_EQ(l.name, 1);
ASSERT_EQ(l.len, 7);
ASSERT_STR_EQ(l.buf[0], ":123456");
ASSERT_STR_EQ(l.buf[1], "Arg 1");
ASSERT_STR_EQ(l.buf[2], "Arg 2");
ASSERT_STR_EQ(l.buf[3], "Arg 3");
ASSERT_STR_EQ(l.buf[4], "Arg 4");
ASSERT_STR_EQ(l.buf[5], "Arg 5");
ASSERT_STR_EQ(l.buf[6], "Arg 6");
PASS();
}
GREATEST_MAIN_DEFS();
int main(int argc, char *argv[]) {
@ -161,6 +194,7 @@ int main(int argc, char *argv[]) {
RUN_TEST(too_many_arg);
RUN_TEST(two_in_one);
RUN_TEST(label);
RUN_TEST(split);
GREATEST_MAIN_END();
}