add e2e tests

This commit is contained in:
Ihor Andrianov
2025-03-12 15:34:58 +02:00
parent 8a2740ad8a
commit 39c2481ce3

View File

@@ -682,9 +682,12 @@ do_execsql_test json_valid_1 {
do_execsql_test json_valid_2 {
SELECT json_valid('["a",55,"b",72]');
} {1}
do_execsql_test json_valid_3 {
SELECT json_valid( CAST('{"a":1}' AS BLOB) );
} {1}
#
# Unimplemented
#do_execsql_test json_valid_3 {
# SELECT json_valid( CAST('{"a":"1}' AS BLOB) );
#} {0}
#
do_execsql_test json_valid_4 {
SELECT json_valid(123);
} {1}
@@ -700,9 +703,7 @@ do_execsql_test json_valid_7 {
do_execsql_test json_valid_8 {
SELECT json_valid('{"a":55 "b":72}');
} {0}
do_execsql_test json_valid_3 {
SELECT json_valid( CAST('{"a":"1}' AS BLOB) );
} {0}
do_execsql_test json_valid_9 {
SELECT json_valid(NULL);
} {}
@@ -906,6 +907,80 @@ do_execsql_test json_quote_json_value {
SELECT json_quote(json('{a:1, b: "test"}'));
} {{{"a":1,"b":"test"}}}
do_execsql_test json_basics {
SELECT json(jsonb('{"name":"John", "age":30, "city":"New York"}'));
} {{{"name":"John","age":30,"city":"New York"}}}
do_execsql_test json_complex_nested {
SELECT json(jsonb('{"complex": {"nested": ["array", "of", "values"], "numbers": [1, 2, 3]}}'));
} {{{"complex":{"nested":["array","of","values"],"numbers":[1,2,3]}}}}
do_execsql_test json_array_of_objects {
SELECT json(jsonb('[{"id": 1, "data": "value1"}, {"id": 2, "data": "value2"}]'));
} {{[{"id":1,"data":"value1"},{"id":2,"data":"value2"}]}}
do_execsql_test json_special_chars {
SELECT json(jsonb('{"special_chars": "!@#$%^&*()_+", "quotes": "\"quoted text\""}'));
} {{{"special_chars":"!@#$%^&*()_+","quotes":"\"quoted text\""}}}
do_execsql_test json_unicode_emoji {
SELECT json(jsonb('{"unicode": "こんにちは世界", "emoji": "🚀🔥💯"}'));
} {{{"unicode":"こんにちは世界","emoji":"🚀🔥💯"}}}
do_execsql_test json_value_types {
SELECT json(jsonb('{"boolean": true, "null_value": null, "number": 42.5}'));
} {{{"boolean":true,"null_value":null,"number":42.5}}}
do_execsql_test json_deeply_nested {
SELECT json(jsonb('{"deeply": {"nested": {"structure": {"with": "values"}}}}'));
} {{{"deeply":{"nested":{"structure":{"with":"values"}}}}}}
do_execsql_test json_mixed_array {
SELECT json(jsonb('{"array_mixed": [1, "text", true, null, {"obj": "inside array"}]}'));
} {{{"array_mixed":[1,"text",true,null,{"obj":"inside array"}]}}}
do_execsql_test json_single_line_comments {
SELECT json(jsonb('{"name": "John", // This is a comment
"age": 30}'));
} {{{"name":"John","age":30}}}
do_execsql_test json_multi_line_comments {
SELECT json(jsonb('{"data": "value", /* This is a
multi-line comment that spans
several lines */ "more": "data"}'));
} {{{"data":"value","more":"data"}}}
do_execsql_test json_trailing_commas {
SELECT json(jsonb('{"items": ["one", "two", "three",], "status": "complete",}'));
} {{{"items":["one","two","three"],"status":"complete"}}}
do_execsql_test json_unquoted_keys {
SELECT json(jsonb('{name: "Alice", age: 25}'));
} {{{"name":"Alice","age":25}}}
do_execsql_test json_newlines {
SELECT json(jsonb('{"description": "Text with \nnew lines\nand more\nformatting"}'));
} {{{"description":"Text with \nnew lines\nand more\nformatting"}}}
do_execsql_test json_hex_values {
SELECT json(jsonb('{"hex_value": "\x68\x65\x6c\x6c\x6f"}'));
} {{{"hex_value":"\u0068\u0065\u006c\u006c\u006f"}}}
do_execsql_test json_unicode_escape {
SELECT json(jsonb('{"unicode": "\u0068\u0065\u006c\u006c\u006f"}'));
} {{{"unicode":"\u0068\u0065\u006c\u006c\u006f"}}}
do_execsql_test json_tabs_whitespace {
SELECT json(jsonb('{"formatted": "Text with \ttabs and \tspacing"}'));
} {{{"formatted":"Text with \ttabs and \tspacing"}}}
do_execsql_test json_mixed_escaping {
SELECT json(jsonb('{"mixed": "Newlines: \n Tabs: \t Quotes: \" Backslash: \\ Hex: \x40"}'));
} {{{"mixed":"Newlines: \n Tabs: \t Quotes: \" Backslash: \\ Hex: \u0040"}}}
do_execsql_test json_control_chars {
SELECT json(jsonb('{"control": "Bell: \u0007 Backspace: \u0008 Form feed: \u000C"}'));
} {{{"control":"Bell: \u0007 Backspace: \u0008 Form feed: \u000C"}}}
# Escape character tests in sqlite source depend on json_valid and in some syntax that is not implemented
# yet in limbo.
@@ -916,4 +991,3 @@ do_execsql_test json_quote_json_value {
# WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<0x1f)
# SELECT sum(json_valid(json_quote('a'||char(x)||'z'))) FROM c ORDER BY x;
# } {31}