3-phase PV router
Loading...
Searching...
No Matches
test_main.cpp File Reference

Native unit tests for relay_engine.h: the decisions of the relay diversion. More...

#include <unity.h>
#include "relay_engine.h"
Include dependency graph for test_main.cpp:

Go to the source code of this file.

Functions

int main (void)
 
void setUp (void)
 
void tearDown (void)
 
void test_a_change_of_any_relay_holds_every_relay_for_a_minute (void)
 
void test_a_forced_relay_comes_in_during_an_import (void)
 
void test_a_forced_relay_is_not_turned_off_by_an_import (void)
 
void test_a_forced_relay_stays_on_while_the_others_go_out (void)
 
void test_a_forced_relay_turns_on_whatever_the_power (void)
 
void test_a_forced_relay_waits_its_minimum_off_time (void)
 
void test_a_minimum_time_beyond_1092_minutes_is_marked_for_validation (void)
 
void test_a_negative_import_threshold_turns_off_on_a_small_surplus (void)
 
void test_a_new_relay_waits_its_minimum_off_time (void)
 
void test_a_relay_held_by_its_minimum_off_time_lets_the_next_one_in (void)
 
void test_a_relay_held_by_its_minimum_on_time_lets_the_previous_one_out (void)
 
void test_a_released_relay_is_left_to_the_engine (void)
 
void test_battery_relays_go_out_by_decreasing_index_on_a_small_surplus (void)
 
void test_between_the_thresholds_nothing_changes (void)
 
void test_diversion_off_ignores_the_surplus_and_forces_on (void)
 
void test_diversion_off_keeps_the_minimum_times_and_the_settle_time (void)
 
void test_diversion_off_turns_every_unforced_relay_off_in_one_go (void)
 
void test_each_relay_comes_in_at_its_own_threshold (void)
 
void test_exactly_the_import_threshold_does_not_turn_off (void)
 
void test_exactly_the_surplus_threshold_does_not_turn_on (void)
 
void test_forced_only_turns_an_unforced_relay_off_after_its_minimum_on_time (void)
 
void test_no_change_starts_no_settle_time (void)
 
void test_nothing_switches_during_the_first_minute (void)
 
void test_on_a_surplus_the_relays_come_in_one_at_a_time_by_increasing_index (void)
 
void test_on_an_import_the_relays_go_out_one_at_a_time_by_decreasing_index (void)
 
void test_the_defaults (void)
 
void test_the_duration_stops_at_its_maximum_instead_of_wrapping (void)
 
void test_the_engine_decides_on_the_average_not_on_the_last_value (void)
 
void test_the_engine_decides_on_the_triple_ema (void)
 
void test_the_minimum_off_time_restarts_at_each_switch_off (void)
 
void test_the_minimum_on_time_ends_after_exactly_min_on_seconds (void)
 
void test_the_minimum_times_are_given_in_minutes_and_kept_in_seconds (void)
 
void test_the_settle_time_holds_a_switch_off_after_a_switch_on (void)
 
void test_the_surplus_threshold_is_positive_whatever_its_sign_in_the_config (void)
 

Detailed Description

Native unit tests for relay_engine.h: the decisions of the relay diversion.

The real code, no stubs: RelayLogic::Relay on an output that records each switch (pin, new state) instead of driving a pin, and RelayLogic::Engine on those relays. As in loop(), the engine gets inc_duration() then proceed_relays() once per second. The average is negative on a surplus, positive on an import.

Each relay pin differs from its index, so that a test tells an override bit read by index from one read by pin.

Definition in file test_main.cpp.

Function Documentation

◆ main()

int main ( void )

Definition at line 682 of file test_main.cpp.

Here is the call graph for this function:

◆ setUp()

void setUp ( void )

Definition at line 128 of file test_main.cpp.

◆ tearDown()

void tearDown ( void )

Definition at line 133 of file test_main.cpp.

◆ test_a_change_of_any_relay_holds_every_relay_for_a_minute()

void test_a_change_of_any_relay_holds_every_relay_for_a_minute ( void )

Definition at line 385 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_forced_relay_comes_in_during_an_import()

void test_a_forced_relay_comes_in_during_an_import ( void )

Definition at line 546 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_forced_relay_is_not_turned_off_by_an_import()

void test_a_forced_relay_is_not_turned_off_by_an_import ( void )

Definition at line 325 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_forced_relay_stays_on_while_the_others_go_out()

void test_a_forced_relay_stays_on_while_the_others_go_out ( void )

Definition at line 557 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_forced_relay_turns_on_whatever_the_power()

void test_a_forced_relay_turns_on_whatever_the_power ( void )

Definition at line 311 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_forced_relay_waits_its_minimum_off_time()

void test_a_forced_relay_waits_its_minimum_off_time ( void )

