test/tc_bencode.rb in bencode-0.3.1 vs test/tc_bencode.rb in bencode-0.3.2
- old
+ new
@@ -1,16 +1,20 @@
require 'test/unit'
-require 'rubygems'
-require 'bencode'
+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_multiline_string
+ assert_equal "1:\n", "\n".bencode
+ assert_equal "2:\n\n", "\n\n".bencode
+ end
+
def test_integer
assert_equal "i42e", 42.bencode
assert_equal "i-3e", -3.bencode
end
@@ -25,7 +29,12 @@
end
def test_hash
assert_equal "d1:a3:foo1:g3:bar1:z3:baze",
{"a" => "foo", "g" => "bar", "z" => "baz"}.bencode
+ end
+
+ def test_hash_julien
+ assert_equal "d1:ai1e2:bbi1e1:ci1ee",
+ {'a' => 1, 'c' => 1, 'bb' => 1}.bencode
end
end