emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/emacsql 9272d13ace 036/427: Add some tests for the expande


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 9272d13ace 036/427: Add some tests for the expanders.
Date: Tue, 13 Dec 2022 02:59:25 -0500 (EST)

branch: elpa/emacsql
commit 9272d13ace5bf59dbb8b04554a631361deca9335
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Add some tests for the expanders.
---
 emacsql-tests.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/emacsql-tests.el b/emacsql-tests.el
index 481c09c566..32b984a130 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -27,3 +27,22 @@
                    "a, b REAL PRIMARY KEY UNIQUE"))
   (should (string= (emacsql--schema-to-string [(a integer) (b float)])
                    "a INTEGER, b REAL")))
+
+(ert-deftest emacsql-var ()
+  (should (eq (emacsql-var 'a) nil))
+  (should (eq (emacsql-var 0) nil))
+  (should (eq (emacsql-var "") nil))
+  (should (eq (emacsql-var '$) 0))
+  (should (eq (emacsql-var '$1) 0))
+  (should (eq (emacsql-var '$5) 4))
+  (should (eq (emacsql-var '$10) 9)))
+
+(defun emacsql-tests-query (query args result)
+  "Check that QUERY outputs RESULT for ARGS."
+  (should (string= (apply #'emacsql-format (emacsql-expand query) args) 
result)))
+
+(ert-deftest emacsql-expand ()
+  (emacsql-tests-query [:select [$1 name] :from $2] '(id people)
+                       "SELECT id, name FROM people;")
+  (emacsql-tests-query [:select * :from employees] ()
+                       "SELECT * FROM employees;"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]