From 5b951a8fd1b380daab4f9e470425236f70ac0c8f Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 21 Feb 2021 11:16:02 +0100 Subject: Use boost test --- Makefile | 9 ++++++++- testsuite.cpp | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 8325934..bba1d16 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,14 @@ PORTAUDIOCFLAGS=$(shell pkg-config --cflags portaudiocpp) PORTAUDIOLIBS=$(shell pkg-config --libs portaudiocpp) CXX=clang++-11 -CXXFLAGS=-stdlib=libc++ -Wall -O2 -std=c++17 -fexceptions -Iexternal + +ifeq ($(CXXFLAGS),) +#CXXFLAGS=-O0 -g -D_DEBUG +CXXFLAGS=-O2 -DNDEBUG +endif +CXXFLAGS+=-stdlib=libc++ +CXXFLAGS+=-Wall +CXXFLAGS+=-std=c++17 -fexceptions -Iexternal #-march=native -mtune=native # is not better for llvm CC=clang CFLAGS=-Wall -O2 -Iexternal diff --git a/testsuite.cpp b/testsuite.cpp index 09ac565..cc51cfa 100644 --- a/testsuite.cpp +++ b/testsuite.cpp @@ -1,4 +1,9 @@ -// FFT Test +#define BOOST_TEST_MODULE fft_test + +#include +#include +#include +#include #include "autocorrelation.h" #include "fft.h" @@ -162,13 +167,10 @@ public: [](const std::complex& x, const std::complex&y) -> double { return abs(y - x);} ); - if (diff > tolerance) - std::cout << "Error: Results diff: " << diff << "\n"; + BOOST_CHECK_MESSAGE(diff <= tolerance, "Error: Results diff: " << diff); } - if (mElapsed > mReference->mElapsed) { - std::cout << "Error: " << mName << " too slow!\n"; - } + BOOST_CHECK_MESSAGE(mElapsed <= mReference->mElapsed, "Error: " << mName << " too slow!"); } } @@ -249,7 +251,8 @@ public: } }; -int main(int argc, char* argv[]) { +BOOST_AUTO_TEST_CASE(fft) +{ std::vector> v(4096, 0); generate(v); @@ -279,8 +282,6 @@ int main(int argc, char* argv[]) { MeasureTuner_RR measureTuner_RR(v); measureTuner_RR.run(); - - return 0; } // TODO: -- cgit v1.2.3