github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/pybind11/tests/test_const_name.cpp (about)

     1  // Copyright (c) 2021 The Pybind Development Team.
     2  // All rights reserved. Use of this source code is governed by a
     3  // BSD-style license that can be found in the LICENSE file.
     4  
     5  #include "pybind11_tests.h"
     6  
     7  // IUT = Implementation Under Test
     8  #define CONST_NAME_TESTS(TEST_FUNC, IUT)                                                          \
     9      std::string TEST_FUNC(int selector) {                                                         \
    10          switch (selector) {                                                                       \
    11              case 0:                                                                               \
    12                  return IUT("").text;                                                              \
    13              case 1:                                                                               \
    14                  return IUT("A").text;                                                             \
    15              case 2:                                                                               \
    16                  return IUT("Bd").text;                                                            \
    17              case 3:                                                                               \
    18                  return IUT("Cef").text;                                                           \
    19              case 4:                                                                               \
    20                  return IUT<int>().text; /*NOLINT(bugprone-macro-parentheses)*/                    \
    21              case 5:                                                                               \
    22                  return IUT<std::string>().text; /*NOLINT(bugprone-macro-parentheses)*/            \
    23              case 6:                                                                               \
    24                  return IUT<true>("T1", "T2").text; /*NOLINT(bugprone-macro-parentheses)*/         \
    25              case 7:                                                                               \
    26                  return IUT<false>("U1", "U2").text; /*NOLINT(bugprone-macro-parentheses)*/        \
    27              case 8:                                                                               \
    28                  /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/                                    \
    29                  return IUT<true>(IUT("D1"), IUT("D2")).text;                                      \
    30              case 9:                                                                               \
    31                  /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/                                    \
    32                  return IUT<false>(IUT("E1"), IUT("E2")).text;                                     \
    33              case 10:                                                                              \
    34                  return IUT("KeepAtEnd").text;                                                     \
    35              default:                                                                              \
    36                  break;                                                                            \
    37          }                                                                                         \
    38          throw std::runtime_error("Invalid selector value.");                                      \
    39      }
    40  
    41  CONST_NAME_TESTS(const_name_tests, py::detail::const_name)
    42  
    43  #ifdef PYBIND11_DETAIL_UNDERSCORE_BACKWARD_COMPATIBILITY
    44  CONST_NAME_TESTS(underscore_tests, py::detail::_)
    45  #endif
    46  
    47  TEST_SUBMODULE(const_name, m) {
    48      m.def("const_name_tests", const_name_tests);
    49  
    50  #if defined(PYBIND11_DETAIL_UNDERSCORE_BACKWARD_COMPATIBILITY)
    51      m.def("underscore_tests", underscore_tests);
    52  #else
    53      m.attr("underscore_tests") = "PYBIND11_DETAIL_UNDERSCORE_BACKWARD_COMPATIBILITY not defined.";
    54  #endif
    55  }