diff options
Diffstat (limited to 'test/pbmtext-utf8.test')
-rwxr-xr-x | test/pbmtext-utf8.test | 93 |
1 files changed, 51 insertions, 42 deletions
diff --git a/test/pbmtext-utf8.test b/test/pbmtext-utf8.test index 8ebb6e31..551cfe29 100755 --- a/test/pbmtext-utf8.test +++ b/test/pbmtext-utf8.test @@ -6,9 +6,8 @@ LANG=C LC_ALL=C export LANG LC_ALL - -# This test requires a working UTF-8 locale -# Skip this test if it is are not available +# This test requires a working UTF-8 locale +# Skip this test if none are available iconv /dev/null if [ $? -ne 0 ] @@ -20,25 +19,29 @@ fi tmpdir=${tmpdir:-/tmp} utf_locale_list=${tmpdir}/utf_locale_list -locale_to_test="en_US.utf8" # Initial value -# Edit the above value if necessary - -# Make a list of available locales which end in "utf8" -locale -a | grep "\.utf8$" > ${utf_locale_list} +locale_to_test="en_US.utf8" # Initial value; this +# does not have to be actually available. +# Edit the above value if you have a preferred locale. + +# Make a list of available locales which end in "utf8" etc. +# If none are found, abort test -# Hunt for a valid utf8 locale +locale -a | grep -e "\.utf8$" -e "\.utf-8$" -e "\.UTF-8$" \ + > ${utf_locale_list} || locale_to_test="" + +# Hunt for a valid utf8 locale # Submit each candidate to a trial pbmtext run until one that works is # encountered -i=0 until [ -z ${locale_to_test} ] || \ echo "A" | LC_ALL=${locale_to_test} pbmtext -wchar > /dev/null do - let i=$(($i+1)); - locale_to_test=`sed "$i"p -n ${utf_locale_list}`; + # Read first line of file + locale_to_test=`head -n 1 ${utf_locale_list}`; + # then erase the line + sed -i 1d ${utf_locale_list}; done; -rm ${utf_locale_list}; if [ -z ${locale_to_test} ] then echo "No utf-8 locale available." 1>&2 echo "Skipping." 1>&2 @@ -115,10 +118,10 @@ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print "" } ' awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""}' | \ LC_ALL=${locale_for_test} pbmtext -builtin bdf -wchar -text-dump + # Test 5. # Long input text - echo "Test 5 Invalid" long_txt=${tmpdir}/long.txt @@ -135,19 +138,22 @@ echo "Test input text which exceeds length limit" 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -echo -n "z" >> ${long_txt} +printf "z" >> ${long_txt} cat ${long_txt} | wc -c | tr -d ' ' cat ${long_txt} | \ LC_ALL=${locale_for_test} \ pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \ - echo -n "Expected failure 1"; - test -s ${test_out}; echo " "$? + printf "Expected failure 1 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + cat ${long_txt} | \ LC_ALL=${locale_for_test} \ pbmtext -nomargins -builtin fixed -wchar > ${test_out} || \ - echo -n "Expected failure 2"; - test -s ${test_out}; echo " "$? + printf "Expected failure 2 " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} rm ${long_txt} @@ -165,39 +171,42 @@ echo "Test 6 Invalid" awk 'BEGIN { printf("%c%c",128,129); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-1:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? - + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-1: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + awk 'BEGIN { printf("ABC%c%c",192, 193); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-2:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-2: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} awk 'BEGIN { printf("abcde%c%c", 254, 253); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-3:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? - + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-3: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} + awk 'BEGIN { printf("abcdefg%c%c", 195, 15); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-4:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-4: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} awk 'BEGIN { printf("123456789%c%c%c", 224, 143 ,0); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-5:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-5: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} awk 'BEGIN { printf("abcdefg123ABCDEFG%c%c%c%c",247, 135, 135, 7); print ""}' | \ LC_ALL=${locale_for_test} \ - pbmtext -builtin bdf -wchar -text-dump > ${test_out} - echo -n "6-6:" ${PIPESTATUS[@]} ":" $? - test -s ${test_out}; echo " "$? - -rm ${test_out} - + pbmtext -builtin bdf -wchar -text-dump > ${test_out} + printf "6-6: ${PIPESTATUS[*]} : $? " + test -s ${test_out} && echo "unexpected output" || echo "(no output)" + rm -f ${test_out} |