Definition at line 338 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_minimum_time_beyond_1092_minutes_is_marked_for_validation()

void test_a_minimum_time_beyond_1092_minutes_is_marked_for_validation ( void )

Definition at line 147 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_negative_import_threshold_turns_off_on_a_small_surplus()

void test_a_negative_import_threshold_turns_off_on_a_small_surplus ( void )

Definition at line 235 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_new_relay_waits_its_minimum_off_time()

void test_a_new_relay_waits_its_minimum_off_time ( void )

Definition at line 252 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_relay_held_by_its_minimum_off_time_lets_the_next_one_in()

void test_a_relay_held_by_its_minimum_off_time_lets_the_next_one_in ( void )

Definition at line 478 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_relay_held_by_its_minimum_on_time_lets_the_previous_one_out()

void test_a_relay_held_by_its_minimum_on_time_lets_the_previous_one_out ( void )

Definition at line 490 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_a_released_relay_is_left_to_the_engine()

void test_a_released_relay_is_left_to_the_engine ( void )

Definition at line 570 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_battery_relays_go_out_by_decreasing_index_on_a_small_surplus()

void test_battery_relays_go_out_by_decreasing_index_on_a_small_surplus ( void )

Definition at line 513 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_between_the_thresholds_nothing_changes()

void test_between_the_thresholds_nothing_changes ( void )

Definition at line 217 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_diversion_off_ignores_the_surplus_and_forces_on()

void test_diversion_off_ignores_the_surplus_and_forces_on ( void )

Definition at line 606 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_diversion_off_keeps_the_minimum_times_and_the_settle_time()

void test_diversion_off_keeps_the_minimum_times_and_the_settle_time ( void )

Definition at line 622 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_diversion_off_turns_every_unforced_relay_off_in_one_go()

void test_diversion_off_turns_every_unforced_relay_off_in_one_go ( void )

Definition at line 593 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_each_relay_comes_in_at_its_own_threshold()

void test_each_relay_comes_in_at_its_own_threshold ( void )

Definition at line 502 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_exactly_the_import_threshold_does_not_turn_off()

void test_exactly_the_import_threshold_does_not_turn_off ( void )

Definition at line 202 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_exactly_the_surplus_threshold_does_not_turn_on()

void test_exactly_the_surplus_threshold_does_not_turn_on ( void )

Definition at line 188 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_forced_only_turns_an_unforced_relay_off_after_its_minimum_on_time()

void test_forced_only_turns_an_unforced_relay_off_after_its_minimum_on_time ( void )

Definition at line 350 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_no_change_starts_no_settle_time()

void test_no_change_starts_no_settle_time ( void )

Definition at line 419 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_nothing_switches_during_the_first_minute()

void test_nothing_switches_during_the_first_minute ( void )

Definition at line 372 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_on_a_surplus_the_relays_come_in_one_at_a_time_by_increasing_index()

void test_on_a_surplus_the_relays_come_in_one_at_a_time_by_increasing_index ( void )

Definition at line 438 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_on_an_import_the_relays_go_out_one_at_a_time_by_decreasing_index()

void test_on_an_import_the_relays_go_out_one_at_a_time_by_decreasing_index ( void )

Definition at line 455 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_defaults()

void test_the_defaults ( void )

Definition at line 172 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_duration_stops_at_its_maximum_instead_of_wrapping()

void test_the_duration_stops_at_its_maximum_instead_of_wrapping ( void )

Definition at line 298 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_engine_decides_on_the_average_not_on_the_last_value()

void test_the_engine_decides_on_the_average_not_on_the_last_value ( void )

Definition at line 649 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_engine_decides_on_the_triple_ema()

void test_the_engine_decides_on_the_triple_ema ( void )

Definition at line 668 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_minimum_off_time_restarts_at_each_switch_off()

void test_the_minimum_off_time_restarts_at_each_switch_off ( void )

Definition at line 282 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_minimum_on_time_ends_after_exactly_min_on_seconds()

void test_the_minimum_on_time_ends_after_exactly_min_on_seconds ( void )

Definition at line 266 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_minimum_times_are_given_in_minutes_and_kept_in_seconds()

void test_the_minimum_times_are_given_in_minutes_and_kept_in_seconds ( void )

Definition at line 139 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_settle_time_holds_a_switch_off_after_a_switch_on()

void test_the_settle_time_holds_a_switch_off_after_a_switch_on ( void )

Definition at line 403 of file test_main.cpp.

Here is the caller graph for this function:

◆ test_the_surplus_threshold_is_positive_whatever_its_sign_in_the_config()

void test_the_surplus_threshold_is_positive_whatever_its_sign_in_the_config ( void )

Definition at line 160 of file test_main.cpp.

Here is the caller graph for this function: