blob: 1d788a6bebcbfe8dcbd00579cac4585c2318b683 [file] [log] [blame]
drh5fa5c102015-08-12 16:49:40 +00001# 2015-08-12
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11# This file implements tests for JSON SQL functions extension to the
12# SQLite library.
13#
14
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17
18load_static_extension db json
19do_execsql_test json1-1.1 {
20 SELECT json_array(1,2.5,null,'hello');
21} {[1,2.5,null,"hello"]}
22do_execsql_test json1-1.2 {
23 SELECT hex(json_array('String "\ Test'));
24} {5B22537472696E67205C225C5C2054657374225D}
25do_catchsql_test json1-1.3 {
26 SELECT json_array(1,2,x'abcd',3);
27} {1 {JSON cannot hold BLOB values}}
28do_execsql_test json1-1.4 {
29 SELECT json_array(-9223372036854775808,9223372036854775807,0,1,-1,
30 0.0, 1.0, -1.0, -1e99, +2e100,
31 'one','two','three',
32 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
33 19, NULL, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
34 'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',
35 'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',
36 'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',
37 99);
38} {[-9223372036854775808,9223372036854775807,0,1,-1,0.0,1.0,-1.0,-1.0e+99,2.0e+100,"one","two","three",4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,null,21,22,23,24,25,26,27,28,29,30,31,"abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ",99]}
39
drh2032d602015-08-12 17:23:34 +000040do_execsql_test json1-2.1 {
41 SELECT json_object('a',1,'b',2.5,'c',null,'d','String Test');
42} {{{"a":1,"b":2.5,"c":null,"d":"String Test"}}}
43do_catchsql_test json1-2.2 {
44 SELECT json_object('a',1,2,2.5);
45} {1 {json_object() labels must be TEXT}}
46do_catchsql_test json1-2.3 {
47 SELECT json_object('a',1,'b');
48} {1 {json_object() requires an even number of arguments}}
49do_catchsql_test json1-2.4 {
50 SELECT json_object('a',1,'b',x'abcd');
51} {1 {JSON cannot hold BLOB values}}
52
53
drh5fa5c102015-08-12 16:49:40 +000054finish_test