Sha256: d925afc222b61ecb0979670fdd5e90a73bc476c7256fa3a45a1b1f26dc821f27

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

require 'test/unit'
require "#{File.dirname(__FILE__)}/../../lib/bencode.rb"

class BencodeDictionaryTest < Test::Unit::TestCase
  def test_empty
    assert_equal 'de', {}.bencode
  end

  def test_integer_hash
    assert_equal 'd1:ai1ee', {'a' => 1}.bencode
    assert_equal 'd1:ai1e1:bi2e1:ci3ee', 
                 {'a' => 1, 'b' => 2, 'c' => 3}.bencode
  end

  def test_illegal_keys
    assert_raise BEncode::EncodeError do
      {1 => 'foo'}.bencode
    end
  end

  # Thank you, Julien
  def test_key_order
    assert_equal 'd1:ai1e2:bbi3e1:ci2ee', 
                 {'a' => 1, 'c' => 2, 'bb' => 3}.bencode
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bencode-0.5.0 test/encode/test_hash.rb