test-enum-include-name-flags 3.2 KB

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