Sha256: 9f6e3e071b6257c44df7d7a76aa896cb34552e3b41528dca386cf9c4ee5a7155

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 Bytes

Contents

require "test/unit"
require "otp/base32"

class TestBase32 < Test::Unit::TestCase
  def assert_encode(plain, encoded)
    assert_equal(::OTP::Base32.encode(plain), encoded)
  end

  def assert_decode(encoded, plain)
    plain &&= plain.dup.force_encoding("binary")
    assert_equal(::OTP::Base32.decode(encoded), plain)
  end

  def assert_encode_decode(plain, encoded)
    assert_encode(plain, encoded)
    assert_decode(encoded, plain)
  end

  def test_base32
    assert_encode_decode(nil, nil)
    assert_encode_decode("", "")
    assert_encode_decode("f", "MY======")
    assert_encode_decode("fo", "MZXQ====")
    assert_encode_decode("foo", "MZXW6===")
    assert_encode_decode("foob", "MZXW6YQ=")
    assert_encode_decode("fooba", "MZXW6YTB")
    assert_encode_decode("foobar", "MZXW6YTBOI======")
    assert_encode_decode("\u{3042}\u{3044}\u{3046}\u{3048}\u{304a}", "4OAYFY4BQTRYDBXDQGEOHAMK")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
otp-0.0.2 test/test_base32.rb