Sha256: 02b55b862c9439dd3c525c04539c366e067842d63b9c7864485d0fe884392932

Contents?: true

Size: 923 Bytes

Versions: 2

Compression:

Stored size: 923 Bytes

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class ValeriiTest < Test::Unit::TestCase

  def test_encoding_and_decoding_single_chars
    from = (0..31).to_a
    to = %w( B C D F G H J K M N P Q R S T V W Z b c d f h j k m n p r x t v )
    
    from.zip(to) do |symbol_value, encode_symbol|
      assert_equal encode_symbol, Valerii.encode(symbol_value)
      assert_equal symbol_value, Valerii.decode(encode_symbol)
    end
  end

  def test_encoding_larger_numbers
    assert_equal("CB", Valerii.encode(32))
    assert_equal("CJb", Valerii.encode(1234))
    assert_equal("GbNfdbmNWprxRHbVCJGmkHvKDhTMDKDDJcrfPmGJDHMHnKZBBBBBBBBBBBBBBBBBBBB", Valerii.encode(10**100))
  end

  def test_decoding_strings
    assert_equal(32, Valerii.decode("CB"))
    assert_equal(1234, Valerii.decode("CJb"))
    assert_equal(10**100, Valerii.decode("GbNfdbmNWprxRHbVCJGmkHvKDhTMDKDDJcrfPmGJDHMHnKZBBBBBBBBBBBBBBBBBBBB"))
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
ariejan-valerii-1.1.0 test/valerii_test.rb
valerii-1.1.0 test/valerii_test.rb