]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: date: improve locale tests
authorCollin Funk <collin.funk1@gmail.com>
Wed, 24 Dec 2025 04:03:49 +0000 (20:03 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Thu, 25 Dec 2025 02:41:34 +0000 (18:41 -0800)
* tests/date/date-locale-hour.sh: Test that the default format of 10
random supported locales is the same as 'locale date_fmt'.

tests/date/date-locale-hour.sh

index 409091080cd910c94031e13426c234cd426f1b9a..791d73f0d3c80b6219f9e0d749d9329fafe775c4 100755 (executable)
@@ -56,5 +56,15 @@ for loc in "$LOCALE_FR_UTF8" 'en_US.UTF-8'; do
   esac
 done
 
+# Make sure 'date' can use the format string given by 'locale date_fmt'
+# and that it uses it by default when no format string is given.
+for loc in $(locale -a | shuf -n 10); do
+  fmt=$(LC_ALL=$loc locale date_fmt)
+  if test -n "$fmt"; then
+    LC_ALL=$loc date -d '2025-10-11T13:00' +"$fmt" > $loc.exp || fail=1
+    LC_ALL=$loc date -d '2025-10-11T13:00' > $loc.out || fail=1
+    compare $loc.exp $loc.out || fail=1
+  fi
+done
 
 Exit $fail