summaryrefslogtreecommitdiffstats
path: root/src/test/icu
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:17:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:17:33 +0000
commit5e45211a64149b3c659b90ff2de6fa982a5a93ed (patch)
tree739caf8c461053357daa9f162bef34516c7bf452 /src/test/icu
parentInitial commit. (diff)
downloadpostgresql-15-5e45211a64149b3c659b90ff2de6fa982a5a93ed.tar.xz
postgresql-15-5e45211a64149b3c659b90ff2de6fa982a5a93ed.zip
Adding upstream version 15.5.upstream/15.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/icu')
-rw-r--r--src/test/icu/.gitignore2
-rw-r--r--src/test/icu/Makefile25
-rw-r--r--src/test/icu/README25
-rw-r--r--src/test/icu/t/010_database.pl66
4 files changed, 118 insertions, 0 deletions
diff --git a/src/test/icu/.gitignore b/src/test/icu/.gitignore
new file mode 100644
index 0000000..871e943
--- /dev/null
+++ b/src/test/icu/.gitignore
@@ -0,0 +1,2 @@
+# Generated by test suite
+/tmp_check/
diff --git a/src/test/icu/Makefile b/src/test/icu/Makefile
new file mode 100644
index 0000000..e30f5e9
--- /dev/null
+++ b/src/test/icu/Makefile
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/test/icu
+#
+# Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
+#
+# src/test/icu/Makefile
+#
+#-------------------------------------------------------------------------
+
+subdir = src/test/icu
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+export with_icu
+
+check:
+ $(prove_check)
+
+installcheck:
+ $(prove_installcheck)
+
+clean distclean maintainer-clean:
+ rm -rf tmp_check
diff --git a/src/test/icu/README b/src/test/icu/README
new file mode 100644
index 0000000..c257af1
--- /dev/null
+++ b/src/test/icu/README
@@ -0,0 +1,25 @@
+src/test/icu/README
+
+Regression tests for ICU functionality
+======================================
+
+This directory contains a test suite for ICU functionality.
+
+Running the tests
+=================
+
+NOTE: You must have given the --enable-tap-tests argument to configure.
+
+Run
+ make check
+or
+ make installcheck
+You can use "make installcheck" if you previously did "make install".
+In that case, the code in the installation tree is tested. With
+"make check", a temporary installation tree is built from the current
+sources and then tested.
+
+Either way, this test initializes, starts, and stops several test Postgres
+clusters.
+
+See src/test/perl/README for more info about running these tests.
diff --git a/src/test/icu/t/010_database.pl b/src/test/icu/t/010_database.pl
new file mode 100644
index 0000000..3ddc5d8
--- /dev/null
+++ b/src/test/icu/t/010_database.pl
@@ -0,0 +1,66 @@
+# Copyright (c) 2022, PostgreSQL Global Development Group
+
+use strict;
+use warnings;
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+
+if ($ENV{with_icu} ne 'yes')
+{
+ plan skip_all => 'ICU not supported by this build';
+}
+
+my $node1 = PostgreSQL::Test::Cluster->new('node1');
+$node1->init;
+$node1->start;
+
+$node1->safe_psql('postgres',
+ q{CREATE DATABASE dbicu LOCALE_PROVIDER icu LOCALE 'C' ICU_LOCALE 'en@colCaseFirst=upper' ENCODING 'UTF8' TEMPLATE template0}
+);
+
+$node1->safe_psql(
+ 'dbicu',
+ q{
+CREATE COLLATION upperfirst (provider = icu, locale = 'en@colCaseFirst=upper');
+CREATE TABLE icu (def text, en text COLLATE "en-x-icu", upfirst text COLLATE upperfirst);
+INSERT INTO icu VALUES ('a', 'a', 'a'), ('b', 'b', 'b'), ('A', 'A', 'A'), ('B', 'B', 'B');
+});
+
+is( $node1->safe_psql('dbicu', q{SELECT def FROM icu ORDER BY def}),
+ qq(A
+a
+B
+b),
+ 'sort by database default locale');
+
+is( $node1->safe_psql(
+ 'dbicu', q{SELECT def FROM icu ORDER BY def COLLATE "en-x-icu"}),
+ qq(a
+A
+b
+B),
+ 'sort by explicit collation standard');
+
+is( $node1->safe_psql(
+ 'dbicu', q{SELECT def FROM icu ORDER BY en COLLATE upperfirst}),
+ qq(A
+a
+B
+b),
+ 'sort by explicit collation upper first');
+
+
+# Test error cases in CREATE DATABASE involving locale-related options
+
+my ($ret, $stdout, $stderr) = $node1->psql('postgres',
+ q{CREATE DATABASE dbicu LOCALE_PROVIDER icu TEMPLATE template0 ENCODING UTF8});
+isnt($ret, 0,
+ "ICU locale must be specified for ICU provider: exit code not 0");
+like(
+ $stderr,
+ qr/ERROR: ICU locale must be specified/,
+ "ICU locale must be specified for ICU provider: error message");
+
+
+done_testing();