Skip to content

Commit

Permalink
Add a test case for localcc#103
Browse files Browse the repository at this point in the history
  • Loading branch information
scottanderson committed May 14, 2024
1 parent 55f799b commit e8deeb1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
Binary file added resources/test/issue103.sav
Binary file not shown.
6 changes: 5 additions & 1 deletion src/properties/map_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,11 @@ impl MapProperty {
for _ in 0..element_count {
let properties_stack = &mut options.properties_stack;
let key_stack_entry = ScopedStackEntry::new(properties_stack, "Key".to_string());
let key = Property::new(cursor, &key_type, false, options, None)?;
let suggested_length = match key_type.as_ref() {
"ByteProperty" => Some(u32::MAX),
_ => None,
};
let key = Property::new(cursor, &key_type, false, options, suggested_length)?;
drop(key_stack_entry);

let properties_stack = &mut options.properties_stack;
Expand Down
13 changes: 13 additions & 0 deletions tests/common/issue103.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::collections::HashMap;

const KEY_1: &str = "LandscapeData.MapProperty.Value.StructProperty";
const KEY_2: &str = "Buildings.ArrayProperty.ToolsBuffer_118_137A92324AB6747A399BA4B732BE0166.MapProperty.Value.StructProperty";
const KEY_3: &str = "NPCs.ArrayProperty.PresetsIDs_166_980BA472412B10BA3984DCB92C30E02A.MapProperty.Value.StructProperty";

pub(crate) fn hints() -> HashMap<String, String> {
HashMap::from([
(KEY_1.to_string(), "Unknown".to_string()),
(KEY_2.to_string(), "Unknown".to_string()),
// (KEY_3.to_string(), "???".to_string()),
])
}
2 changes: 2 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pub mod delegate;
pub mod features;
pub mod issue103;
pub mod options;
pub mod palworld;
pub mod profile0;
Expand All @@ -15,6 +16,7 @@ pub const COMPONENT8_PATH: &str = "resources/test/component8.sav";
pub const DELEGATE_PATH: &str = "resources/test/Delegate.sav";
pub const ENUM_ARRAY_PATH: &str = "resources/test/enum_array.sav";
pub const FEATURES_01_PATH: &str = "resources/test/features_01.bin";
pub const ISSUE103_PATH: &str = "resources/test/issue103.sav";
pub const OPTIONS_PATH: &str = "resources/test/Options.sav";
pub const PACKAGE_VERSION_524_PATH: &str = "resources/test/package_version_524.sav";
pub const PALWORLD_ZLIB_PATH: &str = "resources/test/palworld_zlib.sav";
Expand Down
5 changes: 5 additions & 0 deletions tests/gvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ fn features_01() {
test_gvas_file_(FEATURES_01_PATH, GameVersion::Default, &features::hints());
}

#[test]
fn issue103() {
test_gvas_file_(ISSUE103_PATH, GameVersion::Default, &issue103::hints());
}

#[test]
fn options() {
assert_eq!(test_gvas_file(OPTIONS_PATH), options::expected());
Expand Down

0 comments on commit e8deeb1

Please sign in to comment.