[Groonga-commit] droonga/fluent-plugin-droonga at 9dbdca3 [master] test message_pack_packer: split a large test to small tests

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Dec 16 15:11:52 JST 2013


Kouhei Sutou	2013-12-16 15:11:52 +0900 (Mon, 16 Dec 2013)

  New Revision: 9dbdca39906c27d1fb612c272cd76451bb24ec5b
  https://github.com/droonga/fluent-plugin-droonga/commit/9dbdca39906c27d1fb612c272cd76451bb24ec5b

  Message:
    test message_pack_packer: split a large test to small tests

  Modified files:
    test/unit/test_message_pack_packer.rb

  Modified: test/unit/test_message_pack_packer.rb (+31 -12)
===================================================================
--- test/unit/test_message_pack_packer.rb    2013-12-16 15:05:49 +0900 (495e432)
+++ test/unit/test_message_pack_packer.rb    2013-12-16 15:11:52 +0900 (96f5d2f)
@@ -16,17 +16,36 @@
 require "droonga/message_pack_packer"
 
 class MessagePackPackerTest < Test::Unit::TestCase
-  def test_to_msgpack
-    src = [
-      11,
-      29,
-      Time.parse("2013-11-29T08:00:00Z"),
-      "Groonga",
-      {"key" => "value"}
-    ]
-    actual = Droonga::MessagePackPacker.to_msgpack(src)
-    expected = "\x95\v\x1D\xB42013-11-29T08:00:00Z\xA7Groonga\x81\xA3key\xA5value".force_encoding("ASCII-8BIT")
-
-    assert_equal(expected, actual)
+  def test_integer
+    assert_equal(29, unpack(pack(29)))
+  end
+
+  def test_string
+    assert_equal("Droonga", unpack(pack("Droonga")))
+  end
+
+  def test_time
+    w3c_dtf_time = "2013-11-29T08:00:00Z"
+    time = Time.parse(w3c_dtf_time)
+    assert_equal(w3c_dtf_time, unpack(pack(time)))
+  end
+
+  def test_hash
+    hash = {"key" => "value"}
+    assert_equal(hash, unpack(pack(hash)))
+  end
+
+  def test_array
+    array = ["Groonga", "Rroonga", "Droonga"]
+    assert_equal(array, unpack(pack(array)))
+  end
+
+  private
+  def pack(object)
+    Droonga::MessagePackPacker.to_msgpack(object)
+  end
+
+  def unpack(msgpack)
+    MessagePack.unpack(msgpack)
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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