summaryrefslogtreecommitdiff
path: root/test/soap/marshal/test_struct.rb
blob: d3c0a4e5e8d22620ec0e9b45c3f39c016d972700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'test/unit'
require 'soap/marshal'


module SOAP
module Marshal


Foo1 = Struct.new("Foo1", :m)
Foo2 = Struct.new(:m)
class Foo3
  attr_accessor :m
end

class TestStruct < Test::Unit::TestCase
  def test_foo1
    org = Foo1.new
    org.m = org
    obj = convert(org)
    assert_equal(Foo1, obj.class)
    assert_equal(obj.m, obj)
  end

  def test_foo2
    org = Foo2.new
    org.m = org
    obj = convert(org)
    assert_equal(Foo2, obj.class)
    assert_equal(obj.m, obj)
  end

  def test_foo3
    org = Foo3.new
    org.m = org
    obj = convert(org)
    assert_equal(Foo3, obj.class)
    assert_equal(obj.m, obj)
  end

  def convert(obj)
    SOAP::Marshal.unmarshal(SOAP::Marshal.marshal(obj))
  end
end


end
end