File indexing completed on 2025-01-18 10:17:52
0001
0002
0003
0004
0005 #include "pybind11_tests.h"
0006
0007
0008 #define CONST_NAME_TESTS(TEST_FUNC, IUT) \
0009 std::string TEST_FUNC(int selector) { \
0010 switch (selector) { \
0011 case 0: \
0012 return IUT("").text; \
0013 case 1: \
0014 return IUT("A").text; \
0015 case 2: \
0016 return IUT("Bd").text; \
0017 case 3: \
0018 return IUT("Cef").text; \
0019 case 4: \
0020 return IUT<int>().text; \
0021 case 5: \
0022 return IUT<std::string>().text; \
0023 case 6: \
0024 return IUT<true>("T1", "T2").text; \
0025 case 7: \
0026 return IUT<false>("U1", "U2").text; \
0027 case 8: \
0028 \
0029 return IUT<true>(IUT("D1"), IUT("D2")).text; \
0030 case 9: \
0031 \
0032 return IUT<false>(IUT("E1"), IUT("E2")).text; \
0033 case 10: \
0034 return IUT("KeepAtEnd").text; \
0035 default: \
0036 break; \
0037 } \
0038 throw std::runtime_error("Invalid selector value."); \
0039 }
0040
0041 CONST_NAME_TESTS(const_name_tests, py::detail::const_name)
0042
0043 #ifdef PYBIND11_DETAIL_UNDERSCORE_BACKWARD_COMPATIBILITY
0044 CONST_NAME_TESTS(underscore_tests, py::detail::_)
0045 #endif
0046
0047 TEST_SUBMODULE(const_name, m) {
0048 m.def("const_name_tests", const_name_tests);
0049
0050 #if defined(PYBIND11_DETAIL_UNDERSCORE_BACKWARD_COMPATIBILITY)
0051 m.def("underscore_tests", underscore_tests);
0052 #else
0053 m.attr("underscore_tests") = "PYBIND11_DETAIL_UNDERSCORE_BACKWARD_COMPATIBILITY not defined.";
0054 #endif
0055 }