test_const_name.cpp
Go to the documentation of this file.
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 
42 
43 #ifdef PYBIND11_DETAIL_UNDERSCORE_BACKWARD_COMPATIBILITY
44 CONST_NAME_TESTS(underscore_tests, py::detail::_)
45 #endif
46 
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 }
CONST_NAME_TESTS
#define CONST_NAME_TESTS(TEST_FUNC, IUT)
Definition: test_const_name.cpp:8
const_name
constexpr descr< N - 1 > const_name(char const (&text)[N])
Definition: descr.h:60
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
pybind11_tests.h
TEST_SUBMODULE
TEST_SUBMODULE(const_name, m)
Definition: test_const_name.cpp:47
_
constexpr descr< N - 1 > _(char const (&text)[N])
Definition: descr.h:109


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:39:26