transfered from codeberg

This commit is contained in:
2026-03-26 14:46:39 -05:00
parent 630f28bb7e
commit 5ed2173793
136 changed files with 14932 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
#include "test_chunk.h"
#include "chunk.h"
#include "unity.h"
#include <stdint.h>
/* Verify spatial indexing is unique and within the 1D array bounds */
void test_chunk_index_calculation_is_unique_and_valid(void)
{
uint16_t maximum_index = chunk_size * chunk_size * chunk_size;
uint32_t index_origin = index_chunk(0, 0, 0);
uint32_t index_far_corner = index_chunk(chunk_size - 1,
chunk_size - 1,
chunk_size - 1);
TEST_ASSERT_EQUAL_UINT16(0, index_origin);
TEST_ASSERT_LESS_THAN_UINT16(maximum_index, index_far_corner);
}
/* Verify that a new chunk is initialized with the correct defaults */
void test_chunk_initialization_sets_correct_defaults(void)
{
chunk_position_struct initial_position = { 16.0f, 0.0f, -32.0f };
chunk_struct *test_chunk = initialize_chunk(initial_position);
TEST_ASSERT_NOT_NULL(test_chunk);
TEST_ASSERT_EQUAL_FLOAT(initial_position.x, test_chunk->position.x);
TEST_ASSERT_EQUAL_INT(state_needs_data, test_chunk->build_state);
destroy_chunk(test_chunk);
}
/* Verify that chunk bounds are correctly calculated based on world position */
void test_chunk_bounds_calculation_is_accurate(void)
{
chunk_position_struct initial_position = { 100.0f, 100.0f, 100.0f };
chunk_struct *test_chunk = initialize_chunk(initial_position);
float expected_maximum_x = (float)(initial_position.x + chunk_size);
TEST_ASSERT_EQUAL_FLOAT(initial_position.x, test_chunk->bounds.min.x);
TEST_ASSERT_EQUAL_FLOAT(expected_maximum_x, test_chunk->bounds.max.x);
destroy_chunk(test_chunk);
}
/* Runner for this specific module */
void run_chunk_tests(void)
{
RUN_TEST(test_chunk_index_calculation_is_unique_and_valid);
RUN_TEST(test_chunk_initialization_sets_correct_defaults);
RUN_TEST(test_chunk_bounds_calculation_is_accurate);
}

View File

@@ -0,0 +1,12 @@
#ifndef test_chunk_h
#define test_chunk_h
void test_chunk_index_calculation_is_unique_and_valid(void);
void test_chunk_initialization_sets_correct_defaults(void);
void test_chunk_bounds_calculation_is_accurate(void);
void run_chunk_tests(void);
#endif