inf2Projekt_3/test_stack.c

41 lines
681 B
C

//
// Created by faizi on 05.12.2025.
//
#include <stdio.h>
#include <stdlib.h>
#include "stack.h"
int main(void)
{
StackNode *stack = NULL;
printf("Starte Stack Test\n");
// push test
int *a = malloc(sizeof(int));
int *b = malloc(sizeof(int));
*a = 10;
*b = 20;
stack = push(stack, a);
stack = push(stack, b);
printf("Top sollte 20 sein, es kommt %d raus\n", *(int*)top(stack));
// pop test
stack = pop(stack);
printf("Top sollte jetzt 10 sein, es kommt %d raus\n", *(int*)top(stack));
// clearStack test
printf("fuehre ClearStack aus...\n");
clearStack(stack);
free(a);
free(b);
return 0;
}