test/hexapdf/test_importer.rb in hexapdf-0.6.0 vs test/hexapdf/test_importer.rb in hexapdf-0.7.0

- old
+ new

@@ -2,10 +2,18 @@ require 'test_helper' require 'hexapdf/importer' require 'hexapdf/document' +describe HexaPDF::Importer::NullableWeakRef do + it "returns nil instead of an error when the referred-to object is GCed" do + obj = HexaPDF::Importer::NullableWeakRef.new(Object.new) + GC.start + assert_equal("", obj.to_s) + end +end + describe HexaPDF::Importer do before do @source = HexaPDF::Document.new obj = @source.add("test") @hash = @source.wrap(key: "value") @@ -59,9 +67,15 @@ obj[:key][:array][0].upcase! assert_equal("str", data[:str]) assert_equal("value", @obj[:hash][:key]) assert_equal(["one", "two"], @obj[:array]) + end + + it "duplicates the stream if it is a string" do + src_obj = @source.add({}, stream: 'data') + dst_obj = @importer.import(src_obj) + refute_same(dst_obj.data.stream, src_obj.data.stream) end it "does not import objects of type Catalog or Pages" do @obj[:catalog] = @source.catalog @obj[:pages] = @source.catalog.pages