blob: 2a570d2e588f26b1f51bcafc138d00a6873659c6 [file] [log] [blame]
Dean Moldovana0c1ccf2016-08-12 13:50:00 +02001
2
3def test_constants():
4 from pybind11_tests import some_constant
5
6 assert some_constant == 14
7
8
Dean Moldovan665e8802016-08-12 22:28:31 +02009def test_function_overloading():
Dean Moldovana9a37b42016-08-13 00:57:24 +020010 from pybind11_tests import MyEnum, test_function
Dean Moldovana0c1ccf2016-08-12 13:50:00 +020011
Dean Moldovan665e8802016-08-12 22:28:31 +020012 assert test_function() == "test_function()"
13 assert test_function(7) == "test_function(7)"
Dean Moldovana9a37b42016-08-13 00:57:24 +020014 assert test_function(MyEnum.EFirstEntry) == "test_function(enum=1)"
15 assert test_function(MyEnum.ESecondEntry) == "test_function(enum=2)"
Dean Moldovana0c1ccf2016-08-12 13:50:00 +020016
Dean Moldovan4e959c92016-12-08 11:07:52 +010017 assert test_function(1, 1.0) == "test_function(int, float)"
18 assert test_function(2.0, 2) == "test_function(float, int)"
19
Dean Moldovana0c1ccf2016-08-12 13:50:00 +020020
Dean Moldovan665e8802016-08-12 22:28:31 +020021def test_bytes():
Dean Moldovana0c1ccf2016-08-12 13:50:00 +020022 from pybind11_tests import return_bytes, print_bytes
23
Dean Moldovan665e8802016-08-12 22:28:31 +020024 assert print_bytes(return_bytes()) == "bytes[1 0 2 0]"
Jason Rhinelander6e036e72016-12-13 20:06:41 -050025
26
27def test_exception_specifiers():
28 from pybind11_tests.exc_sp import C, f1, f2, f3, f4
29
30 c = 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 f1(33) == 34
41 assert f2(53) == 55
42 assert f3(86) == 89
43 assert f4(140) == 144