X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fregex%2Ftest_regex_graph_api.c;h=2bf5395a3e64fa3a5e02af64b7d976ec9c7e3e3b;hb=a3acd27f0acf30a6c4803ec933c4fe7650bc296c;hp=c2c1c74e1a497018f98d27f41a49c174dd56f64d;hpb=0e4c7cdccfc4105f9c6e529cfa0e3722104b0ddf;p=oweals%2Fgnunet.git diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c index c2c1c74e1..2bf5395a3 100644 --- a/src/regex/test_regex_graph_api.c +++ b/src/regex/test_regex_graph_api.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2012 Christian Grothoff (and other contributing authors) + Copyright (C) 2012 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** * @file regex/test_regex_graph_api.c @@ -25,10 +25,11 @@ #include #include #include "platform.h" -#include "gnunet_regex_lib.h" +#include "regex_internal_lib.h" +#include "regex_test_lib.h" #include "regex_internal.h" -#define KEEP_FILES 0 +#define KEEP_FILES 1 /** * Check if 'filename' exists and is not empty. @@ -43,7 +44,7 @@ filecheck (const char *filename) int error = 0; FILE *fp; - // Check if file was created and delete it again + /* Check if file was created and delete it again */ if (NULL == (fp = fopen (filename, "r"))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find graph %s\n", filename); @@ -54,18 +55,16 @@ filecheck (const char *filename) if (1 > ftell (fp)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Graph writing failed, got empty file (%s)!\n", - filename); + "Graph writing failed, got empty file (%s)!\n", filename); error = 2; } - + GNUNET_assert (0 == fclose (fp)); if (!KEEP_FILES) { if (0 != unlink (filename)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, - "unlink", filename); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink", filename); } return error; } @@ -75,9 +74,10 @@ int main (int argc, char *argv[]) { int error; - struct GNUNET_REGEX_Automaton *a; + struct REGEX_INTERNAL_Automaton *a; unsigned int i; const char *filename = "test_graph.dot"; + const char *regex[12] = { "ab(c|d)+c*(a(b|c)+d)+(bla)+", "(bla)*", @@ -90,7 +90,6 @@ main (int argc, char *argv[]) "a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*", "a", "a|b", -// "abc(d+|e)fgh" "PADPADPADPADPADPabcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd" }; @@ -98,61 +97,59 @@ main (int argc, char *argv[]) error = 0; for (i = 0; i < 12; i++) { - // Check NFA graph creation - a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); - GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); - GNUNET_REGEX_automaton_destroy (a); + /* Check NFA graph creation */ + a = REGEX_INTERNAL_construct_nfa (regex[i], strlen (regex[i])); + REGEX_TEST_automaton_save_graph (a, filename, REGEX_TEST_GRAPH_DEFAULT); + REGEX_INTERNAL_automaton_destroy (a); error += filecheck (filename); - a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); - GNUNET_REGEX_automaton_save_graph (a, filename, - GNUNET_REGEX_GRAPH_DEFAULT | - GNUNET_REGEX_GRAPH_VERBOSE); - GNUNET_REGEX_automaton_destroy (a); + a = REGEX_INTERNAL_construct_nfa (regex[i], strlen (regex[i])); + REGEX_TEST_automaton_save_graph (a, filename, + REGEX_TEST_GRAPH_DEFAULT | + REGEX_TEST_GRAPH_VERBOSE); + REGEX_INTERNAL_automaton_destroy (a); error += filecheck (filename); - a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); - GNUNET_REGEX_automaton_save_graph (a, filename, - GNUNET_REGEX_GRAPH_DEFAULT | - GNUNET_REGEX_GRAPH_COLORING); - GNUNET_REGEX_automaton_destroy (a); + a = REGEX_INTERNAL_construct_nfa (regex[i], strlen (regex[i])); + REGEX_TEST_automaton_save_graph (a, filename, + REGEX_TEST_GRAPH_DEFAULT | + REGEX_TEST_GRAPH_COLORING); + REGEX_INTERNAL_automaton_destroy (a); error += filecheck (filename); - a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); - GNUNET_REGEX_automaton_save_graph (a, filename, - GNUNET_REGEX_GRAPH_DEFAULT | - GNUNET_REGEX_GRAPH_VERBOSE | - GNUNET_REGEX_GRAPH_COLORING); - GNUNET_REGEX_automaton_destroy (a); + a = REGEX_INTERNAL_construct_nfa (regex[i], strlen (regex[i])); + REGEX_TEST_automaton_save_graph (a, filename, + REGEX_TEST_GRAPH_DEFAULT | + REGEX_TEST_GRAPH_VERBOSE | + REGEX_TEST_GRAPH_COLORING); + REGEX_INTERNAL_automaton_destroy (a); error += filecheck (filename); - // Check DFA graph creation - a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); - GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); - GNUNET_REGEX_automaton_destroy (a); + /* Check DFA graph creation */ + a = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 0); + REGEX_TEST_automaton_save_graph (a, filename, REGEX_TEST_GRAPH_DEFAULT); + REGEX_INTERNAL_automaton_destroy (a); error += filecheck (filename); - a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); - GNUNET_REGEX_automaton_save_graph (a, filename, - GNUNET_REGEX_GRAPH_DEFAULT | - GNUNET_REGEX_GRAPH_VERBOSE); - GNUNET_REGEX_automaton_destroy (a); + a = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 0); + REGEX_TEST_automaton_save_graph (a, filename, + REGEX_TEST_GRAPH_DEFAULT | + REGEX_TEST_GRAPH_VERBOSE); + REGEX_INTERNAL_automaton_destroy (a); error += filecheck (filename); - a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); - GNUNET_REGEX_automaton_save_graph (a, filename, - GNUNET_REGEX_GRAPH_DEFAULT | - GNUNET_REGEX_GRAPH_COLORING); - GNUNET_REGEX_automaton_destroy (a); + a = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 0); + REGEX_TEST_automaton_save_graph (a, filename, + REGEX_TEST_GRAPH_DEFAULT | + REGEX_TEST_GRAPH_COLORING); + REGEX_INTERNAL_automaton_destroy (a); error += filecheck (filename); - a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); - GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); //| - // GNUNET_REGEX_GRAPH_VERBOSE | - //GNUNET_REGEX_GRAPH_COLORING); - GNUNET_REGEX_automaton_destroy (a); + a = REGEX_INTERNAL_construct_dfa (regex[i], strlen (regex[i]), 4); + REGEX_TEST_automaton_save_graph (a, filename, REGEX_TEST_GRAPH_DEFAULT); + REGEX_INTERNAL_automaton_destroy (a); error += filecheck (filename); }