Sha256: 8d6c91d5bc9300a441ebe25252c03b69cbb9da1768a753da1445d2f898bba952

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

require 'test/unit'
require 'facet/orderedhash'


class TC_OrderedHash < Test::Unit::TestCase

  def test01
   hsh = OrderedHash.new
   hsh['z'] = 1
   hsh['a'] = 2
   hsh['c'] = 3
   assert_equal( ['z','a','c'], hsh.keys )
  end
  
  def test02
    hsh = OrderedHash['z', 1, 'a', 2, 'c', 3] 
    assert_equal( ['z','a','c'], hsh.keys )
  end

  def test03
    hsh = OrderedHash['a', 1, 'c', 2, 'z', 3]
    assert( hsh.push('end', 15) )
    assert_equal( 15, hsh['end'] )
    assert( ! hsh.push('end', 30) )
    assert( hsh.unshift('begin', 50) )
    assert_equal( 50, hsh['begin'] )
    assert( ! hsh.unshift('begin', 60) )
    assert_equal( ["begin", "a", "c", "z", "end"], hsh.keys )
    assert_equal( ["end", 15], hsh.pop )
    assert_equal( ["begin", "a", "c", "z"], hsh.keys )
    assert_equal( ["begin", 50], hsh.shift )
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 test/tc_orderedhash.rb
facets-0.7.1 test/tc_orderedhash.rb
facets-0.7.2 test/tc_orderedhash.rb