From 8b2e182c47b5482569358494d72f419c580a123c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 29 Mar 2026 11:14:44 +0000 Subject: [PATCH] test: add test for recursive_sort with empty arrays This adds a missing edge case test for `recursive_sort` when handling empty arrays and objects containing empty arrays, ensuring the function completes successfully without modifying the structure or erroring. Co-authored-by: ffalcinelli <1167082+ffalcinelli@users.noreply.github.com> --- src/utils.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index b1d806c..0fc6d5b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -129,4 +129,15 @@ mod tests { assert_eq!(lines[11], "- name: c"); assert_eq!(lines[12], " v: 3"); } + + #[test] + fn test_recursive_sort_empty_array() { + let mut val = serde_json::json!([]); + recursive_sort(&mut val); + assert_eq!(val, serde_json::json!([])); + + let mut val_obj = serde_json::json!({ "empty_arr": [] }); + recursive_sort(&mut val_obj); + assert_eq!(val_obj, serde_json::json!({ "empty_arr": [] })); + } }