File: test-label-mangling

package info (click to toggle)
triehash 0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 168 kB
  • sloc: sh: 1,161; perl: 391; makefile: 10
file content (235 lines) | stat: -rwxr-xr-x 6,153 bytes parent folder | download
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/sh
. $(dirname $(readlink -f $0))/framework.sh

WORDS="Package
Source
Binary
Version"

# Check the --label-prefix
testsuccessequal "#ifndef TRIE_HASH_PerfectHash
#define TRIE_HASH_PerfectHash
#include <stddef.h>
#include <stdint.h>
enum PerfectKey {
    Field_Binary = 2,
    Field_Package = 0,
    Field_Source = 1,
    Field_Version = 3,
    Field_Unknown = -1,
};
static enum PerfectKey PerfectHash(const char *string, size_t length);
static enum PerfectKey PerfectHash6(const char *string)
{
    switch(string[0]) {
    case 'B':
        switch(string[1]) {
        case 'i':
            switch(string[2]) {
            case 'n':
                switch(string[3]) {
                case 'a':
                    switch(string[4]) {
                    case 'r':
                        switch(string[5]) {
                        case 'y':
                            return Field_Binary;
                        }
                    }
                }
            }
        }
        break;
    case 'S':
        switch(string[1]) {
        case 'o':
            switch(string[2]) {
            case 'u':
                switch(string[3]) {
                case 'r':
                    switch(string[4]) {
                    case 'c':
                        switch(string[5]) {
                        case 'e':
                            return Field_Source;
                        }
                    }
                }
            }
        }
    }
    return Field_Unknown;
}
static enum PerfectKey PerfectHash7(const char *string)
{
    switch(string[0]) {
    case 'P':
        switch(string[1]) {
        case 'a':
            switch(string[2]) {
            case 'c':
                switch(string[3]) {
                case 'k':
                    switch(string[4]) {
                    case 'a':
                        switch(string[5]) {
                        case 'g':
                            switch(string[6]) {
                            case 'e':
                                return Field_Package;
                            }
                        }
                    }
                }
            }
        }
        break;
    case 'V':
        switch(string[1]) {
        case 'e':
            switch(string[2]) {
            case 'r':
                switch(string[3]) {
                case 's':
                    switch(string[4]) {
                    case 'i':
                        switch(string[5]) {
                        case 'o':
                            switch(string[6]) {
                            case 'n':
                                return Field_Version;
                            }
                        }
                    }
                }
            }
        }
    }
    return Field_Unknown;
}
static enum PerfectKey PerfectHash(const char *string, size_t length)
{
    switch (length) {
    case 6:
        return PerfectHash6(string);
    case 7:
        return PerfectHash7(string);
    default:
        return Field_Unknown;
    }
}
#endif                       /* TRIE_HASH_PerfectHash */" triehash --multi-byte=0 --label-prefix=Field_ /dev/stdin

# Check the --label--uppercase
testsuccessequal "#ifndef TRIE_HASH_PerfectHash
#define TRIE_HASH_PerfectHash
#include <stddef.h>
#include <stdint.h>
enum PerfectKey {
    BINARY = 2,
    PACKAGE = 0,
    SOURCE = 1,
    VERSION = 3,
    UNKNOWN = -1,
};
static enum PerfectKey PerfectHash(const char *string, size_t length);
static enum PerfectKey PerfectHash6(const char *string)
{
    switch(string[0]) {
    case 'B':
        switch(string[1]) {
        case 'i':
            switch(string[2]) {
            case 'n':
                switch(string[3]) {
                case 'a':
                    switch(string[4]) {
                    case 'r':
                        switch(string[5]) {
                        case 'y':
                            return BINARY;
                        }
                    }
                }
            }
        }
        break;
    case 'S':
        switch(string[1]) {
        case 'o':
            switch(string[2]) {
            case 'u':
                switch(string[3]) {
                case 'r':
                    switch(string[4]) {
                    case 'c':
                        switch(string[5]) {
                        case 'e':
                            return SOURCE;
                        }
                    }
                }
            }
        }
    }
    return UNKNOWN;
}
static enum PerfectKey PerfectHash7(const char *string)
{
    switch(string[0]) {
    case 'P':
        switch(string[1]) {
        case 'a':
            switch(string[2]) {
            case 'c':
                switch(string[3]) {
                case 'k':
                    switch(string[4]) {
                    case 'a':
                        switch(string[5]) {
                        case 'g':
                            switch(string[6]) {
                            case 'e':
                                return PACKAGE;
                            }
                        }
                    }
                }
            }
        }
        break;
    case 'V':
        switch(string[1]) {
        case 'e':
            switch(string[2]) {
            case 'r':
                switch(string[3]) {
                case 's':
                    switch(string[4]) {
                    case 'i':
                        switch(string[5]) {
                        case 'o':
                            switch(string[6]) {
                            case 'n':
                                return VERSION;
                            }
                        }
                    }
                }
            }
        }
    }
    return UNKNOWN;
}
static enum PerfectKey PerfectHash(const char *string, size_t length)
{
    switch (length) {
    case 6:
        return PerfectHash6(string);
    case 7:
        return PerfectHash7(string);
    default:
        return UNKNOWN;
    }
}
#endif                       /* TRIE_HASH_PerfectHash */" triehash --multi-byte=0 --label-uppercase /dev/stdin