Sha256: 7bacf24a48793c6dc88e9d8e85aef94b8458bbb371b67de4e916131b0ae6804b

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 Bytes

Contents

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

class BencodeStringTest < Test::Unit::TestCase
  def test_empty
    assert_equal '0:', ''.bencode
  end

  def test_single_char
    ('a'..'z').each do |char|
      assert_equal '1:' + char, char.bencode
    end
  end

  def test_single_line
    assert_equal '2:ab', 'ab'.bencode
    assert_equal '3:abc', 'abc'.bencode
    assert_equal '4:abcd', 'abcd'.bencode
  end

  def test_whitespace
    [" ", "\t", "\n", "\r"].each do |char|
      assert_equal '1:' + char, char.bencode
      assert_equal '2:' + char * 2, (char * 2).bencode
    end
  end

  def test_multi_line
    assert_equal "3:a\nb", "a\nb".bencode
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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