2de74d699d0d5863ab86737cb61569ae74b3648e
[working/Evergreen.git] / Open-ILS / src / sql / Pg / t / lp1501781-unaccent_and_squash.pg
1 -- Start transaction and plan the tests.
2 BEGIN;
3
4 -- Number of tests that will be run
5 SELECT plan(18);
6
7 -- Run the tests
8
9 SELECT isnt_empty(
10     'SELECT * FROM config.org_unit_setting_type WHERE name = $$circ.patron_search.diacritic_insensitive$$',
11     'circ.patron_search.diacritic_insensitive exists');
12
13 SELECT has_index('actor', 'usr', 'actor_usr_first_given_name_unaccent_idx',
14                  'unaccent_and_squash(first_given_name)',
15                  'Index actor_usr_first_given_name_unaccent_idx exists');
16
17 SELECT has_index('actor', 'usr', 'actor_usr_second_given_name_unaccent_idx',
18                  'unaccent_and_squash(second_given_name)',
19                  'Index actor_usr_second_given_name_unaccent_idx exists');
20
21 SELECT has_index('actor', 'usr', 'actor_usr_family_name_unaccent_idx',
22                  'unaccent_and_squash(family_name)',
23                  'Index actor_usr_family_name_unaccent_idx exists');
24
25 SELECT is(evergreen.unaccent_and_squash('aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'),
26           'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz',
27           'English Characters');
28
29 SELECT is(evergreen.unaccent_and_squash('0123456789!@#$%^&*()-+'),
30           '0123456789', 'Numbers and Symbols');
31
32 SELECT is(evergreen.unaccent_and_squash('ÁÉÍÑÓÚÜáéíñóúü¿¡'),
33           'aeinouuaeinouu¿¡', 'Spanish');
34
35 SELECT is(evergreen.unaccent_and_squash('ÖÜÇĞŞöüçğşİI'),
36           'oucgsoucgsii', 'Turkish');
37
38 SELECT is(evergreen.unaccent_and_squash('ÄÉÖÜ'),
39           'aeou', 'German');
40
41 SELECT is(evergreen.unaccent_and_squash('АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'),
42           'абвгдежзийклмнопрстуфхцчшщъыьэюя', 'Russian');
43
44 SELECT is(evergreen.unaccent_and_squash('ÁĄÄÉĘĚÍÓÔÚŮÝČĹŇŔŘŠŽ'),
45           'aaaeeeioouuyclnrrsz', 'Czeck, Slovack & Slovenian');
46
47 SELECT is(evergreen.unaccent_and_squash('Άά Έέ Ήή Ίί Όό Ύύ Ώώ'),
48           'άάέέήήίίόόύύώώ', 'Greek');
49
50 SELECT is(evergreen.unaccent_and_squash('Jacques Bélanger'),
51           'jacquesbelanger', 'French nom and prénom');
52
53 SELECT is(evergreen.unaccent_and_squash('El Niño'),
54           'elnino', 'Spanish "The Kid"');
55
56 SELECT is(evergreen.unaccent_and_squash('Œuvres'),
57           CASE WHEN substring(version() from '^PostgreSQL ([0-9]+\.[0-9]+)')::DECIMAL > 9.5 THEN 'oeuvres' ELSE 'euvres' END, 'oe ligature');
58
59 -- Punctuation Tests
60
61 SELECT is(evergreen.unaccent_and_squash('O''Brien'),
62           'obrien', 'Apostrophe');
63
64 SELECT is(evergreen.unaccent_and_squash('Grubbly-Plank'),
65           'grubblyplank', 'Hyphen');
66
67 SELECT is(evergreen.unaccent_and_squash('p&#$(a#*&$!s))(\\s'),
68           'pass', 'Punctuation hash');
69
70 -- Finish the test and clean up.
71 SELECT * FROM finish();
72 ROLLBACK;