Sha256: 2c6cdbffd98c1d2a6c3fa6d72308d995ef66ec28ada1b3812e4e899841523c40
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
# encoding: UTF-8 require 'spec_helper' describe "FFI_Yajl::Encoder" do let(:encoder) { FFI_Yajl::Encoder.new } it "encodes fixnums in keys as strings" do ruby = {1 => 2} expect(encoder.encode(ruby)).to eq('{"1":2}') end it "encodes floats in keys as strings" do ruby = {1.1 => 2} expect(encoder.encode(ruby)).to eq('{"1.1":2}') end it "encodes bignums in keys as strings" do ruby = {12345678901234567890 => 2} expect(encoder.encode(ruby)).to eq('{"12345678901234567890":2}') end # XXX: 127 == YAJL_MAX_DEPTH hardcodedness, zero control for us, it isn't even a twiddleable #define it "raises an exception for deeply nested arrays" do root = [] a = root 127.times { |_| a << []; a = a[0] } expect{ encoder.encode(root) }.to raise_error(FFI_Yajl::EncodeError) end it "raises an exception for deeply nested hashes" do root = {} a = root 127.times {|_| a["a"] = {}; a = a["a"] } expect{ encoder.encode(root) }.to raise_error(FFI_Yajl::EncodeError) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ffi-yajl-0.0.1-universal-java | spec/ffi_yajl/encoder_spec.rb |
ffi-yajl-0.0.1 | spec/ffi_yajl/encoder_spec.rb |