test/test_bencoding.rb in simonmenke-bencoding-0.0.2 vs test/test_bencoding.rb in simonmenke-bencoding-0.0.3

- old
+ new

@@ -8,10 +8,14 @@ def test_load_integer test_load "i17e", 17 end + def test_load_negative_integer + test_load "i-17e", -17 + end + def test_load_list test_load "l5:helloi17ee", ["hello", 17] end def test_load_dictionary @@ -20,19 +24,49 @@ end def test_load_fake str = "d5:key_ai16e5:a_key4:helloe" assert_raise Bencoding::ParseError do - out = Bencoding.load(str) + out = Bencoding.load!(str) end end + def test_load_partial_integer + str = "i12" + assert_raise Bencoding::ParseError do + out = Bencoding.load!(str) + end + end + + def test_load_partial_integer_in_list + str = "li12i45ee" + assert_raise Bencoding::ParseError do + out = Bencoding.load!(str) + end + end + + def test_load_partial_string + str = "5:hel" + assert_raise Bencoding::ParseError do + out = Bencoding.load!(str) + end + end + + def test_load_form_uri + uri = "http://torrents.thepiratebay.org/4385574/Ubuntu_8.10_(Intrepid_Ibex)_Alpha_5.4385574.TPB.torrent" + assert Bencoding.load!(uri)['announce']=='http://tpb.tracker.thepiratebay.org:80/announce' + end + def test_dump_string test_dump "hello", "5:hello" end def test_dump_integer test_dump 25, "i25e" + end + + def test_dump_negative_integer + test_dump -25, "i-25e" end def test_dump_float test_dump 25.4, "i25e" end