Removed the ancient Rake version test.
[ruby-eet.git] / test / test_sub.rb
1 require "eet"
2 require "test/unit"
3 require "common"
4
5 class SubTestData
6         def initialize
7                 @string = WrappedString.new("foobar")
8         end
9
10         private
11         def to_eet_name
12                 "SubTest"
13         end
14
15         def to_eet_properties
16                 {"sub_test" => [@string],
17                  "nil_test" => [nil]}
18         end
19 end
20
21 class SubTest < Test::Unit::TestCase
22         def test_sub
23                 data = SubTestData.new.to_eet
24                 assert_not_nil(data)
25
26                 stream = nil
27
28                 assert_nothing_raised do
29                         stream = Eet::Stream.deserialize(data)
30                 end
31
32                 assert_equal(1, stream.length)
33                 assert_equal("SubTest", stream.first.tag)
34
35                 assert_nothing_raised do
36                         stream = Eet::Stream.deserialize(stream.first.data)
37                 end
38
39                 assert_equal(1, stream.length)
40                 assert_equal("sub_test", stream.first.tag)
41
42                 assert_nothing_raised do
43                         stream = Eet::Stream.deserialize(stream.first.data)
44                 end
45
46                 assert_equal(1, stream.length)
47                 assert_equal("String", stream.first.tag)
48
49                 assert_nothing_raised do
50                         stream = Eet::Stream.deserialize(stream.first.data)
51                 end
52
53                 assert_equal(1, stream.length)
54                 assert_equal("buf", stream.first.tag)
55                 assert_equal("foobar\0", stream.first.data)
56         end
57 end