diff options
author | Vaclav Dolezal | 2017-12-21 15:10:15 +0100 |
---|---|---|
committer | Vaclav Dolezal | 2018-01-10 17:40:53 +0100 |
commit | cad13ba3441efd3889c0be922397b822e9054aaa (patch) | |
tree | 13817b56ac67fac8d02120fe964134bd3e2f7370 /tests/ts | |
parent | lib/mbsalign: escape "\x" when HAVE_WIDECHAR not defined (diff) | |
download | kernel-qcow2-util-linux-cad13ba3441efd3889c0be922397b822e9054aaa.tar.gz kernel-qcow2-util-linux-cad13ba3441efd3889c0be922397b822e9054aaa.tar.xz kernel-qcow2-util-linux-cad13ba3441efd3889c0be922397b822e9054aaa.zip |
tests: add tests for encode functions from lib/mbsalign.c
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Diffstat (limited to 'tests/ts')
-rwxr-xr-x | tests/ts/misc/mbsencode | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/ts/misc/mbsencode b/tests/ts/misc/mbsencode new file mode 100755 index 000000000..7790ef08d --- /dev/null +++ b/tests/ts/misc/mbsencode @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# Copyright (C) 2018 Vaclav Dolezal <vdolezal@redhat.com> +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mbsencode" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +STRINGS=( +# ASCII + $'foo\tbar baz' + '\\foo.local\bar' + '\\foo.local\xbar' + +# UNICODE + 'über' + $'c\xcc\x8ca\xcc\x81rka' # 'c\u030Ca\u0301rka' + 'Москва́' + '北京' + $'\xf0\x9f\x90\xb1' # \U0001F431 + +# INVALID UNICODE + $'\xff' + $'\xe8\xe1\xf9\xa7' +) + +ts_init_subtest "safe-ascii" +$TS_HELPER_MBSENCODE --safe "${STRINGS[@]}" >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "invalid-ascii" +$TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "safe-utf8" +LC_ALL=C.UTF-8 \ +$TS_HELPER_MBSENCODE --safe "${STRINGS[@]}" >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_init_subtest "invalid-utf8" +LC_ALL=C.UTF-8 \ +$TS_HELPER_MBSENCODE --invalid "${STRINGS[@]}" >> $TS_OUTPUT 2>&1 +ts_finalize_subtest + +ts_finalize + |