Research portable Memory game | Исследовать портируемую игру Память
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

307 行
6.4KB

  1. #include <map>
  2. #include <string>
  3. #include <vector>
  4. #include "memory_Context.h"
  5. #include "main.h"
  6. std::string cli_test_exit_e(
  7. ) {
  8. auto c = memory_createContext();
  9. c.input = "e";
  10. c.recentField = "input";
  11. c = cli_exit(c);
  12. if (
  13. c.recentField == "exit"
  14. ) {
  15. return "OK: cli_exit_e";
  16. }
  17. return "ERR: cli_exit_e";
  18. }
  19. std::string cli_test_exit_exit(
  20. ) {
  21. auto c = memory_createContext();
  22. c.input = "exit";
  23. c.recentField = "input";
  24. c = cli_exit(c);
  25. if (
  26. c.recentField == "exit"
  27. ) {
  28. return "OK: cli_exit_exit";
  29. }
  30. return "ERR: cli_exit_e";
  31. }
  32. std::string cli_test_exit_victory(
  33. ) {
  34. auto c = memory_createContext();
  35. c.playfieldSize = 2;
  36. c.recentField = "playfieldSize";
  37. c = memory_generateConstPlayfield(c);
  38. // Match the first pair of tiles.
  39. c.input = "1";
  40. c.recentField = "input";
  41. c = cli_selectItem(c);
  42. c = memory_selectItem(c);
  43. c.input = "2";
  44. c.recentField = "input";
  45. c = cli_selectItem(c);
  46. c = memory_selectItem(c);
  47. c = memory_hideMatchingItems(c);
  48. // Match the second pair of tiles.
  49. c.input = "3";
  50. c.recentField = "input";
  51. c = cli_selectItem(c);
  52. c = memory_selectItem(c);
  53. c.input = "4";
  54. c.recentField = "input";
  55. c = cli_selectItem(c);
  56. c = memory_selectItem(c);
  57. c = memory_hideMatchingItems(c);
  58. c = memory_detectVictory(c);
  59. c = cli_reportVictory(c);
  60. c = cli_exit(c);
  61. if (
  62. c.recentField == "exit"
  63. ) {
  64. return "OK: cli_exit_victory";
  65. }
  66. return "ERR: cli_exit_victory";
  67. }
  68. std::string cli_test_exit_q(
  69. ) {
  70. auto c = memory_createContext();
  71. c.input = "q";
  72. c.recentField = "input";
  73. c = cli_exit(c);
  74. if (
  75. c.recentField == "exit"
  76. ) {
  77. return "OK: cli_exit_q";
  78. }
  79. return "ERR: cli_exit_q";
  80. }
  81. std::string cli_test_exit_quit(
  82. ) {
  83. auto c = memory_createContext();
  84. c.input = "quit";
  85. c.recentField = "input";
  86. c = cli_exit(c);
  87. if (
  88. c.recentField == "exit"
  89. ) {
  90. return "OK: cli_exit_quit";
  91. }
  92. return "ERR: cli_exit_quit";
  93. }
  94. std::string cli_test_goOn(
  95. ) {
  96. auto c = memory_createContext();
  97. c.playfieldSize = 2;
  98. c.recentField = "playfieldSize";
  99. c = memory_generateConstPlayfield(c);
  100. // Match the first pair of items.
  101. c.input = "1";
  102. c.recentField = "input";
  103. c = cli_selectItem(c);
  104. c = memory_selectItem(c);
  105. c.input = "2";
  106. c.recentField = "input";
  107. c = cli_selectItem(c);
  108. c = memory_selectItem(c);
  109. c = memory_hideMatchingItems(c);
  110. c = cli_reportMatchedItems(c);
  111. c = cli_goOn(c);
  112. if (
  113. c.recentField == "outputGoOn"
  114. ) {
  115. return "OK: cli_goOn";
  116. }
  117. return "ERR: cli_goOn";
  118. }
  119. std::string cli_test_greetUser(
  120. ) {
  121. auto c = memory_createContext();
  122. c.didLaunch = true;
  123. c.recentField = "didLaunch";
  124. c = cli_greetUser(c);
  125. if (
  126. c.recentField == "outputGreeting"
  127. ) {
  128. return "OK: cli_greetUser";
  129. }
  130. return "ERR: cli_greetUser";
  131. }
  132. std::string cli_test_promptSecondItemSelection(
  133. ) {
  134. auto c = memory_createContext();
  135. c.input = "1";
  136. c.recentField = "input";
  137. c = cli_selectItem(c);
  138. c = memory_selectItem(c);
  139. c = cli_promptSecondItemSelection(c);
  140. if (
  141. c.recentField == "outputPromptSelection"
  142. ) {
  143. return "OK: cli_promptSecondItemSelection";
  144. }
  145. return "ERR: cli_promptSecondItemSelection";
  146. }
  147. std::string cli_test_reportMatchedItems(
  148. ) {
  149. auto c = memory_createContext();
  150. c.playfieldSize = 2;
  151. c.recentField = "playfieldSize";
  152. c = memory_generateConstPlayfield(c);
  153. c.input = "1";
  154. c.recentField = "input";
  155. c = cli_selectItem(c);
  156. c = memory_selectItem(c);
  157. c.input = "2";
  158. c.recentField = "input";
  159. c = cli_selectItem(c);
  160. c = memory_selectItem(c);
  161. c = memory_hideMatchingItems(c);
  162. c = cli_reportMatchedItems(c);
  163. if (
  164. c.recentField == "outputMatchedItems"
  165. ) {
  166. return "OK: cli_reportMatchedItems";
  167. }
  168. return "ERR: cli_reportMatchedItems";
  169. }
  170. std::string cli_test_reportMismatchedItems(
  171. ) {
  172. auto c = memory_createContext();
  173. c.playfieldSize = 2;
  174. c.recentField = "playfieldSize";
  175. c = memory_generateConstPlayfield(c);
  176. c.input = "1";
  177. c.recentField = "input";
  178. c = cli_selectItem(c);
  179. c = memory_selectItem(c);
  180. c.input = "3";
  181. c.recentField = "input";
  182. c = cli_selectItem(c);
  183. c = memory_selectItem(c);
  184. c = memory_detectMismatchedItems(c);
  185. c = cli_reportMismatchedItems(c);
  186. if (
  187. c.recentField == "outputMismatchedItems"
  188. ) {
  189. return "OK: cli_reportMismatchedItems";
  190. }
  191. return "ERR: cli_reportMismatchedItems";
  192. }
  193. std::string cli_test_selectItem(
  194. ) {
  195. auto c = memory_createContext();
  196. c.input = "1";
  197. c.recentField = "input";
  198. c = cli_selectItem(c);
  199. if (
  200. c.recentField == "selectedId" &&
  201. c.selectedId == 0
  202. ) {
  203. return "OK: cli_selectItem";
  204. }
  205. return "ERR: cli_selectItem";
  206. }
  207. std::string cli_test_showHelp_h(
  208. ) {
  209. auto c = memory_createContext();
  210. c.input = "h";
  211. c.recentField = "input";
  212. c = cli_showHelp(c);
  213. if (
  214. c.recentField == "outputHelp"
  215. ) {
  216. return "OK: cli_showHelp_h";
  217. }
  218. return "ERR: cli_showHelp_h";
  219. }
  220. std::string cli_test_showHelp_help(
  221. ) {
  222. auto c = memory_createContext();
  223. c.input = "help";
  224. c.recentField = "input";
  225. c = cli_showHelp(c);
  226. if (
  227. c.recentField == "outputHelp"
  228. ) {
  229. return "OK: cli_showHelp_help";
  230. }
  231. return "ERR: cli_showHelp_help";
  232. }
  233. std::string cli_test_reportVictory(
  234. ) {
  235. auto c = memory_createContext();
  236. c.playfieldSize = 2;
  237. c.recentField = "playfieldSize";
  238. c = memory_generateConstPlayfield(c);
  239. // Match the first pair of tiles.
  240. c.input = "1";
  241. c.recentField = "input";
  242. c = cli_selectItem(c);
  243. c = memory_selectItem(c);
  244. c.input = "2";
  245. c.recentField = "input";
  246. c = cli_selectItem(c);
  247. c = memory_selectItem(c);
  248. c = memory_hideMatchingItems(c);
  249. // Match the second pair of tiles.
  250. c.input = "3";
  251. c.recentField = "input";
  252. c = cli_selectItem(c);
  253. c = memory_selectItem(c);
  254. c.input = "4";
  255. c.recentField = "input";
  256. c = cli_selectItem(c);
  257. c = memory_selectItem(c);
  258. c = memory_hideMatchingItems(c);
  259. c = memory_detectVictory(c);
  260. c = cli_reportVictory(c);
  261. if (
  262. c.recentField == "outputVictory"
  263. ) {
  264. return "OK: cli_reportVictory";
  265. }
  266. return "ERR: cli_reportVictory";
  267. }
  268. //def cli_test_shouldReportIvalidItemSelection_outOfBoundsMin(
  269. //) -> str:
  270. // c = cli_createContext()
  271. // c.cMemory = memory_createContext()
  272. // c.input = "0"
  273. // c = cli_selectItem(c)
  274. // c = cli_shouldReportInvalidItemSelection(c)
  275. // if (
  276. // c.recentField == "outputInvalidItemSelection"
  277. // ):
  278. // return "OK: cli_shouldReportInvalidItemSelection"
  279. // //}
  280. // return "ERR: cli_shouldReportInvalidItemSelection"
  281. ////}
  282. //