diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/check_dfa.c | 10 | ||||
-rw-r--r-- | src/test/check_pred.c | 15 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/test/check_dfa.c b/src/test/check_dfa.c index a728fb8..426eee4 100644 --- a/src/test/check_dfa.c +++ b/src/test/check_dfa.c @@ -104,5 +104,15 @@ main(int UNUSED argc, char ** UNUSED argv) * printf("the result = %d\n", result); */ if (dfap) destroy_dfa(dfap); + + dfap = dfa_from_ranges(3, (NUM []) { 1, 10, 'a', 'z', 'A', 'Z' }); + + if (dfap) { + printf("Successfully created a DFA from an array of ranges\n"); + print_dfa(dfap); + } + + if (dfap) destroy_dfa(dfap); + return 0; } diff --git a/src/test/check_pred.c b/src/test/check_pred.c index 14081d5..8a3e613 100644 --- a/src/test/check_pred.c +++ b/src/test/check_pred.c @@ -1,3 +1,4 @@ +#include "limits.h" #include "time.h" #include "../cnp.h" @@ -88,7 +89,7 @@ main(int UNUSED argc, char ** UNUSED argv) *(user_name+4) = 'i'; *(user_name+5) = 0; - user_name_s = new_utf8(user_name, 5); + user_name_s = (str *) new_utf8(user_name, 5); SAFE_MALLOC(char, raw_name, 8, return 1;); @@ -101,7 +102,7 @@ main(int UNUSED argc, char ** UNUSED argv) *(raw_name+6) = 'Z'; *(raw_name+7) = 0; - raw_name_s = new_utf8(raw_name, 6); + raw_name_s = (str *) new_utf8(raw_name, 6); SAFE_MALLOC(NUM, pred_bytes, 52, return 1;); @@ -111,9 +112,11 @@ main(int UNUSED argc, char ** UNUSED argv) for (int i = 0; i < 26; i++) *(pred_bytes+pred_bytes_len++) = 'A' + i; - if (add_to_list(preds, new_ptd(user_name_s, raw_name_s, - dfa_from_bytes_neg - (pred_bytes_len, pred_bytes)))) { + if (add_to_list(preds, + new_ptd(user_name_s, raw_name_s, + dfa_from_ranges_both + (2, (NUM[]) { 'a', 'z', 'A', 'Z' }, + 2, (NUM[]) { 'b', 'w', 'B', 'W' })))) { fleprintf0("Fail to add a predicate\n"); return 1; } @@ -126,7 +129,7 @@ main(int UNUSED argc, char ** UNUSED argv) print_grammar(g); - utf8 *string = new_utf8("++--__,.(){}><|", 15); + utf8 *string = new_utf8("aaaxxxxaaaaaaaa", 15); printf("\nPrinting the input...\n%s\n", get_data((str *) string)); |