Fix divide by zero in pck_packer
This commit is contained in:
@ -40,17 +40,11 @@
|
||||
|
||||
namespace TestPCKPacker {
|
||||
|
||||
// Dummy 64-character encryption key (since it's required).
|
||||
constexpr const char *ENCRYPTION_KEY = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
TEST_CASE("[PCKPacker] Pack an empty PCK file") {
|
||||
PCKPacker pck_packer;
|
||||
const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck");
|
||||
CHECK_MESSAGE(
|
||||
pck_packer.pck_start(
|
||||
output_pck_path,
|
||||
32,
|
||||
ENCRYPTION_KEY) == OK,
|
||||
pck_packer.pck_start(output_pck_path) == OK,
|
||||
"Starting a PCK file should return an OK error code.");
|
||||
|
||||
CHECK_MESSAGE(
|
||||
@ -70,14 +64,27 @@ TEST_CASE("[PCKPacker] Pack an empty PCK file") {
|
||||
"The generated empty PCK file shouldn't be too large.");
|
||||
}
|
||||
|
||||
TEST_CASE("[PCKPacker] Pack empty with zero alignment invalid") {
|
||||
PCKPacker pck_packer;
|
||||
const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck");
|
||||
ERR_PRINT_OFF;
|
||||
CHECK_MESSAGE(pck_packer.pck_start(output_pck_path, 0) != OK, "PCK with zero alignment should fail.");
|
||||
ERR_PRINT_ON;
|
||||
}
|
||||
|
||||
TEST_CASE("[PCKPacker] Pack empty with invalid key") {
|
||||
PCKPacker pck_packer;
|
||||
const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck");
|
||||
ERR_PRINT_OFF;
|
||||
CHECK_MESSAGE(pck_packer.pck_start(output_pck_path, 32, "") != OK, "PCK with invalid key should fail.");
|
||||
ERR_PRINT_ON;
|
||||
}
|
||||
|
||||
TEST_CASE("[PCKPacker] Pack a PCK file with some files and directories") {
|
||||
PCKPacker pck_packer;
|
||||
const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_with_files.pck");
|
||||
CHECK_MESSAGE(
|
||||
pck_packer.pck_start(
|
||||
output_pck_path,
|
||||
32,
|
||||
ENCRYPTION_KEY) == OK,
|
||||
pck_packer.pck_start(output_pck_path) == OK,
|
||||
"Starting a PCK file should return an OK error code.");
|
||||
|
||||
const String base_dir = OS::get_singleton()->get_executable_path().get_base_dir();
|
||||
|
||||
Reference in New Issue
Block a user