aboutsummaryrefslogtreecommitdiff
path: root/src/regex/test_regex_eval_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-20 09:02:43 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-20 09:02:43 +0000
commit566b7539fcaf9c455da665cb641016d2cfbb1b47 (patch)
treeeb12baa08d99313d6da7eb8c1be17c5e447f1586 /src/regex/test_regex_eval_api.c
parentde9409f80dbfc5cc61a28316b271600e9da95cdc (diff)
downloadgnunet-566b7539fcaf9c455da665cb641016d2cfbb1b47.tar.gz
gnunet-566b7539fcaf9c455da665cb641016d2cfbb1b47.zip
renaming symbols from libgnunetregextest to have the prefix REGEX_TEST
Diffstat (limited to 'src/regex/test_regex_eval_api.c')
-rw-r--r--src/regex/test_regex_eval_api.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c
index 3ab914dc1..a3dffc022 100644
--- a/src/regex/test_regex_eval_api.c
+++ b/src/regex/test_regex_eval_api.c
@@ -67,7 +67,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
67 int eval_check; 67 int eval_check;
68 int eval_canonical; 68 int eval_canonical;
69 int eval_canonical_check; 69 int eval_canonical_check;
70 struct REGEX_ITERNAL_Automaton *dfa; 70 struct REGEX_INTERNAL_Automaton *dfa;
71 regex_t rx; 71 regex_t rx;
72 regmatch_t matchptr[1]; 72 regmatch_t matchptr[1];
73 char error[200]; 73 char error[200];
@@ -81,7 +81,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
81 81
82 /* Generate random regex and a string that matches the regex */ 82 /* Generate random regex and a string that matches the regex */
83 matching_str = GNUNET_malloc (rx_length + 1); 83 matching_str = GNUNET_malloc (rx_length + 1);
84 rand_rx = REGEX_ITERNAL_generate_random_regex (rx_length, matching_str); 84 rand_rx = REGEX_TEST_generate_random_regex (rx_length, matching_str);
85 85
86 /* Now match */ 86 /* Now match */
87 result = 0; 87 result = 0;
@@ -89,21 +89,21 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
89 { 89 {
90 if (0 < i) 90 if (0 < i)
91 { 91 {
92 matching_str = REGEX_ITERNAL_generate_random_string (max_str_len); 92 matching_str = REGEX_TEST_generate_random_string (max_str_len);
93 } 93 }
94 94
95 /* Match string using DFA */ 95 /* Match string using DFA */
96 dfa = REGEX_ITERNAL_construct_dfa (rand_rx, strlen (rand_rx), 0); 96 dfa = REGEX_INTERNAL_construct_dfa (rand_rx, strlen (rand_rx), 0);
97 if (NULL == dfa) 97 if (NULL == dfa)
98 { 98 {
99 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); 99 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n");
100 goto error; 100 goto error;
101 } 101 }
102 102
103 eval = REGEX_ITERNAL_eval (dfa, matching_str); 103 eval = REGEX_INTERNAL_eval (dfa, matching_str);
104 /* save the canonical regex for later comparison */ 104 /* save the canonical regex for later comparison */
105 canonical_regex = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (dfa)); 105 canonical_regex = GNUNET_strdup (REGEX_INTERNAL_get_canonical_regex (dfa));
106 REGEX_ITERNAL_automaton_destroy (dfa); 106 REGEX_INTERNAL_automaton_destroy (dfa);
107 107
108 /* Match string using glibc regex */ 108 /* Match string using glibc regex */
109 if (0 != regcomp (&rx, rand_rx, REG_EXTENDED)) 109 if (0 != regcomp (&rx, rand_rx, REG_EXTENDED))
@@ -124,7 +124,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
124 124
125 /* Match canonical regex */ 125 /* Match canonical regex */
126 dfa = 126 dfa =
127 REGEX_ITERNAL_construct_dfa (canonical_regex, strlen (canonical_regex), 127 REGEX_INTERNAL_construct_dfa (canonical_regex, strlen (canonical_regex),
128 0); 128 0);
129 if (NULL == dfa) 129 if (NULL == dfa)
130 { 130 {
@@ -132,8 +132,8 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
132 goto error; 132 goto error;
133 } 133 }
134 134
135 eval_canonical = REGEX_ITERNAL_eval (dfa, matching_str); 135 eval_canonical = REGEX_INTERNAL_eval (dfa, matching_str);
136 REGEX_ITERNAL_automaton_destroy (dfa); 136 REGEX_INTERNAL_automaton_destroy (dfa);
137 137
138 if (0 != regcomp (&rx, canonical_regex, REG_EXTENDED)) 138 if (0 != regcomp (&rx, canonical_regex, REG_EXTENDED))
139 { 139 {
@@ -193,7 +193,7 @@ error:
193 * @return 0 on successfull, non 0 otherwise 193 * @return 0 on successfull, non 0 otherwise
194 */ 194 */
195int 195int
196test_automaton (struct REGEX_ITERNAL_Automaton *a, regex_t * rx, 196test_automaton (struct REGEX_INTERNAL_Automaton *a, regex_t * rx,
197 struct Regex_String_Pair *rxstr) 197 struct Regex_String_Pair *rxstr)
198{ 198{
199 int result; 199 int result;
@@ -213,7 +213,7 @@ test_automaton (struct REGEX_ITERNAL_Automaton *a, regex_t * rx,
213 213
214 for (i = 0; i < rxstr->string_count; i++) 214 for (i = 0; i < rxstr->string_count; i++)
215 { 215 {
216 eval = REGEX_ITERNAL_eval (a, rxstr->strings[i]); 216 eval = REGEX_INTERNAL_eval (a, rxstr->strings[i]);
217 eval_check = regexec (rx, rxstr->strings[i], 1, matchptr, 0); 217 eval_check = regexec (rx, rxstr->strings[i], 1, matchptr, 0);
218 218
219 /* We only want to match the whole string, because that's what our DFA does, 219 /* We only want to match the whole string, because that's what our DFA does,
@@ -234,7 +234,7 @@ test_automaton (struct REGEX_ITERNAL_Automaton *a, regex_t * rx,
234 "string: %s\nexpected result: %i\n" 234 "string: %s\nexpected result: %i\n"
235 "gnunet regex: %i\nglibc regex: %i\nglibc error: %s\n" 235 "gnunet regex: %i\nglibc regex: %i\nglibc error: %s\n"
236 "rm_so: %i\nrm_eo: %i\n\n", rxstr->regex, 236 "rm_so: %i\nrm_eo: %i\n\n", rxstr->regex,
237 REGEX_ITERNAL_get_canonical_regex (a), rxstr->strings[i], 237 REGEX_INTERNAL_get_canonical_regex (a), rxstr->strings[i],
238 rxstr->expected_results[i], eval, eval_check, error, 238 rxstr->expected_results[i], eval, eval_check, error,
239 matchptr[0].rm_so, matchptr[0].rm_eo); 239 matchptr[0].rm_so, matchptr[0].rm_eo);
240 } 240 }
@@ -247,7 +247,7 @@ main (int argc, char *argv[])
247{ 247{
248 GNUNET_log_setup ("test-regex", "WARNING", NULL); 248 GNUNET_log_setup ("test-regex", "WARNING", NULL);
249 249
250 struct REGEX_ITERNAL_Automaton *a; 250 struct REGEX_INTERNAL_Automaton *a;
251 regex_t rx; 251 regex_t rx;
252 int i; 252 int i;
253 int check_nfa; 253 int check_nfa;
@@ -337,19 +337,19 @@ main (int argc, char *argv[])
337 } 337 }
338 338
339 /* NFA test */ 339 /* NFA test */
340 a = REGEX_ITERNAL_construct_nfa (rxstr[i].regex, strlen (rxstr[i].regex)); 340 a = REGEX_INTERNAL_construct_nfa (rxstr[i].regex, strlen (rxstr[i].regex));
341 check_nfa += test_automaton (a, &rx, &rxstr[i]); 341 check_nfa += test_automaton (a, &rx, &rxstr[i]);
342 REGEX_ITERNAL_automaton_destroy (a); 342 REGEX_INTERNAL_automaton_destroy (a);
343 343
344 /* DFA test */ 344 /* DFA test */
345 a = REGEX_ITERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0); 345 a = REGEX_INTERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
346 check_dfa += test_automaton (a, &rx, &rxstr[i]); 346 check_dfa += test_automaton (a, &rx, &rxstr[i]);
347 check_proof = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (a)); 347 check_proof = GNUNET_strdup (REGEX_INTERNAL_get_canonical_regex (a));
348 REGEX_ITERNAL_automaton_destroy (a); 348 REGEX_INTERNAL_automaton_destroy (a);
349 349
350 a = REGEX_ITERNAL_construct_dfa (check_proof, strlen (check_proof), 0); 350 a = REGEX_INTERNAL_construct_dfa (check_proof, strlen (check_proof), 0);
351 check_dfa += test_automaton (a, &rx, &rxstr[i]); 351 check_dfa += test_automaton (a, &rx, &rxstr[i]);
352 REGEX_ITERNAL_automaton_destroy (a); 352 REGEX_INTERNAL_automaton_destroy (a);
353 if (0 != check_dfa) 353 if (0 != check_dfa)
354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "check_proof: %s\n", check_proof); 354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "check_proof: %s\n", check_proof);
355 GNUNET_free_non_null (check_proof); 355 GNUNET_free_non_null (check_proof);