-
Notifications
You must be signed in to change notification settings - Fork 15
/
test_generate_connectors.py
58 lines (45 loc) · 1.56 KB
/
test_generate_connectors.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
import pytest
import generate_connectors
@pytest.mark.parametrize(['pin_number', 'pin_count', 'rows', 'spacing', 'y'], [
# Special case: 1
(1, 1, 1, 2.54, 0),
# Odd number of pins
(1, 5, 1, 2.54, 5.08),
(2, 5, 1, 2.54, 2.54),
(3, 5, 1, 2.54, 0),
(4, 5, 1, 2.54, -2.54),
(5, 5, 1, 2.54, -5.08),
# Even number of pins, grid align
(1, 4, 1, 1.6, 1.6),
(2, 4, 1, 1.6, 0),
(3, 4, 1, 1.6, -1.6),
(4, 4, 1, 1.6, -3.2),
# Two rows, odd number of cols
(1, 6, 2, 5.0, 5.0),
(2, 6, 2, 5.0, 5.0),
(3, 6, 2, 5.0, 0),
(4, 6, 2, 5.0, 0),
(5, 6, 2, 5.0, -5.0),
(6, 6, 2, 5.0, -5.0),
# Two rows, even number of cols, grid align
(1, 4, 2, 1.0, 0.0),
(2, 4, 2, 1.0, 0.0),
(3, 4, 2, 1.0, -1.0),
(4, 4, 2, 1.0, -1.0),
])
def test_get_y_grid_align(pin_number, pin_count, rows, spacing, y):
result = generate_connectors.get_y(pin_number, pin_count, rows, spacing, True)
assert result == y
@pytest.mark.parametrize(['pin_count', 'rows', 'spacing', 'top', 'grid', 'expected'], [
# Special case: 1
(1, 1, 1.6, 2, True, (2, -2)),
# Odd number of pins
(5, 1, 2.54, 1.5, True, (5.08 + 1.5, -5.08 - 1.5)),
# Even number of pins
(6, 1, 2.54, 1.5, True, (2.54 * 2 + 1.5, -(2.54 * 3) - 1.5)),
# Two rows, odd number of cols
(6, 2, 1.0, 0.3, True, (1.3, -1.3)),
])
def test_get_rectangle_bounds(pin_count, rows, spacing, top, grid, expected):
result = generate_connectors.get_rectangle_bounds(pin_count, rows, spacing, top, grid)
assert result == pytest.approx(expected)