added and fixed stack
This commit is contained in:
12
interpreter/test/Makefile
Normal file
12
interpreter/test/Makefile
Normal 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
|
29
interpreter/test/test_stack.c
Normal file
29
interpreter/test/test_stack.c
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user