aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorEsteban Manchado Velázquez <emanchado@demiurgo.org>2012-02-20 13:24:22 +0100
committerNick Mathewson <nickm@torproject.org>2012-03-08 21:16:45 -0500
commitc0974018793f6260b16e473de64cb5717f9764d0 (patch)
tree7a1c6805a871294393113751c6728eca1cd30093 /src/test
parent1f6e3ec5006076d5ee7254489795bebbf8dab36a (diff)
downloadtor-c0974018793f6260b16e473de64cb5717f9764d0.tar.gz
tor-c0974018793f6260b16e473de64cb5717f9764d0.zip
Add tests for string_is_C_identifier
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_util.c30
1 files changed, 30 insertions, 0 deletions
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
@@ -1633,6 +1633,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)
{
#define LOREMIPSUM \
@@ -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),