unit testst for utility-max3 supplied
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
find_package(GTest REQUIRED)
|
find_package(GTest REQUIRED)
|
||||||
|
|
||||||
add_executable(tests filter-test.cpp)
|
add_executable(tests filter-test.cpp
|
||||||
|
util-test.cpp
|
||||||
|
)
|
||||||
target_link_libraries(tests GTest::gtest_main app_lib)
|
target_link_libraries(tests GTest::gtest_main app_lib)
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
|||||||
0
tests/CTestTestfile.cmake
Executable file → Normal file
0
tests/CTestTestfile.cmake
Executable file → Normal file
0
tests/cmake_install.cmake
Executable file → Normal file
0
tests/cmake_install.cmake
Executable file → Normal file
48
tests/cmake_test_discovery_59830ebc3a.json
Executable file → Normal file
48
tests/cmake_test_discovery_59830ebc3a.json
Executable file → Normal file
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"tests": 3,
|
"tests": 11,
|
||||||
"name": "AllTests",
|
"name": "AllTests",
|
||||||
"testsuites": [
|
"testsuites": [
|
||||||
{
|
{
|
||||||
@@ -22,6 +22,52 @@
|
|||||||
"line": 20
|
"line": 20
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "UtilityTest_max3",
|
||||||
|
"tests": 8,
|
||||||
|
"testsuite": [
|
||||||
|
{
|
||||||
|
"name": "param_3_is_max",
|
||||||
|
"file": "\/home\/k4\/tmp\/bbr-algo\/BinderBeispielRegler\/tests\/util-test.cpp",
|
||||||
|
"line": 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "param_2_is_max",
|
||||||
|
"file": "\/home\/k4\/tmp\/bbr-algo\/BinderBeispielRegler\/tests\/util-test.cpp",
|
||||||
|
"line": 31
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "param_1_is_max",
|
||||||
|
"file": "\/home\/k4\/tmp\/bbr-algo\/BinderBeispielRegler\/tests\/util-test.cpp",
|
||||||
|
"line": 37
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "all_params_equal",
|
||||||
|
"file": "\/home\/k4\/tmp\/bbr-algo\/BinderBeispielRegler\/tests\/util-test.cpp",
|
||||||
|
"line": 43
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "all_params_zero",
|
||||||
|
"file": "\/home\/k4\/tmp\/bbr-algo\/BinderBeispielRegler\/tests\/util-test.cpp",
|
||||||
|
"line": 49
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "2_params_negative_one_is_zero",
|
||||||
|
"file": "\/home\/k4\/tmp\/bbr-algo\/BinderBeispielRegler\/tests\/util-test.cpp",
|
||||||
|
"line": 55
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "all_params_negative_one_is_max",
|
||||||
|
"file": "\/home\/k4\/tmp\/bbr-algo\/BinderBeispielRegler\/tests\/util-test.cpp",
|
||||||
|
"line": 61
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "all_params_type_double",
|
||||||
|
"file": "\/home\/k4\/tmp\/bbr-algo\/BinderBeispielRegler\/tests\/util-test.cpp",
|
||||||
|
"line": 67
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
tests/tests
BIN
tests/tests
Binary file not shown.
66
tests/tests[1]_tests.cmake
Executable file → Normal file
66
tests/tests[1]_tests.cmake
Executable file → Normal file
@@ -22,4 +22,68 @@ set_tests_properties([=[PT1FilterTest.FilterFactorEffect]=]
|
|||||||
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
)
|
)
|
||||||
set( tests_TESTS PT1FilterTest.InitialOutputIsZero PT1FilterTest.StepResponse PT1FilterTest.FilterFactorEffect)
|
add_test([=[UtilityTest_max3.param_3_is_max]=] /home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/tests [==[--gtest_filter=UtilityTest_max3.param_3_is_max]==] --gtest_also_run_disabled_tests)
|
||||||
|
set_tests_properties([=[UtilityTest_max3.param_3_is_max]=]
|
||||||
|
PROPERTIES
|
||||||
|
|
||||||
|
DEF_SOURCE_LINE [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/util-test.cpp:25]==]
|
||||||
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
|
)
|
||||||
|
add_test([=[UtilityTest_max3.param_2_is_max]=] /home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/tests [==[--gtest_filter=UtilityTest_max3.param_2_is_max]==] --gtest_also_run_disabled_tests)
|
||||||
|
set_tests_properties([=[UtilityTest_max3.param_2_is_max]=]
|
||||||
|
PROPERTIES
|
||||||
|
|
||||||
|
DEF_SOURCE_LINE [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/util-test.cpp:31]==]
|
||||||
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
|
)
|
||||||
|
add_test([=[UtilityTest_max3.param_1_is_max]=] /home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/tests [==[--gtest_filter=UtilityTest_max3.param_1_is_max]==] --gtest_also_run_disabled_tests)
|
||||||
|
set_tests_properties([=[UtilityTest_max3.param_1_is_max]=]
|
||||||
|
PROPERTIES
|
||||||
|
|
||||||
|
DEF_SOURCE_LINE [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/util-test.cpp:37]==]
|
||||||
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
|
)
|
||||||
|
add_test([=[UtilityTest_max3.all_params_equal]=] /home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/tests [==[--gtest_filter=UtilityTest_max3.all_params_equal]==] --gtest_also_run_disabled_tests)
|
||||||
|
set_tests_properties([=[UtilityTest_max3.all_params_equal]=]
|
||||||
|
PROPERTIES
|
||||||
|
|
||||||
|
DEF_SOURCE_LINE [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/util-test.cpp:43]==]
|
||||||
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
|
)
|
||||||
|
add_test([=[UtilityTest_max3.all_params_zero]=] /home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/tests [==[--gtest_filter=UtilityTest_max3.all_params_zero]==] --gtest_also_run_disabled_tests)
|
||||||
|
set_tests_properties([=[UtilityTest_max3.all_params_zero]=]
|
||||||
|
PROPERTIES
|
||||||
|
|
||||||
|
DEF_SOURCE_LINE [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/util-test.cpp:49]==]
|
||||||
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
|
)
|
||||||
|
add_test([=[UtilityTest_max3.2_params_negative_one_is_zero]=] /home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/tests [==[--gtest_filter=UtilityTest_max3.2_params_negative_one_is_zero]==] --gtest_also_run_disabled_tests)
|
||||||
|
set_tests_properties([=[UtilityTest_max3.2_params_negative_one_is_zero]=]
|
||||||
|
PROPERTIES
|
||||||
|
|
||||||
|
DEF_SOURCE_LINE [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/util-test.cpp:55]==]
|
||||||
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
|
)
|
||||||
|
add_test([=[UtilityTest_max3.all_params_negative_one_is_max]=] /home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/tests [==[--gtest_filter=UtilityTest_max3.all_params_negative_one_is_max]==] --gtest_also_run_disabled_tests)
|
||||||
|
set_tests_properties([=[UtilityTest_max3.all_params_negative_one_is_max]=]
|
||||||
|
PROPERTIES
|
||||||
|
|
||||||
|
DEF_SOURCE_LINE [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/util-test.cpp:61]==]
|
||||||
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
|
)
|
||||||
|
add_test([=[UtilityTest_max3.all_params_type_double]=] /home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/tests [==[--gtest_filter=UtilityTest_max3.all_params_type_double]==] --gtest_also_run_disabled_tests)
|
||||||
|
set_tests_properties([=[UtilityTest_max3.all_params_type_double]=]
|
||||||
|
PROPERTIES
|
||||||
|
|
||||||
|
DEF_SOURCE_LINE [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests/util-test.cpp:67]==]
|
||||||
|
WORKING_DIRECTORY [==[/home/k4/tmp/bbr-algo/BinderBeispielRegler/tests]==]
|
||||||
|
SKIP_REGULAR_EXPRESSION [==[\[ SKIPPED \]]==]
|
||||||
|
)
|
||||||
|
set( tests_TESTS PT1FilterTest.InitialOutputIsZero PT1FilterTest.StepResponse PT1FilterTest.FilterFactorEffect UtilityTest_max3.param_3_is_max UtilityTest_max3.param_2_is_max UtilityTest_max3.param_1_is_max UtilityTest_max3.all_params_equal UtilityTest_max3.all_params_zero UtilityTest_max3.2_params_negative_one_is_zero UtilityTest_max3.all_params_negative_one_is_max UtilityTest_max3.all_params_type_double)
|
||||||
|
|||||||
74
tests/util-test.cpp
Normal file
74
tests/util-test.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
File: util-test.cpp
|
||||||
|
Description: This is a C++ source file containing unit tests for util.cpp.
|
||||||
|
Rev: 0.1
|
||||||
|
Created: 01.04.26
|
||||||
|
Author: Uwe Jakobeit
|
||||||
|
Copyright: Binder GmbH
|
||||||
|
Purpose: Testing utility functions
|
||||||
|
Notes: [Any relevant details, such as dependencies, usage examples, or known issues.]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
using namespace UTILITY_FUNCTIONS;
|
||||||
|
|
||||||
|
//----------- Test of utility function 'max3' ---------
|
||||||
|
// Magic numbers for simplicity ( exceptionally allowed here )
|
||||||
|
|
||||||
|
// test if param 3 is max value
|
||||||
|
TEST(UtilityTest_max3, param_3_is_max) {
|
||||||
|
double max = max3(1.0f, 2.0f, 3.0f);
|
||||||
|
EXPECT_DOUBLE_EQ(max, 3.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test if param 2 is max value
|
||||||
|
TEST(UtilityTest_max3, param_2_is_max) {
|
||||||
|
double max = max3(1.0f, 3.0f, 2.0f);
|
||||||
|
EXPECT_DOUBLE_EQ(max, 3.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test if param 1 is max value
|
||||||
|
TEST(UtilityTest_max3, param_1_is_max) {
|
||||||
|
double max = max3( 3.0f, 1.0f, 2.0f);
|
||||||
|
EXPECT_DOUBLE_EQ(max, 3.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test all params are max value
|
||||||
|
TEST(UtilityTest_max3, all_params_equal) {
|
||||||
|
double max = max3( 3.0f, 3.0f, 3.0f);
|
||||||
|
EXPECT_DOUBLE_EQ(max, 3.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test all params are zero
|
||||||
|
TEST(UtilityTest_max3, all_params_zero) {
|
||||||
|
double max = max3( 0.0f, 0.0f, 0.0f);
|
||||||
|
EXPECT_DOUBLE_EQ(max, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test 2 params negatve, one is zero
|
||||||
|
TEST(UtilityTest_max3, 2_params_negative_one_is_zero) {
|
||||||
|
double max = max3( -2.0f, -1.0f, 0.0f);
|
||||||
|
EXPECT_DOUBLE_EQ(max, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test 2 params negatve, one is zero
|
||||||
|
TEST(UtilityTest_max3, all_params_negative_one_is_max) {
|
||||||
|
double max = max3( -2.0f, -1.0f, -3.0f);
|
||||||
|
EXPECT_DOUBLE_EQ(max, -1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(UtilityTest_max3, all_params_type_double) {
|
||||||
|
double max = max3( std::numeric_limits<double>::max(), 0.0f, 0.0f);
|
||||||
|
|
||||||
|
EXPECT_DOUBLE_EQ(max, std::numeric_limits<double>::max());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user