Sha256: 5cb41a94ebb42f2b5294646d45bf6ac1b63ad28e62d16c6749b96ba968537af6

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'test/unit'

require 'util/string_location'

class UTestStringLocation < Test::Unit::TestCase
  def setup
    @sl = StringLocations.new "a\nb\nc\r\nd"
  end

  def test_01_creation
    assert_kind_of(StringLocations, @sl)
  end

  def test_02_line
    assert_equal(1, @sl.line(0))
    assert_equal(1, @sl.line(1))
    assert_equal(2, @sl.line(2))
    assert_equal(2, @sl.line(3))
    assert_equal(3, @sl.line(4))
    assert_equal(3, @sl.line(5))
    assert_equal(3, @sl.line(6))
    assert_equal(4, @sl.line(7))
  end

  def test_03_column
    assert_equal(0, @sl.column(0))
    assert_equal(1, @sl.column(1))
    assert_equal(0, @sl.column(2))
    assert_equal(1, @sl.column(3))
    assert_equal(0, @sl.column(4))
    assert_equal(1, @sl.column(5))
    assert_equal(2, @sl.column(6))
    assert_equal(0, @sl.column(7))
  end

  def test_04_location
    assert_equal([1, 0], @sl.location(0))
    assert_equal([1, 1], @sl.location(1))
    assert_equal([2, 0], @sl.location(2))
    assert_equal([2, 1], @sl.location(3))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rockit-0.7.1 tests/unit/util/utest_string_location.rb