Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 68 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { XorTruthTable } from '../../src/TruthTable.mjs'; |
||
2 | |||
3 | const TestCasesResult = [ |
||
4 | { |
||
5 | description: '1 proposition', |
||
6 | input: 1, |
||
7 | expectedResult: [ |
||
8 | false, // 0 |
||
9 | true, // 1 |
||
10 | ], |
||
11 | }, |
||
12 | { |
||
13 | description: '2 propositions', |
||
14 | input: 2, |
||
15 | expectedResult: [ |
||
16 | false, // 00 |
||
17 | true, // 01 |
||
18 | true, // 10 |
||
19 | false, // 11 |
||
20 | ], |
||
21 | }, |
||
22 | { |
||
23 | description: '3 propositions', |
||
24 | input: 3, |
||
25 | expectedResult: [ |
||
26 | false, // 000 |
||
27 | true, // 001 |
||
28 | true, // 010 |
||
29 | false, // 011 |
||
30 | true, // 100 |
||
31 | false, // 101 |
||
32 | false, // 110 |
||
33 | true, // 111 |
||
34 | ], |
||
35 | }, |
||
36 | { |
||
37 | description: '4 propositions', |
||
38 | input: 4, |
||
39 | expectedResult: [ |
||
40 | false, // 0000 |
||
41 | true, // 0001 |
||
42 | true, // 0010 |
||
43 | false, // 0011 |
||
44 | true, // 0100 |
||
45 | false, // 0101 |
||
46 | false, // 0110 |
||
47 | true, // 0111 |
||
48 | true, // 1000 |
||
49 | false, // 1001 |
||
50 | false, // 1010 |
||
51 | true, // 1011 |
||
52 | false, // 1100 |
||
53 | true, // 1101 |
||
54 | true, // 1110 |
||
55 | false, // 1111 |
||
56 | ], |
||
57 | }, |
||
58 | ]; |
||
59 | |||
60 | describe.each(TestCasesResult)( |
||
61 | 'Test xor', |
||
62 | ({ description, input, expectedResult }) => { |
||
63 | it(description, () => { |
||
64 | const table = XorTruthTable.create(input); |
||
65 | expect(table.output).toMatchObject(expectedResult); |
||
66 | }); |
||
67 | } |
||
68 | ); |
||
69 |