diff --git a/Startcode/stack.c b/Startcode/stack.c index e3a90d4..488ec95 100644 --- a/Startcode/stack.c +++ b/Startcode/stack.c @@ -5,7 +5,10 @@ /* * `push`: legt ein Element oben auf den Stack, * `pop`: entfernt das oberste Element, * `top`: liefert das oberste Element zurück, - * `clearStack`: gibt den gesamten Speicher frei. */ + * `clearStack`: gibt den gesamten Speicher frei. +*/ + + // Pushes data as pointer onto the stack. StackNode *push(StackNode *stack, void *data) @@ -13,6 +16,8 @@ StackNode *push(StackNode *stack, void *data) } + + // Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be // freed by caller.) StackNode *pop(StackNode *stack) @@ -20,14 +25,18 @@ StackNode *pop(StackNode *stack) } + + // Returns the data of the top element. void *top(StackNode *stack) { } + + // Clears stack and releases all memory. void clearStack(StackNode *stack) { -} \ No newline at end of file +} diff --git a/Startcode/stack.h b/Startcode/stack.h index f7d542d..4da2dd6 100644 --- a/Startcode/stack.h +++ b/Startcode/stack.h @@ -1,13 +1,17 @@ #ifndef STACK_H #define STACK_H -/* A stack is a special type of queue which uses the LIFO (last in, first out) principle. -This means that with each new element all other elements are pushed deeper into the stack. +/* A stack is a special type of queue which uses the LIFO (last in, first out) principle. +This means that with each new element all other elements are pushed deeper into the stack. The latest element is taken from the stack. */ + #include -//TODO: passenden Datentyp als struct anlegen + + +//Erschaft den stack. +StackNode *create(); // Pushes data as pointer onto the stack. StackNode *push(StackNode *stack, void *data); diff --git a/Startcode/test_stack.c b/Startcode/test_stack.c new file mode 100644 index 0000000..33b906c --- /dev/null +++ b/Startcode/test_stack.c @@ -0,0 +1,36 @@ +#include +#include +#include "stack.h" +#include "unity/unity.h" + + +//Gebastelt von Maxi +/*Unit-Tests sollen: + Integer-Werte auf den Stack legen + Integer-Werte auf den Stack wieder entfernen +*/ + + +//TODO Testcases einfügen +//void test_name(void){} + + + + + + + + + + + +int main() +{ + UNITY_BEGIN(); + + printf("============================\nStack tests\n============================\n"); + RUN_TEST(); + + + return UNITY_END(); +}