You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

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