3 # Requires perl-Test-Simple installation.
4 use Test::Simple tests => 19;
7 if (-e "../dos2unix.exe") {
12 if ($system =~ m/MINGW/)
19 $DOS2UNIX = "../dos2unix" . $suffix;
20 $MAC2UNIX = "../mac2unix" . $suffix;
21 $UNIX2DOS = "../unix2dos" . $suffix;
22 $UNIX2MAC = "../unix2mac" . $suffix;
24 $ENV{'LC_ALL'} = 'en_US.UTF-8';
26 system("$DOS2UNIX -v -n utf16le.txt out_unix.txt; cmp out_unix.txt utf8unix.txt");
27 ok( $? == 0, 'DOS UTF-16LE to Unix UTF-8' );
28 system("$DOS2UNIX -v -n utf16be.txt out_unix.txt; cmp out_unix.txt utf8unix.txt");
29 ok( $? == 0, 'DOS UTF-16BE to Unix UTF-8' );
30 system("$UNIX2DOS -v -n utf16le.txt out_dos.txt; cmp out_dos.txt utf8dos.txt");
31 ok( $? == 0, 'DOS UTF-16LE to DOS UTF-8' );
32 system("$UNIX2DOS -v -n utf16be.txt out_dos.txt; cmp out_dos.txt utf8dos.txt");
33 ok( $? == 0, 'DOS UTF-16BE to DOS UTF-8' );
35 system("$DOS2UNIX -v -ul -n utf16len.txt out_unix.txt; cmp out_unix.txt utf8unix.txt");
36 ok( $? == 0, 'UTF-16LE without BOM to UTF-8' );
37 system("$DOS2UNIX -v -ub -n utf16ben.txt out_unix.txt; cmp out_unix.txt utf8unix.txt");
38 ok( $? == 0, 'UTF-16BE without BOM to UTF-8' );
39 system("$DOS2UNIX -v -ul -n utf16be.txt out_unix.txt; cmp out_unix.txt utf8unix.txt");
40 ok( $? == 0, 'BOM overrides -ul' );
41 system("$DOS2UNIX -v -ub -n utf16le.txt out_unix.txt; cmp out_unix.txt utf8unix.txt");
42 ok( $? == 0, 'BOM overrides -ub' );
44 system("$DOS2UNIX -v -b -n utf16le.txt out_unix.txt; cmp out_unix.txt utf8unxb.txt");
45 ok( $? == 0, 'DOS UTF-16LE to Unix UTF-8, keep BOM' );
46 system("$UNIX2DOS -v -r -n utf16le.txt out_dos.txt; cmp out_dos.txt utf8dosn.txt");
47 ok( $? == 0, 'DOS UTF-16LE to DOS UTF-8, remove BOM' );
49 system("$MAC2UNIX -v -n utf16le.txt out_unix.txt; cmp out_unix.txt utf8dosn.txt");
50 ok( $? == 0, 'mac2unix does not change utf16 DOS line breaks.' );
51 system("$UNIX2MAC -v -n utf16le.txt out_mac.txt; cmp out_mac.txt utf8dos.txt");
52 ok( $? == 0, 'unix2mac does not change utf16 DOS line breaks.' );
54 system("$UNIX2DOS -v -u -n utf16le.txt out_dos.txt; cmp out_dos.txt utf16le.txt");
55 ok( $? == 0, 'DOS UTF-16LE to DOS UTF-16' );
56 system("$UNIX2DOS -v -u -n utf16be.txt out_dos.txt; cmp out_dos.txt utf16be.txt");
57 ok( $? == 0, 'DOS UTF-16BE to DOS UTF-16' );
58 system("$DOS2UNIX -v -b -u -n utf16.txt out_unix.txt; cmp out_unix.txt utf16u.txt");
59 ok( $? == 0, 'DOS UTF-16LE to Unix UTF-16' );
60 system("$MAC2UNIX -v -b -u -n utf16m.txt out_unix.txt; cmp out_unix.txt utf16u.txt");
61 ok( $? == 0, 'Mac UTF-16LE to Unix UTF-16' );
62 system("$UNIX2DOS -v -b -u -n utf16u.txt out_dos.txt; cmp out_dos.txt utf16.txt");
63 ok( $? == 0, 'Unix UTF-16 to DOS UTF-16LE' );
64 system("$UNIX2MAC -v -b -u -n utf16u.txt out_mac.txt; cmp out_mac.txt utf16m.txt");
65 ok( $? == 0, 'Unix UTF-16 to Mac UTF-16LE' );
67 $ENV{'LC_ALL'} = 'en_US.ISO-8859-1';
69 system("$DOS2UNIX -v -n utf16le.txt out_unix.txt");
71 if ( $unix ) { $expected = 1; } else { $expected = 0 };
72 print "UNIX" . $unix . "\n";
73 print "EXP" . $expected . "\n";
74 ok( $result == $expected, 'DOS UTF-16LE to Unix UTF-8, env is not UTF-8' );