Class TestText
In: lib/text.rb
Parent: ::Test::Unit::TestCase

Methods

Public Instance methods

[Source]

# File lib/text.rb, line 173
    def setup
      @o = { :width => 10 }
      @text = " foofoof barbarfoo foo f bar for na goo baz buz g"
      @cropped = " foofo ...\n"
      @splitted = " foofoof\n barbarfoo\n foo f bar\n for na\n goo baz\n buz g"
      @splitted_justified = " foofoof\n barbarfoo\n foo  f bar\n for     na\n goo    baz\n buz g"
      @splitted_justified_cropped = " foofoof\n barba ...\n foo   ...\n for   ...\n goo   ...\n buz g"
      @clipped = " foofoof\n barbarfoo\n\n[...clipped...]\n\n buz g"
    end

[Source]

# File lib/text.rb, line 183
    def teardown
    end

[Source]

# File lib/text.rb, line 203
    def test_clip
      assert_equal @clipped, @splitted_justified.to_text(@o).clip(2, 1).text
      assert_equal 'yo', @splitted_justified.to_text(@o).clip(0, 0, 'yo').text
      assert_equal " foofoof\nyo", @splitted_justified.to_text(@o).clip(1, 0, 'yo').text
      assert_equal 'yo buz g', @splitted_justified.to_text(@o).clip(0, 1, 'yo').text
      assert_equal @splitted_justified, @splitted_justified.to_text(@o).clip(100, 0, 'yo').text
      assert_equal @splitted_justified, @splitted_justified.to_text(@o).clip(6, 0, 'yo').text
      assert_equal @splitted_justified, @splitted_justified.to_text(@o).clip(0, 6, 'yo').text
      assert_equal @splitted_justified, @splitted_justified.to_text(@o).clip(3, 3, 'yo').text
      assert_equal " foofoof\n barbarfoo\nyo for     na\n goo    baz\n buz g",
                   @splitted_justified.to_text(@o).clip(2, 3, 'yo').text
    end

[Source]

# File lib/text.rb, line 198
    def test_crop
      assert_equal @cropped, @text.to_text(@o).crop.text
      assert_equal @splitted_justified_cropped, @splitted_justified.to_text(@o).crop.text
    end

[Source]

# File lib/text.rb, line 186
    def test_justify
      assert_equal @splitted_justified, @splitted.to_text(@o).justify.text
    end

[Source]

# File lib/text.rb, line 190
    def test_split
      assert_equal @splitted, @text.to_text(@o).split.text
    end

[Source]

# File lib/text.rb, line 194
    def test_split_and_justify
      assert_equal @splitted_justified, @text.to_text(@o).split_and_justify.text
    end

[Validate]