test(platform): improve btreemap extensions test coverage#3380
Conversation
Add comprehensive unit tests for btreemap_removal_extensions.rs and btreemap_path_extensions.rs, which previously had 20.1% and 9.2% coverage respectively. Tests cover both BTreeMap<String, Value> (owned) and BTreeMap<String, &Value> (ref) impls across all public methods including string, float, integer, bool, hash256, bytes, identifier, binary data, bytes32, bytes20, array, map, and tuple operations. Also fixes an off-by-one bug in remove_optional_tuple where arr.remove(1) was called after arr.remove(0) had already shifted the array. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughTwo Rust extension modules for BTreeMap handling receive updates: comprehensive test suites are added for path-based access operations, and tuple removal logic is corrected to properly account for index shifts after element removal, accompanied by extensive removal operation tests. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3380 +/- ##
============================================
+ Coverage 75.87% 76.24% +0.36%
============================================
Files 2912 2914 +2
Lines 283860 285358 +1498
============================================
+ Hits 215375 217557 +2182
+ Misses 68485 67801 -684
🚀 New features to boost your workflow:
|
Issue being fixed or feature implemented
Improve test coverage for
rs-platform-valuebtreemap extension modules which had very low coverage:btreemap_removal_extensions.rs: 20.1% coverage (414 uncovered lines)btreemap_path_extensions.rs: 9.2% coverage (347 uncovered lines)What was done?
Added comprehensive
#[cfg(test)] mod teststo both files:btreemap_removal_extensions.rs (~130 tests):
BTreeMap<String, Value>(owned) andBTreeMap<String, &Value>(ref) implsremove_string,remove_float,remove_integer,remove_bool,remove_hash256_bytes,remove_bytes,remove_identifier,remove_binary_data,remove_bytes_32,remove_bytes_20,remove_hash256s,remove_identifiers,remove_map_as_btree_map,remove_map_as_btree_map_keep_values_as_platform_value, andremove_tupleremove_optional_tuple(arr.remove(1)afterarr.remove(0)shifted the array)btreemap_path_extensions.rs (~80 tests):
get_at_path,get_optional_at_pathwith single-level, nested, and deeply nested pathsget_inner_value_array_at_path,get_inner_string_array_at_path,get_inner_borrowed_str_value_map_at_pathBTreeMap<String, Value>andBTreeMap<String, &Value>How Has This Been Tested?
cargo fmt -p platform-value-- passescargo test -p platform-value-- all 248 tests passcargo clippy -p platform-value-- no warnings in modified filesBreaking Changes
None.
Checklist:
Summary by CodeRabbit