Sha256: 485e5c3e2acd9f3d157aef40d266f844e8028789c41825a3b3566c913e2c7634

Contents?: true

Size: 747 Bytes

Versions: 27

Compression:

Stored size: 747 Bytes

Contents

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

$: << File.dirname(__FILE__)

require 'helper'

class HashTest < 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

27 entries across 27 versions & 2 rubygems

Version Path
oj-3.14.3 test/test_hash.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/oj-3.13.2/test/test_hash.rb
oj-3.14.2 test/test_hash.rb
oj-3.14.1 test/test_hash.rb
oj-3.14.0 test/test_hash.rb
oj-3.13.23 test/test_hash.rb
oj-3.13.22 test/test_hash.rb
oj-3.13.21 test/test_hash.rb
oj-3.13.20 test/test_hash.rb
oj-3.13.19 test/test_hash.rb
oj-3.13.18 test/test_hash.rb
oj-3.13.17 test/test_hash.rb
oj-3.13.16 test/test_hash.rb
oj-3.13.15 test/test_hash.rb
oj-3.13.14 test/test_hash.rb
oj-3.13.13 test/test_hash.rb
oj-3.13.12 test/test_hash.rb
oj-3.13.11 test/test_hash.rb
oj-3.13.10 test/test_hash.rb
oj-3.13.9 test/test_hash.rb