3 # Requires perl-Test-Simple installation.
4 use Test::More tests => 16;
7 if (-e "../dos2unix.exe") {
10 $DOS2UNIX = "../dos2unix" . $suffix;
11 $MAC2UNIX = "../mac2unix" . $suffix;
12 $UNIX2DOS = "../unix2dos" . $suffix;
13 $UNIX2MAC = "../unix2mac" . $suffix;
15 $ENV{'LC_ALL'} = 'en_US.UTF-8';
17 system("$DOS2UNIX -v -7 -n chardos.txt out_unix.txt; cmp out_unix.txt charu7.txt");
20 system("$DOS2UNIX -v < dos.txt > out_unix.txt; cmp out_unix.txt unix.txt");
21 ok( $? == 0, 'DOS to Unix conversion, stdin/out' );
23 system("$UNIX2DOS -v < unix.txt > out_dos.txt; cmp out_dos.txt dos.txt");
24 ok( $? == 0, 'Unix to DOS conversion, stdin/out' );
26 system("cat utf16le.txt | $DOS2UNIX -v > out_unix.txt; cmp out_unix.txt utf8unix.txt");
27 ok( $? == 0, 'UTF-16LE with BOM to UTF-8, stdin/out' );
29 system("cat utf16u.txt | $UNIX2DOS -v -u > out_dos.txt; cmp out_dos.txt utf16.txt");
30 ok( $? == 0, 'UTF-16LE with BOM to UTF-16LE, stdin/out' );
32 system("$DOS2UNIX -v -n utf16len.txt out_bin.txt");
33 # file out_bin.txt may not exist.
34 if (-e "out_bin.txt") {
39 ok( $exists == 0, 'dos2unix skip binary file.' );
41 system("$UNIX2DOS -v -n utf16len.txt out_bin.txt");
42 # file out_bin.txt may not exist.
43 if (-e "out_bin.txt") {
48 ok( $exists == 0, 'unix2dos skip binary file.' );
50 system("$DOS2UNIX -v < utf16len.txt > out.txt");
52 ok( $result == 1, 'Dos2unix stdio returns error on binary input.' );
54 system("$UNIX2DOS -v < utf16len.txt > out.txt");
56 ok( $result == 1, 'Unix2dos stdio returns error on binary input.' );
58 system("rm -f out_forc.txt");
59 system("$DOS2UNIX -v -n utf16len.txt out_forc.txt");
60 # file out_bin.txt may not exist.
61 if (-e "out_forc.txt") {
66 ok( $exists == 0, 'dos2unix force binary file.' );
68 system("rm -f out_forc.txt");
69 system("$UNIX2DOS -v -n utf16len.txt out_forc.txt");
70 # file out_bin.txt may not exist.
71 if (-e "out_forc.txt") {
76 ok( $exists == 0, 'unix2dos force binary file.' );
78 system("$DOS2UNIX -v -7 -n utf16le.txt out_unix.txt chardos.txt out_u7.txt; cmp out_unix.txt utf8unix.txt");
79 ok( $? == 0, '7bit disabled for utf16');
81 system("cmp out_u7.txt charu7.txt");
82 ok( $? == 0, '7bit enabled again, dos2unix');
84 system("$UNIX2DOS -v -7 -n utf8unxb.txt out_dos.txt charunix.txt out_d7.txt; cmp out_dos.txt utf8dos.txt");
85 ok( $? == 0, '7bit disabled for utf8 with BOM');
87 system("cmp out_d7.txt chard7.txt");
88 ok( $? == 0, '7bit enabled again, unix2dos');
90 system("$UNIX2DOS -v -u -m -n unix.txt out_dos.txt; cmp out_dos.txt dos_bom.txt");
91 ok( $? == 0, 'Option -u must not disable -m on ASCII input');