} else {
print "no 5\n";
}
+}
-
+sub command_tests {
+ my @tests = @_;
+ my ($in, $out, $ans);
+
+ for (my $i = 0; $i <= $#tests; $i += 3){
+ local (@nkf) = split(/ /,$tests[$i]);
+ shift(@nkf);
+ $in = $tests[$i+1];
+ $ans = $tests[$i+2];
+ $out = NKF::nkf(@nkf,$in);
+ $out =~ s/ //g if $nkf =~ /-\w+m[NS]/o;
+ $ans =~ s/ //g if $nkf =~ /-\w+m[NS]/o;
+ if ($out ne $ans) {
+ last;
+ }
+ }
+ if ($out eq $ans) {
+ print "Ok\n";
+ return;
+ }
+ print "Fail\n";
+ if ($diff) {
+ open(R,"|od -c >tmp.result.bad"); binmode R; print R $out; close(R);
+ open(R,"|od -c >tmp.expect.bad"); binmode R; print R $ans; close(R);
+ system "diff -c tmp.result.bad tmp.expect.bad";
+ }
+ return;
}
do "../nkf_test.pl";
printf "%-40s", "test_data/bugs10904";
&test("$nkf -Mj",$example{'test_data/bugs10904'},$example{'test_data/bugs10904.ans'});
+ if (!NKF) {
printf "%-40s", "Guess NL";
&command_tests(
"$nkf --guess","none", "ASCII\n",
"$nkf --guess","\r\n.\n", "ASCII (MIXED NL)\n",
"$nkf --guess","\r\n.\r", "ASCII (MIXED NL)\n",
"$nkf --guess","\r\n.\r\n", "ASCII (CRLF)\n");
+ }
printf "%-40s", "Convert NL to LF";
&command_tests(