aboutsummaryrefslogtreecommitdiff
path: root/src/regex/test_regex_proofs.c
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-07-02 12:22:37 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-07-02 12:22:37 +0000
commita4b40b20949b4ea21d98bed902906cdf56d41326 (patch)
treec21f239124ccc818ca52832b736b18ae3522230a /src/regex/test_regex_proofs.c
parentce4b5c1fa37a9b26df4345d30b6ba2c839ce23d5 (diff)
regex bugfixes
Diffstat (limited to 'src/regex/test_regex_proofs.c')
-rw-r--r--src/regex/test_regex_proofs.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/regex/test_regex_proofs.c b/src/regex/test_regex_proofs.c
index 85fc3079df..831f4dc48e 100644
--- a/src/regex/test_regex_proofs.c
+++ b/src/regex/test_regex_proofs.c
@@ -106,39 +106,48 @@ test_proofs_static (void)
unsigned int i;
unsigned int error;
- const char *regex[4] = {
+ const char *regex[6] = {
"a|aa*a",
"a+",
"a*",
- "a*a*"
+ "a*a*",
+ "(F*C|WfPf|y+F*C)",
+ "y*F*C|WfPf",
+ /* "2?jA?e?D*K", */
+ /* "((j|2j)K|(j|2j)AK|(j|2j)(D|e|(j|2j)A(D|e))D*K)", */
+ /* "((j|2j)K|(j|2j)(D|e|((j|2j)j|(j|2j)2j)A(D|e))D*K|(j|2j)AK)", */
};
- char *canonical_regex;
- struct GNUNET_REGEX_Automaton *dfa;
+ const char *canon_rx1;
+ const char *canon_rx2;
+ struct GNUNET_REGEX_Automaton *dfa1;
+ struct GNUNET_REGEX_Automaton *dfa2;
error = 0;
- for (i = 0; i < 4; i += 2)
+ for (i = 0; i < 6; i += 2)
{
- dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
- canonical_regex = GNUNET_strdup (GNUNET_REGEX_get_canonical_regex (dfa));
- GNUNET_REGEX_automaton_destroy (dfa);
+ dfa1 = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
+ dfa2 = GNUNET_REGEX_construct_dfa (regex[i + 1], strlen (regex[i + 1]));
+
+ canon_rx1 = GNUNET_REGEX_get_canonical_regex (dfa1);
+ canon_rx2 = GNUNET_REGEX_get_canonical_regex (dfa2);
- dfa = GNUNET_REGEX_construct_dfa (regex[i + 1], strlen (regex[i + 1]));
- error +=
- (0 ==
- strcmp (canonical_regex,
- GNUNET_REGEX_get_canonical_regex (dfa))) ? 0 : 1;
+ error += (0 == strcmp (canon_rx1, canon_rx2)) ? 0 : 1;
if (error > 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Comparing canonical regex of %s with %s failed.\n", regex[i],
- regex[i + 1]);
+ "Comparing canonical regex failed:\nrx1: %s\ncrx1: %s\nrx2: %s\ncrx2: %s\n",
+ regex[i], canon_rx1, regex[i + 1], canon_rx2);
+
+ /* Save the graphs of the two conflicting DFAs */
+ /* GNUNET_REGEX_automaton_save_graph (dfa1, "proofs_fail_dfa1.dot"); */
+ /* GNUNET_REGEX_automaton_save_graph (dfa2, "proofs_fail_dfa2.dot"); */
}
- GNUNET_free (canonical_regex);
- GNUNET_REGEX_automaton_destroy (dfa);
+ GNUNET_REGEX_automaton_destroy (dfa1);
+ GNUNET_REGEX_automaton_destroy (dfa2);
}
return error;
@@ -161,7 +170,7 @@ main (int argc, char *argv[])
error = 0;
error += test_proofs_static ();
-// error += test_proofs_random (100, 10);
+ /* error += test_proofs_random (10000, 10); */
return error;
}