MCPcopy Create free account
hub / github.com/coreboot/coreboot / test_strsep

Function test_strsep

payloads/libpayload/tests/libc/string-test.c:6–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <tests/test.h>
5
6static void test_strsep(void **state)
7{
8 /* Use `char x[] = ` instead of `char *x = ` to avoid writing to .rodata. */
9 char test1[] = "abc,def|ghi jklm,\no";
10 const char *delim = ", \n";
11
12 char *stringp = test1;
13 assert_string_equal(strsep(&stringp, delim), "abc");
14 assert_ptr_equal(stringp, test1 + 4);
15 assert_string_equal(strsep(&stringp, delim), "def|ghi");
16 assert_ptr_equal(stringp, test1 + 12);
17 assert_string_equal(strsep(&stringp, delim), "jklm");
18 assert_ptr_equal(stringp, test1 + 17);
19 assert_string_equal(strsep(&stringp, delim), "");
20 assert_ptr_equal(stringp, test1 + 18);
21 assert_string_equal(strsep(&stringp, delim), "o");
22 assert_null(stringp);
23 assert_null(strsep(&stringp, delim));
24 assert_null(stringp);
25
26 char test2[] = "";
27 stringp = test2;
28 assert_string_equal(strsep(&stringp, delim), "");
29 assert_null(strsep(&stringp, delim));
30}
31
32int main(void)
33{

Callers

nothing calls this directly

Calls 1

strsepFunction · 0.85

Tested by

no test coverage detected