1from pybind11_tests import constants_and_functions as m 2 3 4def test_constants(): 5 assert m.some_constant == 14 6 7 8def test_function_overloading(): 9 assert m.test_function() == "test_function()" 10 assert m.test_function(7) == "test_function(7)" 11 assert m.test_function(m.MyEnum.EFirstEntry) == "test_function(enum=1)" 12 assert m.test_function(m.MyEnum.ESecondEntry) == "test_function(enum=2)" 13 14 assert m.test_function() == "test_function()" 15 assert m.test_function("abcd") == "test_function(char *)" 16 assert m.test_function(1, 1.0) == "test_function(int, float)" 17 assert m.test_function(1, 1.0) == "test_function(int, float)" 18 assert m.test_function(2.0, 2) == "test_function(float, int)" 19 20 21def test_bytes(): 22 assert m.print_bytes(m.return_bytes()) == "bytes[1 0 2 0]" 23 24 25def test_exception_specifiers(): 26 c = m.C() 27 assert c.m1(2) == 1 28 assert c.m2(3) == 1 29 assert c.m3(5) == 2 30 assert c.m4(7) == 3 31 assert c.m5(10) == 5 32 assert c.m6(14) == 8 33 assert c.m7(20) == 13 34 assert c.m8(29) == 21 35 36 assert m.f1(33) == 34 37 assert m.f2(53) == 55 38 assert m.f3(86) == 89 39 assert m.f4(140) == 144 40