branch: elpa/pg
commit 7b14df73adaf35eb8e0b3405dda9d650b6f8233d
Author: Eric Marsden <[email protected]>
Commit: Eric Marsden <[email protected]>
Add tests for json_typeof and json_array_length functions.
---
test/test-pg.el | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/test/test-pg.el b/test/test-pg.el
index 6b459c89998..964553548d4 100755
--- a/test/test-pg.el
+++ b/test/test-pg.el
@@ -1845,6 +1845,12 @@ bar$$"))))
(let ((json (scalar "SELECT '[66.7,-42.0,8]'::jsonb")))
(should (pgtest-approx= 66.7 (aref json 0)))
(should (pgtest-approx= -42.0 (aref json 1))))
+ (should (string= "number" (scalar "SELECT json_typeof('123')")))
+ (should (string= "array" (scalar "SELECT json_typeof('[]')")))
+ (should (string= "boolean" (scalar "SELECT json_typeof('true')")))
+ (should (eql 0 (scalar "SELECT json_array_length('[]')")))
+ (should (eql 10 (scalar "SELECT json_array_length('[1, 2, 3, 4, 5, 6, 7,
8, 9, 10]')")))
+ (should (pgtest-approx= 3.14159 (scalar "SELECT to_jsonb(3.14159)")))
;; JSON null in JSONB type is not the same as PostgreSQL NULL value!
(should (eql nil (scalar "SELECT 'null'::jsonb is null")))
(should (eql nil (scalar "SELECT '{\"name\": null}'::jsonb->'name' IS
NULL")))