?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. // https://github.com/vinniefalco/LuaBridge
  2. // Copyright 2019, Dmitry Tarakanov
  3. // SPDX-License-Identifier: MIT
  4.  
  5. #pragma once
  6.  
  7. #include "LuaBridge/detail/Config.h"
  8.  
  9. #include <gtest/gtest.h>
  10.  
  11. #include <string>
  12. #include <vector>
  13.  
  14. #ifdef LUABRIDGE_CXX17
  15. #include <string_view>
  16. #endif
  17.  
  18. using TestTypes = ::testing::Types<bool,
  19.                                    char,
  20.                                    unsigned char,
  21.                                    short,
  22.                                    unsigned short,
  23.                                    int,
  24.                                    unsigned int,
  25.                                    long,
  26.                                    unsigned long,
  27.                                    long long,
  28.                                    unsigned long long,
  29.                                    float,
  30.                                    double,
  31.                                    std::string
  32. #ifdef LUABRIDGE_CXX17
  33.                                    , std::string_view
  34. #endif
  35.                                    >;
  36.  
  37. template<class T>
  38. struct TypeTraits;
  39.  
  40. template<>
  41. struct TypeTraits<bool>
  42. {
  43.     static std::vector<bool> values() { return {true, false, true}; }
  44.     static std::string list() { return "true, false, true"; }
  45. };
  46.  
  47. template<>
  48. struct TypeTraits<char>
  49. {
  50.     static std::vector<char> values() { return {'a', 'b', 'c'}; }
  51.     static std::string list() { return "'a', 'b', 'c'"; }
  52. };
  53.  
  54. template<>
  55. struct TypeTraits<unsigned char>
  56. {
  57.     static std::vector<unsigned char> values() { return {1, 2, 3}; }
  58.     static std::string list() { return "1, 2, 3"; }
  59. };
  60.  
  61. template<>
  62. struct TypeTraits<short>
  63. {
  64.     static std::vector<short> values() { return {1, -2, 3}; }
  65.     static std::string list() { return "1, -2, 3"; }
  66. };
  67.  
  68. template<>
  69. struct TypeTraits<unsigned short>
  70. {
  71.     static std::vector<unsigned short> values() { return {1, 2, 3}; }
  72.     static std::string list() { return "1, 2, 3"; }
  73. };
  74.  
  75. template<>
  76. struct TypeTraits<int>
  77. {
  78.     static std::vector<int> values() { return {1, -2, 3}; }
  79.     static std::string list() { return "1, -2, 3"; }
  80. };
  81.  
  82. template<>
  83. struct TypeTraits<unsigned int>
  84. {
  85.     static std::vector<unsigned int> values() { return {1, 2, 3}; }
  86.     static std::string list() { return "1, 2, 3"; }
  87. };
  88.  
  89. template<>
  90. struct TypeTraits<long>
  91. {
  92.     static std::vector<long> values() { return {1, -2, 3}; }
  93.     static std::string list() { return "1, -2, 3"; }
  94. };
  95.  
  96. template<>
  97. struct TypeTraits<unsigned long>
  98. {
  99.     static std::vector<unsigned long> values() { return {1, 2, 3}; }
  100.     static std::string list() { return "1, 2, 3"; }
  101. };
  102.  
  103. template<>
  104. struct TypeTraits<long long>
  105. {
  106.     static std::vector<long long> values() { return {1, -2, 3}; }
  107.     static std::string list() { return "1, -2, 3"; }
  108. };
  109.  
  110. template<>
  111. struct TypeTraits<unsigned long long>
  112. {
  113.     static std::vector<unsigned long long> values() { return {1, 2, 3}; }
  114.     static std::string list() { return "1, 2, 3"; }
  115. };
  116.  
  117. template<>
  118. struct TypeTraits<float>
  119. {
  120.     static std::vector<float> values() { return {1.2f, -2.5f, 3.14f}; }
  121.     static std::string list() { return "1.2, -2.5, 3.14"; }
  122. };
  123.  
  124. template<>
  125. struct TypeTraits<double>
  126. {
  127.     static std::vector<double> values() { return {1.2, -2.5, 3.14}; }
  128.     static std::string list() { return "1.2, -2.5, 3.14"; }
  129. };
  130.  
  131. template<>
  132. struct TypeTraits<std::string>
  133. {
  134.     static std::vector<std::string> values() { return {"", "a", "xyz"}; }
  135.     static std::string list() { return "'', 'a', 'xyz'"; }
  136. };
  137.  
  138. #ifdef LUABRIDGE_STRING_VIEW
  139.  
  140. template<>
  141. struct TypeTraits<std::string>
  142. {
  143.     static std::vector<std::string> values() { return {"", "a", "xyz"}; }
  144.     static std::string list() { return "'', 'a', 'xyz'"; }
  145. };
  146.  
  147. #endif
  148.  
  149. #ifdef LUABRIDGE_CXX17
  150.  
  151. template<>
  152. struct TypeTraits<std::string_view>
  153. {
  154.     static std::vector<std::string_view> values() { return {"", "a", "xyz"}; }
  155.     static std::string list() { return "'', 'a', 'xyz'"; }
  156. };
  157.  
  158. #endif
  159.