3 # nkf test program for nkf 2.0
4 # Shinji KONO <kono@ie.u-ryukyu.ac.jp>
5 # Sun Aug 18 12:25:40 JST 1996
6 # Sun Nov 8 00:16:06 JST 1998
7 # Sun Sep 8 14:04:02 JST 2002
9 # This is useful when you add new patch on nkf.
10 # Since this test is too strict, faileurs may not mean
14 # nkf 1.5 differs on MIME decoding
15 # nkf 1.4 passes Basic Conversion tests
16 # nkf PDS version passes Basic Conversion tests using "nkf -iB -oB "
22 $nkf = 'MSWin32' eq $^O ? ".\\nkf" : "./nkf";
24 # $nkf = "doscmd nkf.exe";
26 # If you want to see the testing process, set next flag.
37 local ($nkf,$in,@ans) = @_;
45 system("$nkf <nkf.in >nkf.out"); # easy
52 $result =~ s/ //g if $nkf =~ /-\w+m[NS]/o;
54 $ans =~ s/ //g if $nkf =~ /-\w+m[NS]/o;
55 if ($result eq $ans) {
62 system "mv nkf.in nkf.in.$error_count.bad";
63 system "mv nkf.out nkf.out.$error_count.bad";
64 open(OUT,"> nkf.expect.$error_count.bad");
70 open(R,"|od -c >tmp.result.bad"); binmode R; print R $result; close(R);
71 open(R,"|od -c >tmp.expect.bad"); binmode R; print R $ans; close(R);
72 system "diff -c tmp.result.bad tmp.expect.bad";
81 for (my $i = 0; $i <= $#tests; $i += 3){
86 open(OUT, "> nkf.in");
90 system("$nkf <nkf.in >nkf.out"); # easy
97 $out =~ s/ //g if $nkf =~ /-\w+m[NS]/o;
98 $ans =~ s/ //g if $nkf =~ /-\w+m[NS]/o;
108 system "mv nkf.in nkf.in.$error_count.bad";
109 system "mv nkf.out nkf.out.$error_count.bad";
110 open(OUT,"> nkf.expect.$error_count.bad");
116 open(R,"|od -c >tmp.result.bad"); binmode R; print R $out; close(R);
117 open(R,"|od -c >tmp.expect.bad"); binmode R; print R $ans; close(R);
118 system "diff -c tmp.result.bad tmp.expect.bad";
127 if ($error_count > 1) {
128 printf("%d errors were found.\n", $error_count);
129 } elsif ($error_count == 1) {
130 printf("1 error was found.\n");
132 printf("All tests are succeeded.\n");