#include #include "chext.h" #include "test.h" BEGIN_TEST_CASE(test_find_last_pos) TEST( find_last_pos("", '.') == -1 ); TEST( find_last_pos(".", '.') == 0 ); TEST( find_last_pos("...", '.') == 2 ); TEST( find_last_pos("path_to/data_a", '.') == -1 ); TEST( find_last_pos("path_to/data.a", '.') == 12 ); TEST( find_last_pos("path.to/data_a", '.') == 4 ); TEST( find_last_pos("path.to/data.a", '.') == 12 ); END_TEST_CASE() TEST_CASE(test_find_last) { { const char* const str = ""; TEST( find_last(str, '.') == NULL ); } { const char* const str = "."; TEST( find_last(str, '.') == str ); } { const char* const str = "."; TEST( find_last(str, '.') == str ); } { const char* const str = "..."; TEST( find_last(str, '.') == str + 2 ); } { const char* const str = "path_to/data_a"; TEST( find_last(str, '.') == NULL ); } { const char* const str = "path_to/data.a"; TEST( find_last(str, '.') == str + 12 ); } { const char* const str = "path.to/data_a"; TEST( find_last(str, '.') == str + 4 ); } { const char* const str = "path.to/data.a"; TEST( find_last(str, '.') == str + 12 ); } } int main() { test_find_last_pos(); test_find_last(); return 0; }