Skip to content
Snippets Groups Projects
Verified Commit 7a128bc4 authored by Stauder, Lucas's avatar Stauder, Lucas
Browse files

Initial Commit

parents
No related branches found
No related tags found
No related merge requests found
# CLion
/.idea
/*-build-*
# Visual Studio
/.vs
/out
# vscode
/.vscode
/build
cmake_minimum_required(VERSION 3.26)
project(Uebung0)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(common OBJECT
src/controller.c
src/controller.h)
add_executable(Uebung0 src/main.c
src/controller.c
src/controller.h)
# Fetch Catch2
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.3.2
)
FetchContent_MakeAvailable(Catch2)
# Build Tests
enable_testing()
add_executable(test_controller
$<TARGET_OBJECTS:common>
src/controller.test.cpp
)
target_link_libraries(test_controller PRIVATE Catch2::Catch2WithMain)
target_include_directories(test_controller PRIVATE src/)
add_test(test_controller env CTEST_OUTPUT_ON_FAILURE=1 ./test_controller)
#include "controller.h"
int controller(int w, int y, int maxControl) { return 0; }
#ifndef CONTROLLER_H
#define CONTROLLER_H
int controller(int w, int y, int maxControl);
#endif // CONTROLLER_H
#include <catch2/catch_test_macros.hpp>
extern "C" {
#include "controller.h"
}
TEST_CASE("PI_Regler") {
REQUIRE(controller(8, 0, 500) == 16);
REQUIRE(controller(-2, 0, 500) == -4);
REQUIRE(controller(0, 2, 500) == -4);
}
TEST_CASE("limits") {
REQUIRE(controller(2, 0, 2) == 2);
REQUIRE(controller(-2, 0, 2) == -2);
}
\ No newline at end of file
#include <stdio.h>
#include "controller.h"
int main() { return 0; }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment