]>
git.saurik.com Git - apt.git/blob - triehash/tests/test-case-insensitive
2 .
$(dirname $(readlink -f $0))/framework.sh
4 WORDS
="Halllo\nH-lllo\nHalll1"
6 # Case-insensitive test
7 testsuccessequal
"#include \"/dev/null\"
9 typedef uint16_t __attribute__((aligned (1))) triehash_uu16;
10 typedef char static_assert16[__alignof__(triehash_uu16) == 1 ? 1 : -1];
11 typedef uint32_t __attribute__((aligned (1))) triehash_uu32;
12 typedef char static_assert32[__alignof__(triehash_uu32) == 1 ? 1 : -1];
13 typedef uint64_t __attribute__((aligned (1))) triehash_uu64;
14 typedef char static_assert64[__alignof__(triehash_uu64) == 1 ? 1 : -1];
15 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
16 #define onechar(c, s, l) (((uint64_t)(c)) << (s))
18 #define onechar(c, s, l) (((uint64_t)(c)) << (l-8-s))
20 #if (!defined(__ARM_ARCH) || defined(__ARM_FEATURE_UNALIGNED)) && !defined(TRIE_HASH_NO_MULTI_BYTE)
21 #define TRIE_HASH_MULTI_BYTE
24 #ifdef TRIE_HASH_MULTI_BYTE
25 static enum PerfectKey PerfectHash6(const char *string)
27 switch(string[0] | 0x20) {
28 case 0| onechar('h', 0, 8):
30 case 0| onechar('-', 0, 8):
31 switch(*((triehash_uu32*) &string[2]) | 0x20202020) {
32 case 0| onechar('l', 0, 32)| onechar('l', 8, 32)| onechar('l', 16, 32)| onechar('o', 24, 32):
36 case 0| onechar('a', 0, 8):
37 case 0| onechar('A', 0, 8):
38 switch(*((triehash_uu16*) &string[2]) | 0x2020) {
39 case 0| onechar('l', 0, 16)| onechar('l', 8, 16):
40 switch(string[4] | 0x20) {
41 case 0| onechar('l', 0, 8):
43 case 0| onechar('1', 0, 8):
46 case 0| onechar('o', 0, 8):
47 case 0| onechar('O', 0, 8):
57 static enum PerfectKey PerfectHash6(const char *string)
59 switch(string[0] | 0x20) {
63 switch(string[2] | 0x20) {
65 switch(string[3] | 0x20) {
67 switch(string[4] | 0x20) {
69 switch(string[5] | 0x20) {
79 switch(string[2] | 0x20) {
81 switch(string[3] | 0x20) {
83 switch(string[4] | 0x20) {
100 #endif /* TRIE_HASH_MULTI_BYTE */
101 enum PerfectKey PerfectHash(const char *string, size_t length)
105 return PerfectHash6(string);
109 }" triehash
--multi-byte=3210 --ignore-case -H /dev
/null
/dev
/stdin