Sha256: f18d444ef03135e1ff4e2ef67ef33aceeecaa59b9d02cad9aab8703f3a240dc9
Contents?: true
Size: 864 Bytes
Versions: 1
Compression:
Stored size: 864 Bytes
Contents
require 'test/unit' require "#{File.dirname(__FILE__)}/../lib/bencode" class BdecodeTest < Test::Unit::TestCase def test_string assert_equal "foo", "3:foo".bdecode end def test_integer assert_equal 42, "i42e".bdecode assert_raise BdecodeError do "i01e".bdecode end assert_raise BdecodeError do "i-01e".bdecode end end def test_array assert_equal [1, 2, 3], "li1ei2ei3ee".bdecode end def test_hash hsh = {"a" => "monkey", "h" => "elephant", "z" => "zebra"} assert_equal hsh, "d1:a6:monkey1:h8:elephant1:z5:zebrae".bdecode end def test_invalid assert_raises BdecodeError do "foobar".bdecode "i1ei2e".bdecode end end def test_valid assert "3:foo".bencoded? assert !"3:foo3:bar".bencoded? assert "i42e".bencoded? assert !"i42ei101e".bencoded? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bencode-0.3.2 | test/tc_bdecode.rb |