module Reference
  def raw_xml(filename)
    data = File.new("test/reference/#{filename}.xml").read
    data.force_encoding('UTF-8') if data.respond_to?(:force_encoding)
  end
  
  def parsed_xml(filename)
    plist = CFPropertyList::List.new(:data => raw_xml(filename))
    CFPropertyList.native_types(plist.value)
  end
  
  def raw_binary(filename)
    data = File.new("test/reference/#{filename}.plist").read
    data.force_encoding('BINARY') if data.respond_to?(:force_encoding)
  end
  
  def parsed_binary(filename)
    plist = CFPropertyList::List.new(:data => raw_binary(filename))
    CFPropertyList.native_types(plist.value)
  end
end

module Reference
  def raw_xml(filename)
    data = File.new("test/reference/#{filename}.xml").read
    data.force_encoding('UTF-8') if data.respond_to?(:force_encoding)
    data
  end
  
  def parsed_xml(filename)
    plist = CFPropertyList::List.new(:data => raw_xml(filename))
    CFPropertyList.native_types(plist.value)
  end
  
  def raw_binary(filename)
    data = File.new("test/reference/#{filename}.plist").read
    data.force_encoding('BINARY') if data.respond_to?(:force_encoding)
    data
  end
  
  def parsed_binary(filename)
    plist = CFPropertyList::List.new(:data => raw_binary(filename))
    CFPropertyList.native_types(plist.value)
  end
end

Fix broken tests on Ruby 1.8.
Fix broken tests on Ruby 1.8.

If not on Ruby 1.9, the call to #force_encoding doesn't happen because the
test fails, and since that's the last expression in the method, it returns
nil instead of the data from the file.
