diff options
| author | xroneyaa <202318392+xroneyaa@users.noreply.github.com> | 2026-11-24 11:51:04 +0500 |
|---|---|---|
| committer | xroneyaa <202318392+xroneyaa@users.noreply.github.com> | 2026-11-24 11:51:04 +0500 |
| commit | d6ca1fdaea7458f9a854f657fb58092336b61277 (patch) | |
| tree | c8f1fbe40b1fccef17662daa8b73d2fb05f647d8 /runtime/test/mods_test.cpp | |
| parent | c023a365a93e5e3a75290ab70f68c8da4a227700 (diff) | |
mods: reject bare 0x/0X prefix in parse_model_id
Diffstat (limited to 'runtime/test/mods_test.cpp')
| -rw-r--r-- | runtime/test/mods_test.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/runtime/test/mods_test.cpp b/runtime/test/mods_test.cpp index a29979b25..e95bc4e16 100644 --- a/runtime/test/mods_test.cpp +++ b/runtime/test/mods_test.cpp | |||
| @@ -41,6 +41,9 @@ int main() { | |||
| 41 | check(!parse_model_id("0x123456789", id), "a hash wider than 32 bits is refused"); | 41 | check(!parse_model_id("0x123456789", id), "a hash wider than 32 bits is refused"); |
| 42 | check(!parse_model_id("0xZZ", id), "a malformed hash is refused"); | 42 | check(!parse_model_id("0xZZ", id), "a malformed hash is refused"); |
| 43 | check(!parse_model_id("", id), "an empty name is refused"); | 43 | check(!parse_model_id("", id), "an empty name is refused"); |
| 44 | id = 0xCAFEBABEu; | ||
| 45 | check(!parse_model_id("0x", id) && id == 0xCAFEBABEu, "a bare 0x prefix is refused"); | ||
| 46 | check(!parse_model_id("0X", id) && id == 0xCAFEBABEu, "a bare 0X prefix is refused"); | ||
| 44 | 47 | ||
| 45 | Mod mod; | 48 | Mod mod; |
| 46 | std::string error; | 49 | std::string error; |
| @@ -53,6 +56,8 @@ int main() { | |||
| 53 | "a condition the runtime cannot honour yet is refused, not ignored"); | 56 | "a condition the runtime cannot honour yet is refused, not ignored"); |
| 54 | check(!parse_mod(R"({"archetype_swaps":[{"from":"cs_mandy","to":"0xD7C0CDFF"}]})", "m", mod, error), | 57 | check(!parse_mod(R"({"archetype_swaps":[{"from":"cs_mandy","to":"0xD7C0CDFF"}]})", "m", mod, error), |
| 55 | "a swap of a model with itself is refused"); | 58 | "a swap of a model with itself is refused"); |
| 59 | check(!parse_mod(R"({"archetype_swaps":[{"from":"0x","to":"cs_mandy"}]})", "m", mod, error), | ||
| 60 | "a bare 0x prefix in an archetype swap is refused"); | ||
| 56 | check(!parse_mod(R"({"enabled":"yes"})", "m", mod, error), "\"enabled\" must be a boolean"); | 61 | check(!parse_mod(R"({"enabled":"yes"})", "m", mod, error), "\"enabled\" must be a boolean"); |
| 57 | check(!parse_mod("[1,2]", "m", mod, error), "a manifest that is not an object is refused"); | 62 | check(!parse_mod("[1,2]", "m", mod, error), "a manifest that is not an object is refused"); |
| 58 | check(parse_mod("{}", "folder_name", mod, error) && mod.name == "folder_name", "the name defaults to the folder"); | 63 | check(parse_mod("{}", "folder_name", mod, error) && mod.name == "folder_name", "the name defaults to the folder"); |