]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add test cases for json_pretty(). json-pretty
authordrh <>
Wed, 6 Mar 2024 20:38:52 +0000 (20:38 +0000)
committerdrh <>
Wed, 6 Mar 2024 20:38:52 +0000 (20:38 +0000)
FossilOrigin-Name: 6448b90708eeedef03e82dcb10d2879e1bc859d422b450c5fc403ffbe0343bed

manifest
manifest.uuid
test/json106.test
test/json108.test [new file with mode: 0644]

index 3636941e49058d964d6f13ffe5d5a2856c1d64ab..91c87d0a125ce9226536bc3d618d4029603c5d5a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\scouple\sof\sjson_pretty()\sexamples\sto\s/fiddle.
-D 2024-03-06T14:42:06.357
+C Add\stest\scases\sfor\sjson_pretty().
+D 2024-03-06T20:38:52.875
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -1353,8 +1353,9 @@ F test/json102.test 557a46e16df1aa9bdbc4076a71a45814ea0e7503d6621d87d42a8c04cbc2
 F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe
 F test/json104.test 1b844a70cddcfa2e4cd81a5db0657b2e61e7f00868310f24f56a9ba0114348c1
 F test/json105.test 043838b56e68f3252a0dcf5be1689016f6f3f05056f8dcfcdc9d074f4d932988
-F test/json106.test 1d46a9294e2ced35c7f87cebbcb9626d01abab04f1969d7ded7b6f6a1d9be0f2
+F test/json106.test 4aed3afd16549045d198a8d9cea00deea96e1f2ecf55864dce96cac558b8abef
 F test/json107.test 59054e815c8f6b67d634d44ace421cf975828fb5651c4460aa66015c8e19d562
+F test/json108.test 0a5f1e2d4b35a1bc33052563d2a5ede03052e2099e58cb424547656c898e0f49
 F test/json501.test b95e2d14988b682a5cadf079dd6162f0f85fb74cd59c6b1f1624110104a974eb
 F test/json502.test 84634d3dbb521d2814e43624025b760c6198456c8197bbec6c977c0236648f5b
 F test/jsonb01.test f4cdfb4cf5a0c940091b17675ed9583f45add0c938f07d65b0de0e19d3a9a101
@@ -2176,8 +2177,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 39552bd36c06fe9ee346cb71e0659baceccde031b67c0974f2dd14eb11ebc055
-R f12e2eeb9bae468bef7713e1648b6a8a
-U stephan
-Z 3bec70ffdc2a1f410c64a91b9d3ada78
+P d5e1687b1d49cec5daa8793ea138fdf3bd29436c1e67071707ec0594bd1c66c6
+R b5d425c8e8367f72e383ae1d2d9e4ea0
+U drh
+Z ce296be00f3b33d5cde8abdb22061e01
 # Remove this line to create a well-formed Fossil manifest.
index ea3e1e84580fa545acbef1432a926920a7ada9b2..342c0db21d63b5051f7d8e349ec9ed58404af7d6 100644 (file)
@@ -1 +1 @@
-d5e1687b1d49cec5daa8793ea138fdf3bd29436c1e67071707ec0594bd1c66c6
\ No newline at end of file
+6448b90708eeedef03e82dcb10d2879e1bc859d422b450c5fc403ffbe0343bed
\ No newline at end of file
index 23fa028431e3756f0919c4b69e03fa27e496a142..06859a10b44643876a2b564d9bb7dc9b82f49adf 100644 (file)
@@ -67,6 +67,12 @@ for {set ii 1} {$ii<=5000} {incr ii} {
       FROM t1, kv
      WHERE p->>key IS NOT val
   } 0
+  do_execsql_test $ii.8 {
+    SELECT j0 FROM t1 WHERE json(j0)!=json(json_pretty(j0));
+  } {}
+  do_execsql_test $ii.9 {
+    SELECT j5 FROM t1 WHERE json(j5)!=json(json_pretty(j5));
+  } {}
 }
 
 
diff --git a/test/json108.test b/test/json108.test
new file mode 100644 (file)
index 0000000..71f3814
--- /dev/null
@@ -0,0 +1,45 @@
+# 2024-03-06
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# Invariant tests for JSON built around the randomjson extension
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix json108
+
+# These tests require virtual table "json_tree" to run.
+ifcapable !vtab { finish_test ; return }
+
+load_static_extension db randomjson
+db eval {
+  CREATE TEMP TABLE t1(j0,j5);
+  WITH RECURSIVE c(n) AS (VALUES(0) UNION ALL SELECT n+1 FROM c WHERE n<9)
+  INSERT INTO t1 SELECT random_json(n), random_json5(n) FROM c;
+}
+
+do_execsql_test 1.1 {
+  SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL));
+} 10
+do_execsql_test 1.2 {
+  SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL));
+} 10
+do_execsql_test 1.3 {
+  SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,''));
+} 10
+do_execsql_test 1.4 {
+  SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,char(9)));
+} 10
+do_execsql_test 1.5 {
+  SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,'/*hello*/'));
+} 10
+
+
+finish_test