diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:46:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:46:48 +0000 |
commit | 311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 (patch) | |
tree | 0ec307299b1dada3701e42f4ca6eda57d708261e /src/test/icu | |
parent | Initial commit. (diff) | |
download | postgresql-15-311bcfc6b3acdd6fd152798c7f287ddf74fa2a98.tar.xz postgresql-15-311bcfc6b3acdd6fd152798c7f287ddf74fa2a98.zip |
Adding upstream version 15.4.upstream/15.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/icu')
-rw-r--r-- | src/test/icu/.gitignore | 2 | ||||
-rw-r--r-- | src/test/icu/Makefile | 25 | ||||
-rw-r--r-- | src/test/icu/README | 25 | ||||
-rw-r--r-- | src/test/icu/t/010_database.pl | 66 |
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(); |