-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.cpp
40 lines (28 loc) · 791 Bytes
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "keyworddict.h"
int main()
{
char * input = NULL;
char * output = NULL;
const char * keywords[3] = {"DFA", "¶ñÐÄ", "DA"};
input = (char *)malloc(100);
output = (char *)malloc(200);
strcpy( input, "Hello DA World DFA, HaHa! ¶ñÐÄzzz" );
KeywordDict * dict = new KeywordDict;
for (int32_t i = 0; i < 3; ++i)
{
dict->add( (char *)keywords[i] );
}
printf("Content: %s\n", input );
int32_t rc = dict->filter( input, strlen(input) );
printf("rc:%d\nContent: %s\n", rc, input );
strcpy( input, "Hello DA World DFA, HaHa! ¶ñÐÄzzz" );
rc = dict->filter( input, strlen(input), output, 199, "judy", 4 );
printf("rc:%d\nContent: %s\n", rc, output );
free(input);
free(output);
delete dict;
return 0;
}