diff options
author | Sumit Bose <sbose@redhat.com> | 2015-06-16 16:58:23 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-06-19 18:48:13 +0200 |
commit | a99845006f96f9d1e7af871ec67c71cee8408a62 (patch) | |
tree | 25a873d57d0f695652263dfc05de141859ff5a69 /src/tests/cmocka/test_string_utils.c | |
parent | 8d4dedea12e2b71f83a1b0e5f0fc5cdb706dcf98 (diff) | |
download | sssd-a99845006f96f9d1e7af871ec67c71cee8408a62.tar.gz sssd-a99845006f96f9d1e7af871ec67c71cee8408a62.tar.xz sssd-a99845006f96f9d1e7af871ec67c71cee8408a62.zip |
utils: add get_last_x_chars()
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/tests/cmocka/test_string_utils.c')
-rw-r--r-- | src/tests/cmocka/test_string_utils.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tests/cmocka/test_string_utils.c b/src/tests/cmocka/test_string_utils.c index 5d3fcf4fe..4832015a5 100644 --- a/src/tests/cmocka/test_string_utils.c +++ b/src/tests/cmocka/test_string_utils.c @@ -192,3 +192,31 @@ void test_guid_blob_to_string_buf(void **state) assert_string_equal(test_data[c].guid_str, str_buf); } } + +void test_get_last_x_chars(void **state) +{ + const char *s; + + s = get_last_x_chars(NULL, 0); + assert_null(s); + + s = get_last_x_chars("abc", 0); + assert_non_null(s); + assert_string_equal(s, ""); + + s = get_last_x_chars("abc", 1); + assert_non_null(s); + assert_string_equal(s, "c"); + + s = get_last_x_chars("abc", 2); + assert_non_null(s); + assert_string_equal(s, "bc"); + + s = get_last_x_chars("abc", 3); + assert_non_null(s); + assert_string_equal(s, "abc"); + + s = get_last_x_chars("abc", 4); + assert_non_null(s); + assert_string_equal(s, "abc"); +} |