-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update links in assert statements and fix relay diversion configuration
- Loading branch information
Showing
6 changed files
with
152 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <Arduino.h> | ||
#include <unity.h> | ||
|
||
#include "utils_relay.h" | ||
|
||
// Assuming you have a RelayOutput array defined somewhere | ||
const RelayOutput relayArray[2]{ { 5, 1000, 200, 5, 5 }, { 6, 1000, 200, 5, 5 } }; | ||
|
||
RelayEngine< 2 >* relayEngineTest; | ||
|
||
void setUp(void) | ||
{ | ||
relayEngineTest = new RelayEngine< 2 >(relayArray); | ||
} | ||
|
||
void tearDown(void) | ||
{ | ||
delete relayEngineTest; | ||
} | ||
|
||
void test_get_size(void) | ||
{ | ||
TEST_ASSERT_EQUAL(2, relayEngineTest->get_size()); | ||
} | ||
|
||
void test_get_relay(void) | ||
{ | ||
for(uint8_t i = 0; i < relayEngineTest->get_size(); ++i) { | ||
TEST_ASSERT_EQUAL(true, relayArray[i].get_pin() == relayEngineTest->get_relay(i).get_pin()); | ||
TEST_ASSERT_EQUAL(true, relayArray[i].get_minOFF() == relayEngineTest->get_relay(i).get_minOFF()); | ||
TEST_ASSERT_EQUAL(true, relayArray[i].get_minON() == relayEngineTest->get_relay(i).get_minON()); | ||
TEST_ASSERT_EQUAL(true, relayArray[i].get_surplusThreshold() == relayEngineTest->get_relay(i).get_surplusThreshold()); | ||
TEST_ASSERT_EQUAL(true, relayArray[i].get_importThreshold() == relayEngineTest->get_relay(i).get_importThreshold()); | ||
} | ||
} | ||
|
||
void test_get_average(void) | ||
{ | ||
// Assuming initial average is 0 | ||
TEST_ASSERT_EQUAL(0, RelayEngine< 2 >::get_average()); | ||
} | ||
|
||
void test_update_average(void) | ||
{ | ||
RelayEngine< 2 >::update_average(100); | ||
// Assuming the average changes after update | ||
TEST_ASSERT_NOT_EQUAL(0, RelayEngine< 2 >::get_average()); | ||
} | ||
|
||
void setup() | ||
{ | ||
UNITY_BEGIN(); | ||
RUN_TEST(test_get_size); | ||
RUN_TEST(test_get_relay); | ||
RUN_TEST(test_get_average); | ||
RUN_TEST(test_update_average); | ||
UNITY_END(); | ||
} | ||
|
||
void loop() | ||
{ | ||
// Do nothing here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include <Arduino.h> | ||
#include <unity.h> | ||
|
||
#include "utils_relay.h" | ||
|
||
static_assert(__cplusplus >= 201703L, "See also : https://github.com/FredM67/PVRouter-3-phase/blob/main/runtime/Mk2_3phase_RFdatalog_temp/Readme.md"); | ||
|
||
RelayOutput* RelayOutputTest; | ||
|
||
void setUp(void) { | ||
RelayOutputTest = new RelayOutput(5, 1000, 200, 5, 5); | ||
} | ||
|
||
void tearDown(void) { | ||
delete RelayOutputTest; | ||
} | ||
|
||
void test_get_pin(void) { | ||
TEST_ASSERT_EQUAL(5, RelayOutputTest->get_pin()); | ||
} | ||
|
||
void test_get_surplusThreshold(void) { | ||
TEST_ASSERT_EQUAL(1000, RelayOutputTest->get_surplusThreshold()); | ||
} | ||
|
||
void test_get_importThreshold(void) { | ||
TEST_ASSERT_EQUAL(200, RelayOutputTest->get_importThreshold()); | ||
} | ||
|
||
void test_get_minON(void) { | ||
TEST_ASSERT_EQUAL(5 * 60, RelayOutputTest->get_minON()); | ||
} | ||
|
||
void test_get_minOFF(void) { | ||
TEST_ASSERT_EQUAL(5 * 60, RelayOutputTest->get_minOFF()); | ||
} | ||
|
||
void test_isRelayON(void) { | ||
TEST_ASSERT_EQUAL(false, RelayOutputTest->isRelayON()); | ||
} | ||
|
||
void test_proceed_relay(void) { | ||
TEST_ASSERT_EQUAL(false, RelayOutputTest->proceed_relay(150)); | ||
TEST_ASSERT_EQUAL(false, RelayOutputTest->isRelayON()); | ||
|
||
for(uint16_t _time = 0; _time < RelayOutputTest->get_minOFF(); ++_time) { | ||
RelayOutputTest->inc_duration(); | ||
} | ||
|
||
TEST_ASSERT_EQUAL(true, RelayOutputTest->proceed_relay(-1500)); | ||
TEST_ASSERT_EQUAL(true, RelayOutputTest->isRelayON()); | ||
|
||
for(uint16_t _time = 0; _time < RelayOutputTest->get_minON(); ++_time) { | ||
RelayOutputTest->inc_duration(); | ||
} | ||
|
||
TEST_ASSERT_EQUAL(true, RelayOutputTest->proceed_relay(250)); | ||
TEST_ASSERT_EQUAL(false, RelayOutputTest->isRelayON()); | ||
} | ||
|
||
void setup() { | ||
UNITY_BEGIN(); | ||
RUN_TEST(test_get_pin); | ||
RUN_TEST(test_get_surplusThreshold); | ||
RUN_TEST(test_get_importThreshold); | ||
RUN_TEST(test_get_minON); | ||
RUN_TEST(test_get_minOFF); | ||
RUN_TEST(test_isRelayON); | ||
RUN_TEST(test_proceed_relay); | ||
UNITY_END(); | ||
} | ||
|
||
void loop() { | ||
// Do nothing here | ||
} |