3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # Invariant tests for JSON built around the randomjson extension
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 set testprefix json108
18 # These tests require virtual table "json_tree" to run.
19 ifcapable !vtab { finish_test ; return }
21 load_static_extension db randomjson
23 CREATE TEMP TABLE t1(j0,j5);
24 WITH RECURSIVE c(n) AS (VALUES(0) UNION ALL SELECT n+1 FROM c WHERE n<9)
25 INSERT INTO t1 SELECT random_json(n), random_json5(n) FROM c;
29 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL));
32 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL));
35 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,''));
38 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,char(9)));
41 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,'/*hello*/'));