3-phase PV router
Loading...
Searching...
No Matches
test_main.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
9
10#include <unity.h>
11
12#include "utils_override.h" // Real header - pure C++
13
14void setUp(void) {}
15void tearDown(void) {}
16
17// ============================================================================
18// Tests for indicesToBitmask<>()
19// ============================================================================
20
22{
23 TEST_ASSERT_EQUAL(1U << 5, indicesToBitmask< 5 >());
24 TEST_ASSERT_EQUAL(1U << 0, indicesToBitmask< 0 >());
25 TEST_ASSERT_EQUAL(1U << 15, indicesToBitmask< 15 >());
26}
27
29{
30 constexpr uint16_t mask = indicesToBitmask< 2, 4, 7 >();
31 TEST_ASSERT_EQUAL((1U << 2) | (1U << 4) | (1U << 7), mask);
32}
33
35{
36 constexpr uint16_t mask = indicesToBitmask< 3, 4, 5, 6 >();
37 TEST_ASSERT_EQUAL(0b01111000, mask);
38}
39
41{
43 TEST_ASSERT_EQUAL(0xFFFF, mask);
44}
45
46// ============================================================================
47// Tests for are_pins_valid<>()
48// ============================================================================
49
51{
52 TEST_ASSERT_TRUE((are_pins_valid< 2, 7, 10, 13 >()));
53 TEST_ASSERT_TRUE((are_pins_valid< 2 >()));
54 TEST_ASSERT_TRUE((are_pins_valid< 13 >()));
56}
57
59{
60 TEST_ASSERT_FALSE((are_pins_valid< 0 >()));
61 TEST_ASSERT_FALSE((are_pins_valid< 0, 5 >()));
62}
63
65{
66 TEST_ASSERT_FALSE((are_pins_valid< 1 >()));
67 TEST_ASSERT_FALSE((are_pins_valid< 1, 5 >()));
68}
69
71{
72 TEST_ASSERT_FALSE((are_pins_valid< 14 >()));
73 TEST_ASSERT_FALSE((are_pins_valid< 15 >()));
74 TEST_ASSERT_FALSE((are_pins_valid< 5, 14 >()));
75}
76
77// ============================================================================
78// Tests for PinList
79// ============================================================================
80
82{
83 constexpr PinList< 4 > list{};
84 TEST_ASSERT_EQUAL(0, list.count);
85 TEST_ASSERT_EQUAL(0, list.toLocalBitmask());
86}
87
89{
90 constexpr PinList< 4 > list{ 3, 6, 9 };
91 TEST_ASSERT_EQUAL(3, list.count);
92 TEST_ASSERT_EQUAL(3, list.pins[0]);
93 TEST_ASSERT_EQUAL(6, list.pins[1]);
94 TEST_ASSERT_EQUAL(9, list.pins[2]);
95}
96
98{
99 constexpr PinList< 4 > list{ 7 };
100 TEST_ASSERT_EQUAL(1, list.count);
101 TEST_ASSERT_EQUAL(7, list.pins[0]);
102 TEST_ASSERT_EQUAL(1U << 7, list.toLocalBitmask());
103}
104
106{
107 constexpr PinList< 4 > list{ 2, 5, 8, 11 };
108 TEST_ASSERT_EQUAL(4, list.count);
109 TEST_ASSERT_EQUAL((1U << 2) | (1U << 5) | (1U << 8) | (1U << 11), list.toLocalBitmask());
110}
111
113{
114 constexpr PinList< 4 > list{ 2, 5, 8 };
115 constexpr uint16_t expected = (1U << 2) | (1U << 5) | (1U << 8);
116 TEST_ASSERT_EQUAL(expected, list.toLocalBitmask());
117}
118
120{
121 constexpr PinList< 8 > list{ static_cast< uint16_t >(0b10100100) }; // pins 2, 5, 7
122 TEST_ASSERT_EQUAL(3, list.count);
123 TEST_ASSERT_EQUAL(2, list.pins[0]);
124 TEST_ASSERT_EQUAL(5, list.pins[1]);
125 TEST_ASSERT_EQUAL(7, list.pins[2]);
126 TEST_ASSERT_EQUAL(0b10100100, list.toLocalBitmask());
127}
128
130{
131 constexpr PinList< 4 > list{ static_cast< uint16_t >(0) };
132 TEST_ASSERT_EQUAL(0, list.count);
133 TEST_ASSERT_EQUAL(0, list.toLocalBitmask());
134}
135
137{
138 constexpr PinList< 16 > list{ static_cast< uint16_t >(0xFFFF) };
139 TEST_ASSERT_EQUAL(16, list.count);
140 TEST_ASSERT_EQUAL(0xFFFF, list.toLocalBitmask());
141}
142
143// ============================================================================
144// Tests for KeyIndexPair
145// ============================================================================
146
148{
149 constexpr PinList< 4 > list{ 4, 5, 6 };
150 constexpr KeyIndexPair< 4 > pair{ 2, list };
151
152 TEST_ASSERT_EQUAL(2, pair.pin);
153}
154
156{
157 constexpr PinList< 4 > list{ 4, 5, 6 };
158 constexpr KeyIndexPair< 4 > pair{ 2, list };
159
160 TEST_ASSERT_EQUAL((1U << 4) | (1U << 5) | (1U << 6), pair.getLocalBitmask());
161}
162
164{
165 constexpr KeyIndexPair< 4 > pair{ 10, PinList< 4 >{ 7 } };
166 TEST_ASSERT_EQUAL(10, pair.pin);
167 TEST_ASSERT_EQUAL(1U << 7, pair.getLocalBitmask());
168}
169
171{
172 constexpr KeyIndexPair< 8 > pair{ 3, PinList< 8 >{ static_cast< uint16_t >(0b11110000) } };
173 TEST_ASSERT_EQUAL(3, pair.pin);
174 TEST_ASSERT_EQUAL(0b11110000, pair.getLocalBitmask());
175}
176
177// ============================================================================
178// Tests for OverrideTable
179// ============================================================================
180
182{
183 constexpr OverrideTable pins{
184 { KeyIndexPair< 4 >{ 9, { 2, 3, 4 } } }
185 };
186
187 TEST_ASSERT_EQUAL(1, pins.size());
188 TEST_ASSERT_EQUAL(9, pins.getPin(0));
189 TEST_ASSERT_EQUAL((1U << 2) | (1U << 3) | (1U << 4), pins.getLocalBitmask(0));
190}
191
193{
194 constexpr OverrideTable pins{
195 { KeyIndexPair< 4 >{ 2, { 4, 5 } },
196 KeyIndexPair< 4 >{ 3, { 6, 7 } } }
197 };
198
199 TEST_ASSERT_EQUAL(2, pins.size());
200 TEST_ASSERT_EQUAL(2, pins.getPin(0));
201 TEST_ASSERT_EQUAL(3, pins.getPin(1));
202 TEST_ASSERT_EQUAL((1U << 4) | (1U << 5), pins.getLocalBitmask(0));
203 TEST_ASSERT_EQUAL((1U << 6) | (1U << 7), pins.getLocalBitmask(1));
204}
205
207{
208 constexpr OverrideTable pins{
209 { KeyIndexPair< 4 >{ 10, { 4, 5 } } }
210 };
211
212 TEST_ASSERT_EQUAL(0, pins.getPin(1));
213 TEST_ASSERT_EQUAL(0, pins.getPin(99));
214}
215
217{
218 constexpr OverrideTable pins{
219 { KeyIndexPair< 4 >{ 10, { 4, 5 } } }
220 };
221
222 TEST_ASSERT_EQUAL(0, pins.getLocalBitmask(1));
223 TEST_ASSERT_EQUAL(0, pins.getLocalBitmask(99));
224}
225
227{
228 constexpr OverrideTable pins{
229 { KeyIndexPair< 4 >{ 10, { 4, 5 } },
230 KeyIndexPair< 4 >{ 11, { 6, 7 } },
231 KeyIndexPair< 4 >{ 12, { 8, 9 } } }
232 };
233
234 TEST_ASSERT_EQUAL((1U << 4) | (1U << 5), pins.findLocalBitmask(10));
235 TEST_ASSERT_EQUAL((1U << 6) | (1U << 7), pins.findLocalBitmask(11));
236 TEST_ASSERT_EQUAL((1U << 8) | (1U << 9), pins.findLocalBitmask(12));
237}
238
240{
241 constexpr OverrideTable pins{
242 { KeyIndexPair< 4 >{ 10, { 4, 5 } } }
243 };
244
245 TEST_ASSERT_EQUAL(0, pins.findLocalBitmask(99));
246 TEST_ASSERT_EQUAL(0, pins.findLocalBitmask(0));
247}
248
250{
251 // Use bitmask to specify pins: 0b11100 = pins 2, 3, 4
252 constexpr OverrideTable pins{
253 { KeyIndexPair< 8 >{ 5, static_cast< uint16_t >(0b11100) } }
254 };
255
256 TEST_ASSERT_EQUAL(5, pins.getPin(0));
257 TEST_ASSERT_EQUAL(0b11100, pins.getLocalBitmask(0));
258}
259
261{
262 constexpr OverrideTable pins{
263 { KeyIndexPair< 2 >{ 2, { 5, 6 } },
264 KeyIndexPair< 2 >{ 3, { 7, 8 } },
265 KeyIndexPair< 2 >{ 4, { 9, 10 } },
266 KeyIndexPair< 2 >{ 5, { 11, 12 } } }
267 };
268
269 TEST_ASSERT_EQUAL(4, pins.size());
270 TEST_ASSERT_EQUAL((1U << 11) | (1U << 12), pins.findLocalBitmask(5));
271}
272
273// ============================================================================
274// Tests for Remote Load Support (REMOTE_PIN_BASE = 128)
275// ============================================================================
276
277// Helper macro for remote load pins
278#define REMOTE_LOAD(n) (REMOTE_PIN_BASE + (n))
279
281{
282 constexpr PinList< 4 > list{};
283 TEST_ASSERT_EQUAL(0, list.toRemoteBitmask());
284}
285
287{
288 // Local pins should not appear in remote bitmask
289 constexpr PinList< 4 > list{ 2, 5, 8 };
290 TEST_ASSERT_EQUAL(0, list.toRemoteBitmask());
291}
292
294{
295 constexpr PinList< 4 > list{ REMOTE_LOAD(0) }; // Remote load 0 = pin 128
296 TEST_ASSERT_EQUAL(1U << 0, list.toRemoteBitmask());
297}
298
300{
301 constexpr PinList< 4 > list{ REMOTE_LOAD(0), REMOTE_LOAD(2), REMOTE_LOAD(5) };
302 TEST_ASSERT_EQUAL((1U << 0) | (1U << 2) | (1U << 5), list.toRemoteBitmask());
303}
304
306{
307 // Mix of local (5, 8) and remote (0, 3) pins
308 constexpr PinList< 6 > list{ 5, REMOTE_LOAD(0), 8, REMOTE_LOAD(3) };
309 TEST_ASSERT_EQUAL((1U << 5) | (1U << 8), list.toLocalBitmask());
310 TEST_ASSERT_EQUAL((1U << 0) | (1U << 3), list.toRemoteBitmask());
311}
312
314{
315 // Lower 16 bits only (local pins 2, 5, 7)
316 constexpr uint32_t bitmask = 0b10100100;
317 constexpr PinList< 8 > list{ bitmask };
318 TEST_ASSERT_EQUAL(3, list.count);
319 TEST_ASSERT_EQUAL(0b10100100, list.toLocalBitmask());
320 TEST_ASSERT_EQUAL(0, list.toRemoteBitmask());
321}
322
324{
325 // Upper 16 bits only (remote loads 0, 2, 4)
326 constexpr uint32_t bitmask = (1UL << 16) | (1UL << 18) | (1UL << 20);
327 constexpr PinList< 8 > list{ bitmask };
328 TEST_ASSERT_EQUAL(3, list.count);
329 TEST_ASSERT_EQUAL(0, list.toLocalBitmask());
330 TEST_ASSERT_EQUAL((1U << 0) | (1U << 2) | (1U << 4), list.toRemoteBitmask());
331}
332
334{
335 // Local pins 4, 6 + Remote loads 1, 3
336 constexpr uint32_t bitmask = (1UL << 4) | (1UL << 6) | (1UL << 17) | (1UL << 19);
337 constexpr PinList< 8 > list{ bitmask };
338 TEST_ASSERT_EQUAL(4, list.count);
339 TEST_ASSERT_EQUAL((1U << 4) | (1U << 6), list.toLocalBitmask());
340 TEST_ASSERT_EQUAL((1U << 1) | (1U << 3), list.toRemoteBitmask());
341}
342
343// ============================================================================
344// Tests for KeyIndexPair with Remote Loads
345// ============================================================================
346
348{
349 constexpr PinList< 4 > list{ 4, 5, 6 }; // Local only
350 constexpr KeyIndexPair< 4 > pair{ 2, list };
351 TEST_ASSERT_EQUAL(0, pair.getRemoteBitmask());
352}
353
355{
356 constexpr PinList< 4 > list{ REMOTE_LOAD(0), REMOTE_LOAD(2) };
357 constexpr KeyIndexPair< 4 > pair{ 5, list };
358 TEST_ASSERT_EQUAL(0, pair.getLocalBitmask());
359 TEST_ASSERT_EQUAL((1U << 0) | (1U << 2), pair.getRemoteBitmask());
360}
361
363{
364 constexpr PinList< 6 > list{ 4, 5, REMOTE_LOAD(1), REMOTE_LOAD(3) };
365 constexpr KeyIndexPair< 6 > pair{ 10, list };
366 TEST_ASSERT_EQUAL((1U << 4) | (1U << 5), pair.getLocalBitmask());
367 TEST_ASSERT_EQUAL((1U << 1) | (1U << 3), pair.getRemoteBitmask());
368}
369
370// ============================================================================
371// Tests for OverrideTable with Remote Loads
372// ============================================================================
373
375{
376 constexpr OverrideTable pins{
377 { KeyIndexPair< 4 >{ 9, { 2, 3, 4 } } }
378 };
379 TEST_ASSERT_EQUAL(0, pins.getRemoteBitmask(0));
380}
381
383{
384 constexpr OverrideTable pins{
385 { KeyIndexPair< 4 >{ 9, { REMOTE_LOAD(0), REMOTE_LOAD(2) } } }
386 };
387 TEST_ASSERT_EQUAL(0, pins.getLocalBitmask(0));
388 TEST_ASSERT_EQUAL((1U << 0) | (1U << 2), pins.getRemoteBitmask(0));
389}
390
392{
393 constexpr OverrideTable pins{
394 { KeyIndexPair< 6 >{ 9, { 4, 5, REMOTE_LOAD(1), REMOTE_LOAD(3) } } }
395 };
396 TEST_ASSERT_EQUAL((1U << 4) | (1U << 5), pins.getLocalBitmask(0));
397 TEST_ASSERT_EQUAL((1U << 1) | (1U << 3), pins.getRemoteBitmask(0));
398}
399
401{
402 constexpr OverrideTable pins{
403 { KeyIndexPair< 4 >{ 10, { REMOTE_LOAD(2) } } }
404 };
405 TEST_ASSERT_EQUAL(0, pins.getRemoteBitmask(1));
406 TEST_ASSERT_EQUAL(0, pins.getRemoteBitmask(99));
407}
408
410{
411 constexpr OverrideTable pins{
412 { KeyIndexPair< 4 >{ 10, { REMOTE_LOAD(0), REMOTE_LOAD(1) } },
413 KeyIndexPair< 4 >{ 11, { REMOTE_LOAD(2), REMOTE_LOAD(3) } },
414 KeyIndexPair< 4 >{ 12, { REMOTE_LOAD(4), REMOTE_LOAD(5) } } }
415 };
416 TEST_ASSERT_EQUAL((1U << 0) | (1U << 1), pins.findRemoteBitmask(10));
417 TEST_ASSERT_EQUAL((1U << 2) | (1U << 3), pins.findRemoteBitmask(11));
418 TEST_ASSERT_EQUAL((1U << 4) | (1U << 5), pins.findRemoteBitmask(12));
419}
420
422{
423 constexpr OverrideTable pins{
424 { KeyIndexPair< 4 >{ 10, { REMOTE_LOAD(0) } } }
425 };
426 TEST_ASSERT_EQUAL(0, pins.findRemoteBitmask(99));
427 TEST_ASSERT_EQUAL(0, pins.findRemoteBitmask(0));
428}
429
431{
432 // Real-world scenario: some override pins control local loads, some control remote
433 constexpr OverrideTable pins{
434 { KeyIndexPair< 6 >{ 2, { 4, 5 } }, // Local only
435 KeyIndexPair< 6 >{ 3, { REMOTE_LOAD(0), REMOTE_LOAD(1) } }, // Remote only
436 KeyIndexPair< 6 >{ 4, { 6, 7, REMOTE_LOAD(2) } } } // Mixed
437 };
438
439 TEST_ASSERT_EQUAL(3, pins.size());
440
441 // Entry 0: local only
442 TEST_ASSERT_EQUAL((1U << 4) | (1U << 5), pins.getLocalBitmask(0));
443 TEST_ASSERT_EQUAL(0, pins.getRemoteBitmask(0));
444
445 // Entry 1: remote only
446 TEST_ASSERT_EQUAL(0, pins.getLocalBitmask(1));
447 TEST_ASSERT_EQUAL((1U << 0) | (1U << 1), pins.getRemoteBitmask(1));
448
449 // Entry 2: mixed
450 TEST_ASSERT_EQUAL((1U << 6) | (1U << 7), pins.getLocalBitmask(2));
451 TEST_ASSERT_EQUAL(1U << 2, pins.getRemoteBitmask(2));
452
453 // Find by pin
454 TEST_ASSERT_EQUAL((1U << 4) | (1U << 5), pins.findLocalBitmask(2));
455 TEST_ASSERT_EQUAL(0, pins.findRemoteBitmask(2));
456 TEST_ASSERT_EQUAL(0, pins.findLocalBitmask(3));
457 TEST_ASSERT_EQUAL((1U << 0) | (1U << 1), pins.findRemoteBitmask(3));
458}
459
460// ============================================================================
461// Main
462// ============================================================================
463
464// ============================================================================
465// Tests for TargetMap: the codes of config.h turned into pins
466// ============================================================================
467
468namespace
469{
470// load 0 on D5, load 1 remote (the first remote load), load 2 on D6, load 3 remote (the second)
471constexpr uint8_t loadMap[]{ Load::local(5), Load::remote(1), Load::local(6), Load::remote(2) };
472constexpr RelaySetting relaySettings[]{ { 8 }, { 9, 500, 100, 5, 5 } };
473constexpr RelayEngine relays{ relaySettings };
474constexpr TargetMap withRelays{ loadMap, relays, true };
475constexpr TargetMap withoutRelays{ loadMap, relays, false };
476} // namespace
477
479{
480 TEST_ASSERT_EQUAL(5, withRelays.pinOf(LOAD(0)));
481 TEST_ASSERT_EQUAL(REMOTE_PIN_BASE + 0, withRelays.pinOf(LOAD(1)));
482 TEST_ASSERT_EQUAL(6, withRelays.pinOf(LOAD(2)));
483 TEST_ASSERT_EQUAL(REMOTE_PIN_BASE + 1, withRelays.pinOf(LOAD(3)));
484 TEST_ASSERT_EQUAL(6, withRelays.pinOf(LOCAL_LOAD(2)));
485}
486
488{
489 // pin 0 is no output: validation.h reports it
490 TEST_ASSERT_EQUAL(0, withRelays.pinOf(LOAD(4))); // 4 loads
491 TEST_ASSERT_EQUAL(0, withRelays.pinOf(LOAD(32))); // LOAD() itself gives 0 from 32 on
492 TEST_ASSERT_EQUAL(0, withRelays.pinOf(LOCAL_LOAD(4))); // 4 loads
493 TEST_ASSERT_EQUAL(0, withRelays.pinOf(RELAY(2))); // 2 relays
494}
495
497{
498 TEST_ASSERT_EQUAL(8, withRelays.pinOf(RELAY(0)));
499 TEST_ASSERT_EQUAL(9, withRelays.pinOf(RELAY(1)));
500 TEST_ASSERT_EQUAL(0, withoutRelays.pinOf(RELAY(0)));
501}
502
504{
505 TEST_ASSERT_EQUAL(7, withRelays.pinOf(7));
506 TEST_ASSERT_EQUAL(REMOTE_PIN_BASE + 2, withRelays.pinOf(REMOTE_LOAD(2)));
507}
508
510{
511 TEST_ASSERT_EQUAL_HEX16((1U << 5) | (1U << 6), withRelays.localBitmask(PinList< 1 >{ ALL_LOCAL_LOADS() }));
512 TEST_ASSERT_EQUAL_HEX8(0, withRelays.remoteBitmask(PinList< 1 >{ ALL_LOCAL_LOADS() }));
513
514 TEST_ASSERT_EQUAL_HEX16(0, withRelays.localBitmask(PinList< 1 >{ ALL_REMOTE_LOADS() }));
515 TEST_ASSERT_EQUAL_HEX8(0b11, withRelays.remoteBitmask(PinList< 1 >{ ALL_REMOTE_LOADS() }));
516
517 TEST_ASSERT_EQUAL_HEX16((1U << 5) | (1U << 6), withRelays.localBitmask(PinList< 1 >{ ALL_LOADS() }));
518 TEST_ASSERT_EQUAL_HEX8(0b11, withRelays.remoteBitmask(PinList< 1 >{ ALL_LOADS() }));
519
520 TEST_ASSERT_EQUAL_HEX16((1U << 8) | (1U << 9), withRelays.localBitmask(PinList< 1 >{ ALL_RELAYS() }));
521 TEST_ASSERT_EQUAL_HEX16(0, withoutRelays.localBitmask(PinList< 1 >{ ALL_RELAYS() }));
522
523 TEST_ASSERT_EQUAL_HEX16((1U << 5) | (1U << 6) | (1U << 8) | (1U << 9), withRelays.localBitmask(PinList< 1 >{ ALL_LOADS_AND_RELAYS() }));
524 TEST_ASSERT_EQUAL_HEX8(0b11, withRelays.remoteBitmask(PinList< 1 >{ ALL_LOADS_AND_RELAYS() }));
525 TEST_ASSERT_EQUAL_HEX16((1U << 5) | (1U << 6), withoutRelays.localBitmask(PinList< 1 >{ ALL_LOADS_AND_RELAYS() }));
526}
527
529{
530 constexpr PinList< 3 > targets{ ALL_LOCAL_LOADS(), RELAY(1), LOAD(3) };
531 TEST_ASSERT_EQUAL_HEX16((1U << 5) | (1U << 6) | (1U << 9), withRelays.localBitmask(targets));
532 TEST_ASSERT_EQUAL_HEX8(0b10, withRelays.remoteBitmask(targets));
533}
534
536{
537 constexpr OverridePins< 2 > settings{ { { 3, { LOAD(0), RELAY(0) } },
538 { 4, { ALL_LOADS() } } } };
539 constexpr OverrideTable fromSettings{ settings, withRelays };
540 constexpr OverrideTable< 2 > fromPins{ { { 3, { 5, 8 } },
541 { 4, { 5, 6, REMOTE_LOAD(0), REMOTE_LOAD(1) } } } };
542
543 for (uint8_t i = 0; i != 2; ++i)
544 {
545 TEST_ASSERT_EQUAL(fromPins.getPin(i), fromSettings.getPin(i));
546 TEST_ASSERT_EQUAL_HEX16(fromPins.getLocalBitmask(i), fromSettings.getLocalBitmask(i));
547 TEST_ASSERT_EQUAL_HEX8(fromPins.getRemoteBitmask(i), fromSettings.getRemoteBitmask(i));
548 }
549}
550
551int main(void)
552{
553 UNITY_BEGIN();
554
555 // indicesToBitmask tests
560
561 // are_pins_valid tests
566
567 // PinList tests
570 RUN_TEST(test_PinList_single_pin);
571 RUN_TEST(test_PinList_max_pins);
576
577 // KeyIndexPair tests
582
583 // OverrideTable tests
592
593 // PinList remote bitmask tests
602
603 // KeyIndexPair remote bitmask tests
607
608 // OverrideTable remote bitmask tests
616
621 RUN_TEST(test_TargetMap_groups);
624
625 return UNITY_END();
626}
The override pins, as in config.h: each pin with the targets it forces.
Manages override pins and their associated bitmasks for forced operation.
The relays, as in config.h: the sliding average and the settings of each relay.
What the target codes of config.h stand for, once the load map and the relays are known.
constexpr RelayEngine relays
Definition config.h:130
constexpr uint8_t REMOTE_PIN_BASE
Base value for virtual pins representing remote loads.
constexpr uint8_t LOCAL_LOAD(const uint8_t loadNum)
Same as LOAD(), for a load known to be local.
constexpr uint8_t ALL_LOCAL_LOADS()
Every local load.
constexpr uint8_t RELAY(const uint8_t relayNum)
Relay relayNum of relays (0, no relay, if out of range or without relay diversion).
constexpr uint8_t ALL_LOADS()
Every load, local and remote.
constexpr uint8_t LOAD(const uint8_t loadNum)
Load loadNum of physicalLoadPin[], local or remote (0, no load, if out of range).
void setUp(void)
Definition test_main.cpp:27
void tearDown(void)
Definition test_main.cpp:28
uint8_t i
constexpr uint8_t local(uint8_t pin)
Declares a load driven locally by the router.
Definition load_map.h:68
constexpr uint8_t remote(uint8_t unit, uint8_t ledPin=0)
Declares a load driven by a remote unit over RF.
Definition load_map.h:79
int main(void)
void test_are_pins_valid_rejects_pin_14_and_above(void)
Definition test_main.cpp:70
void test_PinList_default_constructor(void)
Definition test_main.cpp:81
void test_OverrideTable_findRemoteBitmask_found(void)
void test_TargetMap_LOAD_gives_the_pin_or_the_remote_rank(void)
void test_OverrideTable_multiple_entries_mixed(void)
void test_OverrideTable_multiple_entries(void)
void test_PinList_from_uint32_bitmask_remote_only(void)
void test_PinList_single_pin(void)
Definition test_main.cpp:97
void test_PinList_toLocalBitmask(void)
void test_are_pins_valid_all_valid(void)
Definition test_main.cpp:50
void test_OverrideTable_findRemoteBitmask_not_found(void)
void test_OverrideTable_many_entries(void)
void test_PinList_from_bitmask(void)
void test_OverrideTable_getRemoteBitmask_mixed(void)
void test_KeyIndexPair_from_bitmask(void)
void test_indicesToBitmask_consecutive(void)
Definition test_main.cpp:34
void test_PinList_toRemoteBitmask_local_only(void)
void test_TargetMap_groups(void)
void test_PinList_variadic_constructor(void)
Definition test_main.cpp:88
void test_PinList_from_bitmask_full(void)
void test_PinList_from_bitmask_empty(void)
void test_indicesToBitmask_single_index(void)
Definition test_main.cpp:21
void test_KeyIndexPair_construction(void)
void test_PinList_toRemoteBitmask_empty(void)
void test_PinList_toRemoteBitmask_multiple_remote(void)
void test_KeyIndexPair_single_pin(void)
void test_OverrideTable_findLocalBitmask_found(void)
void test_OverrideTable_getRemoteBitmask_local_only(void)
void test_OverrideTable_getRemoteBitmask_out_of_bounds(void)
void test_OverrideTable_from_the_settings_matches_plain_pins(void)
void test_OverrideTable_getRemoteBitmask_remote_only(void)
void test_TargetMap_a_group_and_single_targets_in_one_list(void)
void test_OverrideTable_getPin_out_of_bounds(void)
void test_are_pins_valid_rejects_pin_0(void)
Definition test_main.cpp:58
void test_PinList_max_pins(void)
void test_TargetMap_RELAY_needs_relay_diversion(void)
void test_KeyIndexPair_getLocalBitmask(void)
void test_KeyIndexPair_getRemoteBitmask_mixed(void)
#define REMOTE_LOAD(n)
void test_are_pins_valid_rejects_pin_1(void)
Definition test_main.cpp:64
void test_OverrideTable_single_entry(void)
void test_indicesToBitmask_multiple_indices(void)
Definition test_main.cpp:28
void test_KeyIndexPair_getRemoteBitmask_empty(void)
void test_OverrideTable_findLocalBitmask_not_found(void)
void test_PinList_toRemoteBitmask_mixed(void)
void test_OverrideTable_getLocalBitmask_out_of_bounds(void)
void test_PinList_toRemoteBitmask_single_remote(void)
void test_TargetMap_out_of_range_gives_pin_0(void)
void test_PinList_from_uint32_bitmask_local_only(void)
void test_KeyIndexPair_getRemoteBitmask_remote_only(void)
void test_indicesToBitmask_all_bits(void)
Definition test_main.cpp:40
void test_TargetMap_plain_pins_pass_through(void)
void test_OverrideTable_with_bitmask_constructor(void)
void test_PinList_from_uint32_bitmask_mixed(void)
Structure holding a pin and its associated index list.
Wrapper for a list of pins, constructible from variadic arguments.
The settings of one relay, as in config.h: { pin, surplus, import, minON, minOFF }...
Compile-time utilities for managing override pins and index-to-bitmask mapping.
constexpr bool are_pins_valid()
Compile-time validation function for pin values.
constexpr uint16_t indicesToBitmask()
Helper to convert pins to a bitmask at compile-time.