Initial commit
This commit is contained in:
21
tests/CMakeLists.txt
Normal file
21
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
# Explicitly list the test source code and headers. The Catch header-only unit
|
||||
# test framework is stored in with the test source.
|
||||
set(CLANG_UML_TEST_EXAMPLE_SRC
|
||||
test_example.cpp
|
||||
)
|
||||
set(CLANG_UML_TEST_EXAMPLE_HEADER
|
||||
catch.hpp
|
||||
)
|
||||
|
||||
# Make an executable target that depends on the test source code we specified
|
||||
# above.
|
||||
add_executable(test-example ${CLANG_UML_TEST_EXAMPLE_SRC} ${CLANG_UML_TEST_EXAMPL_HEADER})
|
||||
|
||||
# Enable testing via CTest
|
||||
enable_testing()
|
||||
|
||||
# Add our test as runnable via CTest
|
||||
add_test(NAME test-example COMMAND test-example)
|
||||
17618
tests/catch.hpp
Normal file
17618
tests/catch.hpp
Normal file
File diff suppressed because it is too large
Load Diff
19
tests/test_example.cpp
Normal file
19
tests/test_example.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
|
||||
#include "catch.hpp"
|
||||
#include <source_file.hpp>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
|
||||
TEST_CASE("Test add", "[unit-test]"){
|
||||
// not very good tests, but oh well...
|
||||
REQUIRE(add(2, 3) == 5);
|
||||
REQUIRE(add(2., 3.) == 5.);
|
||||
REQUIRE(add(0, 0) == 0);
|
||||
std::cout << "RUNNING TEST" << std::endl;
|
||||
std::complex<double> a(2., 3.);
|
||||
std::complex<double> b(-1., 20.);
|
||||
std::complex<double> c(1., 23.);
|
||||
REQUIRE(add(a,b) == c);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user