test_integration_history.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. /*
  2. * Copyright (c) 2021 Stefan Strobel <stefan.strobel@shimatta.net>
  3. *
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file test_integration_history.cpp
  10. * @brief integration test implementation for the history buffer of the shellmatta
  11. * @author Stefan Strobel <stefan.strobel@shimatta.net>
  12. */
  13. #include "test/framework/catch.hpp"
  14. extern "C" {
  15. #include "test/framework/fff.h"
  16. #include "shellmatta.h"
  17. }
  18. #include <string.h>
  19. FAKE_VALUE_FUNC(shellmatta_retCode_t, writeFct, const char *, uint32_t)
  20. FAKE_VALUE_FUNC(shellmatta_retCode_t, cmdFct1, shellmatta_handle_t, const char *, uint32_t)
  21. FAKE_VALUE_FUNC(shellmatta_retCode_t, cmdFct2, shellmatta_handle_t, const char *, uint32_t)
  22. FAKE_VALUE_FUNC(shellmatta_retCode_t, cmdFct3, shellmatta_handle_t, const char *, uint32_t)
  23. FAKE_VALUE_FUNC(shellmatta_retCode_t, cmdFct4, shellmatta_handle_t, const char *, uint32_t)
  24. /* List of fakes */
  25. #define FFF_FAKES_LIST(FAKE) \
  26. FAKE(writeFct) \
  27. FAKE(cmdFct1) \
  28. FAKE(cmdFct2) \
  29. FAKE(cmdFct3) \
  30. FAKE(cmdFct4)
  31. #define CHECK_FOR_COMMAND(hist, idx) \
  32. CHECK(writeFct_fake.call_count == ((hist) + 1u)); \
  33. CHECK(0 == memcmp(writeFct_fake.arg0_history[(hist)], commandSequence[(idx)], strlen(commandSequence[(idx)]) - 1)); \
  34. CHECK((strlen(commandSequence[(idx)]) - 1) == writeFct_fake.arg1_history[(hist)]);
  35. #define BUTTON_UP "\x1b" "[A"
  36. #define BUTTON_DOWN "\x1b" "[B"
  37. #define PROCESS_INPUT(input) \
  38. CHECK(SHELLMATTA_OK == shellmatta_processData(handle, (char*)(input), sizeof((input)) - 1u));
  39. static shellmatta_cmd_t cmd1 = {(char*)"cmd1", (char*)"1", NULL, NULL, cmdFct1, NULL};
  40. static shellmatta_cmd_t cmd2 = {(char*)"cmd2", (char*)"2", NULL, NULL, cmdFct2, NULL};
  41. static shellmatta_cmd_t cmd3 = {(char*)"cmd3", (char*)"3", NULL, NULL, cmdFct3, NULL};
  42. static shellmatta_cmd_t cmd4 = {(char*)"cmd4", (char*)"4", NULL, NULL, cmdFct4, NULL};
  43. char *commandSequence[] =
  44. {
  45. (char*)"foo\r",
  46. (char*)"bar\r",
  47. (char*)"cmd1\r",
  48. (char*)"2\r",
  49. (char*)"4\r",
  50. (char*)"cmd3\r"
  51. };
  52. #define CMD_SEQ_LEN (sizeof(commandSequence) / sizeof(commandSequence[0]))
  53. SCENARIO("Test the history buffer with a fixed sequence of commands in there")
  54. {
  55. GIVEN("An initialized Shellmatte instance with some commands already in the history buffer")
  56. {
  57. shellmatta_instance_t inst;
  58. shellmatta_handle_t handle;
  59. char buffer[1024u];
  60. char historyBuffer[1024u];
  61. FFF_FAKES_LIST(RESET_FAKE)
  62. CHECK(SHELLMATTA_OK == shellmatta_doInit( &inst,
  63. &handle,
  64. buffer,
  65. sizeof(buffer),
  66. historyBuffer,
  67. sizeof(historyBuffer),
  68. "shellmatta->",
  69. NULL,
  70. writeFct));
  71. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd1));
  72. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd2));
  73. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd3));
  74. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd4));
  75. for(uint32_t i = 0u; i < CMD_SEQ_LEN; i++)
  76. {
  77. CHECK(SHELLMATTA_OK == shellmatta_processData(handle, commandSequence[i], strlen(commandSequence[i])));
  78. }
  79. WHEN("The up button is pressed")
  80. {
  81. THEN("The shellmatta prints the most recent command")
  82. {
  83. FFF_FAKES_LIST(RESET_FAKE)
  84. PROCESS_INPUT(BUTTON_UP)
  85. CHECK(writeFct_fake.call_count == 2);
  86. CHECK(0 == memcmp(writeFct_fake.arg0_history[0], "\x1b" "[K", 3));
  87. CHECK(3 == writeFct_fake.arg1_history[0]);
  88. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], commandSequence[CMD_SEQ_LEN - 1], strlen(commandSequence[CMD_SEQ_LEN - 1]) - 1));
  89. CHECK((strlen(commandSequence[CMD_SEQ_LEN - 1]) - 1) == writeFct_fake.arg1_history[1]);
  90. for(uint32_t i = CMD_SEQ_LEN - 1; i > 0; i--)
  91. {
  92. FFF_FAKES_LIST(RESET_FAKE)
  93. PROCESS_INPUT(BUTTON_UP)
  94. CHECK(writeFct_fake.call_count == 3);
  95. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "\x1b" "[K", 3));
  96. CHECK(3 == writeFct_fake.arg1_history[1]);
  97. CHECK(0 == memcmp(writeFct_fake.arg0_history[2], commandSequence[i - 1u], strlen(commandSequence[i - 1u]) - 1));
  98. CHECK((strlen(commandSequence[i - 1u]) - 1) == writeFct_fake.arg1_history[2]);
  99. }
  100. }
  101. }
  102. WHEN("The history buffer it at the oldest command yet")
  103. {
  104. for(uint32_t i = CMD_SEQ_LEN; i > 0; i--)
  105. {
  106. PROCESS_INPUT(BUTTON_UP)
  107. }
  108. AND_WHEN("The up button is pressed again")
  109. {
  110. THEN("The output is deleted and the oldest command is printed again")
  111. {
  112. for(uint32_t i = 0u; i < 64; i++)
  113. {
  114. FFF_FAKES_LIST(RESET_FAKE)
  115. PROCESS_INPUT(BUTTON_UP)
  116. CHECK_FOR_COMMAND(2u, 0u)
  117. }
  118. }
  119. }
  120. AND_WHEN("The down button is pressed")
  121. {
  122. THEN("On each button press one newer command is printed")
  123. {
  124. for(uint32_t i = 1; i < CMD_SEQ_LEN; i++)
  125. {
  126. FFF_FAKES_LIST(RESET_FAKE)
  127. PROCESS_INPUT(BUTTON_DOWN)
  128. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "\x1b" "[K", 3));
  129. CHECK(3 == writeFct_fake.arg1_history[1]);
  130. CHECK_FOR_COMMAND(2u, i)
  131. }
  132. }
  133. }
  134. }
  135. WHEN("The user pushes the up and down button alternately")
  136. {
  137. THEN("The output shall be updated with the correct command or not updated at all when at the end")
  138. {
  139. FFF_FAKES_LIST(RESET_FAKE)
  140. PROCESS_INPUT(BUTTON_UP)
  141. CHECK_FOR_COMMAND(1u, CMD_SEQ_LEN - 1u)
  142. FFF_FAKES_LIST(RESET_FAKE)
  143. PROCESS_INPUT(BUTTON_UP)
  144. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  145. FFF_FAKES_LIST(RESET_FAKE)
  146. PROCESS_INPUT(BUTTON_DOWN)
  147. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 1u)
  148. FFF_FAKES_LIST(RESET_FAKE)
  149. PROCESS_INPUT(BUTTON_DOWN)
  150. CHECK(writeFct_fake.call_count == 0u);
  151. FFF_FAKES_LIST(RESET_FAKE)
  152. PROCESS_INPUT(BUTTON_DOWN)
  153. CHECK(writeFct_fake.call_count == 0u);
  154. FFF_FAKES_LIST(RESET_FAKE)
  155. PROCESS_INPUT(BUTTON_UP)
  156. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  157. FFF_FAKES_LIST(RESET_FAKE)
  158. PROCESS_INPUT(BUTTON_UP)
  159. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 3u)
  160. FFF_FAKES_LIST(RESET_FAKE)
  161. PROCESS_INPUT(BUTTON_UP)
  162. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 4u)
  163. FFF_FAKES_LIST(RESET_FAKE)
  164. PROCESS_INPUT(BUTTON_UP)
  165. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 5u)
  166. FFF_FAKES_LIST(RESET_FAKE)
  167. PROCESS_INPUT(BUTTON_UP)
  168. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 6u)
  169. FFF_FAKES_LIST(RESET_FAKE)
  170. PROCESS_INPUT(BUTTON_UP)
  171. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 6u)
  172. /* back down again */
  173. FFF_FAKES_LIST(RESET_FAKE)
  174. PROCESS_INPUT(BUTTON_DOWN)
  175. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 5u)
  176. FFF_FAKES_LIST(RESET_FAKE)
  177. PROCESS_INPUT(BUTTON_DOWN)
  178. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 4u)
  179. FFF_FAKES_LIST(RESET_FAKE)
  180. PROCESS_INPUT(BUTTON_DOWN)
  181. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 3u)
  182. FFF_FAKES_LIST(RESET_FAKE)
  183. PROCESS_INPUT(BUTTON_DOWN)
  184. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  185. FFF_FAKES_LIST(RESET_FAKE)
  186. PROCESS_INPUT(BUTTON_DOWN)
  187. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 1u)
  188. /* end of the buffer - shellmatta shall not update */
  189. FFF_FAKES_LIST(RESET_FAKE)
  190. PROCESS_INPUT(BUTTON_DOWN)
  191. CHECK(writeFct_fake.call_count == 0u);
  192. FFF_FAKES_LIST(RESET_FAKE)
  193. PROCESS_INPUT(BUTTON_DOWN)
  194. CHECK(writeFct_fake.call_count == 0u);
  195. FFF_FAKES_LIST(RESET_FAKE)
  196. PROCESS_INPUT(BUTTON_UP)
  197. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  198. }
  199. }
  200. }
  201. }
  202. SCENARIO("Test how the history buffer handles more commands than fits inside the buffer")
  203. {
  204. GIVEN("An initialized Shellmatte instance with some commands already in the history buffer")
  205. {
  206. shellmatta_instance_t inst;
  207. shellmatta_handle_t handle;
  208. char buffer[1024u];
  209. char historyBuffer[16u] = {0};
  210. FFF_FAKES_LIST(RESET_FAKE)
  211. CHECK(SHELLMATTA_OK == shellmatta_doInit( &inst,
  212. &handle,
  213. buffer,
  214. sizeof(buffer),
  215. historyBuffer,
  216. sizeof(historyBuffer),
  217. "shellmatta->",
  218. NULL,
  219. writeFct));
  220. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd1));
  221. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd2));
  222. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd3));
  223. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd4));
  224. for(uint32_t i = 0u; i < CMD_SEQ_LEN; i++)
  225. {
  226. CHECK(SHELLMATTA_OK == shellmatta_processData(handle, commandSequence[i], strlen(commandSequence[i])));
  227. }
  228. WHEN("The user pushes the up and down button alternately")
  229. {
  230. THEN("The output shall be updated with the correct commands that did fit into the buffer")
  231. {
  232. FFF_FAKES_LIST(RESET_FAKE)
  233. PROCESS_INPUT(BUTTON_UP)
  234. CHECK_FOR_COMMAND(1u, CMD_SEQ_LEN - 1u)
  235. FFF_FAKES_LIST(RESET_FAKE)
  236. PROCESS_INPUT(BUTTON_UP)
  237. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  238. FFF_FAKES_LIST(RESET_FAKE)
  239. PROCESS_INPUT(BUTTON_UP)
  240. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 3u)
  241. FFF_FAKES_LIST(RESET_FAKE)
  242. PROCESS_INPUT(BUTTON_UP)
  243. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 4u)
  244. FFF_FAKES_LIST(RESET_FAKE)
  245. PROCESS_INPUT(BUTTON_UP)
  246. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 4u)
  247. FFF_FAKES_LIST(RESET_FAKE)
  248. PROCESS_INPUT(BUTTON_DOWN)
  249. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 3u)
  250. FFF_FAKES_LIST(RESET_FAKE)
  251. PROCESS_INPUT(BUTTON_DOWN)
  252. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  253. FFF_FAKES_LIST(RESET_FAKE)
  254. PROCESS_INPUT(BUTTON_UP)
  255. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 3u)
  256. FFF_FAKES_LIST(RESET_FAKE)
  257. PROCESS_INPUT(BUTTON_DOWN)
  258. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  259. FFF_FAKES_LIST(RESET_FAKE)
  260. PROCESS_INPUT(BUTTON_DOWN)
  261. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 1u)
  262. }
  263. }
  264. WHEN("A command dowes not fit into the history buffer")
  265. {
  266. FFF_FAKES_LIST(RESET_FAKE)
  267. PROCESS_INPUT("This is a very long command input\r")
  268. THEN("The input is not stored")
  269. {
  270. FFF_FAKES_LIST(RESET_FAKE)
  271. PROCESS_INPUT(BUTTON_UP)
  272. CHECK_FOR_COMMAND(1u, CMD_SEQ_LEN - 1u)
  273. FFF_FAKES_LIST(RESET_FAKE)
  274. PROCESS_INPUT(BUTTON_UP)
  275. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  276. FFF_FAKES_LIST(RESET_FAKE)
  277. PROCESS_INPUT(BUTTON_UP)
  278. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 3u)
  279. FFF_FAKES_LIST(RESET_FAKE)
  280. PROCESS_INPUT(BUTTON_UP)
  281. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 4u)
  282. FFF_FAKES_LIST(RESET_FAKE)
  283. PROCESS_INPUT(BUTTON_UP)
  284. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 4u)
  285. }
  286. }
  287. }
  288. }
  289. SCENARIO("Test if the history buffer stores changes done during navigating")
  290. {
  291. GIVEN("An initialized Shellmatte instance with some commands already in the history buffer")
  292. {
  293. shellmatta_instance_t inst;
  294. shellmatta_handle_t handle;
  295. char buffer[1024u];
  296. char historyBuffer[16u] = {0};
  297. FFF_FAKES_LIST(RESET_FAKE)
  298. CHECK(SHELLMATTA_OK == shellmatta_doInit( &inst,
  299. &handle,
  300. buffer,
  301. sizeof(buffer),
  302. historyBuffer,
  303. sizeof(historyBuffer),
  304. "shellmatta->",
  305. NULL,
  306. writeFct));
  307. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd1));
  308. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd2));
  309. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd3));
  310. CHECK(SHELLMATTA_OK == shellmatta_addCmd(handle, &cmd4));
  311. for(uint32_t i = 0u; i < CMD_SEQ_LEN; i++)
  312. {
  313. CHECK(SHELLMATTA_OK == shellmatta_processData(handle, commandSequence[i], strlen(commandSequence[i])));
  314. }
  315. WHEN("The user pushes the up and down button alternately and inputs data in between")
  316. {
  317. THEN("The output shall be updated with the correct commands and the input shall be stored")
  318. {
  319. FFF_FAKES_LIST(RESET_FAKE)
  320. PROCESS_INPUT(BUTTON_UP)
  321. CHECK_FOR_COMMAND(1u, CMD_SEQ_LEN - 1u)
  322. FFF_FAKES_LIST(RESET_FAKE)
  323. PROCESS_INPUT(BUTTON_UP)
  324. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  325. PROCESS_INPUT("\b123456")
  326. FFF_FAKES_LIST(RESET_FAKE)
  327. PROCESS_INPUT(BUTTON_UP)
  328. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 3u)
  329. FFF_FAKES_LIST(RESET_FAKE)
  330. PROCESS_INPUT(BUTTON_DOWN)
  331. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 2u)
  332. FFF_FAKES_LIST(RESET_FAKE)
  333. PROCESS_INPUT(BUTTON_DOWN)
  334. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 1u)
  335. FFF_FAKES_LIST(RESET_FAKE)
  336. PROCESS_INPUT(BUTTON_DOWN)
  337. CHECK(writeFct_fake.call_count == 3);
  338. CHECK(0 == memcmp(writeFct_fake.arg0_history[2], "123456", 6));
  339. CHECK(6 == writeFct_fake.arg1_history[2]);
  340. PROCESS_INPUT("\r")
  341. FFF_FAKES_LIST(RESET_FAKE)
  342. PROCESS_INPUT(BUTTON_UP)
  343. CHECK(writeFct_fake.call_count == 2);
  344. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "123456", 6));
  345. CHECK(6 == writeFct_fake.arg1_history[1]);
  346. FFF_FAKES_LIST(RESET_FAKE)
  347. PROCESS_INPUT(BUTTON_UP)
  348. CHECK_FOR_COMMAND(2u, CMD_SEQ_LEN - 1u)
  349. PROCESS_INPUT("\x03" "12345678\r")
  350. FFF_FAKES_LIST(RESET_FAKE)
  351. PROCESS_INPUT(BUTTON_UP)
  352. CHECK(writeFct_fake.call_count == 2);
  353. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "12345678", 8));
  354. CHECK(8 == writeFct_fake.arg1_history[1]);
  355. PROCESS_INPUT("\r")
  356. FFF_FAKES_LIST(RESET_FAKE)
  357. PROCESS_INPUT(BUTTON_UP)
  358. CHECK(writeFct_fake.call_count == 2);
  359. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "12345678", 8));
  360. CHECK(8 == writeFct_fake.arg1_history[1]);
  361. FFF_FAKES_LIST(RESET_FAKE)
  362. PROCESS_INPUT(BUTTON_UP)
  363. CHECK(writeFct_fake.call_count == 3);
  364. CHECK(0 == memcmp(writeFct_fake.arg0_history[2], "123456", 6));
  365. CHECK(6 == writeFct_fake.arg1_history[2]);
  366. /* check if the compare gets it when the new command is exactly one character longer than the stored */
  367. PROCESS_INPUT("\x03" "123456789\r")
  368. FFF_FAKES_LIST(RESET_FAKE)
  369. PROCESS_INPUT(BUTTON_UP)
  370. CHECK(writeFct_fake.call_count == 2);
  371. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "123456789", 9));
  372. CHECK(9 == writeFct_fake.arg1_history[1]);
  373. FFF_FAKES_LIST(RESET_FAKE)
  374. PROCESS_INPUT(BUTTON_UP)
  375. CHECK(writeFct_fake.call_count == 3);
  376. CHECK(0 == memcmp(writeFct_fake.arg0_history[2], "123456789", 9));
  377. CHECK(9 == writeFct_fake.arg1_history[2]);
  378. /* check if the compare gets it when the last command ist longer than the new one */
  379. PROCESS_INPUT("\x03" "12345678\r")
  380. FFF_FAKES_LIST(RESET_FAKE)
  381. PROCESS_INPUT(BUTTON_UP)
  382. CHECK(writeFct_fake.call_count == 2);
  383. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "12345678", 8));
  384. CHECK(8 == writeFct_fake.arg1_history[1]);
  385. /* check what happens when there is a \0 in the buffer */
  386. PROCESS_INPUT("\x03" "1234" "\0" "678\r")
  387. FFF_FAKES_LIST(RESET_FAKE)
  388. PROCESS_INPUT(BUTTON_UP)
  389. CHECK(writeFct_fake.call_count == 2);
  390. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "1234", 4));
  391. CHECK(4 == writeFct_fake.arg1_history[1]);
  392. /* check what happens when there is a \0 in the buffer */
  393. PROCESS_INPUT("\x03" "1234" "\0" "888\r")
  394. FFF_FAKES_LIST(RESET_FAKE)
  395. PROCESS_INPUT(BUTTON_UP)
  396. CHECK(writeFct_fake.call_count == 2);
  397. CHECK(0 == memcmp(writeFct_fake.arg0_history[1], "1234", 4));
  398. CHECK(4 == writeFct_fake.arg1_history[1]);
  399. FFF_FAKES_LIST(RESET_FAKE)
  400. PROCESS_INPUT(BUTTON_UP)
  401. CHECK(writeFct_fake.call_count == 3);
  402. CHECK(0 == memcmp(writeFct_fake.arg0_history[2], "888", 3));
  403. CHECK(3 == writeFct_fake.arg1_history[2]);
  404. }
  405. }
  406. }
  407. }