forked from freudenreichan/info2Praktikum-DobleSpiel
comitting number.c
This commit is contained in:
1 parent
2cbe4c839c
commit
f003ecb2ed
2 files changed
+57
No files matched your search
Executable
BIN
Binary file not shown.
@@ -0,0 +1,57 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "unity.h"
|
||||
#include "numbers.h"
|
||||
|
||||
void setUp(void) {}
|
||||
void tearDown(void) {}
|
||||
|
||||
static void test_arrayOnlyHasOneDulicate() {
|
||||
unsigned int len = 5;
|
||||
unsigned int *array = createNumbers(len);
|
||||
int duplicateTrue = getDuplicate(array, len);
|
||||
int expectedValue = 0;
|
||||
TEST_ASSERT_NOT_EQUAL_INT(expectedValue,duplicateTrue);
|
||||
}
|
||||
static void test_returnNullWhenLenIs0() {
|
||||
unsigned int len = 0;
|
||||
unsigned int *array = createNumbers(len);
|
||||
TEST_ASSERT_NULL(array);
|
||||
}
|
||||
|
||||
static void test_findsDuplicate() {
|
||||
unsigned int array[] = {5, 10, 9, 3, 3};
|
||||
unsigned int len = 5;
|
||||
unsigned int returnValue = getDuplicate(array, len);
|
||||
unsigned int expectedValue= 3;
|
||||
TEST_ASSERT_EQUAL_INT(expectedValue,returnValue);
|
||||
}
|
||||
static void test_return0WhenNoDuplicate() {
|
||||
unsigned int array[] = {5, 10, 9, 3, 2};
|
||||
unsigned int len = 5;
|
||||
unsigned int returnValue = getDuplicate(array, len);
|
||||
unsigned int expectedValue = 0;
|
||||
TEST_ASSERT_EQUAL_INT(expectedValue, returnValue);
|
||||
}
|
||||
static void test_return0WhenMultipleDuplicates() {
|
||||
unsigned int array[] = {5, 5, 9, 3, 3};
|
||||
unsigned int len = 5;
|
||||
unsigned int returnValue = getDuplicate(array, len);
|
||||
unsigned int expectedValue = 0;
|
||||
TEST_ASSERT_EQUAL_INT(expectedValue, returnValue);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
|
||||
printf("\n============================\nnumber tests\n============================\n");
|
||||
RUN_TEST(test_arrayOnlyHasOneDulicate);
|
||||
RUN_TEST(test_returnNullWhenLenIs0);
|
||||
RUN_TEST(test_findsDuplicate);
|
||||
RUN_TEST(test_return0WhenNoDuplicate);
|
||||
RUN_TEST(test_return0WhenMultipleDuplicates);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user