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

Init

parents
No related branches found
No related tags found
No related merge requests found
/cmake-build-debug/
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
Uebung0
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Uebung0.iml" filepath="$PROJECT_DIR$/.idea/Uebung0.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/catch2-src" vcs="Git" />
</component>
</project>
\ No newline at end of file
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"
double controller(double w, double y,double maxControl){
return 0;
}
#ifndef controller_H
#define controller_H
double controller(double w, double y,double 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.0);
REQUIRE(controller(-2,0,500) == -4.0);
}
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