Skip to content

Commit

Permalink
Merge pull request #7 from mike919192/stdabs
Browse files Browse the repository at this point in the history
Add Wpedantic and Wconversion.  Found bug in test that abs was conver…
  • Loading branch information
mike919192 authored Dec 2, 2023
2 parents 6f05cd9 + ba1dae6 commit 4e959b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ find_package(Catch2 REQUIRED)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if ( CMAKE_COMPILER_IS_GNUCC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wconversion")
endif()

add_executable(${PROJECT_NAME} ${test})
Expand Down
8 changes: 4 additions & 4 deletions test/testIIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST_CASE("Filter test", "[single-file]")
std::vector<double> error(readImpulse.size());

for (size_t i = 0; i < error.size(); i++) {
error.at(i) = abs(data.at(i) - readImpulse.at(i));
error.at(i) = std::abs(data.at(i) - readImpulse.at(i));
}
double maxError = *std::max_element(error.begin(), error.end());
REQUIRE(maxError < 1e-12); //typically error 1e-16 or less
Expand Down Expand Up @@ -91,7 +91,7 @@ TEST_CASE("Filter test", "[single-file]")
lpFilter.SetLPCoeff(f0, fs);
lpFilter.PreloadFilter(steadyValue);
lpFilter.Process(steadyLP.begin(), steadyLP.end());
auto calcError = [steadyValue](double& n) { n = abs(n - steadyValue); };
auto calcError = [steadyValue](double& n) { n = std::abs(n - steadyValue); };
std::for_each(steadyLP.begin(), steadyLP.end(), calcError);
double maxErrorLP = *std::max_element(steadyLP.begin(), steadyLP.end());
REQUIRE(maxErrorLP < 1e-12);
Expand All @@ -104,7 +104,7 @@ TEST_CASE("Filter test", "[single-file]")
hpFilter.SetHPCoeff(f0, fs);
hpFilter.PreloadFilter(steadyValue);
hpFilter.Process(steadyHP.begin(), steadyHP.end());
auto calcError = [](double& n) { n = abs(n); };
auto calcError = [](double& n) { n = std::abs(n); };
std::for_each(steadyHP.begin(), steadyHP.end(), calcError);
double maxErrorHP = *std::max_element(steadyHP.begin(), steadyHP.end());
REQUIRE(maxErrorHP < 1e-12);
Expand All @@ -117,7 +117,7 @@ TEST_CASE("Filter test", "[single-file]")
bpFilter.SetBPCoeff(f0, fs, Q);
bpFilter.PreloadFilter(steadyValue);
bpFilter.Process(steadyBP.begin(), steadyBP.end());
auto calcError = [](double& n) { n = abs(n); };
auto calcError = [](double& n) { n = std::abs(n); };
std::for_each(steadyBP.begin(), steadyBP.end(), calcError);
double maxErrorBP = *std::max_element(steadyBP.begin(), steadyBP.end());
REQUIRE(maxErrorBP < 1e-12);
Expand Down

0 comments on commit 4e959b0

Please sign in to comment.