Sha256: 58eea52d3bb1fd7a844135c65d7f39786cddd453f5b27f652e4d6e205d14d1f3

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require 'facets/string/tab'
require 'test/unit'

class TC_String_Tab < Test::Unit::TestCase

  def setup
    @tabs = <<-EOF

\tOne tab
 \tOne space and one tab
    \t Six spaces, a tab, and a space
    EOF
  end  # def setup

  def test_tab
    a = "xyz".tab(4)
    assert_equal( '    ', a[0..3] )
    # Need to expand on this
  end

  def test_expand_tabs_1
    expected = <<-EOF

        One tab
        One space and one tab
         Six spaces, a tab, and a space
    EOF
    assert_equal(expected, @tabs.expand_tabs)
    assert_equal(expected, @tabs.expand_tabs(8))
  end

  def test_expand_tabs_2
    expected = <<-EOF

    One tab
    One space and one tab
         Six spaces, a tab, and a space
    EOF
    assert_equal(expected, @tabs.expand_tabs(4))
  end

  def test_expand_tabs_3
    expected = <<-EOF

                One tab
                One space and one tab
                 Six spaces, a tab, and a space
    EOF
    assert_equal(expected, @tabs.expand_tabs(16))
  end

  def test_expand_tabs_4
    expected = <<-EOF

 One tab
  One space and one tab
      Six spaces, a tab, and a space
    EOF
    assert_equal(expected, @tabs.expand_tabs(1))
  end

  def test_expand_tabs_5
    expected = <<-EOF

One tab
 One space and one tab
     Six spaces, a tab, and a space
    EOF
    assert_equal(expected, @tabs.expand_tabs(0))
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
facets-2.8.0 test/core/string/test_tab.rb
facets-2.7.0 test/core/string/test_tab.rb
facets-2.6.0 test/core/string/test_tab.rb
facets-2.5.0 test/core/string/test_tab.rb
facets-2.5.1 test/core/string/test_tab.rb
facets-2.5.2 test/core/string/test_tab.rb