Debian Codegraph @

test/json108.test

raw
1 # 2024-03-06
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 # Invariant tests for JSON built around the randomjson extension
12 #
13
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 set testprefix json108
17
18 # These tests require virtual table "json_tree" to run.
19 ifcapable !vtab { finish_test ; return }
20
21 load_static_extension db randomjson
22 db eval {
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;
26 }
27
28 do_execsql_test 1.1 {
29 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL));
30 } 10
31 do_execsql_test 1.2 {
32 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL));
33 } 10
34 do_execsql_test 1.3 {
35 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,''));
36 } 10
37 do_execsql_test 1.4 {
38 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,char(9)));
39 } 10
40 do_execsql_test 1.5 {
41 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,'/*hello*/'));
42 } 10
43
44
45 finish_test