45 lines
844 B
C
45 lines
844 B
C
#include <criterion/criterion.h>
|
|
|
|
#include "utils.h"
|
|
|
|
/*
|
|
** TESTS: string/extract_file_ext.c
|
|
*/
|
|
|
|
Test(utils_string, extract_file_ext_valid)
|
|
{
|
|
const char *ext;
|
|
|
|
ext = extract_file_ext("file.c");
|
|
cr_assert_not_null(ext);
|
|
cr_assert_str_eq(ext, "c");
|
|
|
|
ext = extract_file_ext("test.md");
|
|
cr_assert_not_null(ext);
|
|
cr_assert_str_eq(ext, "md");
|
|
|
|
ext = extract_file_ext("path/to/file.txt");
|
|
cr_assert_not_null(ext);
|
|
cr_assert_str_eq(ext, "txt");
|
|
|
|
ext = extract_file_ext("file.c.md");
|
|
cr_assert_not_null(ext);
|
|
cr_assert_str_eq(ext, "md");
|
|
}
|
|
|
|
Test(utils_string, extract_file_ext_invalid)
|
|
{
|
|
const char *ext;
|
|
|
|
ext = extract_file_ext("noext");
|
|
cr_assert_null(ext);
|
|
|
|
ext = extract_file_ext(".hidden");
|
|
cr_assert_null(ext);
|
|
|
|
ext = extract_file_ext("");
|
|
cr_assert_null(ext);
|
|
|
|
ext = extract_file_ext("path/to/dir/");
|
|
cr_assert_null(ext);
|
|
}
|