File: test-issue3.rb

package info (click to toggle)
ruby-columnize 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 232 kB
  • ctags: 88
  • sloc: ruby: 477; makefile: 22
file content (24 lines) | stat: -rwxr-xr-x 991 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env ruby
require 'test/unit'

# Test of Columnize module for github issue #3
class TestIssue3 < Test::Unit::TestCase
  @@TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
  require 'columnize'

  # test columnize
  def test_long_column
    data = ["what's", "upppppppppppppppppp"]
    data.columnize_opts = Columnize::DEFAULT_OPTS.merge :displaywidth => 7, :arrange_vertical => false
    assert_equal("what's\nupppppppppppppppppp", data.columnize)
    assert_equal("what's\nupppppppppppppppppp", data.columnize(:arrange_vertical => true))
  end

  def test_long_column_with_ljust
    data = ["whaaaaaat's", "up"]
    data.columnize_opts = Columnize::DEFAULT_OPTS.merge :displaywidth => 7, :arrange_vertical => false, :ljust => true
    assert_equal("whaaaaaat's\nup", data.columnize)
    assert_equal("whaaaaaat's\n         up", data.columnize(:ljust => false))
    assert_equal("whaaaaaat's\nup", data.columnize(:arrange_vertical => true))
  end
end