From a3dacdd1a7cd2cb4c7069f792c049011ea9c2f0d Mon Sep 17 00:00:00 2001 From: rkcf Date: Tue, 28 Feb 2023 09:24:23 -0600 Subject: [PATCH] Test: add coverage for Wave construction Refs: #18, #16 --- CMakeLists.txt | 3 +++ Makefile | 2 +- tests/wave_test.cpp | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/wave_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f320013..d3d92b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,11 @@ FetchContent_MakeAvailable(googletest) enable_testing() add_executable(wtpp_test tests/wtpp_test.cpp) +add_executable(wave_test tests/wave_test.cpp) target_link_libraries(wtpp_test GTest::gtest_main) +target_link_libraries(wave_test GTest::gtest_main) include(GoogleTest) gtest_discover_tests(wtpp_test) +gtest_discover_tests(wave_test) diff --git a/Makefile b/Makefile index 05457f7..3c86085 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ clean: rm build/wtpp test: build - cd build && ctest + cd build && ctest --output-on-failure debug: $(CC) -g $(CFLAGS) $(OBJECTS) diff --git a/tests/wave_test.cpp b/tests/wave_test.cpp new file mode 100644 index 0000000..1d612cd --- /dev/null +++ b/tests/wave_test.cpp @@ -0,0 +1,34 @@ +#include "../src/wave.h" +#include "gtest/gtest.h" + +// Initialize index at 0 for wave cycles +uint16_t Wave::m_nid = 0; + +TEST(Wave, DefaultConstructor) +{ + Wave w1, w2; + // Check that ids are correct + EXPECT_EQ(w1.getId(), 0); + EXPECT_EQ(w2.getId(), 1); + // Sample table should be 0 initialized + EXPECT_EQ(w1.getVal(0), 0); +} + +TEST(Wave, CopyConstructor) { + Wave w1; + Wave w2(w1); + // Check id is correct + EXPECT_EQ(w2.getId(), 0); + // Sample table should be 0 initialized + EXPECT_EQ(w2.getVal(0), 0); +} + +TEST(Wave, CopyAssignment) +{ + Wave w1; + Wave w2 = w1; + // Check id is correct + EXPECT_EQ(w2.getId(), 0); + // Sample table should be 0 initialized + EXPECT_EQ(w2.getVal(0), 0); +}