use ctest to run unit tests in parallel (requires newer catch2)
This commit is contained in:
@ -1,11 +1,3 @@
|
||||
add_library(Catch INTERFACE)
|
||||
if(EXISTS /usr/include/catch/catch.hpp)
|
||||
target_include_directories(Catch INTERFACE /usr/include/catch)
|
||||
elseif(EXISTS /usr/include/catch2/catch.hpp)
|
||||
target_include_directories(Catch INTERFACE /usr/include/catch2)
|
||||
else()
|
||||
endif()
|
||||
|
||||
#code coverage
|
||||
add_library(coverage_config INTERFACE)
|
||||
target_compile_options(coverage_config INTERFACE -O0 -g --coverage)
|
||||
@ -18,11 +10,35 @@ add_library(decn decn.c ../utils.c)
|
||||
add_library(decn_cover decn.c)
|
||||
target_link_libraries(decn_cover PUBLIC coverage_config)
|
||||
|
||||
add_executable(decn_test decn_test.c ../utils.c)
|
||||
target_link_libraries(decn_test decn_cover coverage_config Catch)
|
||||
# old tests (compare output with reference "golden" output file)
|
||||
add_executable(decn_test
|
||||
decn_test.c
|
||||
../utils.c
|
||||
)
|
||||
target_link_libraries(decn_test
|
||||
decn_cover
|
||||
coverage_config
|
||||
)
|
||||
|
||||
add_executable(decn_tests catch_main.cpp decn_tests.cpp decn_tests_trig.cpp ../utils.c)
|
||||
target_link_libraries(decn_tests decn_cover coverage_config mpfr Catch)
|
||||
# catch2 unit tests
|
||||
find_package(Catch2 REQUIRED)
|
||||
enable_testing()
|
||||
set (BUILD_TESTING ON)
|
||||
add_executable(decn_tests
|
||||
catch_main.cpp
|
||||
decn_tests.cpp
|
||||
decn_tests_trig.cpp
|
||||
../utils.c
|
||||
)
|
||||
target_link_libraries(decn_tests
|
||||
mpfr
|
||||
decn_cover
|
||||
coverage_config
|
||||
Catch2::Catch2
|
||||
)
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
catch_discover_tests(decn_tests)
|
||||
|
||||
# decn prototyping
|
||||
add_subdirectory(proto)
|
||||
|
@ -21,4 +21,4 @@
|
||||
|
||||
|
||||
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
|
||||
#include "catch.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <string>
|
||||
#include <random>
|
||||
#include <boost/multiprecision/mpfr.hpp>
|
||||
#include <catch.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include "decn.h"
|
||||
#include "../utils.h"
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
namespace bmp = boost::multiprecision;
|
||||
using Catch::Matchers::Equals;
|
||||
|
||||
static const int NUM_RAND_TESTS = 1234567;
|
||||
static const int NUM_RAND_TESTS = 123456;
|
||||
|
||||
|
||||
TEST_CASE("build decn"){
|
||||
@ -570,10 +570,16 @@ static void log_test_near1(int lsu0_low, int lsu0_high, int exp){
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("log random near 1"){
|
||||
TEST_CASE("log random 0 to 0.99..."){
|
||||
log_test_near1(0, 99, -1);
|
||||
}
|
||||
TEST_CASE("log random 0.8 to 0.99..."){
|
||||
log_test_near1(80, 99, -1);
|
||||
}
|
||||
TEST_CASE("log random 1.0 to 9.9"){
|
||||
log_test_near1(10, 99, 0);
|
||||
}
|
||||
TEST_CASE("log random 1.0 to 2.0"){
|
||||
log_test_near1(10, 20, 0);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <boost/multiprecision/mpfr.hpp>
|
||||
#include <catch.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include "decn.h"
|
||||
namespace bmp = boost::multiprecision;
|
||||
using Catch::Matchers::Equals;
|
||||
|
Reference in New Issue
Block a user