-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtests.c++
45 lines (32 loc) · 972 Bytes
/
tests.c++
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
41
42
43
44
45
#include "BloomSet.h"
#include "PrefixSet.h"
#include "PostfixSet.h"
#include <cassert>
int main(void) {
BloomSet set(1024);
assert(!set.contains("abcd", 4));
assert(!set.contains("abce", 4));
assert(!set.contains("abcf", 4));
set.insert("abce", 4);
assert(!set.contains("abcd", 4));
assert(set.contains("abce", 4));
assert(!set.contains("abcf", 4));
PrefixSet prefix;
prefix.insert("/log/");
prefix.insert("/blog");
assert(prefix.matches("/log/abcdef"));
assert(!prefix.matches("/logabcdef"));
assert(!prefix.matches("logabcdef"));
assert(!prefix.matches("/blorg"));
assert(prefix.matches("/blog/what"));
assert(prefix.matches("/blogwhat"));
PostfixSet postfix;
postfix.insert(".xyz");
assert(postfix.matches("/testing.xyz"));
assert(postfix.matches("whatever.xyz"));
assert(!postfix.matches("someother"));
postfix.insert("");
assert(postfix.matches("someother"));
assert(postfix.matches(""));
return 0;
}