Merge branch 'v1.0.1'

This commit is contained in:
Nicu Hodos 2024-06-30 13:18:36 +02:00
commit bf8439bdd1
6 changed files with 94 additions and 25 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.pio/
.vscode/

View File

@ -1,27 +1,24 @@
{
"name": "ha-mqtt",
"version": "1.0.0",
"description": "Home Assistant classes for integration with MQTT auto discovery",
"repository":
"$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
"name": "ha-mqtt",
"version": "1.0.1",
"description": "Home Assistant classes for integration with MQTT auto discovery",
"repository": {
"type": "git",
"url": "https://git.hodos.ro/arduino/ha-mqtt.git"
},
"authors": [
{
"type": "git",
"url": "https://git.hodos.ro/arduino/ha-mqtt.git"
},
"authors":
[
{
"name": "Nicu Hodos",
"email": "nicu@hodos.ro",
"maintainer": true
}
],
"dependencies":
{
"bblanchon/ArduinoJson": "6.21.5",
"arkhipenko/TaskScheduler": "^3.7.0",
"marvinroger/AsyncMqttClient": "^0.9.0"
},
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
}
"name": "Nicu Hodos",
"email": "nicu@hodos.ro",
"maintainer": true
}
],
"dependencies": {
"bblanchon/ArduinoJson": "6.21.5",
"marvinroger/AsyncMqttClient": "^0.9.0"
},
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
}

16
platformio.ini Normal file
View File

@ -0,0 +1,16 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = native
[env:native]
platform = native
debug_build_flags = -std=c++11

View File

@ -30,6 +30,7 @@ struct List {
delete c;
c = n;
}
first = last = nullptr;
}
};

11
test/README Normal file
View File

@ -0,0 +1,11 @@
This directory is intended for PlatformIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

42
test/utils.cpp Normal file
View File

@ -0,0 +1,42 @@
#include <unity.h>
#include "utils.h"
void setUp(void) {
// set stuff up here
}
void tearDown(void) {
// clean stuff up here
}
void test_add(void) {
List<int> list;
int value = 10;
list.add(&value);
TEST_ASSERT_EQUAL(value, *list.last->t);
TEST_ASSERT_EQUAL_PTR(list.first, list.last);
int value2 = 12;
list.add(&value2);
TEST_ASSERT_EQUAL(value2, *list.last->t);
TEST_ASSERT_EQUAL_PTR(list.first->next, list.last);
}
void test_empty(void) {
List<int> list;
int value = 10;
list.add(&value);
list.add(&value);
list.empty();
TEST_ASSERT_EQUAL_PTR(nullptr, list.first);
TEST_ASSERT_EQUAL_PTR(list.first, list.last);
}
int main(int argc, char **argv) {
UNITY_BEGIN();
RUN_TEST(test_add);
RUN_TEST(test_empty);
UNITY_END();
return 0;
}