blob: 9aa5b00dd98e81b2ee86e2817b5880064eca9943 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
require_relative '../../spec_helper'
require 'strscan'
describe "StringScanner#charpos" do
it "returns character index corresponding to the current position" do
s = StringScanner.new("abc")
s.scan_until(/b/)
s.charpos.should == 2
end
it "is multi-byte character sensitive" do
s = StringScanner.new("abcädeföghi")
s.scan_until(/ö/)
s.charpos.should == 8
end
end
|