123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #!/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"
|