diff options
| author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2026-04-06 12:31:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-06 12:31:05 -0400 |
| commit | d01b465eee667e8efa4aa7c3088dc7af18ea2ab2 (patch) | |
| tree | bf63c1378044c446f62dd20ce956a5a6d5e1973a /tests/test_strlist.c | |
| parent | 83831af6502e68fe6199c29614e2df68ffbca170 (diff) | |
| parent | dfe3420de345a7d4c6a529e1c240138ca9852c86 (diff) | |
| download | stasis-next.tar.gz | |
Manylinux
Diffstat (limited to 'tests/test_strlist.c')
| -rw-r--r-- | tests/test_strlist.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_strlist.c b/tests/test_strlist.c index 47722c0..38343f4 100644 --- a/tests/test_strlist.c +++ b/tests/test_strlist.c @@ -200,6 +200,20 @@ void test_strlist_append_tokenize() { guard_strlist_free(&list); } +void test_strlist_appendf() { + const char *fmt = "%c %s %d"; + struct StrList *list; + list = strlist_init(); + const int len = strlist_appendf(NULL, fmt, 'a', "abc", strlen(fmt)); + STASIS_ASSERT(strlist_appendf(&list, fmt, 'a', "abc", strlen(fmt)) == len, "length of formatted string should be 7"); + const char *item = strlist_item(list, 0); + STASIS_ASSERT(item != NULL, "valid pointer expected, item should not be NULL"); + STASIS_ASSERT(strncmp(item, "a", 1) == 0, "first character should be 'a'"); + STASIS_ASSERT(strncmp(item + 2, "abc", 3) == 0, "string should be 'abc'"); + STASIS_ASSERT(strncmp(item + 6, "8", 1) == 0, "length of the raw format should be 8"); + guard_strlist_free(&list); +} + void test_strlist_copy() { struct StrList *list = strlist_init(); struct StrList *list_copy; @@ -628,6 +642,7 @@ void test_strlist_item_as_long_double() { int main(int argc, char *argv[]) { STASIS_TEST_BEGIN_MAIN(); STASIS_TEST_FUNC *tests[] = { + test_strlist_appendf, test_strlist_init, test_strlist_free, test_strlist_append, |
