| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# Requires perl-Test-Simple installation. |
| 4 |
use Test::Simple tests => 3; |
| 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 |
if ($ENV{'MSYSTEM'} =~ /^MINGW/) |
| 16 |
{ |
| 17 |
$GB_OPT = '-gb'; |
| 18 |
} |
| 19 |
else |
| 20 |
{ |
| 21 |
$GB_OPT = ''; |
| 22 |
$ENV{'LC_ALL'} = 'zh_CN.GB18030'; |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
system("$DOS2UNIX $GB_OPT -v -n utf16le.txt out_unix.txt; cmp out_unix.txt gb18030u.txt"); |
| 27 |
ok( $? == 0, 'dos2unix convert DOS UTF-16LE to Unix GB18030' ); |
| 28 |
|
| 29 |
system("$DOS2UNIX $GB_OPT -b -v -n utf16le.txt out_unix.txt; cmp out_unix.txt gb18030b.txt"); |
| 30 |
ok( $? == 0, 'dos2unix convert DOS UTF-16LE to Unix GB18030, keep BOM' ); |
| 31 |
|
| 32 |
system("$UNIX2DOS $GB_OPT -v -n utf16be.txt out_dos.txt; cmp out_dos.txt gb18030.txt"); |
| 33 |
ok( $? == 0, 'unix2dos convert DOS UTF-16BE to DOS GB18030, keep BOM' ); |