Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
Uebung0
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Control and Cyber-Physical Systems (Public)
Programmierung in der Automatisierungstechnik
Uebung0
Commits
f6c638d9
Commit
f6c638d9
authored
9 months ago
by
Stauder, Lucas
Browse files
Options
Downloads
Patches
Plain Diff
feat: switch to gtest
parent
23a2382d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+9
-9
9 additions, 9 deletions
CMakeLists.txt
src/controller.test.cpp
+8
-9
8 additions, 9 deletions
src/controller.test.cpp
with
17 additions
and
18 deletions
CMakeLists.txt
+
9
−
9
View file @
f6c638d9
...
...
@@ -14,15 +14,15 @@ add_executable(Uebung0 src/main.c
src/controller.c
src/controller.h
)
# Fetch
Catch2
# Fetch
GoogleTest
Include
(
FetchContent
)
FetchContent_Declare
(
Catch2
GIT_REPOSITORY https://github.com/
catchorg/Catch2
.git
GIT_TAG v
3.3
.2
googletest
GIT_REPOSITORY https://github.com/
google/googletest
.git
GIT_TAG v
1.15
.2
)
F
et
chCon
te
n
t_
MakeAvailable
(
Catch2
)
s
et
(
g
te
s
t_
force_shared_crt ON CACHE BOOL
""
FORCE
)
FetchContent_MakeAvailable
(
googletest
)
# Build Tests
enable_testing
()
...
...
@@ -32,7 +32,7 @@ add_executable(test_controller
src/controller.test.cpp
)
target_link_libraries
(
test_controller PRIVATE
Catch2::Catch2WithM
ain
)
target_link_libraries
(
test_controller PRIVATE
GTest::gtest_m
ain
)
target_include_directories
(
test_controller PRIVATE src/
)
add_test
(
test_controller ./test_controller
)
set_property
(
TEST test_controller PROPERTY ENVIRONMENT
"CTEST_OUTPUT_ON_FAILURE=1"
)
include
(
GoogleTest
)
gtest_discover_tests
(
test_controller
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/controller.test.cpp
+
8
−
9
View file @
f6c638d9
#include
<
catch2/catch_test_macros.hpp
>
#include
<
gtest/gtest.h
>
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
(
ControllerTest
,
gain
)
{
EXPECT_EQ
(
controller
(
8
,
0
,
500
),
16
);
EXPECT_EQ
(
controller
(
-
2
,
0
,
500
),
-
4
);
EXPECT_EQ
(
controller
(
0
,
2
,
500
),
-
4
);
}
TEST
_CASE
(
"limits"
)
{
REQUIRE
(
controller
(
2
,
0
,
2
)
==
2
);
REQUIRE
(
controller
(
-
2
,
0
,
2
)
==
-
2
);
TEST
(
ControllerTest
,
saturation
)
{
EXPECT_EQ
(
controller
(
2
,
0
,
2
)
,
2
);
EXPECT_EQ
(
controller
(
-
2
,
0
,
2
)
,
-
2
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment