-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefault-arguments_test.py
67 lines (57 loc) · 1.6 KB
/
default-arguments_test.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# SPDX-FileCopyrightText: 2024 Johann Klähn <johann@jklaehn.de>
#
# SPDX-License-Identifier: MIT
import default_arguments as m
import pytest
EXPECTED = {
1: 123,
2: None,
3: 3,
4: 4,
5: 1234,
6: 1234,
7: 456,
8: 456,
9: 456,
10: 456,
11: 0,
12: 0,
13: 5,
14: 5,
15: 1234,
16: 6,
17: 123,
18: 123,
19: 123,
20: 123,
21: 123,
22: 123,
23: 123,
24: 123,
25: 123,
}
@pytest.mark.parametrize("index", EXPECTED.keys())
def test_function_can_be_called_without_arguments(index):
if index == max(EXPECTED.keys()):
assert not hasattr(m, f"function_{index + 1:02}")
if index == 15:
# TODO: Investigate pointer default arguments
# (`munmap_chunk(): invalid pointer`)
pytest.xfail("pointer default argument is broken")
if index == 24:
# TODO: Investigate reference template parameter
# (gets expanded to `Reference<&nested::global_a>`)
pytest.xfail("reference template parameter is broken")
name = f"function_{index:02}"
function = getattr(m, name)
assert function() == EXPECTED[index]
def test_template_functions_can_be_called_without_arguments():
for index in range(1, 6):
name = f"template_function_{index:02}"
function = getattr(m, name)
assert function() == 123
assert not hasattr(m, f"template_function_{index + 1:02}")
def test_member_function_of_template_can_be_called_without_arguments():
assert m.Template_Example_().member_function() == 123
def test_not_all_parameters_need_to_have_default_values():
pass