mirror of
https://github.com/cellos51/balatro-gba.git
synced 2026-09-12 02:46:37 -05:00
Add initial stack implementation
This commit is contained in:
41
tests/stack/stack_test.c
Normal file
41
tests/stack/stack_test.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "stack.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define STACK_SIZE 64
|
||||
|
||||
STACK_DEFINE(coolstack, STACK_SIZE)
|
||||
|
||||
void test_stack(void)
|
||||
{
|
||||
int int_arr[STACK_SIZE];
|
||||
|
||||
for(int i = 0; i < STACK_SIZE; i++)
|
||||
{
|
||||
int_arr[i] = i;
|
||||
}
|
||||
|
||||
for(int i = 0; i < STACK_SIZE; i++)
|
||||
{
|
||||
stack_push(&coolstack, &int_arr[i]);
|
||||
}
|
||||
|
||||
for(int i = STACK_SIZE - 1; i >= 0; i--)
|
||||
{
|
||||
assert(*(int*)stack_pop(&coolstack) == i);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Testing Stack.\n");
|
||||
test_stack();
|
||||
|
||||
printf("-------------------------------------------------------------------------------\n");
|
||||
printf("Stack Tests Passed :)\n");
|
||||
printf("-------------------------------------------------------------------------------\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user