working, but need to write test

This commit is contained in:
2021-06-25 18:35:16 +02:00
parent 55ebd21975
commit d059c3d72d
5 changed files with 142 additions and 79 deletions
+30 -30
View File
@@ -1,40 +1,40 @@
#include <Arduino.h>
#include <unity.h>
// #include <Arduino.h>
// #include <unity.h>
String STR_TO_TEST;
// String STR_TO_TEST;
void setUp(void) {
// set stuff up here
STR_TO_TEST = "Hello, world!";
}
// // void setUp(void) {
// // // set stuff up here
// // STR_TO_TEST = "Hello, world!";
// // }
void tearDown(void) {
// clean stuff up here
STR_TO_TEST = "";
}
// // void tearDown(void) {
// // // clean stuff up here
// // STR_TO_TEST = "";
// // }
void test_led_builtin_pin_number(void) {
TEST_ASSERT_EQUAL(2, LED_BUILTIN);
}
// void test_led_builtin_pin_number(void) {
// TEST_ASSERT_EQUAL(2, LED_BUILTIN);
// }
void test_string_concat(void) {
String hello = "Hello, ";
String world = "world!";
TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str());
}
// void test_string_concat(void) {
// String hello = "Hello, ";
// String world = "world!";
// TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str());
// }
void setup()
{
delay(2000); // service delay
UNITY_BEGIN();
// void setup()
// {
// delay(2000); // service delay
// UNITY_BEGIN();
RUN_TEST(test_led_builtin_pin_number);
RUN_TEST(test_string_concat);
// RUN_TEST(test_led_builtin_pin_number);
// RUN_TEST(test_string_concat);
UNITY_END(); // stop unit testing
}
// UNITY_END(); // stop unit testing
// }
void loop()
{
}
// void loop()
// {
// }
+48
View File
@@ -0,0 +1,48 @@
#include <Arduino.h>
#include "treppe.h"
#include <unity.h>
Treppe stairs(10);
void setUp(void) {
// run before each test
// set stuff up here
stairs.setup();
Serial.println("Treppe initialized !");
Serial.println("PCA9685 connected !");
}
void tearDown(void) {
// clean stuff up here
}
void test_set_state(void) {
stairs.setState(1);
TEST_ASSERT_EQUAL(1, stairs.getState());
stairs.setState(0);
TEST_ASSERT_EQUAL(0, stairs.getState());
}
void test_set_direction(void) {
stairs.setDirection(1);
TEST_ASSERT_EQUAL(1, stairs.getDirection());
stairs.setDirection(0);
TEST_ASSERT_EQUAL(0, stairs.getDirection());
}
void setup()
{
delay(2000); // service delay
UNITY_BEGIN();
RUN_TEST(test_set_state);
RUN_TEST(test_set_direction);
UNITY_END(); // stop unit testing
}
void loop()
{
}