diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-06-11 15:10:21 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-06-11 15:10:21 +0000 |
commit | 16cf819a0feb38c36b046c59febae5bc511a3d1b (patch) | |
tree | 5a2add323bee9c5646cd56a0e37eb6a29c5de034 /src/regex/test_regex_eval_api.c | |
parent | 300a9b12a902e6af2b763910fb372020a857ae7c (diff) | |
download | gnunet-16cf819a0feb38c36b046c59febae5bc511a3d1b.tar.gz gnunet-16cf819a0feb38c36b046c59febae5bc511a3d1b.zip |
simplified regex/proof generation
Diffstat (limited to 'src/regex/test_regex_eval_api.c')
-rw-r--r-- | src/regex/test_regex_eval_api.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c index 392fb3b36..89a757806 100644 --- a/src/regex/test_regex_eval_api.c +++ b/src/regex/test_regex_eval_api.c | |||
@@ -263,8 +263,9 @@ main (int argc, char *argv[]) | |||
263 | int check_nfa; | 263 | int check_nfa; |
264 | int check_dfa; | 264 | int check_dfa; |
265 | int check_rand; | 265 | int check_rand; |
266 | char *check_proof; | ||
266 | 267 | ||
267 | struct Regex_String_Pair rxstr[8] = { | 268 | struct Regex_String_Pair rxstr[12] = { |
268 | {"ab?(abcd)?", 5, | 269 | {"ab?(abcd)?", 5, |
269 | {"ababcd", "abab", "aabcd", "a", "abb"}, | 270 | {"ababcd", "abab", "aabcd", "a", "abb"}, |
270 | {match, nomatch, match, match, nomatch}}, | 271 | {match, nomatch, match, match, nomatch}}, |
@@ -288,6 +289,19 @@ main (int argc, char *argv[]) | |||
288 | {"V|M*o?x*p*d+h+b|E*m?h?Y*E*O?W*W*P+o?Z+H*M|I*q+C*a+5?5*9|b?z|G*y*k?R|p+u|8*h?B+l*H|e|L*O|1|F?v*0?5|C+", 1, | 289 | {"V|M*o?x*p*d+h+b|E*m?h?Y*E*O?W*W*P+o?Z+H*M|I*q+C*a+5?5*9|b?z|G*y*k?R|p+u|8*h?B+l*H|e|L*O|1|F?v*0?5|C+", 1, |
289 | {"VMoxpdhbEmhYEOWWPoZHMIqCa559bzGykRpu8hBlHeLO1Fv05C"}, | 290 | {"VMoxpdhbEmhYEOWWPoZHMIqCa559bzGykRpu8hBlHeLO1Fv05C"}, |
290 | {nomatch}}, | 291 | {nomatch}}, |
292 | {"(bla)*", 8, | ||
293 | {"", "bla", "blabla", "bl", "la", "b", "l", "a"}, | ||
294 | {match, match, match, nomatch, nomatch, nomatch, nomatch, nomatch}}, | ||
295 | {"ab(c|d)+c*(a(b|c)+d)+(bla)(bla)*", 8, | ||
296 | {"ab", "abcabdbla", "abdcccccccccccabcbccdblablabla", "bl", "la", "b", "l", | ||
297 | "a"}, | ||
298 | {nomatch, match, match, nomatch, nomatch, nomatch, nomatch, nomatch}}, | ||
299 | {"a|aa*a", 6, | ||
300 | {"", "a", "aa", "aaa", "aaaa", "aaaaa"}, | ||
301 | {nomatch, match, match, match, match, match}}, | ||
302 | {"ab(c|d)+c*(a(b|c)+d)+(bla)+", 1, | ||
303 | {"abcabdblaacdbla"}, | ||
304 | {nomatch}}, | ||
291 | {"ab(c|d)+c*(a(b|c)d)+", 1, | 305 | {"ab(c|d)+c*(a(b|c)d)+", 1, |
292 | {"abacd"}, | 306 | {"abacd"}, |
293 | {nomatch}} | 307 | {nomatch}} |
@@ -297,7 +311,7 @@ main (int argc, char *argv[]) | |||
297 | check_dfa = 0; | 311 | check_dfa = 0; |
298 | check_rand = 0; | 312 | check_rand = 0; |
299 | 313 | ||
300 | for (i = 0; i < 8; i++) | 314 | for (i = 0; i < 12; i++) |
301 | { | 315 | { |
302 | if (0 != regcomp (&rx, rxstr[i].regex, REG_EXTENDED)) | 316 | if (0 != regcomp (&rx, rxstr[i].regex, REG_EXTENDED)) |
303 | { | 317 | { |
@@ -314,7 +328,14 @@ main (int argc, char *argv[]) | |||
314 | // DFA test | 328 | // DFA test |
315 | a = GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex)); | 329 | a = GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex)); |
316 | check_dfa += test_automaton (a, &rx, &rxstr[i]); | 330 | check_dfa += test_automaton (a, &rx, &rxstr[i]); |
331 | check_proof = GNUNET_strdup (GNUNET_REGEX_get_computed_regex (a)); | ||
332 | GNUNET_REGEX_automaton_destroy (a); | ||
333 | a = GNUNET_REGEX_construct_dfa (check_proof, strlen (check_proof)); | ||
334 | check_dfa += test_automaton (a, &rx, &rxstr[i]); | ||
317 | GNUNET_REGEX_automaton_destroy (a); | 335 | GNUNET_REGEX_automaton_destroy (a); |
336 | if (0 != check_dfa) | ||
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "check_proof: %s\n", check_proof); | ||
338 | GNUNET_free_non_null (check_proof); | ||
318 | 339 | ||
319 | regfree (&rx); | 340 | regfree (&rx); |
320 | } | 341 | } |