Sha256: b0667f832d7a8ce891c85b5a4ea20e071dd1912184e81e72f5462bfd907f6a3a

Contents?: true

Size: 878 Bytes

Versions: 3

Compression:

Stored size: 878 Bytes

Contents

require 'strscan'

describe "StringScanner#search_full" do
  before :each do
    @s = StringScanner.new("This is a test")
  end

  it "returns the number of bytes advanced" do
    orig_pos = @s.pos
    @s.search_full(/This/, false, false).should == 4
    @s.pos.should == orig_pos
  end

  it "returns the number of bytes advanced and advances the scan pointer if the second argument is true" do
    @s.search_full(/This/, true, false).should == 4
    @s.pos.should == 4
  end

  it "returns the matched string if the third argument is true" do
    orig_pos = @s.pos
    @s.search_full(/This/, false, true).should == "This"
    @s.pos.should == orig_pos
  end

  it "returns the matched string if the third argument is true and advances the scan pointer if the second argument is true" do
    @s.search_full(/This/, true, true).should == "This"
    @s.pos.should == 4
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysl-strscan-1.0.1 spec/search_full_spec.rb
rubysl-strscan-1.0.0 spec/search_full_spec.rb
rubysl-strscan-2.0.0 spec/search_full_spec.rb