Sha256: 7a4d086f57261817c7174e373dd5a2686e4a76862a1bd5a1fdd652a135515b46

Contents?: true

Size: 1014 Bytes

Versions: 4

Compression:

Stored size: 1014 Bytes

Contents

# coding: utf-8
$:.unshift "."
require File.join(File.dirname(__FILE__), 'spec_helper')

describe "String RDF encoding" do
  {
    "Gregg" => 'Gregg',
    "Dürst" => 'D\u00FCrst',
    "simple literal"  => 'simple literal',
    "backslash:\\" => 'backslash:\\\\',
    "dquote:\"" => 'dquote:\\"',
    "newline:\n" => 'newline:\\n',
    "return:\r" => 'return:\\r',
    "tab:\t" => 'tab:\\t',
  }.each_pair do |raw, encoded|
    specify "'#{raw}' should escape to '#{encoded}'" do
      raw.rdf_escape.should == encoded
    end

    specify "'#{encoded}' should unescape to '#{raw}'" do
      encoded.rdf_unescape.should == raw
    end
  end
  
  # 16-bit string encodings
  {
    "16-bit:\u{15678}another" => '16-bit:\\U00015678another',
  }.each_pair do |raw, encoded|
    specify "'#{raw}' should escape to '#{encoded}'" do
      raw.rdf_escape.should == encoded
    end

    specify "'#{encoded}' should unescape to '#{raw}'" do
      encoded.rdf_unescape.should == raw
    end
  end if defined?(::Encoding)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf_context-0.5.9.1 spec/string_hacks_spec.rb
rdf_context-0.5.9 spec/string_hacks_spec.rb
rdf_context-0.5.8.2 spec/string_hacks_spec.rb
rdf_context-0.5.8.1 spec/string_hacks_spec.rb