52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
#include "io.h"
|
|
#include "pak.h"
|
|
#include "test_utils.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
asset_pack_t *pack = load_asset_pack("assets.pak");
|
|
if (!pack) {
|
|
printf("Failed to load asset pack");
|
|
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
asset_t assets[] = {
|
|
(asset_t){.name = "file01", .contents = "Hello\n"},
|
|
(asset_t){.name = "name.txt", .contents = "Abdelrahman\n"},
|
|
(asset_t){.name = "file02", .contents = "This is the second file\n"},
|
|
};
|
|
|
|
for (u64 i = 0; i < ARRLEN(assets); ++i) {
|
|
buf_t *buf = read_file_from_pack(pack, assets[i].name);
|
|
if (!buf || buf->size == 0) {
|
|
printf("Failed to read file %s\n", assets[i].name);
|
|
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
if (!(STREQ((char *)(buf->data), assets[i].contents))) {
|
|
printf("File contents mismatch for file %s\n", assets[i].name);
|
|
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
close_pack_file(&buf);
|
|
if (buf) {
|
|
printf("Failed to close file %s\n", assets[i].name);
|
|
|
|
return EXIT_FAILURE;
|
|
}
|
|
}
|
|
|
|
close_asset_pack(&pack);
|
|
if (pack) {
|
|
printf("Failed to close asset pack");
|
|
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|