From 8f1d7d3000647c049cca7c235d273637cae19885 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 29 Dec 2023 17:21:16 +0100 Subject: Added tests --- testsuite.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'testsuite.cpp') diff --git a/testsuite.cpp b/testsuite.cpp index eeed1c6..a846883 100644 --- a/testsuite.cpp +++ b/testsuite.cpp @@ -305,7 +305,7 @@ BOOST_AUTO_TEST_CASE(fft_2) BOOST_REQUIRE_EQUAL(ifft_result[1], (std::complex{0.0, 0.0})); } -BOOST_AUTO_TEST_CASE(fft_4) +BOOST_AUTO_TEST_CASE(fft_4a) { std::vector> v{{1, 0}, {0, 0}, {0, 0}, {0, 0}}; RIT::FFT fft{4}; @@ -326,3 +326,47 @@ BOOST_AUTO_TEST_CASE(fft_4) BOOST_REQUIRE_EQUAL(ifft_result[2], (std::complex{0.0, 0.0})); BOOST_REQUIRE_EQUAL(ifft_result[3], (std::complex{0.0, 0.0})); } + +BOOST_AUTO_TEST_CASE(fft_4b) +{ + std::vector> v{{1, 0}, {-1, 0}, {1, 0}, {-1, 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{0.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[1], (std::complex{0.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[2], (std::complex{4.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[3], (std::complex{0.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{-1.0, 0.0})); + BOOST_REQUIRE_EQUAL(ifft_result[2], (std::complex{1.0, 0.0})); + BOOST_REQUIRE_EQUAL(ifft_result[3], (std::complex{-1.0, 0.0})); +} + +BOOST_AUTO_TEST_CASE(fft_4c) +{ + std::vector> v{{-1, 0}, {1, 0}, {-1, 0}, {1, 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{0.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[1], (std::complex{0.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[2], (std::complex{-4.0, 0.0})); + BOOST_REQUIRE_EQUAL(fft_result[3], (std::complex{0.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{1.0, 0.0})); + BOOST_REQUIRE_EQUAL(ifft_result[2], (std::complex{-1.0, 0.0})); + BOOST_REQUIRE_EQUAL(ifft_result[3], (std::complex{1.0, 0.0})); +} -- cgit v1.2.3