6 def initialize(key, value)
7 @key = key.to_str.dup.freeze
8 @value = value.to_str.dup.freeze
14 @hash = {"artist" => HashEntry.new("artist", "Amon Amarth"),
15 "title" => HashEntry.new("title", "Death In Fire")}
28 class HashTest < Test::Unit::TestCase
30 data = HashTestData.new.to_eet
35 assert_nothing_raised do
36 stream = Eet::Stream.deserialize(data)
39 assert_equal(1, stream.length)
40 assert_equal("HashTest", stream.first.tag)
43 assert_nothing_raised do
44 stream = Eet::Stream.deserialize(stream.first.data)
47 assert_equal(2, stream.length)
50 hashlist = stream.find_all { |c| c.tag == "hash" }
51 assert_equal(2, hashlist.length)
53 hash = {"artist" => "Amon Amarth",
54 "title" => "Death In Fire"}
55 hash.each do |key, value|
58 assert_nothing_raised do
59 d = hashlist.shift.data
60 str_stream = Eet::Stream.deserialize(d)
63 assert_equal(1, str_stream.length)
64 assert_equal("HashEntry", str_stream.first.tag)
68 assert_nothing_raised do
69 foo = Eet::Stream.deserialize(str_stream.first.data)
72 assert_equal(2, foo.length)
74 {"key" => key, "value" => value}.each do |tag, data|
75 found = foo.find { |i| i.tag == tag }
77 assert_equal(data + "\0", found.data)
81 assert_equal([], hashlist)