Sha256: 46cd043026d7690c265fd03b8c5feba221a8125d807b253ec8a3551dc49fac91
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require 'test/unit' require "#{File.dirname(__FILE__)}/../lib/bencode" class BencodeTest < Test::Unit::TestCase def test_string assert_equal "3:foo", "foo".bencode assert_equal "0:", "".bencode end def test_tab_string assert_equal "1:\t", "\t".bencode assert_equal "2:\t\t", "\t\t".bencode end def test_multiline_string assert_equal "1:\n", "\n".bencode assert_equal "2:\n\n", "\n\n".bencode end def test_integer assert_equal "i0e", 0.bencode assert_equal "i42e", 42.bencode assert_equal "i-3e", -3.bencode end def test_float assert_raise BencodeError do 42.4.bencode end end def test_array assert_equal "le", [].bencode assert_equal "li1ei2ei3ee", [1, 2, 3].bencode end def test_hash assert_equal "de", {}.bencode assert_equal "d1:a3:foo1:g3:bar1:z3:baze", {"a" => "foo", "g" => "bar", "z" => "baz"}.bencode end def test_illegal_hash_keys assert_raise BencodeError do {1 => 'foo'}.bencode end assert_raise BencodeError do {1 => 'foo', 2 => 'bar'}.bencode end end def test_hash_julien assert_equal "d1:ai1e2:bbi1e1:ci1ee", {'a' => 1, 'c' => 1, 'bb' => 1}.bencode end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bencode-0.4.0 | test/tc_bencode.rb |