~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to test/soap/marshal/test_digraph.rb

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-01-24 11:42:29 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080124114229-jw2f87rdxlq6gp11
Tags: 1.9.0.0-2ubuntu1
* Merge from debian unstable, remaining changes:
  - Robustify check for target_os, fixing build failure on lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'test/unit'
2
 
require 'soap/marshal'
3
 
 
4
 
 
5
 
module SOAP
6
 
module Marshal
7
 
 
8
 
 
9
 
class Node; include SOAP::Marshallable
10
 
  attr_reader :first, :second, :str
11
 
 
12
 
  def initialize(*init_next)
13
 
    @first = init_next[0]
14
 
    @second = init_next[1]
15
 
  end
16
 
end
17
 
 
18
 
class TestDigraph < Test::Unit::TestCase
19
 
  def setup
20
 
    @n9 = Node.new
21
 
    @n81 = Node.new(@n9)
22
 
    @n82 = Node.new(@n9)
23
 
    @n7 = Node.new(@n81, @n82)
24
 
    @n61 = Node.new(@n7)
25
 
    @n62 = Node.new(@n7)
26
 
    @n5 = Node.new(@n61, @n62)
27
 
    @n41 = Node.new(@n5)
28
 
    @n42 = Node.new(@n5)
29
 
    @n3 = Node.new(@n41, @n42)
30
 
    @n21 = Node.new(@n3)
31
 
    @n22 = Node.new(@n3)
32
 
    @n1 = Node.new(@n21, @n22)
33
 
  end
34
 
 
35
 
  def test_marshal
36
 
    f = File.open("digraph_marshalled_string.soap", "wb")
37
 
    SOAP::Marshal.dump(@n1, f)
38
 
    f.close
39
 
    f = File.open("digraph_marshalled_string.soap")
40
 
    str = f.read
41
 
    f.close
42
 
    newnode = SOAP::Marshal.unmarshal(str)
43
 
    assert_equal(newnode.first.first.__id__, newnode.second.first.__id__)
44
 
    assert_equal(newnode.first.first.first.first.__id__, newnode.second.first.second.first.__id__)
45
 
  end
46
 
 
47
 
  def teardown
48
 
    if File.exist?("digraph_marshalled_string.soap")
49
 
      File.unlink("digraph_marshalled_string.soap")
50
 
    end
51
 
  end
52
 
end
53
 
 
54
 
 
55
 
end
56
 
end