Files
link/tests/01_stack.c

40 lines
934 B
C
Raw Normal View History

2026-03-10 19:01:36 -05:00
#define DEBUG
#include "../include/link.h"
#include <stdlib.h>
#include <stdio.h>
int main(void){
List s1 = NULL;
struct Node *n1 = node_alloc(1);
struct Node *n2 = node_alloc(2);
struct Node *n3 = node_alloc(3);
struct Node *n4 = node_alloc(4);
stack_push(&s1, n4);
stack_push(&s1, n3);
stack_push(&s1, n2);
stack_push(&s1, n1);
list_print(&s1);
uint64_t test1 = stack_pop(&s1);
printf("Removed %ld from end of list.\n", test1);
list_print(&s1);
uint64_t test2 = stack_pop(&s1);
printf("Removed %ld from end of list.\n", test2);
list_print(&s1);
uint64_t test3 = stack_pop(&s1);
printf("Removed %ld from end of list.\n", test3);
list_print(&s1);
uint64_t test4 = stack_pop(&s1);
printf("Removed %ld from end of list.\n", test4);
list_print(&s1);
list_free(&s1);
return EXIT_SUCCESS;
}