Navigation Menu

Skip to content

Commit

Permalink
Add tests for Reducer#recursive_sum
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 30, 2015
1 parent ee4ccc0 commit 521580b
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/unit/test_reducer.rb
Expand Up @@ -86,6 +86,60 @@ def test_sum(data)
assert_equal(data[:expected], reduced)
end

data(
:int => {
:expected => 3,
:left => 1,
:right => 2,
},
:float => {
:expected => 3.0,
:left => 1.0,
:right => 2.0,
},
:string => {
:expected => "ab",
:left => "a",
:right => "b",
},
:array => {
:expected => [3],
:left => [1],
:right => [2],
},
:hash => {
:expected => {:a => 0, :b => 1, :c => 5},
:left => {:a => 0, :c => 2},
:right => {:b => 1, :c => 3},
},
:nested_hash => {
:expected => {:a => 0, :b => 1, :c => {:d => 2, :e => 3}},
:left => {:a => 0, :c => {:d => 2}},
:right => {:b => 1, :c => {:e => 3}},
},
:nil_left => {
:expected => 0,
:left => nil,
:right => 0,
},
:nil_right => {
:expected => 0,
:left => 0,
:right => nil,
},
:nil_both => {
:expected => nil,
:left => nil,
:right => nil,
},
)
def test_recursive_sum(data)
reduced = reduce_value({ "type" => "recursive-sum" },
data[:left],
data[:right])
assert_equal(data[:expected], reduced)
end

data(
:int => {
:expected => 1.5,
Expand Down

0 comments on commit 521580b

Please sign in to comment.