Sha256: 3f5a378becba8e8160fae98b7b5ba8e2eee6b66d15f95885f575747adb24d816

Contents?: true

Size: 567 Bytes

Versions: 2

Compression:

Stored size: 567 Bytes

Contents

require 'unit/test'
require 'bencode'

class BencodeTest < Test::Unit::TestCase
  def test_string
    assert_equal "3:foo", "foo".bencode
    assert_equal "0:", "".bencode
  end

  def test_integer
    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 "li1ei2ei3ee", [1, 2, 3].bencode
  end

  def test_hash
    assert_equal "d1:a3:foo1:g3:bar1:z3:baze", 
      {"a" => "foo", "g" => "bar", "z" => "baz"}.bencode
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bencode-0.0.1 test/tc_bencode.rb
bencode-0.1.0 test/tc_bencode.rb