test/func.rb in ox-1.4.6 vs test/func.rb in ox-1.5.0
- old
+ new
@@ -189,10 +189,21 @@
loaded = Ox.load(xml2, :mode => :object, :trace => 0, :effort => :auto_define)
assert_equal(loaded.class.to_s, 'Bad')
assert_equal(loaded.class.superclass.to_s, 'Ox::Bag')
end
+ def test_bad_class
+ xml = %{<?xml version="1.0"?>
+<o c="Bad:Boy">
+ <i a="@x">3</i>
+</o>
+}
+ assert_raise(SyntaxError) {
+ Ox.load(xml, :mode => :object, :trace => 0)
+ }
+ end
+
def test_xml_instruction
xml = Ox.dump("test", :mode => :object, :with_xml => false)
assert_equal("<s>test</s>\n", xml)
xml = Ox.dump("test", :mode => :object, :with_xml => true)
assert_equal("<?xml version=\"1.0\"?>\n<s>test</s>\n", xml)
@@ -426,9 +437,31 @@
def test_instructions
xml = Ox.dump("test", :with_instructions => true)
#puts xml
obj = Ox.load(xml) # should convert it to an object
assert_equal("test", obj)
+ end
+
+ def test_generic_string
+ xml = %{<?xml?>
+<Str>A <boo></Str>
+}
+ doc = Ox.load(xml, :mode => :generic)
+ xml2 = Ox.dump(doc, :with_xml => true)
+ assert_equal(xml, xml2)
+ end
+
+ def test_generic_encoding
+ if RUBY_VERSION.start_with?('1.8')
+ assert(true)
+ else
+ xml = %{<?xml encoding="UTF-8"?>
+<Str><γΎγγ></Str>
+}
+ doc = Ox.load(xml, :mode => :generic)
+ xml2 = Ox.dump(doc, :with_xml => true)
+ assert_equal(xml, xml2)
+ end
end
def test_IO
f = File.open(__FILE__, "r")
assert_raise(NotImplementedError) {