formatierung
This commit is contained in:
parent
74e2421312
commit
593a86acaa
@ -126,7 +126,8 @@ void clearTree(TreeNode *root)
|
||||
// Returns the number of entries in the tree given by root.
|
||||
unsigned int treeSize(const TreeNode *root)
|
||||
{
|
||||
if (root == NULL) {
|
||||
if (root == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
4
main.c
4
main.c
@ -14,7 +14,9 @@ int inputNumber(const char *promptText)
|
||||
{
|
||||
printf("%s", promptText);
|
||||
numberOfInputs = scanf("%u", &number);
|
||||
while(getchar() != '\n') {} // clear input buffer
|
||||
while (getchar() != '\n')
|
||||
{
|
||||
} // clear input buffer
|
||||
}
|
||||
|
||||
return number;
|
||||
|
||||
3
stack.h
3
stack.h
@ -8,7 +8,8 @@ The latest element is taken from the stack. */
|
||||
#include <stdlib.h>
|
||||
|
||||
// TODO: passenden Datentyp als struct anlegen
|
||||
typedef struct node {
|
||||
typedef struct node
|
||||
{
|
||||
void *data;
|
||||
struct node *prev;
|
||||
} StackNode;
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
#include "bintree.h"
|
||||
#include "unity/unity.h"
|
||||
|
||||
|
||||
void test_getDuplicateLogic()
|
||||
{
|
||||
unsigned int test1[] = {1, 9, 3, 5, 2, 5, 8};
|
||||
@ -22,39 +21,43 @@ void test_getDuplicateLogic()
|
||||
unsigned int len3 = 5;
|
||||
unsigned int res3 = getDuplicate(test3, len3);
|
||||
TEST_ASSERT_EQUAL_UINT32(0, res3);
|
||||
|
||||
}
|
||||
|
||||
void test_Integration(unsigned int len) {
|
||||
void test_Integration(unsigned int len)
|
||||
{
|
||||
unsigned int *arr = createNumbers(len);
|
||||
TEST_ASSERT_NOT_NULL(arr);
|
||||
unsigned int duplicate = getDuplicate(arr, len);
|
||||
TEST_ASSERT_NOT_EQUAL_UINT32(0, duplicate);
|
||||
|
||||
int count = 0;
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
if (arr[i] == duplicate) {
|
||||
for (unsigned int i = 0; i < len; i++)
|
||||
{
|
||||
if (arr[i] == duplicate)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(2, count);
|
||||
|
||||
|
||||
free(arr);
|
||||
}
|
||||
|
||||
void test_IntegrationVar () {
|
||||
void test_IntegrationVar()
|
||||
{
|
||||
test_Integration(10);
|
||||
test_Integration(100);
|
||||
test_Integration(1000);
|
||||
}
|
||||
|
||||
void setUp(void) {
|
||||
void setUp(void)
|
||||
{
|
||||
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
||||
}
|
||||
|
||||
void tearDown(void) {
|
||||
void tearDown(void)
|
||||
{
|
||||
// Hier kann Bereinigungsarbeit nach jedem Test durchgeführt werden
|
||||
}
|
||||
|
||||
|
||||
BIN
test_numbers.exe
BIN
test_numbers.exe
Binary file not shown.
49
test_stack.c
49
test_stack.c
@ -4,16 +4,20 @@
|
||||
#include "stack.h"
|
||||
#include "unity/unity.h"
|
||||
|
||||
void test_pushFailsOnNullPointer(StackNode *stack, void *data) {
|
||||
void test_pushFailsOnNullPointer(StackNode *stack, void *data)
|
||||
{
|
||||
|
||||
StackNode *test = push(NULL, data);
|
||||
if (test != 0) {
|
||||
if (test != 0)
|
||||
{
|
||||
printf("Pass test_pushFailsOnNullPointerStack\n");
|
||||
} else
|
||||
}
|
||||
else
|
||||
printf("Did Not Pass test_pushFailsOnNullPointerStack EXPECTED StackNode\n");
|
||||
|
||||
test = push(stack, NULL);
|
||||
if (test == 0) {
|
||||
if (test == 0)
|
||||
{
|
||||
printf("Pass test_pushFailsOnNullPointerData\n");
|
||||
return;
|
||||
}
|
||||
@ -21,10 +25,12 @@ void test_pushFailsOnNullPointer(StackNode *stack, void *data) {
|
||||
return;
|
||||
}
|
||||
|
||||
void test_popFailsOnNullPointer() { //pop on null returns NULL
|
||||
void test_popFailsOnNullPointer()
|
||||
{ // pop on null returns NULL
|
||||
|
||||
StackNode *test = pop(NULL);
|
||||
if (test == 0) {
|
||||
if (test == 0)
|
||||
{
|
||||
printf("Pass test_popFailsOnNullPointerStack\n");
|
||||
return;
|
||||
}
|
||||
@ -33,10 +39,12 @@ void test_popFailsOnNullPointer() { //pop on null returns NULL
|
||||
return;
|
||||
}
|
||||
|
||||
void test_topFailsOnNullPointer() {
|
||||
void test_topFailsOnNullPointer()
|
||||
{
|
||||
|
||||
int *test = (int *)top(NULL);
|
||||
if (test == 0) {
|
||||
if (test == 0)
|
||||
{
|
||||
printf("Pass test_topFailsOnNullPointerStack\n");
|
||||
return;
|
||||
}
|
||||
@ -45,11 +53,12 @@ void test_topFailsOnNullPointer() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void setUp(void) {
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void) {
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
int main()
|
||||
@ -71,23 +80,29 @@ int main()
|
||||
test_topFailsOnNullPointer();
|
||||
|
||||
StackNode *stack1 = push(stack0, dataTest1);
|
||||
if(strcmp(stack1->data ,dataTest1) == 0) {
|
||||
if (strcmp(stack1->data, dataTest1) == 0)
|
||||
{
|
||||
printf("Pass test_pushString\n");
|
||||
} else
|
||||
}
|
||||
else
|
||||
printf("Fails test_pushString\n expected: %s\n was: %s\n", dataTest1, (char *)(stack1->data));
|
||||
|
||||
StackNode *stack2 = push(stack1, dataTest2);
|
||||
if(stack2->data == dataTest2) {
|
||||
if (stack2->data == dataTest2)
|
||||
{
|
||||
printf("Pass test_pushFloat\n");
|
||||
} else
|
||||
}
|
||||
else
|
||||
printf("Fails test_pushFloat\n expected: %f\n was: %f\n", *dataTest2, *(float *)(stack2->data));
|
||||
|
||||
int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
|
||||
for(size_t i = 0; i<10; i++) {
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
{
|
||||
stack2 = push(stack2, &array[i]);
|
||||
}
|
||||
for(size_t i = 0; i<10; i++) {
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
{
|
||||
int *data = (int *)top(stack2);
|
||||
printf("%d\n", *data);
|
||||
stack2 = pop(stack2);
|
||||
|
||||
BIN
test_stack.exe
BIN
test_stack.exe
Binary file not shown.
3
timer.c
3
timer.c
@ -21,7 +21,8 @@ double stopTimer()
|
||||
|
||||
double measuredSeconds = (double)delta_us / 1000000.;
|
||||
|
||||
if(start.tv_nsec > 0) {
|
||||
if (start.tv_nsec > 0)
|
||||
{
|
||||
start.tv_nsec = 0;
|
||||
start.tv_sec = 0;
|
||||
}
|
||||
|
||||
BIN
unittest.o
BIN
unittest.o
Binary file not shown.
BIN
unittestTree.o
BIN
unittestTree.o
Binary file not shown.
@ -4,7 +4,6 @@
|
||||
#include "stack.h"
|
||||
#include "unity.h"
|
||||
|
||||
|
||||
void test_createMatrixFailsOnZeroDimensions(void)
|
||||
{
|
||||
Matrix matrixToTest1 = createMatrix(0, 1);
|
||||
@ -167,11 +166,13 @@ void test_setMatrixAtFailsOnIndicesOutOfRange(void)
|
||||
TEST_ASSERT_EQUAL_FLOAT_ARRAY(expectedResults, matrixToTest.buffer, sizeof(buffer) / sizeof(MatrixType));
|
||||
}
|
||||
|
||||
void setUp(void) {
|
||||
void setUp(void)
|
||||
{
|
||||
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
||||
}
|
||||
|
||||
void tearDown(void) {
|
||||
void tearDown(void)
|
||||
{
|
||||
// Hier kann Bereinigungsarbeit nach jedem Test durchgeführt werden
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,12 @@ void verifyTest(void);
|
||||
/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails.
|
||||
* This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */
|
||||
#define TEST_PASS() TEST_ABORT()
|
||||
#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while (0)
|
||||
#define TEST_PASS_MESSAGE(message) \
|
||||
do \
|
||||
{ \
|
||||
UnityMessage((message), __LINE__); \
|
||||
TEST_ABORT(); \
|
||||
} while (0)
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* Build Directives
|
||||
@ -295,7 +300,6 @@ void verifyTest(void);
|
||||
#define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||
|
||||
|
||||
/* Structs and Strings */
|
||||
#define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL)
|
||||
@ -466,7 +470,6 @@ void verifyTest(void);
|
||||
#define TEST_ASSERT_NOT_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
||||
#define TEST_ASSERT_NOT_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
||||
|
||||
|
||||
/* Integer Greater Than/ Less Than (of all sizes) */
|
||||
#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
|
||||
#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
|
||||
@ -578,7 +581,6 @@ void verifyTest(void);
|
||||
#define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||
#define TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||
|
||||
|
||||
/* Structs and Strings */
|
||||
#define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, (message))
|
||||
#define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user