aboutsummaryrefslogtreecommitdiff
path: root/src/regex/test_regex_iterate_api.c
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-09-07 16:38:49 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-09-07 16:38:49 +0000
commit88638fd30b3c7898e1209b8128adf42b1e4bd315 (patch)
tree47433205bf0092f5144e4c0b1b2ac3807654582e /src/regex/test_regex_iterate_api.c
parent9f81c1a85bb5485bdd2b4dd5a95fc02d2f6deeb4 (diff)
coverage
Diffstat (limited to 'src/regex/test_regex_iterate_api.c')
-rw-r--r--src/regex/test_regex_iterate_api.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/regex/test_regex_iterate_api.c b/src/regex/test_regex_iterate_api.c
index 96f1087e7c..afbb548c70 100644
--- a/src/regex/test_regex_iterate_api.c
+++ b/src/regex/test_regex_iterate_api.c
@@ -26,6 +26,9 @@
#include <time.h>
#include "platform.h"
#include "gnunet_regex_lib.h"
+#include "regex_internal.h"
+
+static unsigned int transition_counter;
void
key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
@@ -46,6 +49,7 @@ key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
for (i = 0; i < num_edges; i++)
{
+ transition_counter++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Edge %i: Label: %s Destination: %s\n",
i, edges[i].label, GNUNET_h2s (&edges[i].destination));
}
@@ -67,6 +71,7 @@ main (int argc, char *argv[])
int error;
int i;
struct GNUNET_REGEX_Automaton *dfa;
+ unsigned int num_transitions;
error = 0;
@@ -92,7 +97,23 @@ main (int argc, char *argv[])
for (i = 0; i < 17; i++)
{
+ transition_counter = 0;
+ dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
+ GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &error);
+ num_transitions = GNUNET_REGEX_get_transition_count (dfa);
+ if (transition_counter != num_transitions)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Automaton has %d transitions, iterated over %d transitions\n",
+ num_transitions, transition_counter);
+ }
+ GNUNET_REGEX_automaton_destroy (dfa);
+ }
+
+ for (i = 0; i < 17; i++)
+ {
dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
+ GNUNET_REGEX_add_multi_strides_to_dfa (NULL, dfa, 2);
GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &error);
GNUNET_REGEX_automaton_destroy (dfa);
}