Skip to content

Commit

Permalink
Add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
ameir committed Feb 12, 2021
1 parent 78fd372 commit 1f7ed45
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/test_deep_merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ def test_deep_merge
DeepMerge::deep_merge!(hash_src, hash_dst, {:sort_merged_arrays => true})
assert_equal(["1","2","3","4"].sort, hash_dst['property'])

# hashes with a false value; do not overwrite keys (like having a defaults hash and a user-defined hash)
hash_src = {"name" => true, "name1" => "value1"}
hash_dst = {"name" => false, "name1" => "value"}
DeepMerge::deep_merge!(hash_src, hash_dst, preserve_unmergeables: true)
assert_equal({"name" => false, "name1" => "value"}, hash_dst)

# hashes holding hashes holding arrays (array with duplicate elements is merged with dest then src
hash_src = {"property" => {"bedroom_count" => ["1", "2"], "bathroom_count" => ["1", "4+"]}}
hash_dst = {"property" => {"bedroom_count" => ["3", "2"], "bathroom_count" => ["2"]}}
Expand Down

0 comments on commit 1f7ed45

Please sign in to comment.