Sha256: eec72e042656e247ef1e27f00c62df7170f0ba5bd53564216dcb9b2f215e51b0
Contents?: true
Size: 1.78 KB
Versions: 4
Compression:
Stored size: 1.78 KB
Contents
require 'test/unit' require 'eymiha/util/methodic_hash' include Eymiha class TC_MethodicHash < Test::Unit::TestCase def test_accesses mh = MethodicHash.new assert((mh['one'] = 1) == 1) assert(mh['one'] == 1) assert(mh[:one] == 1) assert(mh.one == 1) assert((mh[:two] = 2) == 2) assert(mh['two'] == 2) assert(mh[:two] == 2) assert(mh.two == 2) assert(mh['three'] == nil) assert(mh[:three] == nil) assert(mh.three == nil) assert((mh.four = 4) == 4) assert(mh['four'] == 4) assert(mh[:four] == 4) assert(mh.four == 4) assert(mh[1.25] == nil) end def test_remove mh = MethodicHash.new mh[:one] = 1 assert(mh.size == 1) assert((mh.delete :one) == 1) assert(mh.size == 0) mh['two'] = 2 assert(mh.size == 1) assert((mh.delete :two) == 2) assert(mh.size == 0) mh[:three] = 3 assert(mh.size == 1) assert((mh.delete 'three') == 3) assert(mh.size == 0) mh['four'] = 4 assert(mh.size == 1) assert((mh.delete 'four') == 4) assert(mh.size == 0) mh[:five] = 5 mh['five'] = 'v' assert(mh.size == 2) deleted = mh.delete :five assert(deleted.index(5) != nil) assert(deleted.index('v') != nil) assert(mh.size == 0) mh[:six] = 6 mh['six'] = 'vi' assert(mh.size == 2) deleted = mh.delete 'six' assert(deleted.index(6) != nil) assert(deleted.index('vi') != nil) assert(mh.size == 0) mh[:seven] = 7 assert(mh.size == 1) assert((mh.delete 'eight') == nil) assert((mh.delete('nine') {|key| "#{key} not found"}) == "nine not found") assert(mh.size == 1) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
eymiha_util-1.0.1 | test/tc_methodic_hash.rb |
eymiha_util-1.0.2 | test/tc_methodic_hash.rb |
eymiha_util-1.0.3 | test/tc_methodic_hash.rb |
eymiha_util-1.0.0 | test/tc_methodic_hash.rb |