summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2021-02-21 11:16:02 +0100
committerRoland Reichwein <mail@reichwein.it>2021-02-21 11:16:02 +0100
commit5b951a8fd1b380daab4f9e470425236f70ac0c8f (patch)
tree23a869f6a8aade01247c0604fdb9f991b3c446d5
parent3b758009c7b1e945444ca3be746d05074bac0dab (diff)
Use boost test
-rw-r--r--Makefile9
-rw-r--r--testsuite.cpp19
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 <boost/test/included/unit_test.hpp>
+#include <boost/test/data/dataset.hpp>
+#include <boost/test/data/monomorphic.hpp>
+#include <boost/test/data/test_case.hpp>
#include "autocorrelation.h"
#include "fft.h"
@@ -162,13 +167,10 @@ public:
[](const std::complex<double>& x, const std::complex<double>&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<std::complex<double>> 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: