From c0974018793f6260b16e473de64cb5717f9764d0 Mon Sep 17 00:00:00 2001 From: Esteban Manchado Velázquez Date: Mon, 20 Feb 2012 13:24:22 +0100 Subject: Add tests for string_is_C_identifier --- src/test/test_util.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/test/test_util.c') diff --git a/src/test/test_util.c b/src/test/test_util.c index 4fb565d6ec..cc974842f1 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -1632,6 +1632,35 @@ test_util_find_str_at_start_of_line(void *ptr) ; } +static void +test_util_string_is_C_identifier(void *ptr) +{ + (void)ptr; + + test_eq(1, string_is_C_identifier("string_is_C_identifier")); + test_eq(1, string_is_C_identifier("_string_is_C_identifier")); + test_eq(1, string_is_C_identifier("_")); + test_eq(1, string_is_C_identifier("i")); + test_eq(1, string_is_C_identifier("_____")); + test_eq(1, string_is_C_identifier("__00__")); + test_eq(1, string_is_C_identifier("__init__")); + test_eq(1, string_is_C_identifier("_0")); + test_eq(1, string_is_C_identifier("_0string_is_C_identifier")); + test_eq(1, string_is_C_identifier("_0")); + + test_eq(0, string_is_C_identifier("0_string_is_C_identifier")); + test_eq(0, string_is_C_identifier("0")); + test_eq(0, string_is_C_identifier("")); + test_eq(0, string_is_C_identifier(";")); + test_eq(0, string_is_C_identifier("i;")); + test_eq(0, string_is_C_identifier("_;")); + test_eq(0, string_is_C_identifier("í")); + test_eq(0, string_is_C_identifier("ñ")); + + done: + ; +} + static void test_util_asprintf(void *ptr) { @@ -2679,6 +2708,7 @@ struct testcase_t util_tests[] = { UTIL_LEGACY(strtok), UTIL_LEGACY(di_ops), UTIL_TEST(find_str_at_start_of_line, 0), + UTIL_TEST(string_is_C_identifier, 0), UTIL_TEST(asprintf, 0), UTIL_TEST(listdir, 0), UTIL_TEST(parent_dir, 0), -- cgit v1.2.3-54-g00ecf