starting with component unit testing (running on device)
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2
components/logger/CMakeLists.txt
Normal file
2
components/logger/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "logger.c"
|
||||
INCLUDE_DIRS "include")
|
5
components/logger/include/logger.h
Normal file
5
components/logger/include/logger.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
int add(int a, int b);
|
||||
|
||||
void log_message(const char* message);
|
11
components/logger/logger.c
Normal file
11
components/logger/logger.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "logger.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int add(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
void log_message(const char* message) {
|
||||
printf("%s\n", message);
|
||||
}
|
3
components/logger/test/CMakeLists.txt
Normal file
3
components/logger/test/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES cmock logger)
|
7
components/logger/test/logger_test.c
Normal file
7
components/logger/test/logger_test.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "unity.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
TEST_CASE("Add two numbers", "[logger]") {
|
||||
TEST_ASSERT_EQUAL(3, add(1, 2));
|
||||
}
|
Reference in New Issue
Block a user