12
|
1 #!/usr/bin/perl
|
|
2 #
|
|
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
|
|
8 #
|
|
9 # This is useful when you add new patch on nkf.
|
|
10 # Since this test is too strict, faileurs may not mean
|
|
11 # wrong conversion.
|
|
12 #
|
|
13 # nkf 2.0 utf8
|
|
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 "
|
|
17 #
|
|
18
|
|
19 $nkf = 'MSWin32' eq $^O ? ".\\nkf" : "./nkf";
|
|
20 # $nkf = "doscmd nkf.exe";
|
|
21
|
|
22 # If you want to see the testing process, set next flag.
|
|
23
|
|
24 $detail_all = 0;
|
|
25 $error_count=1;
|
|
26 $diff=1;
|
|
27
|
|
28 # &library_test0();
|
|
29 sub test {
|
|
30 &command_test(@_);
|
|
31 }
|
|
32
|
|
33 sub command_test {
|
|
34 local ($nkf,$in,@ans) = @_;
|
|
35 local ($result);
|
|
36
|
|
37 $result = '';
|
|
38 open(OUT,"> nkf.in");
|
|
39 binmode OUT;
|
|
40 print OUT $in;
|
|
41 close(OUT);
|
|
42 system("$nkf <nkf.in >nkf.out"); # easy
|
|
43 open(IN,"< nkf.out");
|
|
44 binmode IN;
|
|
45 while(<IN>) {
|
|
46 $result .= $_;
|
|
47 }
|
|
48
|
|
49 if( $nkf =~ /-\S*m/) {
|
|
50 $result =~ s/ //g;
|
|
51 }
|
|
52 $i = 0;
|
|
53 foreach $ans (@ans) {
|
|
54 if( $nkf =~ /-\S*m/) {
|
|
55 $ans =~ s/ //g;
|
|
56 }
|
|
57 if ($result eq $ans) {
|
|
58 print "Ok\n";
|
|
59 return $result;
|
|
60 }
|
|
61 $i++;
|
|
62 }
|
|
63 $ans = $ans[0];
|
|
64 print "Fail\n";
|
|
65 system "mv nkf.in nkf.in.$error_count.bad";
|
|
66 system "mv nkf.out nkf.out.$error_count.bad";
|
|
67 open(OUT,"> nkf.expect.$error_count.bad");
|
|
68 binmode OUT;
|
|
69 print OUT $ans;
|
|
70 close(OUT);
|
|
71 $error_count++;
|
|
72 if ($diff) {
|
|
73 open(R,"|od -c >tmp.result.bad"); binmode R; print R $result; close(R);
|
|
74 open(R,"|od -c >tmp.expect.bad"); binmode R; print R $ans; close(R);
|
|
75 system "diff -c tmp.result.bad tmp.expect.bad";
|
|
76 }
|
|
77 return $result;
|
|
78 }
|
|
79
|
|
80 do "nkf_test.pl";
|
|
81
|
|
82 unlink "nkf.in";
|
|
83 unlink "nkf.out";
|