1 # $Id: test_stream.rb 1 2005-03-26 01:45:38Z tilman $
6 class StreamTest < Test::Unit::TestCase
8 stream = Eet::Stream.new
9 stream << Eet::Chunk.new("tag", "foo")
10 stream << Eet::Chunk.new("tag2", "bar")
11 stream << Eet::Chunk.new("tag23", "baz")
13 @data = stream.serialize
18 assert_equal("CHnK\007\0\0\0tag\0foo" +
19 "CHnK\010\0\0\0tag2\0bar" +
20 "CHnK\011\0\0\0tag23\0baz", @data)
26 assert_nothing_raised do
27 stream = Eet::Stream.deserialize(@data)
30 assert_equal(3, stream.length)
32 values = {"tag" => "foo", "tag2" => "bar", "tag23" => "baz"}
34 found = stream.find { |c| c.tag == k }
35 assert_not_nil(found, "chunk not found - #{k}")
36 assert_equal(found.data, v)
40 assert_equal([], stream)