From bb98f3fd2887468ada6b3cee7cdccd05b809c545 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 10 Apr 2013 20:18:10 -0400 Subject: [PATCH] start adding pgTAP test cases pgTAP is a PostgreSQL unit testing framework; about which more can be found at http://pgtap.org/ This commit introduces the first pgTAP test case, which exercises the NACO normalization functions. To run the tests, install pgTAP, create an Evergreen database that contains (for now) just the seed data, and from the top of the source tree run pg_prove -vr -U evergreen Open-ILS/src/sql/Pg/t/* Replace '-U evergreen' with the psql command-line switches needed to access your database. To install pgTAP on a Debian Wheezy system, you can do: Then, to load the pgTAP extension into the database, run psql> CREATE EXTENSION pgtap; Signed-off-by: Galen Charlton Signed-off-by: Mike Rylander --- Open-ILS/src/sql/Pg/t/naco_normalize.sql | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/t/naco_normalize.sql diff --git a/Open-ILS/src/sql/Pg/t/naco_normalize.sql b/Open-ILS/src/sql/Pg/t/naco_normalize.sql new file mode 100644 index 0000000000..0e59107e99 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/naco_normalize.sql @@ -0,0 +1,44 @@ +BEGIN; + +SELECT plan(25); + +CREATE FUNCTION nfkd(TEXT) RETURNS TEXT AS $$ + use strict; + use warnings; + use Unicode::Normalize; + my $str = shift; + return NFKD($str); +$$ LANGUAGE PLPERLU STABLE; + +SELECT is( public.naco_normalize('abc'), 'abc', 'regular text' ); +SELECT is( public.naco_normalize('ABC'), 'abc', 'regular text' ); +SELECT is( public.naco_normalize('åbçdéñœöîøæÇıÂÅÍÎÏÔÔÒÚÆŒè'), 'abcdenoeoioaeciaaiiiooouaeoee', 'European diacritics' ); +SELECT is( public.naco_normalize('“‘„«quotes»’”'), 'quotes', 'special quotes' ); +SELECT is( public.naco_normalize('˜abcœ def'), 'def', 'special non-filing characters designation' ); +SELECT is( public.naco_normalize('œabcdef'), 'abcdef', 'unpaired start of string' ); +SELECT is( public.naco_normalize('ß'), 'ss', 'sharp S (eszett)' ); +SELECT is( public.naco_normalize('flfiff'), 'flfiff', 'ligatures' ); +SELECT is( public.naco_normalize('ƠơƯư²IJij'), 'oouu2ijij', 'NFKD applied correctly' ); +SELECT is( public.naco_normalize('ÆØÞæðøþĐđıŁłŒœʻʼℓ'), 'aeothaedothddilloeoel', 'part 3.6' ); +SELECT is( public.naco_normalize('Ð'), 'd', 'uppercase eth (missing from 3.6?)' ); +SELECT is( public.naco_normalize('ıİ'), 'ii', 'Turkish I' ); +SELECT is( public.naco_normalize('[book''s cover]'), 'books cover', 'square brackets and apostrophe' ); +SELECT is( public.naco_normalize(' grue food '), 'grue food', 'trim spaces' ); +-- note addition of nfkd() to transform expected output +SELECT is( public.naco_normalize('한국어 조선말'), nfkd('한국어 조선말'), 'Korean text' ); +SELECT is( public.naco_normalize('普通話 / 普通话'), '普通話 普通话', 'Chinese text' ); +SELECT is( public.naco_normalize('العربية'), 'العربية', 'Arabic text' ); +SELECT is( public.naco_normalize('ქართული ენა'), 'ქართული ენა', 'Georgian text' ); +SELECT is( public.naco_normalize('русский язык'), 'русскии язык', 'Russian text' ); +SELECT is( public.naco_normalize(E'\r\npa\tper\f'), 'paper', 'other whitespace' ); +SELECT is( public.naco_normalize('#1: ∃ C++, @ home & abroad'), '#1 c++ @ home & abroad', 'other punctuation' ); +SELECT is( public.naco_normalize('٠١٢٣٤٥'), '012345', 'other decimal digits' ); +SELECT is( public.naco_normalize('²³¹'), '231', 'superscript numbers' ); +SELECT is( public.naco_normalize('♭©®♯'), '♭ ♯', 'other symbols' ); + +SELECT is( public.naco_normalize('Smith, Jane. Poet, painter, and author', 'a'), 'smith, jane poet painter and author', + 'retain first comma' ); + +SELECT * FROM finish(); + +ROLLBACK; -- 2.43.2