#include "platform.h"
#include "gnunet_regex_lib.h"
+#define KEEP_FILES 0
+
/**
* Check if 'filename' exists and is not empty.
*
if (NULL == fp)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find graph %s\n", filename);
- error++;
+ return ++error;
}
fseek (fp, 0L, SEEK_END);
error++;
}
+ error += fclose (fp);
+
+ if (!KEEP_FILES)
+ {
+ if (0 != unlink (filename))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not remove temp files (%s)\n",
+ filename);
+ }
+ }
+
+
return error;
}
int
main (int argc, char *argv[])
{
- GNUNET_log_setup ("test-regex",
-#if VERBOSE
- "DEBUG",
-#else
- "WARNING",
-#endif
- NULL);
+ GNUNET_log_setup ("test-regex", "WARNING", NULL);
int error;
struct GNUNET_REGEX_Automaton *a;
error = 0;
- const char *regex[10] = {
+ const char *regex[12] = {
"ab(c|d)+c*(a(b|c)+d)+(bla)+",
"(bla)*",
"b(lab)*la",
"1*0(0|1)*",
"a*b*",
"a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*",
- "a"
+ "a",
+ "a|b",
+// "abc(d+|e)fgh"
+ "PADPADPADPADPADPabcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd"
};
- for (i = 0; i < 10; i++)
+ for (i = 0; i < 12; i++)
{
// Check NFA graph creation
a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i]));
a = GNUNET_REGEX_construct_dfa (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_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); //|
+ // GNUNET_REGEX_GRAPH_VERBOSE |
+ //GNUNET_REGEX_GRAPH_COLORING);
GNUNET_REGEX_automaton_destroy (a);
error += filecheck (filename);