File: test_constants_and_functions.py

package info (click to toggle)
pybind11 2.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,640 kB
  • ctags: 2,200
  • sloc: cpp: 8,259; python: 3,109; ansic: 1,448; makefile: 182; sh: 53
file content (43 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43


def test_constants():
    from pybind11_tests import some_constant

    assert some_constant == 14


def test_function_overloading():
    from pybind11_tests import MyEnum, test_function

    assert test_function() == "test_function()"
    assert test_function(7) == "test_function(7)"
    assert test_function(MyEnum.EFirstEntry) == "test_function(enum=1)"
    assert test_function(MyEnum.ESecondEntry) == "test_function(enum=2)"

    assert test_function(1, 1.0) == "test_function(int, float)"
    assert test_function(2.0, 2) == "test_function(float, int)"


def test_bytes():
    from pybind11_tests import return_bytes, print_bytes

    assert print_bytes(return_bytes()) == "bytes[1 0 2 0]"


def test_exception_specifiers():
    from pybind11_tests.exc_sp import C, f1, f2, f3, f4

    c = C()
    assert c.m1(2) == 1
    assert c.m2(3) == 1
    assert c.m3(5) == 2
    assert c.m4(7) == 3
    assert c.m5(10) == 5
    assert c.m6(14) == 8
    assert c.m7(20) == 13
    assert c.m8(29) == 21

    assert f1(33) == 34
    assert f2(53) == 55
    assert f3(86) == 89
    assert f4(140) == 144