Wrap long lines to fit within 80 columns across the codebase

Pure whitespace/line-break reformatting (braces, newlines, and line
continuations matching this codebase's existing wrap conventions) - no
logic, string content, or identifiers changed anywhere. Confirmed via
diff against the pre-change tree and by rebuilding + re-running the
affected test suites, which produce identical pass/fail results.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
2026-09-05 13:13:10 -05:00
co-authored by Claude Sonnet 5
parent de53bebeb8
commit cebd3d81e7
70 changed files with 1025 additions and 425 deletions
+137 -55
View File
@@ -90,7 +90,8 @@ static bool_t loading_slot_has_entry(const assetentry_t *entry) {
// ============================================================
static void test_getEntry_creates_new(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assert_non_null(entry);
assert_int_equal(entry->state, ASSET_ENTRY_STATE_NOT_STARTED);
@@ -101,8 +102,10 @@ static void test_getEntry_creates_new(void **state) {
}
static void test_getEntry_dedup(void **state) {
assetentry_t *a = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *b = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *a =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *b =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assert_ptr_equal(a, b);
assert_int_equal(memoryGetAllocatedCount(), 0);
@@ -121,7 +124,8 @@ static void test_getEntry_distinct_names(void **state) {
// ============================================================
static void test_update_entry_reaches_loaded(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assert_int_equal(entry->state, ASSET_ENTRY_STATE_NOT_STARTED);
assetEntryLock(entry);
@@ -134,7 +138,8 @@ static void test_update_entry_reaches_loaded(void **state) {
}
static void test_update_slot_cleared_after_first_update(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(entry);
assetUpdate();
@@ -149,7 +154,8 @@ static void test_update_slot_cleared_after_first_update(void **state) {
}
static void test_update_slot_stays_cleared_on_further_updates(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(entry);
assetUpdate();
@@ -186,10 +192,12 @@ static void test_update_four_slots_fill_independently(void **state) {
static void test_update_error_state(void **state) {
ASSET_LOADER_CALLBACKS[ASSET_LOADER_TYPE_LOCALE].loadSync = stub_load_fail;
assetentry_t *entry = assetGetEntry("fail.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("fail.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
// First update: dispatches and calls the failing stub.
// assetUpdate itself returns OK here; the error from loadSync is caught internally.
// assetUpdate itself returns OK here; the error from loadSync is
// caught internally.
errorret_t ret = assetUpdate();
assert_true(errorIsOk(ret));
assert_int_equal(entry->state, ASSET_ENTRY_STATE_ERROR);
@@ -209,7 +217,8 @@ static void test_update_noop_on_empty_table(void **state) {
}
static void test_update_loaded_entry_not_redispatched(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(entry);
assetUpdate();
@@ -255,13 +264,17 @@ static void test_update_overflow_queues_entries(void **state) {
for(int i = 0; i < ASSET_LOADING_COUNT_MAX; i++) {
assert_int_equal(entries[i]->state, ASSET_ENTRY_STATE_LOADED);
}
assert_int_equal(entries[ASSET_LOADING_COUNT_MAX]->state, ASSET_ENTRY_STATE_NOT_STARTED);
assert_int_equal(
entries[ASSET_LOADING_COUNT_MAX]->state, ASSET_ENTRY_STATE_NOT_STARTED
);
// Update 2: the slots freed during update 1 are now available, so the
// overflow entry is dispatched and loaded in this pass.
ret = assetUpdate();
assert_true(errorIsOk(ret));
assert_int_equal(entries[ASSET_LOADING_COUNT_MAX]->state, ASSET_ENTRY_STATE_LOADED);
assert_int_equal(
entries[ASSET_LOADING_COUNT_MAX]->state, ASSET_ENTRY_STATE_LOADED
);
for(int i = 0; i < TOTAL; i++) {
assetEntryUnlock(entries[i]);
@@ -273,12 +286,14 @@ static void test_update_overflow_queues_entries(void **state) {
static void test_update_error_slot_stays_occupied(void **state) {
ASSET_LOADER_CALLBACKS[ASSET_LOADER_TYPE_LOCALE].loadSync = stub_load_fail;
assetentry_t *entry = assetGetEntry("fail.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("fail.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetUpdate();
assert_int_equal(entry->state, ASSET_ENTRY_STATE_ERROR);
// Unlike LOADED, the ERROR case does NOT clear the slot - it throws instead.
// Unlike LOADED, the ERROR case does NOT clear the slot - it throws
// instead.
assert_true(loading_slot_has_entry(entry));
errorret_t ret = assetUpdate();
@@ -293,7 +308,8 @@ static void test_update_error_slot_stays_occupied(void **state) {
// ============================================================
static void test_getEntry_null_input_stays_null(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assert_null(entry->input);
assert_int_equal(memoryGetAllocatedCount(), 0);
@@ -304,7 +320,8 @@ static void test_getEntry_input_copied_into_entry(void **state) {
memoryZero(&input, sizeof(input));
input.texture = (textureformat_t)42;
assetentry_t *entry = assetGetEntry("test.texture", ASSET_LOADER_TYPE_TEXTURE, &input);
assetentry_t *entry =
assetGetEntry("test.texture", ASSET_LOADER_TYPE_TEXTURE, &input);
// input must have been copied - entry->input must point inside the entry.
assert_non_null(entry->input);
@@ -338,10 +355,13 @@ static errorret_t reentrant_stub_load(assetloading_t *loading) {
static void test_update_reentrant_sync_loader(void **state) {
reentrant_inner_entry = NULL;
reentrant_inner_loaded = false;
// LOCALE uses the re-entrant loader; JSON keeps the default stub_load_success.
ASSET_LOADER_CALLBACKS[ASSET_LOADER_TYPE_LOCALE].loadSync = reentrant_stub_load;
// LOCALE uses the re-entrant loader; JSON keeps the default
// stub_load_success.
ASSET_LOADER_CALLBACKS[ASSET_LOADER_TYPE_LOCALE].loadSync =
reentrant_stub_load;
assetentry_t *outer = assetGetEntry("outer.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *outer =
assetGetEntry("outer.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
errorret_t ret = assetRequireLoaded(outer);
assert_true(errorIsOk(ret));
@@ -360,7 +380,8 @@ static void test_update_reentrant_sync_loader(void **state) {
// ============================================================
static void test_getEntry_returns_loaded_entry(void **state) {
assetentry_t *a = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *a =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(a);
assetUpdate();
@@ -368,7 +389,8 @@ static void test_getEntry_returns_loaded_entry(void **state) {
// A second request for the same name must return the same entry even though
// it is already LOADED rather than NOT_STARTED.
assetentry_t *b = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *b =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assert_ptr_equal(a, b);
assert_int_equal(b->state, ASSET_ENTRY_STATE_LOADED);
assetEntryUnlock(a);
@@ -381,7 +403,8 @@ static void test_getEntry_returns_loaded_entry(void **state) {
// ============================================================
static void test_entry_dispose_clears_entry(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(entry);
assetUpdate();
@@ -427,7 +450,8 @@ static void test_entry_dispose_slot_reusable(void **state) {
// ============================================================
static void test_requireLoaded_already_loaded(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(entry);
assetUpdate();
@@ -442,7 +466,8 @@ static void test_requireLoaded_already_loaded(void **state) {
}
static void test_requireLoaded_spins_to_loaded(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assert_int_equal(entry->state, ASSET_ENTRY_STATE_NOT_STARTED);
// requireLoaded calls assetUpdate internally until LOADED.
@@ -456,10 +481,12 @@ static void test_requireLoaded_spins_to_loaded(void **state) {
static void test_requireLoaded_propagates_error(void **state) {
ASSET_LOADER_CALLBACKS[ASSET_LOADER_TYPE_LOCALE].loadSync = stub_load_fail;
assetentry_t *entry = assetGetEntry("fail.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("fail.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
// requireLoaded spins assetUpdate until LOADED - but the loader always fails,
// so the second assetUpdate sees ERROR and throws, which errorChain propagates.
// requireLoaded spins assetUpdate until LOADED - but the loader
// always fails, so the second assetUpdate sees ERROR and throws, which
// errorChain propagates.
errorret_t ret = assetRequireLoaded(entry);
assert_true(errorIsNotOk(ret));
errorCatch(ret);
@@ -473,7 +500,8 @@ static void test_requireLoaded_propagates_error(void **state) {
// ============================================================
static void test_update_does_not_reap_automatically(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(entry);
assetUpdate();
@@ -497,7 +525,8 @@ static void test_update_does_not_reap_automatically(void **state) {
}
static void test_reapUnused_disposes_zero_ref_loaded(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(entry);
assetUpdate();
@@ -513,7 +542,8 @@ static void test_reapUnused_disposes_zero_ref_loaded(void **state) {
}
static void test_reapUnused_ignores_referenced_entries(void **state) {
assetentry_t *entry = assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *entry =
assetGetEntry("test.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetEntryLock(entry);
assetUpdate();
@@ -548,7 +578,8 @@ static void test_getEntry_reaps_when_pool_full(void **state) {
// The pool is now completely full of zero-ref LOADED entries with no
// ASSET_LOADER_TYPE_NULL slots left. Requesting one more must trigger an
// implicit reap instead of asserting.
assetentry_t *fresh = assetGetEntry("fresh.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assetentry_t *fresh =
assetGetEntry("fresh.locale", ASSET_LOADER_TYPE_LOCALE, NULL);
assert_non_null(fresh);
assert_int_equal(fresh->state, ASSET_ENTRY_STATE_NOT_STARTED);
@@ -572,39 +603,90 @@ int main(void) {
assertInit();
const struct CMUnitTest tests[] = {
// getEntry
cmocka_unit_test_setup_teardown(test_getEntry_creates_new, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_getEntry_dedup, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_getEntry_distinct_names, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_getEntry_returns_loaded_entry, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_getEntry_null_input_stays_null, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_getEntry_input_copied_into_entry, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(
test_getEntry_creates_new, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_getEntry_dedup, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_getEntry_distinct_names, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_getEntry_returns_loaded_entry, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_getEntry_null_input_stays_null, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_getEntry_input_copied_into_entry, asset_setup, asset_teardown
),
// assetUpdate - state machine
cmocka_unit_test_setup_teardown(test_update_noop_on_empty_table, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_entry_reaches_loaded, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_slot_cleared_after_first_update, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_slot_stays_cleared_on_further_updates, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_four_slots_fill_independently, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_loaded_entry_not_redispatched, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_overflow_queues_entries, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_error_state, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_error_slot_stays_occupied, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_update_reentrant_sync_loader, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(
test_update_noop_on_empty_table, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_entry_reaches_loaded, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_slot_cleared_after_first_update, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_slot_stays_cleared_on_further_updates,
asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_four_slots_fill_independently, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_loaded_entry_not_redispatched, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_overflow_queues_entries, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_error_state, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_error_slot_stays_occupied, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_update_reentrant_sync_loader, asset_setup, asset_teardown
),
// assetEntryDispose
cmocka_unit_test_setup_teardown(test_entry_dispose_clears_entry, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_entry_dispose_slot_reusable, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(
test_entry_dispose_clears_entry, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_entry_dispose_slot_reusable, asset_setup, asset_teardown
),
// assetRequireLoaded
cmocka_unit_test_setup_teardown(test_requireLoaded_already_loaded, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_requireLoaded_spins_to_loaded, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_requireLoaded_propagates_error, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(
test_requireLoaded_already_loaded, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_requireLoaded_spins_to_loaded, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_requireLoaded_propagates_error, asset_setup, asset_teardown
),
// assetReapUnused
cmocka_unit_test_setup_teardown(test_update_does_not_reap_automatically, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_reapUnused_disposes_zero_ref_loaded, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_reapUnused_ignores_referenced_entries, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(test_getEntry_reaps_when_pool_full, asset_setup, asset_teardown),
cmocka_unit_test_setup_teardown(
test_update_does_not_reap_automatically, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_reapUnused_disposes_zero_ref_loaded, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_reapUnused_ignores_referenced_entries, asset_setup, asset_teardown
),
cmocka_unit_test_setup_teardown(
test_getEntry_reaps_when_pool_full, asset_setup, asset_teardown
),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}