From b0b0c67955ef0ec3f6a4708b79abe86d53359092 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Tue, 27 Mar 2012 16:06:27 -0400 Subject: [PATCH] convered orphan sql-ident-table test function to use RT and run with the rest of the syntax tests (and fail) Had to fix some package references, and uses backquote to splice together the a decent deftest form without being overly verbose. Also used clsql:sql instead of calling output-sql directly. Currently fails by not preserving case when using a symbol like '|foo| as the table name, we're getting "FOO" not "foo". --- tests/test-syntax.lisp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/tests/test-syntax.lisp b/tests/test-syntax.lisp index c910448..01a7612 100644 --- a/tests/test-syntax.lisp +++ b/tests/test-syntax.lisp @@ -445,18 +445,21 @@ )) -(defun test-output-sql/sql-ident-table () - (let ((tests `((,(make-instance 'sql-ident-table :name :foo) "FOO") - (,(make-instance 'sql-ident-table :name :foo-bar) "FOO_BAR") - (,(make-instance 'sql-ident-table :name "foo") "\"foo\"") - (,(make-instance 'sql-ident-table :name '|foo bar|) "\"foo bar\"") - (,(make-instance 'sql-ident-table :name :foo :table-alias :bar) "FOO BAR" ) - (,(make-instance 'sql-ident-table :name :foo_bar :table-alias :bar-bast) "FOO_BAR BAR_BAST") - (,(make-instance 'sql-ident-table :name "foo" :table-alias "Bar") "\"foo\" \"Bar\"") - (,(make-instance 'sql-ident-table :name '|foo bar| :table-alias :bast) "\"foo bar\" BAST")))) - (loop for (test expected-result) in tests - for test-out = (with-output-to-string (*sql-stream*) (output-sql test nil)) - do (assert (string-equal test-out expected-result) - (test test-out expected-result) - "Test:~s didnt match ~S" - test-out expected-result)))) +(let ((tests '(((:foo) "FOO") + ((:foo-bar) "FOO_BAR") + (("foo") "\"foo\"") + (('|foo bar|) "\"foo bar\"") + ((:foo :table-alias :bar) "FOO BAR" ) + ((:foo_bar :table-alias :bar-bast) "FOO_BAR BAR_BAST") + (("foo" :table-alias "Bar") "\"foo\" \"Bar\"") + (('|foo bar| :table-alias :bast) "\"foo bar\" BAST")))) + + (push + `(deftest :syntax/sql-ident-table + (values ,@(mapcar + #'(lambda (args) + `(clsql:sql (make-instance 'clsql-sys:sql-ident-table + :name ,@args))) + (mapcar #'first tests))) + ,@(mapcar #'second tests)) + *rt-syntax*)) -- 2.34.1