-
Notifications
You must be signed in to change notification settings - Fork 47
/
index_eval.t
executable file
·52 lines (42 loc) · 1.07 KB
/
index_eval.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!./perl
no strict; # preload strict.pm
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
}
use strict;
plan( tests => 21 );
sub run_tests {
# Tests for NUL characters.
{
my @tests = (
["", -1, -1, -1],
["foo", -1, -1, -1],
["\0", 0, -1, -1],
["\0\0", 0, 0, -1],
["\0\0\0", 0, 0, 0],
["foo\0", 3, -1, -1],
["foo\0foo\0\0", 3, 7, -1],
);
foreach my $l (1 .. 3) {
my $q = "\0" x $l;
my $i = 0;
foreach my $test (@tests) {
$i ++;
my $str = $$test [0];
my $res = $$test [$l];
#
# Bug #53746 shows a difference between variables and literals,
# so test literals as well.
#
my $test_str = qq {is (index ("$str", "$q"), $res, } .
qq {"Find NUL character(s)")};
$test_str =~ s/\0/\\0/g;
eval $test_str;
die $@ if $@;
}
}
}
}
run_tests() unless 0;