Sha256: 09b55d659ee735cc58f87b7b5fae5a58d0057910a92368feb846020fdee352f1

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

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

class BdecodeIntegerTest < Test::Unit::TestCase
  def test_zero
    assert_equal 0, 'i0e'.bdecode
  end
  
  def test_single_digit
    (1..9).each do |digit|
      assert_equal digit, "i#{digit}e".bdecode
    end
  end

  def test_multi_digit
    (1..10).each do |digit|
      assert_equal digit * 10, "i#{digit * 10}e".bdecode
    end
  end

  def test_negative
    (-9..-1).each do |digit|
      assert_equal digit, "i#{digit}e".bdecode
    end
  end

  def test_invalid
    assert_raise(BEncode::DecodeError){ 'i01e'.bdecode }
    assert_raise(BEncode::DecodeError){ 'i-0e'.bdecode }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bencode-0.5.0 test/decode/test_integer.rb