From e98b6fab47a954c822126a0354e6f824c24446f7 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Sep 2015 15:32:33 +0000 Subject: [PATCH] More test cases in test/json102.test corresponding to new examples in the json1 documentation. FossilOrigin-Name: f599a42e190b4b89d74055402143c5487985cd90 --- manifest | 14 ++--- manifest.uuid | 2 +- test/json102.test | 130 ++++++++++++++++++++++++++-------------------- 3 files changed, 83 insertions(+), 63 deletions(-) diff --git a/manifest b/manifest index 5d0cbe90ef..8b1f777811 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\scompiler\swarnings\sin\sfts5\scode. -D 2015-09-11T14:15:46.470 +C More\stest\scases\sin\stest/json102.test\scorresponding\sto\snew\sexamples\sin\sthe\njson1\sdocumentation. +D 2015-09-11T15:32:33.147 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in f85066ce844a28b671aaeeff320921cd0ce36239 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -815,7 +815,7 @@ F test/jrnlmode.test 7864d59cf7f6e552b9b99ba0f38acd167edc10fa F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa F test/json101.test e20d2421c531db32fad59c5e06e80af0b1b002c8 -F test/json102.test b5da30aef253102ad63f2186c9319e4b5d505a1b +F test/json102.test 4e1403cb06481ab160cf471c3c139820498e0563 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 @@ -1386,7 +1386,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d6cadbe9fefce9a7af6b2d0cb83362f967d7d89a -R 142f8055af436e9c39db41b2b1d79675 -U dan -Z 56f93ac2844adc1c45e33937963b4c3d +P 0dc436116e55e3fd55eb6085ada71e099069b32d +R 6a1dee4bd5e0067c0115e5b47549c01a +U drh +Z 3b3b3aa659d24a2dd31ae86f119af47f diff --git a/manifest.uuid b/manifest.uuid index ecea4d71e9..a402b58010 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0dc436116e55e3fd55eb6085ada71e099069b32d \ No newline at end of file +f599a42e190b4b89d74055402143c5487985cd90 \ No newline at end of file diff --git a/test/json102.test b/test/json102.test index 2c8dc49c57..da9fbd1b76 100644 --- a/test/json102.test +++ b/test/json102.test @@ -20,145 +20,165 @@ source $testdir/tester.tcl load_static_extension db json do_execsql_test json102-100 { + SELECT json_object('ex','[52,3.14159]'); +} {{{"ex":"[52,3.14159]"}}} +do_execsql_test json102-110 { + SELECT json_object('ex',json('[52,3.14159]')); +} {{{"ex":[52,3.14159]}}} +do_execsql_test json102-120 { + SELECT json_object('ex',json_array(52,3.14159)); +} {{{"ex":[52,3.14159]}}} +do_execsql_test json102-130 { SELECT json(' { "this" : "is", "a": [ "test" ] } '); } {{{"this":"is","a":["test"]}}} -do_execsql_test json102-110 { +do_execsql_test json102-140 { SELECT json_array(1,2,'3',4); } {{[1,2,"3",4]}} -do_execsql_test json102-120 { +do_execsql_test json102-150 { SELECT json_array('[1,2]'); } {{["[1,2]"]}} -do_execsql_test json102-130 { +do_execsql_test json102-160 { SELECT json_array(json_array(1,2)); } {{[[1,2]]}} -do_execsql_test json102-140 { +do_execsql_test json102-170 { SELECT json_array(1,null,'3','[4,5]','{"six":7.7}'); } {{[1,null,"3","[4,5]","{\"six\":7.7}"]}} -do_execsql_test json102-150 { +do_execsql_test json102-180 { SELECT json_array(1,null,'3',json('[4,5]'),json('{"six":7.7}')); } {{[1,null,"3",[4,5],{"six":7.7}]}} -do_execsql_test json102-160 { +do_execsql_test json102-190 { SELECT json_array_length('[1,2,3,4]'); } {{4}} -do_execsql_test json102-170 { +do_execsql_test json102-200 { + SELECT json_array_length('[1,2,3,4]', '$'); +} {{4}} +do_execsql_test json102-210 { + SELECT json_array_length('[1,2,3,4]', '$[2]'); +} {{0}} +do_execsql_test json102-220 { SELECT json_array_length('{"one":[1,2,3]}'); } {{0}} -do_execsql_test json102-180 { +do_execsql_test json102-230 { SELECT json_array_length('{"one":[1,2,3]}', '$.one'); } {{3}} -do_execsql_test json102-190 { - SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$'); -} {{{"a":2,"c":[4,5,{"f":7}]}}} -do_execsql_test json102-200 { - SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c'); -} {{[4,5,{"f":7}]}} -do_execsql_test json102-210 { - SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2]'); -} {{{"f":7}}} -do_execsql_test json102-220 { - SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2].f'); -} {{7}} -do_execsql_test json102-230 { - SELECT json_extract('{"a":2,"c":[4,5],"f":7}','$.c','$.a'); -} {{[[4,5],2]}} do_execsql_test json102-240 { - SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x'); + SELECT json_array_length('{"one":[1,2,3]}', '$.two'); } {{}} do_execsql_test json102-250 { + SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$'); +} {{{"a":2,"c":[4,5,{"f":7}]}}} +do_execsql_test json102-260 { + SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c'); +} {{[4,5,{"f":7}]}} +do_execsql_test json102-270 { + SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2]'); +} {{{"f":7}}} +do_execsql_test json102-280 { + SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2].f'); +} {{7}} +do_execsql_test json102-290 { + SELECT json_extract('{"a":2,"c":[4,5],"f":7}','$.c','$.a'); +} {{[[4,5],2]}} +do_execsql_test json102-300 { + SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x'); +} {{}} +do_execsql_test json102-310 { + SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x', '$.a'); +} {{[null,2]}} +do_execsql_test json102-320 { SELECT json_insert('{"a":2,"c":4}', '$.a', 99); } {{{"a":2,"c":4}}} -do_execsql_test json102-260 { +do_execsql_test json102-330 { SELECT json_insert('{"a":2,"c":4}', '$.e', 99); } {{{"a":2,"c":4,"e":99}}} -do_execsql_test json102-270 { +do_execsql_test json102-340 { SELECT json_replace('{"a":2,"c":4}', '$.a', 99); } {{{"a":99,"c":4}}} -do_execsql_test json102-280 { +do_execsql_test json102-350 { SELECT json_replace('{"a":2,"c":4}', '$.e', 99); } {{{"a":2,"c":4}}} -do_execsql_test json102-290 { +do_execsql_test json102-360 { SELECT json_set('{"a":2,"c":4}', '$.a', 99); } {{{"a":99,"c":4}}} -do_execsql_test json102-300 { +do_execsql_test json102-370 { SELECT json_set('{"a":2,"c":4}', '$.e', 99); } {{{"a":2,"c":4,"e":99}}} -do_execsql_test json102-310 { +do_execsql_test json102-380 { SELECT json_set('{"a":2,"c":4}', '$.c', '[97,96]'); } {{{"a":2,"c":"[97,96]"}}} -do_execsql_test json102-320 { +do_execsql_test json102-390 { SELECT json_set('{"a":2,"c":4}', '$.c', json('[97,96]')); } {{{"a":2,"c":[97,96]}}} -do_execsql_test json102-330 { +do_execsql_test json102-400 { SELECT json_set('{"a":2,"c":4}', '$.c', json_array(97,96)); } {{{"a":2,"c":[97,96]}}} -do_execsql_test json102-340 { +do_execsql_test json102-410 { SELECT json_object('a',2,'c',4); } {{{"a":2,"c":4}}} -do_execsql_test json102-350 { +do_execsql_test json102-420 { SELECT json_object('a',2,'c','{e:5}'); } {{{"a":2,"c":"{e:5}"}}} -do_execsql_test json102-360 { +do_execsql_test json102-430 { SELECT json_object('a',2,'c',json_object('e',5)); } {{{"a":2,"c":{"e":5}}}} -do_execsql_test json102-370 { +do_execsql_test json102-440 { SELECT json_remove('[0,1,2,3,4]','$[2]'); } {{[0,1,3,4]}} -do_execsql_test json102-380 { +do_execsql_test json102-450 { SELECT json_remove('[0,1,2,3,4]','$[2]','$[0]'); } {{[1,3,4]}} -do_execsql_test json102-390 { +do_execsql_test json102-460 { SELECT json_remove('[0,1,2,3,4]','$[0]','$[2]'); } {{[1,2,4]}} -do_execsql_test json102-400 { +do_execsql_test json102-470 { SELECT json_remove('{"x":25,"y":42}'); } {{{"x":25,"y":42}}} -do_execsql_test json102-410 { +do_execsql_test json102-480 { SELECT json_remove('{"x":25,"y":42}','$.z'); } {{{"x":25,"y":42}}} -do_execsql_test json102-420 { +do_execsql_test json102-490 { SELECT json_remove('{"x":25,"y":42}','$.y'); } {{{"x":25}}} -do_execsql_test json102-430 { +do_execsql_test json102-500 { SELECT json_remove('{"x":25,"y":42}','$'); } {{}} -do_execsql_test json102-440 { +do_execsql_test json102-510 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}'); } {{object}} -do_execsql_test json102-450 { +do_execsql_test json102-520 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$'); } {{object}} -do_execsql_test json102-460 { +do_execsql_test json102-530 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a'); } {{array}} -do_execsql_test json102-470 { +do_execsql_test json102-540 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[0]'); } {{integer}} -do_execsql_test json102-480 { +do_execsql_test json102-550 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[1]'); } {{real}} -do_execsql_test json102-490 { +do_execsql_test json102-560 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[2]'); } {{true}} -do_execsql_test json102-500 { +do_execsql_test json102-570 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[3]'); } {{false}} -do_execsql_test json102-510 { +do_execsql_test json102-580 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[4]'); } {{null}} -do_execsql_test json102-520 { +do_execsql_test json102-590 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[5]'); } {{text}} -do_execsql_test json102-530 { +do_execsql_test json102-600 { SELECT json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[6]'); } {{}} -do_execsql_test json102-540 { +do_execsql_test json102-610 { SELECT json_valid(char(123)||'"x":35'||char(125)); } {{1}} -do_execsql_test json102-550 { +do_execsql_test json102-620 { SELECT json_valid(char(123)||'"x":35'); } {{0}} - ifcapable vtab { do_execsql_test json102-1000 { CREATE TABLE user(name,phone);