From af22f78fb470225d276e8903b327bd57732d13a9 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 29 Dec 2023 17:12:32 +0100 Subject: Added tests --- testsuite.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'testsuite.cpp') diff --git a/testsuite.cpp b/testsuite.cpp index cc51cfa..eeed1c6 100644 --- a/testsuite.cpp +++ b/testsuite.cpp @@ -251,7 +251,7 @@ public: } }; -BOOST_AUTO_TEST_CASE(fft) +BOOST_AUTO_TEST_CASE(performance) { std::vector> v(4096, 0); @@ -286,3 +286,43 @@ BOOST_AUTO_TEST_CASE(fft) // TODO: // -0.5 <= deviation <= 0.5 + +BOOST_AUTO_TEST_CASE(fft_2) +{ + std::vector> v{{1, 0}, {0, 0}}; + RIT::FFT fft{2}; + auto fft_result = fft(v); + + BOOST_REQUIRE_EQUAL(fft_result.size(), 2); + BOOST_REQUIRE_EQUAL(fft_result[0], (std::complex{1.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[1], (std::complex{1.0, 0.0})); + + RIT::IFFT ifft{2}; + auto ifft_result = ifft(fft_result); + + BOOST_REQUIRE_EQUAL(ifft_result.size(), 2); + BOOST_REQUIRE_EQUAL(ifft_result[0], (std::complex{1.0, 0.0})); + BOOST_REQUIRE_EQUAL(ifft_result[1], (std::complex{0.0, 0.0})); +} + +BOOST_AUTO_TEST_CASE(fft_4) +{ + std::vector> v{{1, 0}, {0, 0}, {0, 0}, {0, 0}}; + RIT::FFT fft{4}; + auto fft_result = fft(v); + + BOOST_REQUIRE_EQUAL(fft_result.size(), 4); + BOOST_REQUIRE_EQUAL(fft_result[0], (std::complex{1.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[1], (std::complex{1.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[2], (std::complex{1.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[3], (std::complex{1.0, 0.0})); + + RIT::IFFT ifft{4}; + auto ifft_result = ifft(fft_result); + + BOOST_REQUIRE_EQUAL(ifft_result.size(), 4); + BOOST_REQUIRE_EQUAL(ifft_result[0], (std::complex{1.0, 0.0})); + BOOST_REQUIRE_EQUAL(ifft_result[1], (std::complex{0.0, 0.0})); + BOOST_REQUIRE_EQUAL(ifft_result[2], (std::complex{0.0, 0.0})); + BOOST_REQUIRE_EQUAL(ifft_result[3], (std::complex{0.0, 0.0})); +} -- cgit v1.2.3