Research portable Memory game | Исследовать портируемую игру Память
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cli_test.cpp 6.4KB

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