Skip to content

Commit

Permalink
More tests for wrong legacy encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
abelcheung committed Apr 9, 2019
1 parent c6c22f2 commit 0bbc57f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 13 deletions.
8 changes: 5 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ dnl Platform check.
AS_CASE([$host],
[*-*-msys* | *-*-mingw*], [is_mingw=y ],
[*-*-cygwin* ], [is_cygwin=y ],
[*-*-solaris* ], [os_solaris=y])
[*-*-solaris* ], [os_solaris=y],
[*-*-freebsd* ], [os_freebsd=y])
AC_SUBST(is_mingw)
AC_SUBST(is_cygwin)
AC_SUBST(os_solaris)
AC_SUBST(os_freebsd)
AM_CONDITIONAL([OS_WINDOWS], [test "x$is_mingw" != x])

dnl I18N
Expand Down Expand Up @@ -99,8 +102,7 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <glib.h>],
[AC_MSG_RESULT([native/libiconv])],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <glib.h>],
[return (g_iconv_open("UTF-8","646") == (GIConv) -1);])],
[AC_MSG_RESULT([solaris])
AC_SUBST(solaris_iconv)],
[AC_MSG_RESULT([solaris])],
[AC_MSG_RESULT([unknown])
AC_MSG_ERROR([dnl
iconv() implementation used by glib2 is not recognized, which
Expand Down
3 changes: 3 additions & 0 deletions test/atlocal.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ awk="@AWK@"
is_mingw="test x@is_mingw@ != x"
is_cygwin="test x@is_cygwin@ != x"
os_solaris="test x@os_solaris@ != x"
os_freebsd="test x@os_freebsd@ != x"

# abbrev
progf="$abs_top_builddir/src/rifiuti"
Expand All @@ -23,6 +24,8 @@ sample="$abs_srcdir/samples"
# platform specific stuff
if $os_solaris; then
gbk_enc_name=GBK
ebcdic_enc_name=IBM-037
else
gbk_enc_name=CP936
ebcdic_enc_name=IBM037
fi
56 changes: 51 additions & 5 deletions test/test_encoding.at
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,73 @@ dnl
AT_SETUP([Unicode characters in file argument])
AT_KEYWORDS([encoding])
AT_CHECK([
cp $sample/japanese-path-file.txt expout
$as_ln_s $sample/japanese-path-file.txt expout
cd $sample
$progf ./ごみ箱/INFO2-empty
],, [expout])

AT_CHECK([
rm -f expout
cp $sample/japanese-path-dir.txt expout
$as_ln_s $sample/japanese-path-dir.txt expout
cd $sample
$progd ./ごみ箱/dir-empty
],, [expout])
AT_CLEANUP

AT_SETUP([Legacy path encoding - correct])
AT_KEYWORDS([info2 encoding])
_r2_basic_compare([$progf -l $gbk_enc_name INFO2-sample1], [INFO2-sample1-alt.txt])
AT_CLEANUP

AT_SETUP([Legacy path encoding - illegal (1)])
AT_KEYWORDS([info2 encoding])

AT_DATA([experr-win],[dnl
.* is not a valid encoding on this system\.
Please visit following web page .*
https://.*
])

AT_DATA([experr-unix],[dnl
.* is not a valid encoding on this system\.
Run 'iconv -l' for list of supported encodings\.
])

AX_AT_CHECK_PATTERN([
if $is_mingw ; then
$as_ln_s experr-win experr
else
$as_ln_s experr-unix experr
fi
cd $sample
$progf -l xxx INFO2-sample1
], 1,, [experr])
AT_CLEANUP

dnl
dnl Despite IBM037 encoding being supported in Freebsd iconv
dnl (and usable in cmdline), glib can't make use of it
dnl
AT_SETUP([Legacy path encoding - illegal (2)])
AT_KEYWORDS([info2 encoding])
AT_XFAIL_IF([$os_freebsd])
AX_AT_CHECK_PATTERN([
cd $sample
$progf -l $ebcdic_enc_name INFO2-sample1
], 1,, [dnl
.* can't possibly be a code page or compatible encoding .*
])
AT_CLEANUP

dnl
dnl Original file in Windows ANSI (CP1252), but users attempts
dnl to treat it as Shift-JIS, and fails
dnl to treat it as Shift-JIS, and got hex escapes as result
dnl
AT_SETUP([Err when converting from wrong charset])
AT_SETUP([Legacy path encoding - wrong])
AT_KEYWORDS([encoding])
AT_CHECK([
cp $sample/INFO2-sample2-wrong-enc.txt expout
$as_ln_s $sample/INFO2-sample2-wrong-enc.txt expout
cd $sample
$progf -l CP932 INFO2-sample2
], 5, [expout], [ignore])
Expand Down
5 changes: 0 additions & 5 deletions test/test_parse_info2.at
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,3 @@ AT_SETUP([INFO2 Sample 6 - XP/03])
AT_KEYWORDS([info2])
_r2_basic_compare([$progf INFO2-sample1], [INFO2-sample1.txt])
AT_CLEANUP

AT_SETUP([Legacy path names])
AT_KEYWORDS([info2])
_r2_basic_compare([$progf -l $gbk_enc_name INFO2-sample1], [INFO2-sample1-alt.txt])
AT_CLEANUP

0 comments on commit 0bbc57f

Please sign in to comment.