mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Fix a JSON1 test case so that it works on builds that omit virtual tables.
FossilOrigin-Name: a4444c0f662058bdd5267e616c31cef828bc1fc5
This commit is contained in:
@ -16,28 +16,28 @@ set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
load_static_extension db json
|
||||
do_execsql_test json1-1.1.00 {
|
||||
do_execsql_test json101-1.1.00 {
|
||||
SELECT json_array(1,2.5,null,'hello');
|
||||
} {[1,2.5,null,"hello"]}
|
||||
do_execsql_test json1-1.1.01 {
|
||||
do_execsql_test json101-1.1.01 {
|
||||
SELECT json_array(1,'{"abc":2.5,"def":null,"ghi":hello}',99);
|
||||
-- the second term goes in as a string:
|
||||
} {[1,"{\\"abc\\":2.5,\\"def\\":null,\\"ghi\\":hello}",99]}
|
||||
do_execsql_test json1-1.1.02 {
|
||||
do_execsql_test json101-1.1.02 {
|
||||
SELECT json_array(1,json('{"abc":2.5,"def":null,"ghi":"hello"}'),99);
|
||||
-- the second term goes in as JSON
|
||||
} {[1,{"abc":2.5,"def":null,"ghi":"hello"},99]}
|
||||
do_execsql_test json1-1.1.03 {
|
||||
do_execsql_test json101-1.1.03 {
|
||||
SELECT json_array(1,json_object('abc',2.5,'def',null,'ghi','hello'),99);
|
||||
-- the second term goes in as JSON
|
||||
} {[1,{"abc":2.5,"def":null,"ghi":"hello"},99]}
|
||||
do_execsql_test json1-1.2 {
|
||||
do_execsql_test json101-1.2 {
|
||||
SELECT hex(json_array('String "\ Test'));
|
||||
} {5B22537472696E67205C225C5C2054657374225D}
|
||||
do_catchsql_test json1-1.3 {
|
||||
do_catchsql_test json101-1.3 {
|
||||
SELECT json_array(1,printf('%.1000c','x'),x'abcd',3);
|
||||
} {1 {JSON cannot hold BLOB values}}
|
||||
do_execsql_test json1-1.4 {
|
||||
do_execsql_test json101-1.4 {
|
||||
SELECT json_array(-9223372036854775808,9223372036854775807,0,1,-1,
|
||||
0.0, 1.0, -1.0, -1e99, +2e100,
|
||||
'one','two','three',
|
||||
@ -49,39 +49,41 @@ do_execsql_test json1-1.4 {
|
||||
99);
|
||||
} {[-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]}
|
||||
|
||||
do_execsql_test json1-2.1 {
|
||||
do_execsql_test json101-2.1 {
|
||||
SELECT json_object('a',1,'b',2.5,'c',null,'d','String Test');
|
||||
} {{{"a":1,"b":2.5,"c":null,"d":"String Test"}}}
|
||||
do_catchsql_test json1-2.2 {
|
||||
do_catchsql_test json101-2.2 {
|
||||
SELECT json_object('a',printf('%.1000c','x'),2,2.5);
|
||||
} {1 {json_object() labels must be TEXT}}
|
||||
do_catchsql_test json1-2.3 {
|
||||
do_catchsql_test json101-2.3 {
|
||||
SELECT json_object('a',1,'b');
|
||||
} {1 {json_object() requires an even number of arguments}}
|
||||
do_catchsql_test json1-2.4 {
|
||||
do_catchsql_test json101-2.4 {
|
||||
SELECT json_object('a',printf('%.1000c','x'),'b',x'abcd');
|
||||
} {1 {JSON cannot hold BLOB values}}
|
||||
|
||||
do_execsql_test json1-3.1 {
|
||||
do_execsql_test json101-3.1 {
|
||||
SELECT json_replace('{"a":1,"b":2}','$.a','[3,4,5]');
|
||||
} {{{"a":"[3,4,5]","b":2}}}
|
||||
do_execsql_test json1-3.2 {
|
||||
do_execsql_test json101-3.2 {
|
||||
SELECT json_replace('{"a":1,"b":2}','$.a',json('[3,4,5]'));
|
||||
} {{{"a":[3,4,5],"b":2}}}
|
||||
do_execsql_test json1-3.3 {
|
||||
do_execsql_test json101-3.3 {
|
||||
SELECT json_type(json_set('{"a":1,"b":2}','$.b','{"x":3,"y":4}'),'$.b');
|
||||
} {text}
|
||||
do_execsql_test json1-3.4 {
|
||||
do_execsql_test json101-3.4 {
|
||||
SELECT json_type(json_set('{"a":1,"b":2}','$.b',json('{"x":3,"y":4}')),'$.b');
|
||||
} {object}
|
||||
do_execsql_test json1-3.5 {
|
||||
ifcapable vtab {
|
||||
do_execsql_test json101-3.5 {
|
||||
SELECT fullkey, atom, '|' FROM json_tree(json_set('{}','$.x',123,'$.x',456));
|
||||
} {{$} {} | {$.x} 456 |}
|
||||
}
|
||||
|
||||
# Per rfc7159, any JSON value is allowed at the top level, and whitespace
|
||||
# is permitting before and/or after that value.
|
||||
#
|
||||
do_execsql_test json1-4.1 {
|
||||
do_execsql_test json101-4.1 {
|
||||
CREATE TABLE j1(x);
|
||||
INSERT INTO j1(x)
|
||||
VALUES('true'),('false'),('null'),('123'),('-234'),('34.5e+6'),
|
||||
@ -90,32 +92,32 @@ do_execsql_test json1-4.1 {
|
||||
('{"a":true,"b":{"c":false}}');
|
||||
SELECT * FROM j1 WHERE NOT json_valid(x);
|
||||
} {}
|
||||
do_execsql_test json1-4.2 {
|
||||
do_execsql_test json101-4.2 {
|
||||
SELECT * FROM j1 WHERE NOT json_valid(char(0x20,0x09,0x0a,0x0d)||x);
|
||||
} {}
|
||||
do_execsql_test json1-4.3 {
|
||||
do_execsql_test json101-4.3 {
|
||||
SELECT * FROM j1 WHERE NOT json_valid(x||char(0x20,0x09,0x0a,0x0d));
|
||||
} {}
|
||||
|
||||
# But an empty string, or a string of pure whitespace is not valid JSON.
|
||||
#
|
||||
do_execsql_test json1-4.4 {
|
||||
do_execsql_test json101-4.4 {
|
||||
SELECT json_valid(''), json_valid(char(0x20,0x09,0x0a,0x0d));
|
||||
} {0 0}
|
||||
|
||||
# json_remove() and similar functions with no edit operations return their
|
||||
# input unchanged.
|
||||
#
|
||||
do_execsql_test json1-4.5 {
|
||||
do_execsql_test json101-4.5 {
|
||||
SELECT x FROM j1 WHERE json_remove(x)<>x;
|
||||
} {}
|
||||
do_execsql_test json1-4.6 {
|
||||
do_execsql_test json101-4.6 {
|
||||
SELECT x FROM j1 WHERE json_replace(x)<>x;
|
||||
} {}
|
||||
do_execsql_test json1-4.7 {
|
||||
do_execsql_test json101-4.7 {
|
||||
SELECT x FROM j1 WHERE json_set(x)<>x;
|
||||
} {}
|
||||
do_execsql_test json1-4.8 {
|
||||
do_execsql_test json101-4.8 {
|
||||
SELECT x FROM j1 WHERE json_insert(x)<>x;
|
||||
} {}
|
||||
|
||||
|
Reference in New Issue
Block a user