diff options
author | Johnny Richard <johnny@johnnyrichard.com> | 2022-04-18 00:59:18 +0200 |
---|---|---|
committer | Johnny Richard <johnny@johnnyrichard.com> | 2022-04-18 00:59:18 +0200 |
commit | d3bdadd76b59770c9402db1f2475cf760f8f682b (patch) | |
tree | 5318ef2324ed55a9d359e62d32a55396ca6560ca /test/string_view_test.c | |
parent | 7d5b3c1e9ae35cc2f33c05c1f24f8c9a262eb618 (diff) |
string_view: Implement string_view_to_cstr
Diffstat (limited to 'test/string_view_test.c')
-rw-r--r-- | test/string_view_test.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/string_view_test.c b/test/string_view_test.c index a050239..7b2400c 100644 --- a/test/string_view_test.c +++ b/test/string_view_test.c @@ -49,6 +49,22 @@ test_from_cstr(const MunitParameter params[], } static MunitResult +test_to_cstr(const MunitParameter params[], + void *user_data_or_fixture) +{ + char *cstr = "hello world"; + + string_view_t sv = string_view_new(cstr, 5); + + char actual[sv.size + 1]; + string_view_to_cstr(&sv, actual); + + assert_string_equal(actual, "hello"); + + return MUNIT_OK; +} + +static MunitResult test_eq(const MunitParameter params[], void *user_data_or_fixture) { @@ -101,6 +117,7 @@ test_chop_by_delim_when_has_no_delim(const MunitParameter params[], static MunitTest tests[] = { { "/test_create_new", test_create_new, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, { "/test_from_cstr", test_from_cstr, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, + { "/test_to_cstr", test_to_cstr, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, { "/test_eq", test_eq, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, { "/test_chop_by_delim_when_has_delim", test_chop_by_delim_when_has_delim, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, { "/test_chop_by_delim_when_has_no_delim", test_chop_by_delim_when_has_no_delim, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, |