Sha256: e217f24f74f47f14e4f8b71252780690f4d1b2752bc3ffa59895d611efc17b1c

Contents?: true

Size: 1.45 KB

Versions: 19

Compression:

Stored size: 1.45 KB

Contents

# Test for facets/string/bracket

require 'facets/string/bracket.rb'

require 'test/unit'

class TestStringBracket < Test::Unit::TestCase

  def test_bracket
    assert_equal( '#X#', 'X'.bracket('#') )
    assert_equal( 'xX!', 'X'.bracket('x','!') )
    assert_equal( '{X}', 'X'.bracket('{','}') )
    assert_equal( '<X>', 'X'.bracket('<') )
    assert_equal( '(X)', 'X'.bracket('(') )
    assert_equal( '[X]', 'X'.bracket('[') )
    assert_equal( '{X}', 'X'.bracket('{') )
  end

  def test_braket!
    a = 'X' ; a.bracket!('#')
    assert_equal( '#X#', a )
    a = 'X' ; a.bracket!('x','!')
    assert_equal( 'xX!', a )
    a = 'X' ; a.bracket!('{','}')
    assert_equal( '{X}', a )
    a = 'X' ; a.bracket!('<')
    assert_equal( '<X>', a )
    a = 'X' ; a.bracket!('(')
    assert_equal( '(X)', a )
    a = 'X' ; a.bracket!('[')
    assert_equal( '[X]', a )
    a = 'X' ; a.bracket!('{')
    assert_equal( '{X}', a )
  end

  def test_quote_01
    a =  "hi"
    assert_raises( ArgumentError ) { a.quote(1,2) }
  end

  def test_quote_02
    a =  "hi"
    assert_equal( %{'hi'}, a.quote )
  end

  def test_quote_03
    a =  "hi"
    assert_equal( %{"hi"}, a.quote(:d) )
    assert_equal( %{"hi"}, a.quote(:double) )
  end

  def test_quote_04
    a =  "hi"
    assert_equal( %{'hi'}, a.quote(:s) )
    assert_equal( %{'hi'}, a.quote(:single) )
  end

  def test_quote_05
    a =  "hi"
    assert_equal( %{`hi`}, a.quote(:b) )
    assert_equal( %{`hi`}, a.quote(:back) )
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
facets-2.8.4 test/core/string/test_bracket.rb
facets-2.8.3 test/core/string/test_bracket.rb
facets-2.8.2 test/core/string/test_bracket.rb
facets-2.8.1 test/core/string/test_bracket.rb
facets-2.8.0 test/core/string/test_bracket.rb
facets-2.7.0 test/core/string/test_bracket.rb
facets-2.6.0 test/core/string/test_bracket.rb
facets-2.2.0 test/unit/string/test_bracket.rb
facets-2.2.1 test/unit/string/test_bracket.rb
facets-2.3.0 test/core/string/test_bracket.rb
facets-2.4.0 test/string/test_bracket.rb
facets-2.4.1 test/string/test_bracket.rb
facets-2.4.4 test/core/string/test_bracket.rb
facets-2.4.3 test/core/string/test_bracket.rb
facets-2.4.2 test/core/string/test_bracket.rb
facets-2.5.1 test/core/string/test_bracket.rb
facets-2.5.0 test/core/string/test_bracket.rb
facets-2.4.5 test/core/string/test_bracket.rb
facets-2.5.2 test/core/string/test_bracket.rb