initial commit
This commit is contained in:
51
tests/test_wfc.cpp
Normal file
51
tests/test_wfc.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "nd-wfc/wfc.hpp"
|
||||
#include "nd-wfc/types.hpp"
|
||||
|
||||
namespace nd_wfc {
|
||||
|
||||
// Basic test for 2D WFC
|
||||
TEST(WfcTest, Basic2D) {
|
||||
// Create a simple 2x2 grid with 2 tile types
|
||||
Size<2> size = {2, 2};
|
||||
std::vector<TileId> tiles = {0, 1};
|
||||
|
||||
// Simple constraints: tile 0 can connect to tile 0 and 1 in all directions
|
||||
// tile 1 can only connect to tile 1
|
||||
std::vector<Constraint> constraints = {
|
||||
{0, 0, Direction::North}, {0, 0, Direction::South},
|
||||
{0, 0, Direction::East}, {0, 0, Direction::West},
|
||||
{0, 1, Direction::North}, {0, 1, Direction::South},
|
||||
{0, 1, Direction::East}, {0, 1, Direction::West},
|
||||
{1, 1, Direction::North}, {1, 1, Direction::South},
|
||||
{1, 1, Direction::East}, {1, 1, Direction::West}
|
||||
};
|
||||
|
||||
WfcConfig config;
|
||||
config.seed = 42; // For reproducible tests
|
||||
|
||||
Wfc2D wfc(size, tiles, constraints, config);
|
||||
|
||||
WfcResult result = wfc.run();
|
||||
|
||||
// The algorithm should succeed
|
||||
EXPECT_EQ(result, WfcResult::Success);
|
||||
EXPECT_TRUE(wfc.isComplete());
|
||||
}
|
||||
|
||||
// Test grid functionality
|
||||
TEST(GridTest, Basic2D) {
|
||||
Size<2> size = {3, 3};
|
||||
Grid<2> grid(size);
|
||||
|
||||
// Test coordinate conversion
|
||||
Coord<2> coord = {1, 2};
|
||||
Index index = grid.coordToIndex(coord);
|
||||
Coord<2> back_coord = grid.indexToCoord(index);
|
||||
|
||||
EXPECT_EQ(coord, back_coord);
|
||||
EXPECT_EQ(grid.getSize(), size);
|
||||
EXPECT_EQ(grid.getTotalSize(), 9);
|
||||
}
|
||||
|
||||
} // namespace nd_wfc
|
||||
Reference in New Issue
Block a user