test_constants_and_functions.py
Go to the documentation of this file.
1 from __future__ import annotations
2 
3 import pytest
4 
5 m = pytest.importorskip("pybind11_tests.constants_and_functions")
6 
7 
9  assert m.some_constant == 14
10 
11 
13  assert m.test_function() == "test_function()"
14  assert m.test_function(7) == "test_function(7)"
15  assert m.test_function(m.MyEnum.EFirstEntry) == "test_function(enum=1)"
16  assert m.test_function(m.MyEnum.ESecondEntry) == "test_function(enum=2)"
17 
18  assert m.test_function() == "test_function()"
19  assert m.test_function("abcd") == "test_function(char *)"
20  assert m.test_function(1, 1.0) == "test_function(int, float)"
21  assert m.test_function(1, 1.0) == "test_function(int, float)"
22  assert m.test_function(2.0, 2) == "test_function(float, int)"
23 
24 
25 def test_bytes():
26  assert m.print_bytes(m.return_bytes()) == "bytes[1 0 2 0]"
27 
28 
30  c = m.C()
31  assert c.m1(2) == 1
32  assert c.m2(3) == 1
33  assert c.m3(5) == 2
34  assert c.m4(7) == 3
35  assert c.m5(10) == 5
36  assert c.m6(14) == 8
37  assert c.m7(20) == 13
38  assert c.m8(29) == 21
39 
40  assert m.f1(33) == 34
41  assert m.f2(53) == 55
42  assert m.f3(86) == 89
43  assert m.f4(140) == 144
44 
45 
47  class RaisingRepr:
48  def __repr__(self):
49  raise RuntimeError("Surprise!")
50 
51  with pytest.raises(RuntimeError):
52  m.register_large_capture_with_invalid_arguments(m)
53  with pytest.raises(RuntimeError):
54  m.register_with_raising_repr(m, RaisingRepr())
55 
56 
58  assert m.l1() == 0
test_constants_and_functions.test_constants
def test_constants()
Definition: test_constants_and_functions.py:8
test_constants_and_functions.test_bytes
def test_bytes()
Definition: test_constants_and_functions.py:25
test_constants_and_functions.test_function_overloading
def test_function_overloading()
Definition: test_constants_and_functions.py:12
gtwrap.interface_parser.function.__repr__
str __repr__(self)
Definition: interface_parser/function.py:53
test_constants_and_functions.test_function_record_leaks
def test_function_record_leaks()
Definition: test_constants_and_functions.py:46
test_constants_and_functions.test_noexcept_lambda
def test_noexcept_lambda()
Definition: test_constants_and_functions.py:57
test_constants_and_functions.test_exception_specifiers
def test_exception_specifiers()
Definition: test_constants_and_functions.py:29


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:07:05