-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkmp_test.c
More file actions
24 lines (20 loc) · 769 Bytes
/
kmp_test.c
File metadata and controls
24 lines (20 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include "kmp_test.h"
#include "kmp.h"
bool TestKMP(void)
{
int pos;
char *str = "my name is red!";
char *substr = "red";
bool found = KMPFindString(str, substr, 0, &pos);
printf("test kmp: %d %d %s\n", found, pos, str+0+pos);
str = "saoigvhieoraboaenbkeuirghregklxchvbiueqabngl;iewrhbiodftsibhidahrfnbiurewliubnfaibnuiaerbniuerabhur";
substr = "hur";
found = KMPFindString(str, substr, 0, &pos);
printf("test kmp: %d %d %s\n", found, pos, str+0+pos);
str = "aaaaaaaaaaaaaaaaaaaaaaaaaaababababaaabbbfffcccccccbababdsdsdsdsdsdsdsdbbbbbbaaaaaaaaauuuuuuuuuuu";
substr = "aaabb";
found = KMPFindString(str, substr, 0, &pos);
printf("test kmp: %d %d %s\n", found, pos, str+0+pos);
return true;
}