summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-10-31 13:45:06 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-10-31 13:45:06 +0000
commit46f1e5955033fcc63907c341337e8cc34722edf0 (patch)
treea78a5d1afb368b233d5a0b4bf8bbdb8a9db65583 /t
parent0f830e0b62c9aecd65b9af85ec46817dc940d8af (diff)
downloadperl-46f1e5955033fcc63907c341337e8cc34722edf0.tar.gz
Tests for index/rindex with empty search string,
adapted from a patch by Rick Delaney p4raw-id: //depot/perl@25922
Diffstat (limited to 't')
-rwxr-xr-xt/op/index.t16
1 files changed, 15 insertions, 1 deletions
diff --git a/t/op/index.t b/t/op/index.t
index d223265c4f..100439d15e 100755
--- a/t/op/index.t
+++ b/t/op/index.t
@@ -7,7 +7,7 @@ BEGIN {
use strict;
require './test.pl';
-plan( tests => 46 );
+plan( tests => 58 );
my $foo = 'Now is the time for all good men to come to the aid of their country.';
@@ -45,6 +45,20 @@ is(rindex("ababa","a",3), 2);
is(rindex("ababa","a",4), 4);
is(rindex("ababa","a",5), 4);
+# tests for empty search string
+is(index("abc", "", -1), 0);
+is(index("abc", "", 0), 0);
+is(index("abc", "", 1), 1);
+is(index("abc", "", 2), 2);
+is(index("abc", "", 3), 3);
+is(index("abc", "", 4), 3);
+is(rindex("abc", "", -1), 0);
+is(rindex("abc", "", 0), 0);
+is(rindex("abc", "", 1), 1);
+is(rindex("abc", "", 2), 2);
+is(rindex("abc", "", 3), 3);
+is(rindex("abc", "", 4), 3);
+
$a = "foo \x{1234}bar";
is(index($a, "\x{1234}"), 4);