~ubuntu-branches/ubuntu/trusty/postgresql-9.3/trusty-proposed

« back to all changes in this revision

Viewing changes to src/test/regress/sql/json_encoding.sql

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2016-03-31 11:04:53 UTC
  • mfrom: (1.1.11) (18.1.4 trusty-security)
  • Revision ID: package-import@ubuntu.com-20160331110453-h6xfs9f11suj3mze
Tags: 9.3.12-0ubuntu0.14.04
* New upstream bug fix release. (LP: #1564268)
  - See http://www.postgresql.org/about/news/1656/ for details.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
-- encoding-sensitive tests for json
 
3
 
 
4
-- basic unicode input
 
5
SELECT '"\u"'::json;                    -- ERROR, incomplete escape
 
6
SELECT '"\u00"'::json;                  -- ERROR, incomplete escape
 
7
SELECT '"\u000g"'::json;                -- ERROR, g is not a hex digit
 
8
SELECT '"\u0000"'::json;                -- OK, legal escape
 
9
SELECT '"\uaBcD"'::json;                -- OK, uppercase and lower case both OK
 
10
 
 
11
-- handling of unicode surrogate pairs
 
12
 
 
13
select json '{ "a":  "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8;
 
14
select json '{ "a":  "\ud83d\ud83d" }' -> 'a'; -- 2 high surrogates in a row
 
15
select json '{ "a":  "\ude04\ud83d" }' -> 'a'; -- surrogates in wrong order
 
16
select json '{ "a":  "\ud83dX" }' -> 'a'; -- orphan high surrogate
 
17
select json '{ "a":  "\ude04X" }' -> 'a'; -- orphan low surrogate
 
18
 
 
19
--handling of simple unicode escapes
 
20
 
 
21
select json '{ "a":  "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8;
 
22
select json '{ "a":  "dollar \u0024 character" }' ->> 'a' as correct_everywhere;
 
23
select json '{ "a":  "null \u0000 escape" }' ->> 'a' as not_escaped;