From f804dcb9740540b3735628ebf8c006235cc56fca Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 28 Jan 2026 09:15:56 +0100 Subject: test(assets): Add functional tests for asset management system This commit makes the asset packer fully functional and adds an end-to-end test suite. - Updated asset_packer.cc to read file contents and embed them as hex arrays. - Added actual asset files (null.bin, test_asset.txt) for testing. - Implemented src/tests/test_assets.cc to verify data integrity at runtime. - Refactored CMakeLists.txt to handle generated file dependencies correctly. --- src/tests/test_assets.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/tests/test_assets.cc (limited to 'src/tests/test_assets.cc') diff --git a/src/tests/test_assets.cc b/src/tests/test_assets.cc new file mode 100644 index 0000000..eedc92b --- /dev/null +++ b/src/tests/test_assets.cc @@ -0,0 +1,29 @@ +#include "assets.h" +#include +#include +#include + +int main() { + printf("Running AssetManager test...\n"); + + size_t size = 0; + const uint8_t *data = GetAsset(AssetId::ASSET_TEST_ASSET, &size); + + assert(data != nullptr); + assert(size > 0); + + const char *expected_prefix = "This is a test asset file."; + if (strncmp((const char *)data, expected_prefix, strlen(expected_prefix)) == + 0) { + printf("Asset content verification: SUCCESS\n"); + } else { + printf("Asset content verification: FAILED\n"); + printf("Got: %.*s\n", (int)size, (const char *)data); + return 1; + } + + printf("Asset size: %zu bytes\n", size); + printf("AssetManager test PASSED\n"); + + return 0; +} -- cgit v1.2.3