Sha256: 10f882e3e230e284be2e7681fb8e44b4570d43bf8da1b43fbe8fdd5818d8c4fd
Contents?: true
Size: 1.09 KB
Versions: 55
Compression:
Stored size: 1.09 KB
Contents
require 'test_helper' require 'tins' module Tins class TokenTest < Test::Unit::TestCase def test_token_failures assert_raise(ArgumentError) { Tins::Token.new(bits: 0) } assert_raise(ArgumentError) { Tins::Token.new(length: 0) } assert_raise(ArgumentError) { Tins::Token.new(alphabet: %w[0]) } end def test_token_for_length token = Tins::Token.new(length: 22) assert_equal 22, token.length assert_equal 130, token.bits end def test_token_for_bits token = Tins::Token.new(bits: 128) assert_equal 22, token.length # can differ from bits argument depending on alphabet: assert_equal 130, token.bits end def test_alphabet token = Tins::Token.new(alphabet: %w[0 1]) assert_equal 128, token.length assert_equal 128, token.bits token = Tins::Token.new(alphabet: %w[0 1 2 3]) assert_equal 64, token.length assert_equal 128, token.bits token = Tins::Token.new(length: 128, alphabet: %w[0 1 2 3]) assert_equal 128, token.length assert_equal 256, token.bits end end end
Version data entries
55 entries across 45 versions & 2 rubygems