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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#!/bin/sh
. $(dirname $(readlink -f $0))/framework.sh
# Need a short word, we really just need to check if the labels work
WORDS=w
testsuccessequal "\
#ifndef TRIE_HASH_PerfectHash
#define TRIE_HASH_PerfectHash
#include <stddef.h>
#include <stdint.h>
#include <foo.h>
enum PerfectKey {
w = 0,
Unknown = -1,
};
enum PerfectKey PerfectHash(const char *string, size_t length);
#endif /* TRIE_HASH_PerfectHash */" triehash --multi-byte=0 -C /dev/null --include="<foo.h>" /dev/stdin
# Check for --enum-class support
testsuccessequal "\
#ifndef TRIE_HASH_PerfectHash
#define TRIE_HASH_PerfectHash
#include <stddef.h>
#include <stdint.h>
enum class PerfectKey {
w = 0,
Unknown = -1,
};
static enum PerfectKey PerfectHash(const char *string, size_t length);
static enum PerfectKey PerfectHash1(const char *string)
{
switch(string[0]) {
case 'w':
return PerfectKey::w;
}
return PerfectKey::Unknown;
}
static enum PerfectKey PerfectHash(const char *string, size_t length)
{
switch (length) {
case 1:
return PerfectHash1(string);
default:
return PerfectKey::Unknown;
}
}
#endif /* TRIE_HASH_PerfectHash */" triehash --multi-byte=0 --enum-class /dev/stdin
# Check for --enum-name support
testsuccessequal "\
#ifndef TRIE_HASH_PerfectHash
#define TRIE_HASH_PerfectHash
#include <stddef.h>
#include <stdint.h>
enum Foo {
Unknown = -1,
};
static enum Foo PerfectHash(const char *string, size_t length);
static enum Foo PerfectHash(const char *string, size_t length)
{
switch (length) {
default:
return Unknown;
}
}
#endif /* TRIE_HASH_PerfectHash */\
" triehash --multi-byte=0 --enum-name="Foo"
# Check for --enum-class support
testsuccessequal "\
#ifndef TRIE_HASH_PerfectHash
#define TRIE_HASH_PerfectHash
#include <stddef.h>
#include <stdint.h>
enum class Foo::Bar {
Unknown = -1,
};
static enum Foo::Bar PerfectHash(const char *string, size_t length);
static enum Foo::Bar PerfectHash(const char *string, size_t length)
{
switch (length) {
default:
return Foo::Bar::Unknown;
}
}
#endif /* TRIE_HASH_PerfectHash */\
" triehash --multi-byte=0 --enum-class --enum-name="Foo::Bar"
# Check for --function-name support
testsuccessequal "\
#ifndef TRIE_HASH_NonSense
#define TRIE_HASH_NonSense
#include <stddef.h>
#include <stdint.h>
enum PerfectKey {
Unknown = -1,
};
static enum PerfectKey NonSense(const char *string, size_t length);
static enum PerfectKey NonSense(const char *string, size_t length)
{
switch (length) {
default:
return Unknown;
}
}
#endif /* TRIE_HASH_NonSense */\
" triehash --multi-byte=0 --function-name="NonSense"
# Check for --counter-name support
testsuccessequal "\
#ifndef TRIE_HASH_PerfectHash
#define TRIE_HASH_PerfectHash
#include <stddef.h>
#include <stdint.h>
enum { MyCounter = 0 };
enum PerfectKey {
Unknown = -1,
};
static enum PerfectKey PerfectHash(const char *string, size_t length);
static enum PerfectKey PerfectHash(const char *string, size_t length)
{
switch (length) {
default:
return Unknown;
}
}
#endif /* TRIE_HASH_PerfectHash */\
" triehash --multi-byte=0 --counter-name="MyCounter"
|