Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

308 lines
6.4KB

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