]>
Commit | Line | Data |
---|---|---|
e2073b02 JAK |
1 | #!/bin/sh |
2 | . $(dirname $(readlink -f $0))/framework.sh | |
3 | ||
4 | # Need a short word, we really just need to check if the labels work | |
5 | WORDS=w | |
6 | ||
7 | testsuccessequal "\ | |
8 | #ifndef TRIE_HASH_PerfectHash | |
9 | #define TRIE_HASH_PerfectHash | |
10 | #include <stddef.h> | |
11 | #include <stdint.h> | |
12 | #include <foo.h> | |
13 | enum PerfectKey { | |
14 | w = 0, | |
15 | Unknown = -1, | |
16 | }; | |
17 | enum PerfectKey PerfectHash(const char *string, size_t length); | |
18 | #endif /* TRIE_HASH_PerfectHash */" triehash --multi-byte=0 -C /dev/null --include="<foo.h>" /dev/stdin | |
19 | ||
20 | # Check for --enum-class support | |
21 | testsuccessequal "\ | |
22 | #ifndef TRIE_HASH_PerfectHash | |
23 | #define TRIE_HASH_PerfectHash | |
24 | #include <stddef.h> | |
25 | #include <stdint.h> | |
26 | enum class PerfectKey { | |
27 | w = 0, | |
28 | Unknown = -1, | |
29 | }; | |
30 | static enum PerfectKey PerfectHash(const char *string, size_t length); | |
31 | static enum PerfectKey PerfectHash1(const char *string) | |
32 | { | |
33 | switch(string[0]) { | |
34 | case 'w': | |
35 | return PerfectKey::w; | |
36 | } | |
37 | return PerfectKey::Unknown; | |
38 | } | |
39 | static enum PerfectKey PerfectHash(const char *string, size_t length) | |
40 | { | |
41 | switch (length) { | |
42 | case 1: | |
43 | return PerfectHash1(string); | |
44 | default: | |
45 | return PerfectKey::Unknown; | |
46 | } | |
47 | } | |
48 | #endif /* TRIE_HASH_PerfectHash */" triehash --multi-byte=0 --enum-class /dev/stdin | |
49 | ||
50 | # Check for --enum-name support | |
51 | testsuccessequal "\ | |
52 | #ifndef TRIE_HASH_PerfectHash | |
53 | #define TRIE_HASH_PerfectHash | |
54 | #include <stddef.h> | |
55 | #include <stdint.h> | |
56 | enum Foo { | |
57 | Unknown = -1, | |
58 | }; | |
59 | static enum Foo PerfectHash(const char *string, size_t length); | |
60 | static enum Foo PerfectHash(const char *string, size_t length) | |
61 | { | |
62 | switch (length) { | |
63 | default: | |
64 | return Unknown; | |
65 | } | |
66 | } | |
67 | #endif /* TRIE_HASH_PerfectHash */\ | |
68 | " triehash --multi-byte=0 --enum-name="Foo" | |
69 | ||
70 | # Check for --enum-class support | |
71 | testsuccessequal "\ | |
72 | #ifndef TRIE_HASH_PerfectHash | |
73 | #define TRIE_HASH_PerfectHash | |
74 | #include <stddef.h> | |
75 | #include <stdint.h> | |
76 | enum class Foo::Bar { | |
77 | Unknown = -1, | |
78 | }; | |
79 | static enum Foo::Bar PerfectHash(const char *string, size_t length); | |
80 | static enum Foo::Bar PerfectHash(const char *string, size_t length) | |
81 | { | |
82 | switch (length) { | |
83 | default: | |
84 | return Foo::Bar::Unknown; | |
85 | } | |
86 | } | |
87 | #endif /* TRIE_HASH_PerfectHash */\ | |
88 | " triehash --multi-byte=0 --enum-class --enum-name="Foo::Bar" | |
89 | ||
90 | # Check for --function-name support | |
91 | testsuccessequal "\ | |
92 | #ifndef TRIE_HASH_NonSense | |
93 | #define TRIE_HASH_NonSense | |
94 | #include <stddef.h> | |
95 | #include <stdint.h> | |
96 | enum PerfectKey { | |
97 | Unknown = -1, | |
98 | }; | |
99 | static enum PerfectKey NonSense(const char *string, size_t length); | |
100 | static enum PerfectKey NonSense(const char *string, size_t length) | |
101 | { | |
102 | switch (length) { | |
103 | default: | |
104 | return Unknown; | |
105 | } | |
106 | } | |
107 | #endif /* TRIE_HASH_NonSense */\ | |
108 | " triehash --multi-byte=0 --function-name="NonSense" | |
109 | ||
110 | # Check for --counter-name support | |
111 | testsuccessequal "\ | |
112 | #ifndef TRIE_HASH_PerfectHash | |
113 | #define TRIE_HASH_PerfectHash | |
114 | #include <stddef.h> | |
115 | #include <stdint.h> | |
116 | enum { MyCounter = 0 }; | |
117 | enum PerfectKey { | |
118 | Unknown = -1, | |
119 | }; | |
120 | static enum PerfectKey PerfectHash(const char *string, size_t length); | |
121 | static enum PerfectKey PerfectHash(const char *string, size_t length) | |
122 | { | |
123 | switch (length) { | |
124 | default: | |
125 | return Unknown; | |
126 | } | |
127 | } | |
128 | #endif /* TRIE_HASH_PerfectHash */\ | |
129 | " triehash --multi-byte=0 --counter-name="MyCounter" |