From c388759ed67b792201b99bf7d73d036c34b47d87 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Wed, 7 Nov 2018 10:09:47 -0800 Subject: Working on some consistency --- Test/PanelExtractionTests.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++ Test/Test.vcxproj | 1 + 2 files changed, 64 insertions(+) create mode 100644 Test/PanelExtractionTests.cpp (limited to 'Test') diff --git a/Test/PanelExtractionTests.cpp b/Test/PanelExtractionTests.cpp new file mode 100644 index 0000000..dfb9b9e --- /dev/null +++ b/Test/PanelExtractionTests.cpp @@ -0,0 +1,63 @@ +#include "gtest/gtest.h" +#include "Panel.h" + +class PanelExtractionTests : public testing::Test +{ +protected: + Panel _panel; + // std::shared_ptr _panel; + + void SetPanelSize(int width, int height) { + // _panel = std::make_shared(); + _panel._width = width; + _panel._height = height; + } + + std::tuple loc_to_xy(int location) { + return _panel.loc_to_xy(location); + } + + int xy_to_loc(int x, int y) { + return _panel.xy_to_loc(x, y); + } +}; + +TEST_F(PanelExtractionTests, LocToXY_7x5) { + SetPanelSize(7, 5); + /* Here's the panel, with the correct location order + 8 . 9 . 10. 11 (_width = 7) + . . . . . . . + 4 . 5 . 6 . 7 + . . . . . . . + 0 . 1 . 2 . 3 + (_height = 5) + */ + ASSERT_EQ(0, xy_to_loc(0, 4)); + ASSERT_EQ(1, xy_to_loc(2, 4)); + ASSERT_EQ(2, xy_to_loc(4, 4)); + ASSERT_EQ(3, xy_to_loc(6, 4)); + + ASSERT_EQ(4, xy_to_loc(0, 2)); + ASSERT_EQ(5, xy_to_loc(2, 2)); + ASSERT_EQ(6, xy_to_loc(4, 2)); + ASSERT_EQ(7, xy_to_loc(6, 2)); + + ASSERT_EQ(8, xy_to_loc(0, 0)); + ASSERT_EQ(9, xy_to_loc(2, 0)); + ASSERT_EQ(10, xy_to_loc(4, 0)); + ASSERT_EQ(11, xy_to_loc(6, 0)); +} + +TEST_F(PanelExtractionTests, LocToXY_3x3) { + SetPanelSize(3, 3); + /* Here's the panel, with the correct location order + 2 . 3 (_width = 3) + . . . + 0 . 1 + (_height = 3) + */ + ASSERT_EQ(0, xy_to_loc(0, 2)); + ASSERT_EQ(1, xy_to_loc(2, 2)); + ASSERT_EQ(2, xy_to_loc(0, 0)); + ASSERT_EQ(3, xy_to_loc(2, 0)); +} \ No newline at end of file diff --git a/Test/Test.vcxproj b/Test/Test.vcxproj index a6d8f75..55f3ce8 100644 --- a/Test/Test.vcxproj +++ b/Test/Test.vcxproj @@ -33,6 +33,7 @@ + -- cgit 1.4.1