summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-01-28 09:15:56 +0100
committerskal <pascal.massimino@gmail.com>2026-01-28 09:15:56 +0100
commitf804dcb9740540b3735628ebf8c006235cc56fca (patch)
tree69b4f87a47760ccc1eecd43d6c62bf9a611bfca1 /src
parent3e9e69a6cd9212b5cfd956c0a36b9dc07ab88cf7 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/tests/test_assets.cc29
1 files changed, 29 insertions, 0 deletions
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 <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+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;
+}