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.
40 lines
1.1 KiB
40 lines
1.1 KiB
#include "unity.h"
|
|
#include "userinput.h"
|
|
#include "fakeinput.h"
|
|
#include <string.h>
|
|
|
|
void setUp(void){}
|
|
void tearDown(void){}
|
|
|
|
void test_gets_WithMinLengthAndMaxLength(void) {
|
|
unsigned long minLength = 3;
|
|
unsigned long maxLength = 10;
|
|
char *input[] = {"ei", "e", "sddfdfdfdfdf", "dddd", NULL};
|
|
fakeInput = input;
|
|
char *actual = gets("", &minLength, &maxLength);
|
|
TEST_ASSERT_EQUAL_CHAR_ARRAY("dddd", actual, strlen(actual));
|
|
}
|
|
|
|
void test_gethd_WithMinAndMax(void) {
|
|
short min = 10;
|
|
short max = 100;
|
|
char *input[] = {"sdf", "1", "101", "50", NULL};
|
|
fakeInput = input;
|
|
TEST_ASSERT_EQUAL_INT64(50, gethd("", &min, &max));
|
|
}
|
|
|
|
void test_getd_WithMinAndMax(void) {
|
|
int min = 10;
|
|
int max = 100000;
|
|
char *input[] = {"sdf", "4", "10000000", "1167", NULL};
|
|
fakeInput = input;
|
|
TEST_ASSERT_EQUAL_INT64(1167, getd("", &min, &max));
|
|
}
|
|
|
|
void test_getld_WithMinAndMax(void) {
|
|
long min = -100;
|
|
long max = 100000000;
|
|
char *input[] = {"sdf", "-400", "10000000000000", "11001100", NULL};
|
|
fakeInput = input;
|
|
TEST_ASSERT_EQUAL_INT64(11001100, getld("", &min, &max));
|
|
}
|