[Groonga-commit] droonga/droonga-engine at 521580b [master] Add tests for Reducer#recursive_sum

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Apr 30 17:06:26 JST 2015


YUKI Hiroshi	2015-04-30 17:06:26 +0900 (Thu, 30 Apr 2015)

  New Revision: 521580b62d5119ea430ca570d5a9e0bf83b4cb1d
  https://github.com/droonga/droonga-engine/commit/521580b62d5119ea430ca570d5a9e0bf83b4cb1d

  Message:
    Add tests for Reducer#recursive_sum

  Modified files:
    test/unit/test_reducer.rb

  Modified: test/unit/test_reducer.rb (+54 -0)
===================================================================
--- test/unit/test_reducer.rb    2015-04-30 17:04:31 +0900 (8e476ee)
+++ test/unit/test_reducer.rb    2015-04-30 17:06:26 +0900 (9114cd0)
@@ -88,6 +88,60 @@ class ReducerTest < Test::Unit::TestCase
 
   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,
       :left     => 1,
       :right    => 2,
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index