26 TEST_ASSERT_EQUAL(0, groups.size());
32 TEST_ASSERT_EQUAL(1, groups.size());
33 TEST_ASSERT_EQUAL(1, groups.getGroup(0).count);
40 TEST_ASSERT_EQUAL(2, groups.size());
41 TEST_ASSERT_EQUAL(3, groups.getGroup(1).count);
42 TEST_ASSERT_EQUAL(
LOAD(4), groups.getGroup(1).pins[1]);
48 TEST_ASSERT_EQUAL(2, groups.size());
49 TEST_ASSERT_EQUAL(1, groups.getGroup(0).count);
60constexpr uint8_t prio[]{ 0, 1, 2, 3, 4, 5 };
62template<
typename Groups >
63constexpr bool allChecksPass(
const Groups& groups)
107 TEST_ASSERT_TRUE(allChecksPass(groups));
147 TEST_ASSERT_TRUE(allChecksPass(groups));
155 constexpr uint8_t prio4[]{ 0, 1, 2, 3 };
157 uint8_t a[]{ 0, 1, 2 | ON, 3 };
158 uint8_t b[]{ 0, 1, 2 | ON, 3 };
161 TEST_ASSERT_EQUAL_UINT8_ARRAY(b, a, 4);
167 constexpr uint8_t prio6[]{ 0, 3, 1, 4, 2, 5 };
169 uint8_t p[]{ 0, 3, 1, 4, 2, 5 };
171 constexpr uint8_t expected[]{ 2, 5, 0, 3, 1, 4 };
172 TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, p, 6);
178 uint8_t p[]{ 0, 1, 2, 3, 4, 5 };
180 constexpr uint8_t expected[]{ 2, 0, 1, 3, 4, 5 };
181 TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, p, 6);
187 constexpr uint8_t prio3[]{ 0, 1, 2 };
189 uint8_t p[]{ 0 | ON, 1, 2 };
191 constexpr uint8_t expected[]{ 1, 0 | ON, 2 };
192 TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, p, 3);
198 uint8_t p[]{ 0, 1 | ON, 2, 3, 4 | ON, 5 };
199 for (uint8_t
i = 0;
i != 6; ++
i)
203 constexpr uint8_t expected[]{ 0, 1 | ON, 2, 3, 4 | ON, 5 };
204 TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, p, 6);
210 uint8_t p[]{ 5, 4, 3, 2, 1, 0 };
212 constexpr uint8_t expected[]{ 5, 4, 3, 2, 1, 0 };
213 TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, p, 6);
214 TEST_ASSERT_EQUAL(0, table.size());
220 TEST_ASSERT_EQUAL(2, table.size());
221 TEST_ASSERT_EQUAL_HEX32(0b011000, table.loads(0));
222 TEST_ASSERT_EQUAL_HEX32(0b000111, table.loads(1));
The rotation groups, as in config.h: the loads that take turns at the top of the priority list,...
The rotation groups, resolved: the priority places each group holds.
void rotate(uint8_t(&prio)[N]) const
Rotates each group by one among its places; each entry keeps its ON bit.
What config.h is written with: its types, constants and helpers.
constexpr uint8_t ALL_REMOTE_LOADS()
Every remote load.
constexpr uint8_t LOCAL_LOAD(const uint8_t loadNum)
Same as LOAD(), for a load known to be local.
constexpr uint8_t ALL_RELAYS()
Every relay (none without relay diversion).
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).
constexpr uint8_t ALL_LOADS_AND_RELAYS()
Every load and every relay.
Encoding of the load map: one packed byte per dump load.
The load priority state machine: which load to switch at each mains cycle.
constexpr uint8_t loadStateOnBit
void rotate(uint8_t(&priorities)[N])
Rotates the priorities by one: the last load becomes the first, the others move down one place....
constexpr uint8_t local(uint8_t pin)
Declares a load driven locally by the router.
constexpr uint8_t remote(uint8_t unit, uint8_t ledPin=0)
Declares a load driven by a remote unit over RF.
constexpr bool noLoadTwice(const RotationGroups< NG, MaxPins > &groups, const uint8_t(&loadMap)[NL])
No load is named twice, within a group or across groups.
constexpr bool targetsAreLoads(const RotationGroups< NG, MaxPins > &groups, const uint8_t(&loadMap)[NL])
Every code of every group stands for at least one load.
constexpr uint32_t loadsOf(const uint8_t code, const uint8_t(&loadMap)[NL])
The loads a target code stands for, by load number.
constexpr bool groupsHaveTwoLoads(const RotationGroups< NG, MaxPins > &groups, const uint8_t(&loadMap)[NL])
Every group holds at least 2 loads.
constexpr bool groupsAreConsistent(const RotationGroups< NG, MaxPins > &groups, const uint8_t(&loadMap)[NL])
In each group, every load is local, or every load is on the same remote unit.
void test_checks_pass_without_groups(void)
void test_check_mixed_local_and_remote(void)
void test_checks_pass_for_two_good_groups(void)
void test_loads_of_pin_is_the_local_load_on_it(void)
void test_check_group_of_one(void)
void test_table_gives_the_loads_of_each_group(void)
void test_check_two_remote_units(void)
void test_loads_of_load_and_local_load(void)
void test_missing_inner_braces_make_one_load_groups(void)
void test_table_without_groups_changes_nothing(void)
void test_n_rotations_are_back_to_the_start(void)
void test_two_groups_keep_their_codes(void)
void test_loads_of_groups_and_relays(void)
void test_one_group_of_every_local_load(void)
void test_on_bits_travel_with_their_load(void)
void test_two_interleaved_groups_rotate_apart(void)
void test_one_group_of_every_load_is_todays_rotation(void)
void test_loads_of_remote_load_follows_map_order(void)
void test_loads_outside_groups_never_move(void)
void test_check_relay_is_not_a_load(void)
void test_check_load_twice(void)
The rotation groups: which loads take turns, checked and resolved at compile time.