aboutsummaryrefslogtreecommitdiff
path: root/src/regex/test_regex_eval_api.c
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-06-25 08:33:13 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-06-25 08:33:13 +0000
commit6803579aeefc80a95cd2047901fc691fd03401a1 (patch)
tree8efdd648eeeae8bc76bd8f4a0bd0c62755a0260f /src/regex/test_regex_eval_api.c
parentfebbf34313acf57b3a1c336fe0eb2fed80d7a1e0 (diff)
downloadgnunet-6803579aeefc80a95cd2047901fc691fd03401a1.tar.gz
gnunet-6803579aeefc80a95cd2047901fc691fd03401a1.zip
regex simplification wip
Diffstat (limited to 'src/regex/test_regex_eval_api.c')
-rw-r--r--src/regex/test_regex_eval_api.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c
index b875f4088..7d68f84f4 100644
--- a/src/regex/test_regex_eval_api.c
+++ b/src/regex/test_regex_eval_api.c
@@ -44,6 +44,17 @@ struct Regex_String_Pair
44static const char allowed_literals[] = 44static const char allowed_literals[] =
45 "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; 45 "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz";
46 46
47/**
48 * Random regex test. Generate a random regex as well as 'str_count' strings to
49 * match it against. Will match using GNUNET_REGEX implementation and compare
50 * the result to glibc regex result. 'rx_length' has to be smaller then 'max_str_len'.
51 *
52 * @param rx_length length of the regular expression.
53 * @param max_str_len maximum length of the random strings.
54 * @param str_count number of generated random strings.
55 *
56 * @return 0 on success, non 0 otherwise.
57 */
47int 58int
48test_random (unsigned int rx_length, unsigned int max_str_len, 59test_random (unsigned int rx_length, unsigned int max_str_len,
49 unsigned int str_count) 60 unsigned int str_count)
@@ -199,6 +210,17 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
199 return result; 210 return result;
200} 211}
201 212
213/**
214 * Automaton test that compares the result of matching regular expression 'rx'
215 * with the strings and expected results in 'rxstr' with the result of matching
216 * the same strings with glibc regex.
217 *
218 * @param a automaton.
219 * @param rx compiled glibc regex.
220 * @param rxstr regular expression and strings with expected results to match against.
221 *
222 * @return 0 on successfull, non 0 otherwise
223 */
202int 224int
203test_automaton (struct GNUNET_REGEX_Automaton *a, regex_t * rx, 225test_automaton (struct GNUNET_REGEX_Automaton *a, regex_t * rx,
204 struct Regex_String_Pair *rxstr) 226 struct Regex_String_Pair *rxstr)
@@ -347,8 +369,8 @@ main (int argc, char *argv[])
347 } 369 }
348 370
349 srand (time (NULL)); 371 srand (time (NULL));
350 for (i = 0; i < 50; i++) 372 /* for (i = 0; i < 50; i++) */
351 check_rand += test_random (100, 120, 20); 373 /* check_rand += test_random (100, 120, 20); */
352 374
353 return check_nfa + check_dfa + check_rand; 375 return check_nfa + check_dfa + check_rand;
354} 376}