diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-09-07 16:38:49 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-09-07 16:38:49 +0000 |
commit | 88638fd30b3c7898e1209b8128adf42b1e4bd315 (patch) | |
tree | 47433205bf0092f5144e4c0b1b2ac3807654582e /src/regex/test_regex_iterate_api.c | |
parent | 9f81c1a85bb5485bdd2b4dd5a95fc02d2f6deeb4 (diff) | |
download | gnunet-88638fd30b3c7898e1209b8128adf42b1e4bd315.tar.gz gnunet-88638fd30b3c7898e1209b8128adf42b1e4bd315.zip |
coverage
Diffstat (limited to 'src/regex/test_regex_iterate_api.c')
-rw-r--r-- | src/regex/test_regex_iterate_api.c | 21 |
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 96f1087e7..afbb548c7 100644 --- a/src/regex/test_regex_iterate_api.c +++ b/src/regex/test_regex_iterate_api.c | |||
@@ -26,6 +26,9 @@ | |||
26 | #include <time.h> | 26 | #include <time.h> |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_regex_lib.h" | 28 | #include "gnunet_regex_lib.h" |
29 | #include "regex_internal.h" | ||
30 | |||
31 | static unsigned int transition_counter; | ||
29 | 32 | ||
30 | void | 33 | void |
31 | key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, | 34 | 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, | |||
46 | 49 | ||
47 | for (i = 0; i < num_edges; i++) | 50 | for (i = 0; i < num_edges; i++) |
48 | { | 51 | { |
52 | transition_counter++; | ||
49 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Edge %i: Label: %s Destination: %s\n", | 53 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Edge %i: Label: %s Destination: %s\n", |
50 | i, edges[i].label, GNUNET_h2s (&edges[i].destination)); | 54 | i, edges[i].label, GNUNET_h2s (&edges[i].destination)); |
51 | } | 55 | } |
@@ -67,6 +71,7 @@ main (int argc, char *argv[]) | |||
67 | int error; | 71 | int error; |
68 | int i; | 72 | int i; |
69 | struct GNUNET_REGEX_Automaton *dfa; | 73 | struct GNUNET_REGEX_Automaton *dfa; |
74 | unsigned int num_transitions; | ||
70 | 75 | ||
71 | error = 0; | 76 | error = 0; |
72 | 77 | ||
@@ -92,7 +97,23 @@ main (int argc, char *argv[]) | |||
92 | 97 | ||
93 | for (i = 0; i < 17; i++) | 98 | for (i = 0; i < 17; i++) |
94 | { | 99 | { |
100 | transition_counter = 0; | ||
101 | dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i])); | ||
102 | GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &error); | ||
103 | num_transitions = GNUNET_REGEX_get_transition_count (dfa); | ||
104 | if (transition_counter != num_transitions) | ||
105 | { | ||
106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
107 | "Automaton has %d transitions, iterated over %d transitions\n", | ||
108 | num_transitions, transition_counter); | ||
109 | } | ||
110 | GNUNET_REGEX_automaton_destroy (dfa); | ||
111 | } | ||
112 | |||
113 | for (i = 0; i < 17; i++) | ||
114 | { | ||
95 | dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i])); | 115 | dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i])); |
116 | GNUNET_REGEX_add_multi_strides_to_dfa (NULL, dfa, 2); | ||
96 | GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &error); | 117 | GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &error); |
97 | GNUNET_REGEX_automaton_destroy (dfa); | 118 | GNUNET_REGEX_automaton_destroy (dfa); |
98 | } | 119 | } |