|
3 | 3 |
|
4 | 4 | def test_pair_set(): |
5 | 5 | ps = PairSet() |
| 6 | + are_mutually_exclusive = True |
6 | 7 |
|
7 | | - ps.add(1, 2) |
8 | | - ps.add(2, 4) |
| 8 | + ps.add(1, 2, are_mutually_exclusive) |
| 9 | + ps.add(2, 4, are_mutually_exclusive) |
9 | 10 |
|
10 | | - assert ps.has(1, 2) |
11 | | - assert ps.has(2, 1) |
12 | | - assert (1, 2) in ps |
13 | | - assert (2, 1) in ps |
14 | | - assert ps.has(4, 2) |
15 | | - assert ps.has(2, 4) |
| 11 | + assert ps.has(1, 2, are_mutually_exclusive) |
| 12 | + assert ps.has(2, 1, are_mutually_exclusive) |
| 13 | + assert not ps.has(1, 2, not are_mutually_exclusive) |
| 14 | + assert not ps.has(2, 1, not are_mutually_exclusive) |
16 | 15 |
|
17 | | - assert not ps.has(2, 3) |
18 | | - assert not ps.has(1, 3) |
| 16 | + assert (1, 2, are_mutually_exclusive) in ps |
| 17 | + assert (2, 1, are_mutually_exclusive) in ps |
| 18 | + assert (1, 2, (not are_mutually_exclusive)) not in ps |
| 19 | + assert (2, 1, (not are_mutually_exclusive)) not in ps |
19 | 20 |
|
20 | | - ps.remove(1, 2) |
21 | | - assert not ps.has(1, 2) |
22 | | - assert not ps.has(2, 1) |
23 | | - assert (1, 2) not in ps |
24 | | - assert (2, 1) not in ps |
| 21 | + assert ps.has(4, 2, are_mutually_exclusive) |
| 22 | + assert ps.has(2, 4, are_mutually_exclusive) |
25 | 23 |
|
26 | | - assert ps.has(4, 2) |
27 | | - assert ps.has(2, 4) |
| 24 | + assert not ps.has(2, 3, are_mutually_exclusive) |
| 25 | + assert not ps.has(1, 3, are_mutually_exclusive) |
| 26 | + |
| 27 | + assert ps.has(4, 2, are_mutually_exclusive) |
| 28 | + assert ps.has(2, 4, are_mutually_exclusive) |
| 29 | + |
| 30 | + |
| 31 | +def test_pair_set_not_mutually_exclusive(): |
| 32 | + ps = PairSet() |
| 33 | + are_mutually_exclusive = False |
| 34 | + |
| 35 | + ps.add(1, 2, are_mutually_exclusive) |
| 36 | + |
| 37 | + assert ps.has(1, 2, are_mutually_exclusive) |
| 38 | + assert ps.has(2, 1, are_mutually_exclusive) |
| 39 | + |
| 40 | + assert ps.has(1, 2, not are_mutually_exclusive) |
| 41 | + assert ps.has(2, 1, not are_mutually_exclusive) |
0 commit comments