BCI-base/interpreter/test/test_stack.c

35 lines
451 B
C
Raw Normal View History

2018-09-26 16:22:36 +00:00
#include <stdio.h>
#include "../stack.h"
#include <assert.h>
2018-09-26 16:22:36 +00:00
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);
}
--i;
2018-09-26 16:22:36 +00:00
while(!status)
{
status = bci_stack_t_pop(&stack, &res);
if(!status)
{
assert(res == i--);
}
2018-09-26 16:22:36 +00:00
}
for(i = 0; i < 10; i++)
{
bci_stack_t_push(&stack, (uint16_t) i);
}
bci_stack_t_del(&stack);
return 0;
}