// This file is part of the 64k demo project. // It tests the asset manager's ability to retrieve packed data. // Verifies data integrity and size reporting. #if defined(USE_TEST_ASSETS) #include "test_assets.h" #else #include "generated/assets.h" #endif /* defined(USE_TEST_ASSETS) */ #include "util/asset_manager_utils.h" #include #include #include int main() { printf("Running AssetManager test...\n"); // Test WGSL asset size_t size = 0; const uint8_t* data = GetAsset(AssetId::ASSET_TEST_WGSL, &size); assert(data != nullptr); assert(size > 0); assert(GetAssetType(AssetId::ASSET_TEST_WGSL) == AssetType::WGSL); printf("WGSL asset test: SUCCESS\n"); // Test SPEC asset data = GetAsset(AssetId::ASSET_TEST_SPEC, &size); assert(data != nullptr); assert(size > 0); assert(GetAssetType(AssetId::ASSET_TEST_SPEC) == AssetType::SPEC); printf("SPEC asset test: SUCCESS\n"); // Test MESH asset MeshAsset mesh = GetMeshAsset(AssetId::ASSET_TEST_MESH); assert(mesh.vertices != nullptr); assert(mesh.num_vertices > 0); assert(mesh.indices != nullptr); assert(mesh.num_indices > 0); assert(GetAssetType(AssetId::ASSET_TEST_MESH) == AssetType::MESH); printf("MESH asset test: SUCCESS\n"); // Test TEXTURE asset TextureAsset tex = GetTextureAsset(AssetId::ASSET_TEST_TEXTURE); assert(tex.pixels != nullptr); assert(tex.width > 0); assert(tex.height > 0); assert(GetAssetType(AssetId::ASSET_TEST_TEXTURE) == AssetType::TEXTURE); printf("TEXTURE asset test: SUCCESS\n"); // Test MP3 asset data = GetAsset(AssetId::ASSET_TEST_MP3, &size); assert(data != nullptr); assert(size > 0); assert(GetAssetType(AssetId::ASSET_TEST_MP3) == AssetType::MP3); printf("MP3 asset test: SUCCESS\n"); // Test PROC asset data = GetAsset(AssetId::ASSET_TEST_PROC, &size); assert(data != nullptr); assert(size > 0); assert(GetAssetType(AssetId::ASSET_TEST_PROC) == AssetType::PROC); DropAsset(AssetId::ASSET_TEST_PROC, data); printf("PROC asset test: SUCCESS\n"); // Test caching: request the same asset again and verify pointer is identical const uint8_t* data1 = GetAsset(AssetId::ASSET_TEST_WGSL, &size); const uint8_t* data2 = GetAsset(AssetId::ASSET_TEST_WGSL, &size); assert(data1 == data2); printf("Asset caching test: SUCCESS\n"); // Test ASSET_LAST_ID - should not return a valid asset const uint8_t* last_id_data = GetAsset(AssetId::ASSET_LAST_ID, &size); assert(last_id_data == nullptr); printf("ASSET_LAST_ID test: SUCCESS\n"); printf("\n--- ALL ASSET TESTS PASSED ---\n"); return 0; }