Sha256: 8f4320931a82c034f3a693d3a78bc3984f416fc82650aa3041e76f216891a72c

Contents?: true

Size: 744 Bytes

Versions: 12

Compression:

Stored size: 744 Bytes

Contents

#!/usr/bin/env ruby
# encoding: UTF-8

$: << File.dirname(__FILE__)

require 'helper'

class Hashi < Minitest::Test

  module TestModule
  end

  def test_dump
    h = Oj::EasyHash.new()
    h['abc'] = 3
    out = Oj.dump(h, :mode => :compat)
    assert_equal(%|{"abc":3}|, out)
  end

  def test_load
    obj = Oj.load(%|{"abc":3}|, :mode => :compat, :hash_class => Oj::EasyHash)
    
    assert_equal(Oj::EasyHash, obj.class)
    assert_equal(3, obj['abc'])
    assert_equal(3, obj[:abc])
    assert_equal(3, obj.abc())
  end

  def test_marshal
    h = Oj::EasyHash.new()
    h['abc'] = 3
    out = Marshal.dump(h)

    obj = Marshal.load(out)
    assert_equal(Oj::EasyHash, obj.class)
    assert_equal(3, obj[:abc])
  end
  
end # HashTest

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
oj-3.13.1 test/test_hash.rb
oj-3.13.0 test/test_hash.rb
oj-3.12.3 test/test_hash.rb
oj-3.12.2 test/test_hash.rb
oj-3.12.1 test/test_hash.rb
oj-3.12.0 test/test_hash.rb
oj-3.11.8 test/test_hash.rb
oj-3.11.7 test/test_hash.rb
oj-3.11.6 test/test_hash.rb
oj-3.11.5 test/test_hash.rb
oj-3.11.4 test/test_hash.rb
oj-3.11.3 test/test_hash.rb