Sha256: 62c90a45ea746c2e33e90b645bd9aa839cf4f0ab317a854978de22d2a515ef78

Contents?: true

Size: 836 Bytes

Versions: 76

Compression:

Stored size: 836 Bytes

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")

describe String do
  before do
    @string = %{
      0123456789
      012345
      01234567
      0123
    }.tabto(0).strip
  end
  
  it "can translate indices to column numbers" do
    @string.column_of(0).should == 1
    @string.column_of(5).should == 6
    @string.column_of(10).should == 11
    @string.column_of(11).should == 1
    @string.column_of(17).should == 7
    @string.column_of(18).should == 1
    @string.column_of(24).should == 7
  end
  
  it "can translate indices to line numbers" do
    @string.line_of(0).should == 1
    @string.line_of(5).should == 1
    @string.line_of(10).should == 1
    @string.line_of(11).should == 2
    @string.line_of(17).should == 2
    @string.line_of(18).should == 3
    @string.line_of(24).should == 3
  end
end

Version data entries

76 entries across 76 versions & 7 rubygems

Version Path
cloudhead-less-1.0.1 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.10 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.13 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.16 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.2 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.3 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.4 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.5 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.6 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.8 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.0.9 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.0 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.1 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.10 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.11 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.12 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.13 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.2 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.3 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb
cloudhead-less-1.1.4 lib/vendor/treetop/spec/ruby_extensions/string_spec.rb