Sha256: eda307efeed0a7ac869d692aa3ef60cf2b89ea46474e43553d160f63e7eed311

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

require File.dirname(__FILE__)+'/helper'

class TestStringConversion < Test::Unit::TestCase
  def test_replacement
    result = converter.replace("test", {
      :e => 3,
      :s => 5
    })
    assert_equal "t35t", result
  end

  def test_case_swapping
    assert_equal "tEsT", converter.swapcase("test")
  end

  def test_case_swapping_ignores_numbers
    assert_equal "tEsT4fUn", converter.swapcase("test4fun")

    assert_equal "fUn4TeSt", converter.swapcase("fun4test")
  end

  def test_char_collapsing
    assert_equal "abc", converter.collapse_chars("a b c")
  end

  def test_select_first_chars
    assert_equal "t a t f t", converter.first_chars('test all the fucking time')
  end

  protected

  def converter
    klass = Class.new
    klass.send(:extend, ToPass::StringConversions)
    klass
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
to_pass-0.2.3 test/test_string_conversions.rb
to_pass-0.2.2 test/test_string_conversions.rb