You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

74 line
4.4 KiB

  1. #include <gtest/gtest.h>
  2. #include <cppmp.h>
  3. using namespace ::testing;
  4. using namespace ::cppmp;
  5. struct test_obj
  6. {
  7. int test(int);
  8. double ctest(float, std::string) const;
  9. static std::string sget();
  10. };
  11. const test_obj& static_fuu()
  12. {
  13. static const test_obj value;
  14. return value;
  15. }
  16. decltype(auto) cpp_traits_lambda = [](std::string, int)->bool { return true; };
  17. using type0 = ::cppmp::lambda_traits<decltype(&test_obj::test)>;
  18. using type1 = ::cppmp::lambda_traits<decltype(&test_obj::ctest)>;
  19. using type2 = ::cppmp::lambda_traits<decltype(&test_obj::sget)>;
  20. using type3 = ::cppmp::lambda_traits<std::string(*)(bool)>;
  21. using type4 = ::cppmp::lambda_traits<decltype(cpp_traits_lambda)>;
  22. using type5 = ::cppmp::lambda_traits<decltype(&static_fuu)>;
  23. static_assert(is_same<typename type0::object_type, test_obj>::value, "");
  24. static_assert(is_same<typename type0::return_type, int>::value, "");
  25. static_assert(is_same<typename type0::arguments_type, std::tuple<int>>::value, "");
  26. static_assert( type0::is_mutable_v == true, "");
  27. static_assert( type0::is_static_v == false, "");
  28. static_assert( type0::argument_count_v == 1, "");
  29. static_assert(is_same<typename type1::object_type, const test_obj>::value, "");
  30. static_assert(is_same<typename type1::return_type, double>::value, "");
  31. static_assert(is_same<typename type1::arguments_type, std::tuple<float, std::string>>::value, "");
  32. static_assert( type1::is_mutable_v == false, "");
  33. static_assert( type1::is_static_v == false, "");
  34. static_assert( type1::argument_count_v == 2, "");
  35. static_assert(is_same<typename type2::object_type, void>::value, "");
  36. static_assert(is_same<typename type2::return_type, std::string>::value, "");
  37. static_assert(is_same<typename type2::arguments_type, std::tuple<>>::value, "");
  38. static_assert( type2::is_mutable_v == false, "");
  39. static_assert( type2::is_static_v == true, "");
  40. static_assert( type2::argument_count_v == 0, "");
  41. static_assert(is_same<typename type3::object_type, void>::value, "");
  42. static_assert(is_same<typename type3::return_type, std::string>::value, "");
  43. static_assert(is_same<typename type3::arguments_type, std::tuple<bool>>::value, "");
  44. static_assert( type3::is_mutable_v == false, "");
  45. static_assert( type3::is_static_v == true, "");
  46. static_assert( type3::argument_count_v == 1, "");
  47. static_assert(is_same<typename type4::return_type, bool>::value, "");
  48. static_assert(is_same<typename type4::arguments_type, std::tuple<std::string, int>>::value, "");
  49. static_assert( type4::is_mutable_v == false, "");
  50. static_assert( type4::is_static_v == false, "");
  51. static_assert( type4::argument_count_v == 2, "");
  52. static_assert(is_same<typename type5::return_type, const test_obj&>::value, "");
  53. static_assert(is_same<typename type5::arguments_type, std::tuple<>>::value, "");
  54. static_assert( type5::is_mutable_v == false, "");
  55. static_assert( type5::is_static_v == true, "");
  56. static_assert( type5::argument_count_v == 0, "");
  57. TEST(cppmp_traits_test, dummy)
  58. {
  59. (void)cpp_traits_lambda;
  60. }