Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5746: Add optional parameter to Grid interface methods retrieving th…
…e spacing and the grid power. Add getGridBase() method. Add the first few unit tests.
- Loading branch information
1 parent
6658303
commit 6689955
Showing
7 changed files
with
137 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "RadiantTest.h" | ||
|
||
#include "igrid.h" | ||
|
||
namespace test | ||
{ | ||
|
||
using GridTest = RadiantTest; | ||
|
||
inline void checkGridSize(GridSize size, grid::Space space, float expectedSize) | ||
{ | ||
GlobalGrid().setGridSize(size); | ||
EXPECT_EQ(GlobalGrid().getGridSize(space), expectedSize); | ||
} | ||
|
||
inline void checkGridPower(GridSize size, grid::Space space, int expectedPower) | ||
{ | ||
GlobalGrid().setGridSize(size); | ||
EXPECT_EQ(GlobalGrid().getGridPower(space), expectedPower); | ||
} | ||
|
||
TEST_F(GridTest, GridBase) | ||
{ | ||
EXPECT_EQ(GlobalGrid().getGridBase(grid::Space::World), 2); | ||
EXPECT_EQ(GlobalGrid().getGridBase(grid::Space::Texture), 2); | ||
} | ||
|
||
TEST_F(GridTest, WorldGridSize) | ||
{ | ||
checkGridSize(GRID_0125, grid::Space::World, 0.125f); | ||
checkGridSize(GRID_025, grid::Space::World, 0.25f); | ||
checkGridSize(GRID_05, grid::Space::World, 0.5f); | ||
checkGridSize(GRID_1, grid::Space::World, 1.0f); | ||
checkGridSize(GRID_2, grid::Space::World, 2.0f); | ||
checkGridSize(GRID_4, grid::Space::World, 4.0f); | ||
checkGridSize(GRID_8, grid::Space::World, 8.0f); | ||
checkGridSize(GRID_16, grid::Space::World, 16.0f); | ||
checkGridSize(GRID_32, grid::Space::World, 32.0f); | ||
checkGridSize(GRID_64, grid::Space::World, 64.0f); | ||
checkGridSize(GRID_128, grid::Space::World, 128.0f); | ||
checkGridSize(GRID_256, grid::Space::World, 256.0f); | ||
} | ||
|
||
TEST_F(GridTest, WorldGridPower) | ||
{ | ||
checkGridPower(GRID_0125, grid::Space::World, -3); | ||
checkGridPower(GRID_025, grid::Space::World, -2); | ||
checkGridPower(GRID_05, grid::Space::World, -1); | ||
checkGridPower(GRID_1, grid::Space::World, 0); | ||
checkGridPower(GRID_2, grid::Space::World, 1); | ||
checkGridPower(GRID_4, grid::Space::World, 2); | ||
checkGridPower(GRID_8, grid::Space::World, 3); | ||
checkGridPower(GRID_16, grid::Space::World, 4); | ||
checkGridPower(GRID_32, grid::Space::World, 5); | ||
checkGridPower(GRID_64, grid::Space::World, 6); | ||
checkGridPower(GRID_128, grid::Space::World, 7); | ||
checkGridPower(GRID_256, grid::Space::World, 8); | ||
} | ||
|
||
TEST_F(GridTest, TextureGridSize) | ||
{ | ||
checkGridSize(GRID_0125, grid::Space::Texture, 0.0078125f); | ||
checkGridSize(GRID_025, grid::Space::Texture, 0.0078125f); | ||
checkGridSize(GRID_05, grid::Space::Texture, 0.0078125f); | ||
checkGridSize(GRID_1, grid::Space::Texture, 0.0078125f); // lower bound | ||
checkGridSize(GRID_2, grid::Space::Texture, 0.015625f); | ||
checkGridSize(GRID_4, grid::Space::Texture, 0.03125f); | ||
checkGridSize(GRID_8, grid::Space::Texture, 0.0625f); | ||
checkGridSize(GRID_16, grid::Space::Texture, 0.125f); | ||
checkGridSize(GRID_32, grid::Space::Texture, 0.25f); | ||
checkGridSize(GRID_64, grid::Space::Texture, 0.5f); | ||
checkGridSize(GRID_128, grid::Space::Texture, 1.0f); // upper bound | ||
checkGridSize(GRID_256, grid::Space::Texture, 1.0f); | ||
} | ||
|
||
TEST_F(GridTest, TextureGridPower) | ||
{ | ||
checkGridPower(GRID_0125, grid::Space::Texture, -7); | ||
checkGridPower(GRID_025, grid::Space::Texture, -7); | ||
checkGridPower(GRID_05, grid::Space::Texture, -7); | ||
checkGridPower(GRID_1, grid::Space::Texture, -7); // lower bound | ||
checkGridPower(GRID_2, grid::Space::Texture, -6); | ||
checkGridPower(GRID_4, grid::Space::Texture, -5); | ||
checkGridPower(GRID_8, grid::Space::Texture, -4); | ||
checkGridPower(GRID_16, grid::Space::Texture, -3); | ||
checkGridPower(GRID_32, grid::Space::Texture, -2); | ||
checkGridPower(GRID_64, grid::Space::Texture, -1); | ||
checkGridPower(GRID_128, grid::Space::Texture, 0); // upper bound | ||
checkGridPower(GRID_256, grid::Space::Texture, 0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters