summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2013-12-08 12:17:02 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2013-12-08 12:17:02 -0800
commit4cd083a6411efa132071713e15fcb8ba428e4c12 (patch)
treeba3fafde03a48ff11c6efe8b9cceeae252a26e62 /spec
parent5662dde25a4eddb0be664baa78a4b66959783466 (diff)
downloadffi-yajl-4cd083a6411efa132071713e15fcb8ba428e4c12.tar.gz
add more unicode tests
Diffstat (limited to 'spec')
-rw-r--r--spec/ffi_yajl/json_gem_spec.rb59
1 files changed, 43 insertions, 16 deletions
diff --git a/spec/ffi_yajl/json_gem_spec.rb b/spec/ffi_yajl/json_gem_spec.rb
index 196e0c9..a55cd98 100644
--- a/spec/ffi_yajl/json_gem_spec.rb
+++ b/spec/ffi_yajl/json_gem_spec.rb
@@ -195,17 +195,24 @@ describe "JSON Gem Compat API" do
expect(''.to_json).to eq( %q{""} )
end
it "should encode backspace character" do
- pending "FIXME"
expect("\b".to_json).to eq( %q{"\\b"} )
end
it "should encode \u0001 correctly" do
- pending "FIXME"
expect(0x1.chr.to_json).to eq( %q{"\u0001"} )
end
-# '"\u001F"'.should eql(0x1f.chr.to_json)
-# '" "'.should eql(' '.to_json)
-# "\"#{0x7f.chr}\"".should eql(0x7f.chr.to_json)
+ it "should encode \u001f correctly" do
+ expect(0x1f.chr.to_json).to eq( %q{"\u001F"} )
+ end
+
+ it "should encode a string with a space correctly" do
+ expect(' '.to_json).to eq( %q{" "} )
+ end
+
+ it "should encode 0x75 correctly" do
+ expect(0x7f.chr.to_json).to eq( %Q{"#{0x7f.chr}"} )
+ end
+
context"when dealing with common UTF-8 symbols" do
let(:ruby) { [ "© ≠ €! \01" ] }
@@ -220,17 +227,37 @@ describe "JSON Gem Compat API" do
it_behaves_like "handles encoding and parsing correctly"
end
-# utf8 = ['საქართველო']
-# json = "[\"საქართველო\"]"
-# json.should eql(utf8.to_json)
-# utf8.should eql(JSON.parse(json))
-# '["Ã"]'.should eql(JSON.generate(["Ã"]))
-# ["€"].should eql(JSON.parse('["\u20ac"]'))
-# utf8_str = "\xf0\xa0\x80\x81"
-# utf8 = [utf8_str]
-# json = "[\"#{utf8_str}\"]"
-# json.should eql(JSON.generate(utf8))
-# utf8.should eql(JSON.parse(json))
+
+ context "whatever this is" do
+ let(:ruby) { ['საქართველო'] }
+ let(:json) { "[\"საქართველო\"]" }
+
+ it_behaves_like "handles encoding and parsing correctly"
+ end
+
+ context "accents" do
+ let(:ruby) { ["Ã"] }
+ let(:json) { '["Ã"]' }
+
+ it_behaves_like "handles encoding and parsing correctly"
+ end
+
+ context "euro symbol" do
+ let(:ruby) { ["€"] }
+ let(:json) { '["\u20ac"]' }
+ it "should parse the content correctly" do
+ expect(JSON.parse(json)).to eq(ruby)
+ end
+ end
+
+ context "and whatever this is" do
+
+ utf8_str = "\xf0\xa0\x80\x81"
+ let(:ruby) { [utf8_str] }
+ let(:json) { "[\"#{utf8_str}\"]" }
+
+ it_behaves_like "handles encoding and parsing correctly"
+ end
end