]> git.saurik.com Git - apt.git/blame - tests/test-enum-include-name-flags
Squashed 'triehash/' content from commit 16f59e1
[apt.git] / tests / test-enum-include-name-flags
CommitLineData
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
5WORDS=w
6
7testsuccessequal "\
8#ifndef TRIE_HASH_PerfectHash
9#define TRIE_HASH_PerfectHash
10#include <stddef.h>
11#include <stdint.h>
12#include <foo.h>
13enum 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
21testsuccessequal "\
22#ifndef TRIE_HASH_PerfectHash
23#define TRIE_HASH_PerfectHash
24#include <stddef.h>
25#include <stdint.h>
26enum class PerfectKey {
27 w = 0,
28 Unknown = -1,
29};
30static enum PerfectKey PerfectHash(const char *string, size_t length);
31static enum PerfectKey PerfectHash1(const char *string)
32{
33 switch(string[0]) {
34 case 'w':
35 return PerfectKey::w;
36 }
37 return PerfectKey::Unknown;
38}
39static 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
51testsuccessequal "\
52#ifndef TRIE_HASH_PerfectHash
53#define TRIE_HASH_PerfectHash
54#include <stddef.h>
55#include <stdint.h>
56enum Foo {
57 Unknown = -1,
58};
59static enum Foo PerfectHash(const char *string, size_t length);
60static 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
71testsuccessequal "\
72#ifndef TRIE_HASH_PerfectHash
73#define TRIE_HASH_PerfectHash
74#include <stddef.h>
75#include <stdint.h>
76enum class Foo::Bar {
77 Unknown = -1,
78};
79static enum Foo::Bar PerfectHash(const char *string, size_t length);
80static 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
91testsuccessequal "\
92#ifndef TRIE_HASH_NonSense
93#define TRIE_HASH_NonSense
94#include <stddef.h>
95#include <stdint.h>
96enum PerfectKey {
97 Unknown = -1,
98};
99static enum PerfectKey NonSense(const char *string, size_t length);
100static 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
111testsuccessequal "\
112#ifndef TRIE_HASH_PerfectHash
113#define TRIE_HASH_PerfectHash
114#include <stddef.h>
115#include <stdint.h>
116enum { MyCounter = 0 };
117enum PerfectKey {
118 Unknown = -1,
119};
120static enum PerfectKey PerfectHash(const char *string, size_t length);
121static 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"