Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

128 wiersze
3.3 KiB

  1. #include <gtest/gtest.h>
  2. #include <cpphibernate.h>
  3. using namespace ::cpphibernate;
  4. struct test1
  5. {
  6. uuid id;
  7. std::string str_data;
  8. string<64> str64_data;
  9. };
  10. struct test2
  11. {
  12. uuid id;
  13. uint8_t u8_data;
  14. int8_t i8_data;
  15. uint16_t u16_data;
  16. int16_t i16_data;
  17. };
  18. struct test3
  19. {
  20. uuid id;
  21. uint32_t u32_data;
  22. int32_t i32_data;
  23. uint64_t u64_data;
  24. int64_t i64_data;
  25. };
  26. struct base
  27. {
  28. uuid id;
  29. std::string name;
  30. };
  31. struct derived1
  32. : public base
  33. {
  34. uuid derived1_id;
  35. test1 test1_data;
  36. };
  37. struct derived2
  38. : public base
  39. {
  40. uuid derived2_id;
  41. utl::nullable<test2> test2_nullable;
  42. std::unique_ptr<test2> test2_ptr_u;
  43. std::shared_ptr<test2> test2_ptr_s;
  44. };
  45. struct derived3
  46. : public derived1
  47. {
  48. uuid derived3_id;
  49. std::list<test3> test3_list;
  50. std::vector<test3> test3_vector;
  51. };
  52. constexpr decltype(auto) test_schema = cpphibernate_make_schema(
  53. test,
  54. cpphibernate_make_table_name(
  55. tbl_test1,
  56. test1,
  57. 1,
  58. cpphibernate_make_id (&test1::id),
  59. cpphibernate_make_field (test1, str_data),
  60. cpphibernate_make_field (test1, str64_data)
  61. ),
  62. cpphibernate_make_table_name(
  63. tbl_test2,
  64. test2,
  65. 2,
  66. cpphibernate_make_id (&test2::id),
  67. cpphibernate_make_field (test2, u8_data),
  68. cpphibernate_make_field (test2, i8_data),
  69. cpphibernate_make_field (test2, u16_data),
  70. cpphibernate_make_field (test2, i16_data)
  71. ),
  72. cpphibernate_make_table_name(
  73. tbl_test3,
  74. test3,
  75. 3,
  76. cpphibernate_make_id (&test3::id),
  77. cpphibernate_make_field (test3, u32_data),
  78. cpphibernate_make_field (test3, i32_data),
  79. cpphibernate_make_field (test3, u64_data),
  80. cpphibernate_make_field (test3, i64_data)
  81. ),
  82. cpphibernate_make_table_name(
  83. tbl_base,
  84. base,
  85. 10,
  86. cpphibernate_make_id (&base::id),
  87. cpphibernate_make_field (base, name)
  88. ),
  89. cpphibernate_make_table_name(
  90. tbl_derived1,
  91. derived1,
  92. 11,
  93. cpphibernate_make_id (&derived1::derived1_id),
  94. cpphibernate_make_field (derived1, test1_data)
  95. ),
  96. cpphibernate_make_table_name(
  97. tbl_derived2,
  98. derived2,
  99. 12,
  100. cpphibernate_make_id (&derived2::derived2_id),
  101. cpphibernate_make_field (derived2, test2_nullable),
  102. cpphibernate_make_field (derived2, test2_ptr_u),
  103. cpphibernate_make_field (derived2, test2_ptr_s)
  104. ),
  105. cpphibernate_make_table_name(
  106. tbl_derived3,
  107. derived3,
  108. 13,
  109. cpphibernate_make_id (&derived3::derived3_id),
  110. cpphibernate_make_field (derived3, test3_list),
  111. cpphibernate_make_field (derived3, test3_vector)
  112. )
  113. );
  114. TEST(CppHibernateTests, fuuu)
  115. {
  116. std::cout << test_schema << std::endl;
  117. }