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.

85 lines
1.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
  1. #include "unity.h"
  2. #include <input.h>
  3. #include <stdlib.h>
  4. void setUp(void){
  5. }
  6. void tearDown(void){
  7. }
  8. //test arrowkeyinput
  9. void test_testArrow(void){
  10. char result = getTInput('\033');
  11. TEST_ASSERT_EQUAL_CHAR('r', result);
  12. }
  13. //test input 'w'
  14. void test_testw(void){
  15. char result = getTInput('w');
  16. TEST_ASSERT_EQUAL_CHAR('w', result);
  17. }
  18. //test input 'a'
  19. void test_testa(void){
  20. char result = getTInput('a');
  21. TEST_ASSERT_EQUAL_CHAR('a', result);
  22. }
  23. //test input 's'
  24. void test_tests(void){
  25. char result = getTInput('s');
  26. TEST_ASSERT_EQUAL_CHAR('s', result);
  27. }
  28. //test input 'd'
  29. void test_testd(void){
  30. char result = getTInput('d');
  31. TEST_ASSERT_EQUAL_CHAR('d', result);
  32. }
  33. //test input 'q'
  34. void test_testq(void){
  35. char result = getTInput('q');
  36. TEST_ASSERT_EQUAL_CHAR('q', result);
  37. }
  38. //test input 'p'
  39. void test_testp(void){
  40. char result = getTInput('p');
  41. TEST_ASSERT_EQUAL_CHAR('p', result);
  42. }
  43. //test input invalid
  44. void test_testn(void){
  45. char result = getTInput('n');
  46. TEST_ASSERT_EQUAL_CHAR('n', result);
  47. }
  48. //test input invalid
  49. void test_testg(void){
  50. char result = getTInput('g');
  51. TEST_ASSERT_EQUAL_CHAR('n', result);
  52. }
  53. //test input invalid
  54. void test_testb(void){
  55. char result = getTInput('b');
  56. TEST_ASSERT_EQUAL_CHAR('n', result);
  57. }
  58. //test input invalid
  59. void test_testc(void){
  60. char result = getTInput('c');
  61. TEST_ASSERT_EQUAL_CHAR('n', result);
  62. }
  63. void test_testkbhit(void){
  64. int result = kbhit();
  65. TEST_ASSERT_EQUAL_INT(0, result);
  66. }