|
| 1 | +from gpio_expander import _get_registry_params |
| 2 | +import pytest |
| 3 | + |
| 4 | + |
| 5 | +def test_value_16(): |
| 6 | + _, _w, _, _ = _get_registry_params(16, 1) |
| 7 | + assert _w == 2 |
| 8 | + |
| 9 | + |
| 10 | +def test_value_8(): |
| 11 | + _, _w, _, _ = _get_registry_params(8, 1) |
| 12 | + assert _w == 1 |
| 13 | + |
| 14 | + |
| 15 | +@pytest.mark.parametrize( |
| 16 | + "x_input,exp_name,exp_addr_mul,exp_adder,exp_idx", |
| 17 | + [ |
| 18 | + pytest.param(0, "0_", 2, 0, 0, id="input 0"), |
| 19 | + pytest.param(1, "0_", 2, 0, 1, id="input 1"), |
| 20 | + pytest.param(2, "0_", 2, 0, 2, id="input 2"), |
| 21 | + pytest.param(3, "0_", 2, 0, 3, id="input 3"), |
| 22 | + pytest.param(4, "0_", 2, 0, 4, id="input 4"), |
| 23 | + pytest.param(5, "0_", 2, 0, 5, id="input 5"), |
| 24 | + pytest.param(6, "0_", 2, 0, 6, id="input 6"), |
| 25 | + pytest.param(7, "0_", 2, 0, 7, id="input 7"), |
| 26 | +
|
| 27 | + pytest.param(8, "1_", 2, 1, 0, id="input 8"), |
| 28 | + pytest.param(9, "1_", 2, 1, 1, id="input 9"), |
| 29 | + pytest.param(10, "1_", 2, 1, 2, id="input 10"), |
| 30 | + pytest.param(11, "1_", 2, 1, 3, id="input 11"), |
| 31 | + pytest.param(12, "1_", 2, 1, 4, id="input 12"), |
| 32 | + pytest.param(13, "1_", 2, 1, 5, id="input 13"), |
| 33 | + pytest.param(14, "1_", 2, 1, 6, id="input 14"), |
| 34 | + pytest.param(15, "1_", 2, 1, 7, id="input 15") |
| 35 | + ] |
| 36 | +) |
| 37 | +def test_loop_16(x_input, exp_name, exp_addr_mul, exp_adder, exp_idx): |
| 38 | + _name, _reg_address_multiplier, _adder, _idx = _get_registry_params(16, x_input) |
| 39 | + print(_name) |
| 40 | + print(_reg_address_multiplier) |
| 41 | + print(_adder) |
| 42 | + print(_idx) |
| 43 | + assert _name == exp_name |
| 44 | + assert _reg_address_multiplier == exp_addr_mul |
| 45 | + assert _adder == exp_adder |
| 46 | + assert _idx == exp_idx |
| 47 | + |
| 48 | + |
| 49 | +@pytest.mark.parametrize( |
| 50 | + "x_input,exp_name,exp_addr_mul,exp_adder,exp_idx", |
| 51 | + [ |
| 52 | + pytest.param(0, "", 1, 0, 0, id="input 0"), |
| 53 | + pytest.param(1, "", 1, 0, 1, id="input 1"), |
| 54 | + pytest.param(2, "", 1, 0, 2, id="input 2"), |
| 55 | + pytest.param(3, "", 1, 0, 3, id="input 3"), |
| 56 | + pytest.param(4, "", 1, 0, 4, id="input 4"), |
| 57 | + pytest.param(5, "", 1, 0, 5, id="input 5"), |
| 58 | + pytest.param(6, "", 1, 0, 6, id="input 6"), |
| 59 | + pytest.param(7, "", 1, 0, 7, id="input 7"), |
| 60 | + ] |
| 61 | +) |
| 62 | +def test_loop_8(x_input, exp_name, exp_addr_mul, exp_adder, exp_idx): |
| 63 | + _name, _reg_address_multiplier, _adder, _idx = _get_registry_params(8, x_input) |
| 64 | + print(_name) |
| 65 | + print(_reg_address_multiplier) |
| 66 | + print(_adder) |
| 67 | + print(_idx) |
| 68 | + assert _name == exp_name |
| 69 | + assert _reg_address_multiplier == exp_addr_mul |
| 70 | + assert _adder == exp_adder |
| 71 | + assert _idx == exp_idx |
0 commit comments