|
573 | 573 | end |
574 | 574 | end |
575 | 575 |
|
576 | | - context "Writing a Statements" do |
| 576 | + context "Writing Statements" do |
577 | 577 | let(:statements) {[ |
578 | 578 | RDF::Statement(RDF::URI('s'), RDF::URI('p'), RDF::URI('o1')), |
579 | 579 | RDF::Statement(RDF::URI('s'), RDF::URI('p'), RDF::URI('o2')) |
|
600 | 600 | expect(writer.new.format_literal(RDF::Literal.new('Hello, world!'))).to eq '"Hello, world!"' |
601 | 601 | end |
602 | 602 |
|
| 603 | + it "should correctly format string literals" do |
| 604 | + expect(writer.new.format_literal(RDF::Literal.new('Hello, world!', datatype: RDF::XSD.string))).to eq '"Hello, world!"' |
| 605 | + end |
| 606 | + |
603 | 607 | it "should correctly format language-tagged literals" do |
604 | 608 | expect(writer.new.format_literal(RDF::Literal.new('Hello, world!', language: :en))).to eq '"Hello, world!"@en' |
605 | 609 | end |
|
848 | 852 | # @see http://www.w3.org/TR/rdf-testcases/#ntrip_strings |
849 | 853 | it "should correctly escape ASCII characters (#x0-#x7F)" do |
850 | 854 | (0x00..0x07).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" } |
851 | | - expect(writer.escape(0x08.chr, encoding)).to eq "\b" |
852 | | - expect(writer.escape(0x09.chr, encoding)).to eq "\t" |
| 855 | + expect(writer.escape(0x08.chr, encoding)).to eq "\\b" |
| 856 | + expect(writer.escape(0x09.chr, encoding)).to eq "\\t" |
853 | 857 | expect(writer.escape(0x0A.chr, encoding)).to eq "\\n" |
854 | | - expect(writer.escape(0x0B.chr, encoding)).to eq "\v" |
855 | | - expect(writer.escape(0x0C.chr, encoding)).to eq "\f" |
| 858 | + expect(writer.escape(0x0B.chr, encoding)).to eq "\\u000B" |
| 859 | + expect(writer.escape(0x0C.chr, encoding)).to eq "\\f" |
856 | 860 | expect(writer.escape(0x0D.chr, encoding)).to eq "\\r" |
857 | 861 | (0x0E..0x1F).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" } |
858 | 862 | (0x20..0x21).each { |u| expect(writer.escape(u.chr, encoding)).to eq u.chr } |
|
910 | 914 | # @see http://www.w3.org/TR/rdf-testcases/#ntrip_strings |
911 | 915 | it "should correctly escape ASCII characters (#x0-#x7F)" do |
912 | 916 | (0x00..0x07).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" } |
913 | | - expect(writer.escape(0x08.chr, encoding)).to eq "\b" |
914 | | - expect(writer.escape(0x09.chr, encoding)).to eq "\t" |
| 917 | + expect(writer.escape(0x08.chr, encoding)).to eq "\\b" |
| 918 | + expect(writer.escape(0x09.chr, encoding)).to eq "\\t" |
915 | 919 | expect(writer.escape(0x0A.chr, encoding)).to eq "\\n" |
916 | | - expect(writer.escape(0x0B.chr, encoding)).to eq "\v" |
917 | | - expect(writer.escape(0x0C.chr, encoding)).to eq "\f" |
| 920 | + expect(writer.escape(0x0B.chr, encoding)).to eq "\\u000B" |
| 921 | + expect(writer.escape(0x0C.chr, encoding)).to eq "\\f" |
918 | 922 | expect(writer.escape(0x0D.chr, encoding)).to eq "\\r" |
919 | 923 | (0x0E..0x1F).each { |u| expect(writer.escape(u.chr, encoding)).to eq "\\u#{u.to_s(16).upcase.rjust(4, '0')}" } |
920 | 924 | (0x20..0x21).each { |u| expect(writer.escape(u.chr, encoding)).to eq u.chr } |
|
0 commit comments