Sha256: d3c933af2d2c2b7236c3b7052371088aee51af95454c854439b9a65f6daf304d

Contents?: true

Size: 1.35 KB

Versions: 19

Compression:

Stored size: 1.35 KB

Contents

require 'test_helper'
require 'tmail/base64'
require 'test/unit'

class TestTMailBase64 < Test::Unit::TestCase
  def try(orig)
    ok = [orig].pack('m').delete("\r\n")
    result = TMail::Base64.encode(orig)
    assert_equal ok, result, "str=#{orig.inspect}"
    assert_equal orig, TMail::Base64.decode(result), "str=#{orig.inspect}"
  end

  def test_normal
    try ''
    try 'a'
    try 'ab'
    try 'abc'
    try 'abcd'
    try 'abcde'
    try 'abcdef'
    try 'abcdefg'
    try 'abcdefgh'
    try 'abcdefghi'
    try 'abcdefghij'
    try 'abcdefghijk'
    try 'abcdefghijkl'
    try 'abcdefghijklm'
    try 'abcdefghijklmn'
    try 'abcdefghijklmno'
    try 'abcdefghijklmnop'
    try 'abcdefghijklmnopq'
    try 'abcdefghijklmnopqr'
    try 'abcdefghijklmnopqrs'
    try 'abcdefghijklmnopqrst'
    try 'abcdefghijklmnopqrstu'
    try 'abcdefghijklmnopqrstuv'
    try 'abcdefghijklmnopqrstuvw'
    try 'abcdefghijklmnopqrstuvwx'
    try 'abcdefghijklmnopqrstuvwxy'
    try 'abcdefghijklmnopqrstuvwxyz'
  end

  def test_dangerous_chars
    ["\0", "\001", "\002", "\003", "\0xfd", "\0xfe", "\0xff"].each do |ch|
      1.upto(96) do |len|
        try ch * len
      end
    end
  end

  def test_random
    16.times do
      try make_random_string(96)
    end
  end

  def make_random_string(len)
    buf = ''
    len.times do
      buf << rand(255)
    end
    buf
  end
end

Version data entries

19 entries across 19 versions & 9 rubygems

Version Path
tmail_es-1.2.7.3 test/test_base64.rb
tmail_es-1.2.7.2 test/test_base64.rb
bjornblomqvist-tmail-0.0.1 test/test_base64.rb
bjornblomqvist-tmail-0.0.2 test/test_base64.rb
japetheape-tmail-1.2.3.4 test/test_base64.rb
ledermann-tmail-1.2.5 test/test_base64.rb
lonbaker-tmail-1.2.3.1 test/test_base64.rb
valodzka-tmail-1.2.3.2 test/test_base64.rb
valodzka-tmail-1.2.3.3 test/test_base64.rb
valodzka-valodzka-tmail-1.2.3.2 test/test_base64.rb
tmail-1.2.7.1 test/test_base64.rb
tmail-1.2.7 test/test_base64.rb
tmail-1.2.6 test/test_base64.rb
sa-tmail-1.2.5.1 test/test_base64.rb
tmail-1.2.0 test/test_base64.rb
tmail-1.2.2 test/test_base64.rb
tmail-1.2.3.1 test/test_base64.rb
tmail-1.2.3 test/test_base64.rb
tmail-1.2.1 test/test_base64.rb