1# Before `make install' is performed this script should be runnable with 2# `make test'. After `make install' it should work as `perl test.pl' 3 4######################### We start with some black magic to print on failure. 5 6BEGIN { $| = 1; print "1..13\n"; } 7END {print "not ok 1\n" unless $loaded;} 8 9use String::Multibyte; 10 11my $mb = String::Multibyte->new('ShiftJIS',1); 12 13$^W = 1; 14$loaded = 1; 15print "ok 1\n"; 16 17######################### End of black magic. 18 19$n = 3500; 20$f = 10; 21$len = $f * $n; 22 23$sub = "0123456�`����"; 24$str = $sub x $n; 25$rev = "�����`6543210" x $n; 26 27print $mb->islegal($str) ? "ok" : "not ok", " 2\n"; 28 29print ! $mb->islegal($str."\xFF") ? "ok" : "not ok", " 3\n"; 30 31print $mb->length($str) == $len ? "ok" : "not ok", " 4\n"; 32 33print $mb->index($str, "perl") == -1 34 ? "ok" : "not ok", " 5\n"; 35print $mb->index($str.'�o������', '������') == $len + 1 36 ? "ok" : "not ok", " 6\n"; 37print $mb->rindex($str, "����") == $len - 2 38 ? "ok" : "not ok", " 7\n"; 39print $mb->rindex($str, "perl") == -1 40 ? "ok" : "not ok", " 8\n"; 41 42print $mb->strspn($str, $sub) == $len 43 ? "ok" : "not ok", " 9\n"; 44 45print $mb->strcspn($str, "A") == $len 46 ? "ok" : "not ok", " 10\n"; 47 48print $mb->strrev($str) eq $rev 49 ? "ok" : "not ok", " 11\n"; 50 51print $mb->substr($str,-1) eq '��' 52 ? "ok" : "not ok", " 12\n"; 53 54print $mb->substr($str,1000*$f,200*$f) eq ($sub x 200) 55 ? "ok" : "not ok", " 13\n"; 56 571; 58__END__ 59