]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
test: tac: test with non-ASCII values for --separator
authorCollin Funk <collin.funk1@gmail.com>
Fri, 28 Nov 2025 00:55:18 +0000 (16:55 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Fri, 28 Nov 2025 21:23:47 +0000 (13:23 -0800)
* tests/tac/tac-locale.sh: New test.
* tests/local.mk (all_tests): Add it.

tests/local.mk
tests/tac/tac-locale.sh [new file with mode: 0755]

index 26d140dcc827da6e374908536f92992c07d9c0e1..4ae0037192bc9c36d4901dc38d678b094573a039 100644 (file)
@@ -458,6 +458,7 @@ all_tests =                                 \
   tests/misc/sync.sh                           \
   tests/tac/tac.pl                             \
   tests/tac/tac-continue.sh                    \
+  tests/tac/tac-locale.sh                      \
   tests/tac/tac-2-nonseekable.sh               \
   tests/tail/tail.pl                           \
   tests/misc/tee.sh                            \
diff --git a/tests/tac/tac-locale.sh b/tests/tac/tac-locale.sh
new file mode 100755 (executable)
index 0000000..2bb6e40
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Test that tac --separator=SEP works if SEP is not ASCII.
+
+# Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program 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 3 of the License, or
+# (at your option) any later version.
+
+# This program 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.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ tac printf
+
+check_separator ()
+{
+  env printf "1$12$13$1" > inp || framework_failure_
+  env printf "3$12$11$1\n" > exp || framework_failure_
+  tac --separator="$(env printf -- "$1")" inp > out || fail=1
+  env printf '\n' >> out || framework_failure_
+  compare exp out || fail=1
+}
+
+export LC_ALL=en_US.iso8859-1  # only lowercase form works on macOS 10.15.7
+if test "$(locale charmap 2>/dev/null | sed 's/iso/ISO-/')" = ISO-8859-1; then
+  check_separator '\xe9'  # é
+  check_separator '\xe9\xea'  # éê
+fi
+
+export LC_ALL=$LOCALE_FR_UTF8
+if test "$(locale charmap 2>/dev/null)" = UTF-8; then
+  check_separator '\u0434'  # д
+  check_separator '\u0434\u0436'  # дж
+fi
+
+Exit $fail