Debian Codegraph @

test/iso.t

raw
1 #!/usr/bin/perl
2
3 # Requires perl-Test-Simple installation.
4 use Test::Simple tests => 14;
5
6 $suffix = "";
7 if (-e "../dos2unix.exe") {
8 $suffix = ".exe";
9 }
10 $DOS2UNIX = "../dos2unix" . $suffix;
11 $MAC2UNIX = "../mac2unix" . $suffix;
12 $UNIX2DOS = "../unix2dos" . $suffix;
13 $UNIX2MAC = "../unix2mac" . $suffix;
14
15 # To check for instance cp850 to iso88591 conversion
16 # you can do a visual check like this (on Windows).
17 #
18 # In a Windows Command Prompt, set font to Lucida Console.
19 # Then set the code page to 850:
20 # chcp 850
21 # Display complete cp850 code page:
22 # type chardos.txt
23 #
24 # In a Cygwin Mintty terminal, under Options->Text
25 # set Character set to ISO-8859-1
26 # Display converted character set:
27 # cat iso_850.txt
28 #
29 # You now see the same characters as in the Windows Command Prompt
30 # with the non-convertable characters replaced with a dot.
31
32 system("$DOS2UNIX -v -iso -437 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_437.txt");
33 ok( $? == 0, 'DOS to Unix conversion, cp437 to iso88591 with option -iso' );
34
35 system("$DOS2UNIX -v -437 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_437.txt");
36 ok( $? == 0, 'DOS to Unix conversion, cp437 to iso88591 without option -iso' );
37
38 system("$DOS2UNIX -v -850 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_850.txt");
39 ok( $? == 0, 'DOS to Unix conversion, cp850 to iso88591' );
40
41 system("$DOS2UNIX -v -860 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_860.txt");
42 ok( $? == 0, 'DOS to Unix conversion, cp860 to iso88591' );
43
44 system("$DOS2UNIX -v -863 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_863.txt");
45 ok( $? == 0, 'DOS to Unix conversion, cp863 to iso88591' );
46
47 system("$DOS2UNIX -v -865 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_865.txt");
48 ok( $? == 0, 'DOS to Unix conversion, cp865 to iso88591' );
49
50 system("$DOS2UNIX -v -1252 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_1252.txt");
51 ok( $? == 0, 'DOS to Unix conversion, cp1252 to iso88591' );
52
53
54 # To check for instance iso88591 to cp850 conversion
55 # you can do a visual check like this (on Windows).
56 #
57 # In a Cygwin Mintty terminal, under Options->Text
58 # set Character set to ISO-8859-1
59 # Display complete ISO-8859-1 character set:
60 # cat charunix.txt
61 #
62 # In a Windows Command Prompt, set font to Lucida Console.
63 # Then set the code page to 850:
64 # chcp 850
65 # Display converted cp850 code page:
66 # type cp_850.txt
67 #
68 # You now see the same characters as in the Mintty terminal
69 # with the non-convertable characters replaced with a dot.
70
71 system("$UNIX2DOS -v -iso -437 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_437.txt");
72 ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp437 with option -iso' );
73
74 system("$UNIX2DOS -v -437 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_437.txt");
75 ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp437 without option -iso' );
76
77 system("$UNIX2DOS -v -850 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_850.txt");
78 ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp850' );
79
80 system("$UNIX2DOS -v -860 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_860.txt");
81 ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp860' );
82
83 system("$UNIX2DOS -v -863 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_863.txt");
84 ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp863' );
85
86 system("$UNIX2DOS -v -865 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_865.txt");
87 ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp865' );
88
89 system("$UNIX2DOS -v -1252 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_1252.txt");
90 ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp1252' );