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.

55 lines
1.6 KiB

  1. #include "unity.h"
  2. #include "userinput.h"
  3. #include "fakeinput.h"
  4. #include <string.h>
  5. void setUp(void){}
  6. void tearDown(void){}
  7. void test_gets_WithMinLengthAndMaxLength(void) {
  8. unsigned long minLength = 3;
  9. unsigned long maxLength = 10;
  10. char *input[] = {"ei", "e", "sddfdfdfdfdf", "dddd", NULL};
  11. fakeInput = input;
  12. char *actual = gets("", &minLength, &maxLength);
  13. TEST_ASSERT_EQUAL_CHAR_ARRAY("dddd", actual, strlen(actual));
  14. }
  15. void test_gethd_WithMinAndMax(void) {
  16. short min = 10;
  17. short max = 100;
  18. char *input[] = {"sdf", "1", "101", "50", NULL};
  19. fakeInput = input;
  20. TEST_ASSERT_EQUAL_INT64(50, gethd("", &min, &max));
  21. }
  22. void test_getd_WithMinAndMax(void) {
  23. int min = 10;
  24. int max = 100000;
  25. char *input[] = {"sdf", "4", "10000000", "1167", NULL};
  26. fakeInput = input;
  27. TEST_ASSERT_EQUAL_INT64(1167, getd("", &min, &max));
  28. }
  29. void test_getld_WithMinAndMax(void) {
  30. long min = -100;
  31. long max = 100000000;
  32. char *input[] = {"sdf", "-400", "10000000000000", "11001100", NULL};
  33. fakeInput = input;
  34. TEST_ASSERT_EQUAL_INT64(11001100, getld("", &min, &max));
  35. }
  36. void test_getlld_WithMinAndMax(void) {
  37. long long min = -100;
  38. long long max = 100000000;
  39. char *input[] = {"sdf", "-400", "10000000000000", "11001100", NULL};
  40. fakeInput = input;
  41. TEST_ASSERT_EQUAL_INT64(11001100, getlld("", &min, &max));
  42. }
  43. void test_gethu_WithMinAndMax(void) {
  44. unsigned short min = 10;
  45. unsigned short max = 100;
  46. char *input[] = {"sdf", "-1", "1", "101", "50", NULL};
  47. fakeInput = input;
  48. TEST_ASSERT_EQUAL_INT64(50, gethu("", &min, &max));
  49. }