[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add tests for string_is_C_identifier



commit c0974018793f6260b16e473de64cb5717f9764d0
Author: Esteban Manchado Velázquez <emanchado@xxxxxxxxxxxx>
Date:   Mon Feb 20 13:24:22 2012 +0100

    Add tests for string_is_C_identifier
---
 src/test/test_util.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/test/test_util.c b/src/test/test_util.c
index 4fb565d..cc97484 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),



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits