branch: elpa/emacsql commit 9272d13ace5bf59dbb8b04554a631361deca9335 Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@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;"))