test/clone_test.rb in openwferu-0.9.15 vs test/clone_test.rb in openwferu-0.9.16
- old
+ new
@@ -4,12 +4,14 @@
#
# John Mettraux at openwfe.org
#
require 'test/unit'
+require 'rexml/document'
require 'openwfe/utils'
+require 'openwfe/workitem'
class FullDupTest < Test::Unit::TestCase
#def setup
@@ -46,6 +48,66 @@
assert_not_equal o0.object_id, o1.object_id
assert_equal o0.name, o1.name
end
+ def test_dup_0
+ a0 = A.new
+ a0.a = 1
+ a0.b = 2
+ a1 = OpenWFE::fulldup(a0)
+
+ #puts a0
+ #puts a1
+
+ assert_equal a0, a1, "dup() utility not working"
+ end
+
+ def test_dup_1
+ d = REXML::Document.new("<document/>")
+ d1 = OpenWFE::fulldup(d)
+ assert d.object_id != d1.object_id
+ end
+
+ def test_dup_2
+ d = REXML::Document.new("<document>text</document>")
+ d1 = OpenWFE::fulldup(d)
+ assert d.object_id != d1.object_id
+ end
+
+ def test_dup_3
+ d = REXML::Text.new "toto"
+ d1 = OpenWFE::fulldup(d)
+ assert d.object_id != d1.object_id
+ end
+
+ def test_dup_4
+ wi = OpenWFE::InFlowWorkItem.new
+ wi.xml_stuff = REXML::Text.new "whatever"
+ wi1 = wi.dup
+ assert wi.object_id != wi1.object_id
+ assert wi.xml_stuff.object_id != wi1.xml_stuff.object_id
+ assert_equal wi.xml_stuff, wi1.xml_stuff
+ end
+
+ def test_dup_5
+ require 'date'
+ d = DateTime.now()
+ d1 = OpenWFE::fulldup(d)
+ assert d.object_id != d1.object_id
+ end
+
+ private
+
+ class A
+ attr_accessor :a, :b
+
+ def == (other)
+ return false if not other.kind_of?(A)
+ (self.a == other.a and self.b == other.b)
+ end
+
+ def to_s
+ "A : a='#{a}', b='#{b}'"
+ end
+ end
end