From db4ddbaa324e0c7813957dca0a9035f208e07b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Wed, 5 Mar 2014 17:45:40 +0100 Subject: [PATCH] Add failing test for `String#rindex` with multibyte chars. Related to http://hipbyte.myjetbrains.com/youtrack/issue/RM-441 --- test/test/spec/string_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/test/spec/string_spec.rb b/test/test/spec/string_spec.rb index ac65e5fa..9c01834b 100644 --- a/test/test/spec/string_spec.rb +++ b/test/test/spec/string_spec.rb @@ -27,3 +27,18 @@ describe "String#<< with a codepoint" do s.should == "\x03\x03\x03" end end + +# TODO should be part of RubySpec +describe "Strings with multibyte characters" do + it "finds the index of a character" do + "..€€……".index(".").should == 0 + "..€€……".index("€").should == 2 + "..€€……".index("…").should == 4 + end + + it "finds the most right-side index of a character" do + "..€€……".rindex(".").should == 1 + "..€€……".rindex("€").should == 3 + "..€€……".rindex("…").should == 5 + end +end