Sha256: 6e01fc22a2cb99e9fa11e946df1be1866c5b74fa7ca870a77e5b5b138c875975

Contents?: true

Size: 915 Bytes

Versions: 48

Compression:

Stored size: 915 Bytes

Contents

require 'test_helper'

class StringExtensionsTest < ActiveSupport::TestCase

  test 'string has to_hex_string and to_byte_string' do
    s = 'hello'
    assert s.respond_to?(:to_hex_string)
    assert s.respond_to?(:to_byte_string)
  end

  test 'hex and byte conversion works' do
    s_text = 'Hello World'
    s_hex = '48656c6c6f20576f726c64'
    assert_equal s_hex, s_text.to_hex_string
    assert_equal s_text, s_hex.to_byte_string
    s_text += s_hex
    assert_equal s_text, s_text.to_hex_string.to_byte_string
  end

  test 'hex grouping works' do
    s_text = 'Hello World'
    s_hex = '48 65 6c 6c 6f 20 57 6f 72 6c 64'
    assert_equal s_hex, s_text.to_hex_string(true)
    assert_equal s_text, s_text.to_hex_string(true).to_byte_string
    s_hex = '486 56c 6c6 f20 576 f72 6c6 4'
    assert_equal s_hex, s_text.to_hex_string(3)
    assert_equal s_text, s_text.to_hex_string(3).to_byte_string
  end



end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.3.14 test/extensions/string_extensions_test.rb
incline-0.3.13 test/extensions/string_extensions_test.rb
incline-0.3.12 test/extensions/string_extensions_test.rb
incline-0.3.11 test/extensions/string_extensions_test.rb
incline-0.3.10 test/extensions/string_extensions_test.rb
incline-0.3.9 test/extensions/string_extensions_test.rb
incline-0.3.8 test/extensions/string_extensions_test.rb
incline-0.3.7 test/extensions/string_extensions_test.rb
incline-0.3.6 test/extensions/string_extensions_test.rb
incline-0.3.5 test/extensions/string_extensions_test.rb
incline-0.3.4 test/extensions/string_extensions_test.rb
incline-0.3.3 test/extensions/string_extensions_test.rb
incline-0.3.2 test/extensions/string_extensions_test.rb
incline-0.3.1 test/extensions/string_extensions_test.rb
incline-0.3.0 test/extensions/string_extensions_test.rb
incline-0.2.36 test/extensions/string_extensions_test.rb
incline-0.2.35 test/extensions/string_extensions_test.rb
incline-0.2.34 test/extensions/string_extensions_test.rb
incline-0.2.28 test/extensions/string_extensions_test.rb
incline-0.2.27 test/extensions/string_extensions_test.rb