|
|
@@ -1,13 +1,14 @@ |
|
|
|
#include <map> |
|
|
|
#include <string> |
|
|
|
#include <vector> |
|
|
|
#include "memory.h" |
|
|
|
#include "memory_Context.h" |
|
|
|
|
|
|
|
std::string memory_test_generateConstPlayfield( |
|
|
|
) { |
|
|
|
auto c = memory_createContext(); |
|
|
|
c.playfieldSize = 2; |
|
|
|
auto c = memory_generateConstPlayfield(c); |
|
|
|
c = memory_generateConstPlayfield(c); |
|
|
|
if ( |
|
|
|
c.recentField == "playfieldItems" && |
|
|
|
c.playfieldItems.size() == 4 && |
|
|
@@ -27,10 +28,10 @@ std::string memory_test_selectItem_1x( |
|
|
|
) { |
|
|
|
auto c = memory_createContext(); |
|
|
|
c.playfieldSize = 2; |
|
|
|
auto c = memory_generateConstPlayfield(c); |
|
|
|
c = memory_generateConstPlayfield(c); |
|
|
|
# Select the first item.; |
|
|
|
c.selectedId = 0; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
# See if it's in selectedItems now.; |
|
|
|
if ( |
|
|
|
c.recentField == "selectedItems" && |
|
|
@@ -48,12 +49,12 @@ std::string memory_test_selectItem_2x( |
|
|
|
) { |
|
|
|
auto c = memory_createContext(); |
|
|
|
c.playfieldSize = 2; |
|
|
|
auto c = memory_generateConstPlayfield(c); |
|
|
|
c = memory_generateConstPlayfield(c); |
|
|
|
# Select the first two items.; |
|
|
|
c.selectedId = 0; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
c.selectedId = 1; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
# See if both items are selected now.; |
|
|
|
if ( |
|
|
|
c.recentField == "selectedItems" && |
|
|
@@ -72,14 +73,14 @@ std::string memory_test_selectItem_3x( |
|
|
|
) { |
|
|
|
auto c = memory_createContext(); |
|
|
|
c.playfieldSize = 2; |
|
|
|
auto c = memory_generateConstPlayfield(c); |
|
|
|
c = memory_generateConstPlayfield(c); |
|
|
|
# Select three items.; |
|
|
|
c.selectedId = 0; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
c.selectedId = 1; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
c.selectedId = 2; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
# See if only one (last) item is selected now.; |
|
|
|
if ( |
|
|
|
c.recentField == "selectedItems" && |
|
|
@@ -98,14 +99,14 @@ std::string memory_test_shouldDeselectMismatchedItems( |
|
|
|
) { |
|
|
|
auto c = memory_createContext(); |
|
|
|
c.playfieldSize = 2; |
|
|
|
auto c = memory_generateConstPlayfield(c); |
|
|
|
c = memory_generateConstPlayfield(c); |
|
|
|
# Select two items of different groups.; |
|
|
|
c.selectedId = 0; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
c.selectedId = 2; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
# Detect mismatching.; |
|
|
|
auto c = memory_shouldDeselectMismatchedItems(c); |
|
|
|
c = memory_shouldDeselectMismatchedItems(c); |
|
|
|
# See if the two selected items do not match.; |
|
|
|
if ( |
|
|
|
c.recentField == "mismatchedItems" && |
|
|
@@ -125,14 +126,14 @@ std::string memory_test_shouldDeselectMismatchedItems_itemTwice( |
|
|
|
) { |
|
|
|
auto c = memory_createContext(); |
|
|
|
c.playfieldSize = 2; |
|
|
|
auto c = memory_generateConstPlayfield(c); |
|
|
|
c = memory_generateConstPlayfield(c); |
|
|
|
# Select the same item twice.; |
|
|
|
c.selectedId = 0; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
c.selectedId = 0; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
# Detect mismatching.; |
|
|
|
auto c = memory_shouldDeselectMismatchedItems(c); |
|
|
|
c = memory_shouldDeselectMismatchedItems(c); |
|
|
|
# See if the two selected items do not match.; |
|
|
|
if ( |
|
|
|
c.recentField == "mismatchedItems" && |
|
|
@@ -154,23 +155,23 @@ std::string memory_test_shouldDetectVictory( |
|
|
|
) { |
|
|
|
auto c = memory_createContext(); |
|
|
|
c.playfieldSize = 2; |
|
|
|
auto c = memory_generateConstPlayfield(c); |
|
|
|
c = memory_generateConstPlayfield(c); |
|
|
|
# Select the first two items of the same group.; |
|
|
|
c.selectedId = 0; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
c.selectedId = 1; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
# Hide the first pair.; |
|
|
|
auto c = memory_shouldHideMatchingItems(c); |
|
|
|
c = memory_shouldHideMatchingItems(c); |
|
|
|
# Select the last two items of the same group.; |
|
|
|
c.selectedId = 2; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
c.selectedId = 3; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
# Hide the second pair.; |
|
|
|
auto c = memory_shouldHideMatchingItems(c); |
|
|
|
c = memory_shouldHideMatchingItems(c); |
|
|
|
# Detect victory.; |
|
|
|
auto c = memory_shouldDetectVictory(c); |
|
|
|
c = memory_shouldDetectVictory(c); |
|
|
|
# See if victory has been detected.; |
|
|
|
if ( |
|
|
|
c.recentField == "victory" && |
|
|
@@ -188,14 +189,14 @@ std::string memory_test_shouldHideMatchingItems( |
|
|
|
) { |
|
|
|
auto c = memory_createContext(); |
|
|
|
c.playfieldSize = 2; |
|
|
|
auto c = memory_generateConstPlayfield(c); |
|
|
|
c = memory_generateConstPlayfield(c); |
|
|
|
# Select two items of the same group.; |
|
|
|
c.selectedId = 0; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
c.selectedId = 1; |
|
|
|
auto c = memory_selectItem(c); |
|
|
|
c = memory_selectItem(c); |
|
|
|
# Hide matching items.; |
|
|
|
auto c = memory_shouldHideMatchingItems(c); |
|
|
|
c = memory_shouldHideMatchingItems(c); |
|
|
|
# See if the two selected items match.; |
|
|
|
if ( |
|
|
|
c.recentField == "hiddenItems" && |
|
|
|