aboutsummaryrefslogtreecommitdiff
path: root/src/regex/test_regex_iterate_api.c
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-07-04 15:46:47 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-07-04 15:46:47 +0000
commitc6c6d70ac090acbc8b9c75f19af249030e2a751b (patch)
tree960400a3d5fd9d11ee320111caddba8a0a192d5a /src/regex/test_regex_iterate_api.c
parent9534e25a16b3f9d2574ffb969ff295f77f74c351 (diff)
downloadgnunet-c6c6d70ac090acbc8b9c75f19af249030e2a751b.tar.gz
gnunet-c6c6d70ac090acbc8b9c75f19af249030e2a751b.zip
regex: actually checking the proof, fixes
Diffstat (limited to 'src/regex/test_regex_iterate_api.c')
-rw-r--r--src/regex/test_regex_iterate_api.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/src/regex/test_regex_iterate_api.c b/src/regex/test_regex_iterate_api.c
index 9f4f2280e..246ae7767 100644
--- a/src/regex/test_regex_iterate_api.c
+++ b/src/regex/test_regex_iterate_api.c
@@ -33,6 +33,7 @@ key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
33 const struct GNUNET_REGEX_Edge *edges) 33 const struct GNUNET_REGEX_Edge *edges)
34{ 34{
35 unsigned int i; 35 unsigned int i;
36 int *error = cls;
36 37
37 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iterating... (accepting: %i)\n", 38 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iterating... (accepting: %i)\n",
38 accepting); 39 accepting);
@@ -41,6 +42,8 @@ key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
41 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Edge %i: %s\n", i, edges[i].label); 42 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Edge %i: %s\n", i, edges[i].label);
42 } 43 }
43 44
45 *error += (GNUNET_OK == GNUNET_REGEX_check_proof (proof, key)) ? 0 : 1;
46
44 if (NULL != proof) 47 if (NULL != proof)
45 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof: %s\n", proof); 48 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof: %s\n", proof);
46} 49}
@@ -57,44 +60,37 @@ main (int argc, char *argv[])
57 NULL); 60 NULL);
58 61
59 int error; 62 int error;
60 const char *regex; 63 int i;
61 struct GNUNET_REGEX_Automaton *dfa; 64 struct GNUNET_REGEX_Automaton *dfa;
62 65
63 error = 0; 66 error = 0;
64 /* regex = "ab(c|d)+c*(a(b|c)+d)+(bla)+"; */
65 /* regex = "(bla)*"; */
66 /*regex = "b(lab)*la"; */
67 /* regex = "(ab)*"; */
68 regex = "ab(c|d)+c*(a(b|c)+d)+(bla)(bla)*";
69 /*regex = "z(abc|def)?xyz"; */
70 /* regex = "1*0(0|1)*"; */
71 /* regex = "a*b*"; */
72 /* regex = "a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*"; */
73 /* regex = "abcd:(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1):(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)"; */
74 /* regex = "abc(1|0)*def"; */
75 /* regex = "ab|ac"; */
76 /* regex = "(ab)(ab)*"; */
77 /* regex = "ab|cd|ef|gh"; */
78 /* regex = "a|b|c|d|e|f|g"; */
79 /* regex = "(ab)|(ac)"; */
80 /* regex = "a(b|c)"; */
81 /* regex = "a*a"; */
82 /* regex = "ab?(abcd)?"; */
83 /* regex = "(ab)+"; */
84 /* regex = "(ab|cs|df|sdf)*"; */
85 /* regex = "(ab|cd)*"; */
86 /* regex = "(cd|ab)*"; */
87 /* regex = "(ab|c)+"; */
88 /* regex = "(a|bc)+"; */
89 /* regex = "(ab|c)(ab|c)*"; */
90 /* regex = "(a|bc)(a|bc)*"; */
91 /* regex = "(ac|b)*"; */
92 /* regex = "a|aa*a"; */
93 67
94 dfa = GNUNET_REGEX_construct_dfa (regex, strlen (regex)); 68 const char *regex[17] = {
95 GNUNET_REGEX_automaton_save_graph (dfa, "dfa.dot"); 69 "ab(c|d)+c*(a(b|c)+d)+(bla)+",
96 GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, NULL); 70 "(bla)*",
97 GNUNET_REGEX_automaton_destroy (dfa); 71 "b(lab)*la",
72 "(ab)*",
73 "ab(c|d)+c*(a(b|c)+d)+(bla)(bla)*",
74 "z(abc|def)?xyz",
75 "1*0(0|1)*",
76 "a*b*",
77 "a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*",
78 "abcd:(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1):(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)",
79 "abc(1|0)*def",
80 "ab|ac",
81 "(ab)(ab)*",
82 "ab|cd|ef|gh",
83 "a|b|c|d|e|f|g",
84 "(ab)|(ac)",
85 "a(b|c)"
86 };
98 87
88 for (i = 0; i < 17; i++)
89 {
90 dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
91 GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &error);
92 GNUNET_REGEX_automaton_destroy (dfa);
93 }
94
99 return error; 95 return error;
100} 96}