add tets for list
This commit is contained in:
parent
b682c59d33
commit
48b33d5a58
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.pio/
|
||||||
|
.vscode/
|
||||||
16
platformio.ini
Normal file
16
platformio.ini
Normal 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
|
||||||
11
test/README
Normal file
11
test/README
Normal 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
42
test/utils.cpp
Normal 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;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user