diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/regex/test_regex_proofs.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/regex/test_regex_proofs.c')
-rw-r--r-- | src/regex/test_regex_proofs.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/src/regex/test_regex_proofs.c b/src/regex/test_regex_proofs.c index 4f49ef656..3649ac8aa 100644 --- a/src/regex/test_regex_proofs.c +++ b/src/regex/test_regex_proofs.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file regex/test_regex_proofs.c | 21 | * @file regex/test_regex_proofs.c |
22 | * @brief test for regex.c | 22 | * @brief test for regex.c |
@@ -40,32 +40,32 @@ | |||
40 | * @return 0 on success, 1 on failure | 40 | * @return 0 on success, 1 on failure |
41 | */ | 41 | */ |
42 | static unsigned int | 42 | static unsigned int |
43 | test_proof (const char *regex) | 43 | test_proof(const char *regex) |
44 | { | 44 | { |
45 | unsigned int error; | 45 | unsigned int error; |
46 | struct REGEX_INTERNAL_Automaton *dfa; | 46 | struct REGEX_INTERNAL_Automaton *dfa; |
47 | char *c_rx1; | 47 | char *c_rx1; |
48 | const char *c_rx2; | 48 | const char *c_rx2; |
49 | 49 | ||
50 | dfa = REGEX_INTERNAL_construct_dfa (regex, strlen (regex), 1); | 50 | dfa = REGEX_INTERNAL_construct_dfa(regex, strlen(regex), 1); |
51 | GNUNET_assert (NULL != dfa); | 51 | GNUNET_assert(NULL != dfa); |
52 | c_rx1 = GNUNET_strdup (REGEX_INTERNAL_get_canonical_regex (dfa)); | 52 | c_rx1 = GNUNET_strdup(REGEX_INTERNAL_get_canonical_regex(dfa)); |
53 | REGEX_INTERNAL_automaton_destroy (dfa); | 53 | REGEX_INTERNAL_automaton_destroy(dfa); |
54 | dfa = REGEX_INTERNAL_construct_dfa (c_rx1, strlen (c_rx1), 1); | 54 | dfa = REGEX_INTERNAL_construct_dfa(c_rx1, strlen(c_rx1), 1); |
55 | GNUNET_assert (NULL != dfa); | 55 | GNUNET_assert(NULL != dfa); |
56 | c_rx2 = REGEX_INTERNAL_get_canonical_regex (dfa); | 56 | c_rx2 = REGEX_INTERNAL_get_canonical_regex(dfa); |
57 | 57 | ||
58 | error = (0 == strcmp (c_rx1, c_rx2)) ? 0 : 1; | 58 | error = (0 == strcmp(c_rx1, c_rx2)) ? 0 : 1; |
59 | 59 | ||
60 | if (error > 0) | 60 | if (error > 0) |
61 | { | 61 | { |
62 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 62 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
63 | "Comparing canonical regex of\n%s\nfailed:\n%s\nvs.\n%s\n", | 63 | "Comparing canonical regex of\n%s\nfailed:\n%s\nvs.\n%s\n", |
64 | regex, c_rx1, c_rx2); | 64 | regex, c_rx1, c_rx2); |
65 | } | 65 | } |
66 | 66 | ||
67 | GNUNET_free (c_rx1); | 67 | GNUNET_free(c_rx1); |
68 | REGEX_INTERNAL_automaton_destroy (dfa); | 68 | REGEX_INTERNAL_automaton_destroy(dfa); |
69 | 69 | ||
70 | return error; | 70 | return error; |
71 | } | 71 | } |
@@ -81,7 +81,7 @@ test_proof (const char *regex) | |||
81 | * @return 0 on succes, number of failures otherwise. | 81 | * @return 0 on succes, number of failures otherwise. |
82 | */ | 82 | */ |
83 | static unsigned int | 83 | static unsigned int |
84 | test_proofs_random (unsigned int count, size_t rx_length) | 84 | test_proofs_random(unsigned int count, size_t rx_length) |
85 | { | 85 | { |
86 | unsigned int i; | 86 | unsigned int i; |
87 | char *rand_rx; | 87 | char *rand_rx; |
@@ -90,11 +90,11 @@ test_proofs_random (unsigned int count, size_t rx_length) | |||
90 | failures = 0; | 90 | failures = 0; |
91 | 91 | ||
92 | for (i = 0; i < count; i++) | 92 | for (i = 0; i < count; i++) |
93 | { | 93 | { |
94 | rand_rx = REGEX_TEST_generate_random_regex (rx_length, NULL); | 94 | rand_rx = REGEX_TEST_generate_random_regex(rx_length, NULL); |
95 | failures += test_proof (rand_rx); | 95 | failures += test_proof(rand_rx); |
96 | GNUNET_free (rand_rx); | 96 | GNUNET_free(rand_rx); |
97 | } | 97 | } |
98 | 98 | ||
99 | return failures; | 99 | return failures; |
100 | } | 100 | } |
@@ -106,7 +106,7 @@ test_proofs_random (unsigned int count, size_t rx_length) | |||
106 | * @return 0 on success, number of failures otherwise. | 106 | * @return 0 on success, number of failures otherwise. |
107 | */ | 107 | */ |
108 | static unsigned int | 108 | static unsigned int |
109 | test_proofs_static () | 109 | test_proofs_static() |
110 | { | 110 | { |
111 | unsigned int i; | 111 | unsigned int i; |
112 | unsigned int error; | 112 | unsigned int error; |
@@ -130,43 +130,43 @@ test_proofs_static () | |||
130 | error = 0; | 130 | error = 0; |
131 | 131 | ||
132 | for (i = 0; i < 8; i += 2) | 132 | for (i = 0; i < 8; i += 2) |
133 | { | 133 | { |
134 | dfa1 = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 1); | 134 | dfa1 = REGEX_INTERNAL_construct_dfa(regex[i], strlen(regex[i]), 1); |
135 | dfa2 = REGEX_INTERNAL_construct_dfa (regex[i + 1], strlen (regex[i + 1]), 1); | 135 | dfa2 = REGEX_INTERNAL_construct_dfa(regex[i + 1], strlen(regex[i + 1]), 1); |
136 | GNUNET_assert (NULL != dfa1); | 136 | GNUNET_assert(NULL != dfa1); |
137 | GNUNET_assert (NULL != dfa2); | 137 | GNUNET_assert(NULL != dfa2); |
138 | 138 | ||
139 | canon_rx1 = REGEX_INTERNAL_get_canonical_regex (dfa1); | 139 | canon_rx1 = REGEX_INTERNAL_get_canonical_regex(dfa1); |
140 | canon_rx2 = REGEX_INTERNAL_get_canonical_regex (dfa2); | 140 | canon_rx2 = REGEX_INTERNAL_get_canonical_regex(dfa2); |
141 | 141 | ||
142 | error += (0 == strcmp (canon_rx1, canon_rx2)) ? 0 : 1; | 142 | error += (0 == strcmp(canon_rx1, canon_rx2)) ? 0 : 1; |
143 | 143 | ||
144 | if (error > 0) | 144 | if (error > 0) |
145 | { | 145 | { |
146 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 146 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
147 | "Comparing canonical regex failed:\nrx1:\t%s\ncrx1:\t%s\nrx2:\t%s\ncrx2:\t%s\n", | 147 | "Comparing canonical regex failed:\nrx1:\t%s\ncrx1:\t%s\nrx2:\t%s\ncrx2:\t%s\n", |
148 | regex[i], canon_rx1, regex[i + 1], canon_rx2); | 148 | regex[i], canon_rx1, regex[i + 1], canon_rx2); |
149 | } | 149 | } |
150 | 150 | ||
151 | REGEX_INTERNAL_automaton_destroy (dfa1); | 151 | REGEX_INTERNAL_automaton_destroy(dfa1); |
152 | REGEX_INTERNAL_automaton_destroy (dfa2); | 152 | REGEX_INTERNAL_automaton_destroy(dfa2); |
153 | } | 153 | } |
154 | 154 | ||
155 | return error; | 155 | return error; |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | int | 159 | int |
160 | main (int argc, char *argv[]) | 160 | main(int argc, char *argv[]) |
161 | { | 161 | { |
162 | GNUNET_log_setup ("test-regex", "WARNING", NULL); | 162 | GNUNET_log_setup("test-regex", "WARNING", NULL); |
163 | 163 | ||
164 | int error; | 164 | int error; |
165 | 165 | ||
166 | error = 0; | 166 | error = 0; |
167 | 167 | ||
168 | error += test_proofs_static (); | 168 | error += test_proofs_static(); |
169 | error += test_proofs_random (100, 30); | 169 | error += test_proofs_random(100, 30); |
170 | 170 | ||
171 | return error; | 171 | return error; |
172 | } | 172 | } |