Skip to content

Commit

Permalink
Tests: Added HypercubeStorageTest.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Rejeq committed May 30, 2023
1 parent 3f63370 commit 0031d58
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ add_subdirectory(./utils/)
include(GoogleTest)
add_subdirectory(./src/)
add_subdirectory(./src/World/)
add_subdirectory(./src/Renderer/)
11 changes: 11 additions & 0 deletions tests/src/Renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
add_executable(CellntaRendererTests
./Main.cpp
./HypercubeStorageTest.cpp
)

target_link_libraries(CellntaRendererTests PRIVATE
Cellnta::Renderer
GTest::gtest_main
)

gtest_discover_tests(CellntaRendererTests)
22 changes: 22 additions & 0 deletions tests/src/Renderer/HypercubeStorageTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <gtest/gtest.h>

#include <Cellnta/Renderer/HypercubeStorage.h>

using namespace Cellnta;

TEST(HypercubeStorage, PolygonMode_UniqueFaces) {
HypercubeStorage cube;
cube.GenerateCube(8, -1.0f, CubeMode::POLYGON);

int size = cube.GetIndicesSize();
const auto* ind = cube.GetIndices();

for (int i = 0; i < size; i += 6) {
for (int j = 0; j < i; j += 6) {
ASSERT_FALSE(ind[i + 0] == ind[j + 0] && ind[i + 1] == ind[j + 1] &&
ind[i + 2] == ind[j + 2] && ind[i + 3] == ind[j + 3] &&
ind[i + 4] == ind[j + 4] && ind[i + 5] == ind[j + 5])
<< "i = '" << i << "', j = '" << j << "'";
}
}
}
12 changes: 12 additions & 0 deletions tests/src/Renderer/Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <gtest/gtest.h>
#include <Cellnta/Log.h>

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
Cellnta::Log::InitDefault();
Cellnta::Log::GetLogger()->set_level(spdlog::level::trace);

return RUN_ALL_TESTS();
}


0 comments on commit 0031d58

Please sign in to comment.