Complete pakrd_test implementation
This commit is contained in:
parent
490ccfc3c6
commit
c5c447d5c5
@ -1,4 +1,6 @@
|
|||||||
|
#include "io.h"
|
||||||
#include "pak.h"
|
#include "pak.h"
|
||||||
|
#include "test_utils.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -10,5 +12,40 @@ int main(int argc, char *argv[]) {
|
|||||||
return EXIT_FAILURE;
|
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;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user