#include "unity.h"
#include "userinput.h"
#include "fakeinput.h"
#include <string.h>

void setUp(void){}
void tearDown(void){}

void test_usergets_WithMinLengthAndMaxLength(void) {
    unsigned long minLength = 3;
    unsigned long maxLength = 10;
    char *input[] = {"ei", "e", "sddfdfdfdfdf", "dddd", NULL};
    fakeInput = input;
    char *actual = usergets("", &minLength, &maxLength);
    TEST_ASSERT_EQUAL_CHAR_ARRAY("dddd", actual, strlen(actual));
}

void test_usergets_WithMinLength(void) {
    unsigned long minLength = 3;
    char *input[] = {"", "ei", "e", "dddd", NULL};
    fakeInput = input;
    char *actual = usergets("", &minLength, NULL);
    TEST_ASSERT_EQUAL_CHAR_ARRAY("dddd", actual, strlen(actual));
}

void test_usergets_WithMaxLength(void) {
    unsigned long maxLength = 6;
    char *input[] = {"dfdfdfdf", "dddd", NULL};
    fakeInput = input;
    char *actual = usergets("", NULL, &maxLength);
    TEST_ASSERT_EQUAL_CHAR_ARRAY("dddd", actual, strlen(actual));
}

void test_usergets_WithAnyLength(void) {
    char *input[] = {"dfdfdfdf", NULL};
    fakeInput = input;
    char *actual = usergets("", NULL, NULL);
    TEST_ASSERT_EQUAL_CHAR_ARRAY("dfdfdfdf", actual, strlen(actual));
}

void test_usergethd_WithMinAndMax(void) {
    short min = 10;
    short max = 100;
    char *input[] = {"sdf", "1", "101", "50", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_INT(50, usergethd("", &min, &max));
}

void test_usergetd_WithMinAndMax(void) {
    int min = 10;
    int max = 100000;
    char *input[] = {"sdf", "4", "10000000", "1167", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_INT(1167, usergetd("", &min, &max));
}

void test_usergetd_WithMin(void) {
    int min = 10;
    char *input[] = {"sdf", "4", "10000000", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_INT(10000000, usergetd("", &min, NULL));
}

void test_usergetd_WithMax(void) {
    int max = 1000;
    char *input[] = {"sdf", "4000", "10000000", "-200", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_INT(-200, usergetd("", NULL, &max));
}

void test_usergetld_WithMinAndMax(void) {
    long min = -100;
    long max = 100000000;
    char *input[] = {"sdf", "-400", "10000000000000", "11001100", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_INT(11001100, usergetld("", &min, &max));
}

void test_usergetlld_WithMinAndMax(void) {
    long long min = -100;
    long long max = 100000000;
    char *input[] = {"sdf", "-400", "10000000000000", "11001100", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_INT(11001100, usergetlld("", &min, &max));
}

void test_usergethu_WithMinAndMax(void) {
    unsigned short min = 10;
    unsigned short max = 100;
    char *input[] = {"sdf", "-1", "1", "101", "50", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_UINT(50, usergethu("", &min, &max));
}

void test_usergetu_WithMinAndMax(void) {
    unsigned int min = 10;
    unsigned int max = 100000;
    char *input[] = {"sdf", "4", "10000000", "1167", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_UINT(1167, usergetu("", &min, &max));
}

void test_usergetlu_WithMinAndMax(void) {
    unsigned long min = 100;
    unsigned long max = 100000000;
    char *input[] = {"sdf", "-400", "10000000000000", "11001100", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_UINT(11001100, usergetlu("", &min, &max));
}

void test_usergetllu_WithMinAndMax(void) {
    unsigned long long min = 100;
    unsigned long long max = 100000000;
    char *input[] = {"sdf", "-400", "10000000000000", "11001100", NULL};
    fakeInput = input;
    TEST_ASSERT_EQUAL_UINT(11001100, usergetllu("", &min, &max));
}