added and fixed stack

This commit is contained in:
2018-09-26 18:22:36 +02:00
parent 5a5db35123
commit 11ac831fea
5 changed files with 65 additions and 4 deletions

12
interpreter/test/Makefile Normal file
View File

@@ -0,0 +1,12 @@
CC=gcc
all: test_stack
stack: clean
$(CC) -g ../stack.c test_stack.c -o stack
test_stack: stack
valgrind ./stack
clean:
-rm stack

View File

@@ -0,0 +1,29 @@
#include <stdio.h>
#include "../stack.h"
int main(void)
{
bci_stack_t stack = NULL;
int i;
uint16_t res;
char status = 0;
for(i = 0; i < 10; i++)
{
bci_stack_t_push(&stack, (uint16_t) i);
}
while(!status)
{
status = bci_stack_t_pop(&stack, &res);
printf("%d\n", res);
}
for(i = 0; i < 10; i++)
{
bci_stack_t_push(&stack, (uint16_t) i);
}
bci_stack_t_del(&stack);
return 0;
}