Update of /project/pg/cvsroot/pg In directory common-lisp.net:/tmp/cvs-serv13025
Modified Files: pg-tests.lisp Log Message: added pbe test Date: Mon Mar 8 09:37:43 2004 Author: pvaneynde
Index: pg/pg-tests.lisp diff -u pg/pg-tests.lisp:1.2 pg/pg-tests.lisp:1.3 --- pg/pg-tests.lisp:1.2 Fri Mar 5 13:08:08 2004 +++ pg/pg-tests.lisp Mon Mar 8 09:37:43 2004 @@ -7,7 +7,7 @@ ;; ;; These tests assume that a table named "test" is defined in the ;; system catalog, and that the user identified in -;; CALL-WITH-TEST-CONNECTION has the rights to access that table. +;; CALL-WITH-TEST-CONNECTION has the rights to access that table.
(defpackage :pg-tests (:use :cl @@ -279,6 +279,42 @@ (pg-exec conn "DROP TABLE pgmt")))
+(defun test-pbe () + (with-test-connection (conn) + (when (pg-supports-pbe conn) + (format *debug-io* "~&Testing pbe...") + (let ((res nil) + (count 0) + (created nil)) + (unwind-protect + (progn + (pg-exec conn "CREATE TABLE count_test(key int, val int)") + (setq created t) + (format *debug-io* "~&table created") + (pg-prepare conn "ct_insert" + "INSERT INTO count_test VALUES ($1, $2)" + '("int4" "int4")) + (loop :for i :from 1 :to 100 + :do + (pg-bind conn + "ct_portal" "ct_insert" + `((:int32 ,i) + (:int32 ,(* i i)))) + (pg-execute conn "ct_portal") + (pg-close-portal conn "ct_portal")) + (format *debug-io* "~&data inserted") + (setq res (pg-exec conn "SELECT count(val) FROM count_test")) + (assert (eql 100 (first (pg-result res :tuple 0)))) + (setq res (pg-exec conn "SELECT sum(key) FROM count_test")) + (assert (eql 5050 (first (pg-result res :tuple 0)))) + ;; this iterator does the equivalent of the sum(key) SQL statement + ;; above, but on the client side. + (pg-for-each conn "SELECT key FROM count_test" + (lambda (tuple) (incf count (first tuple)))) + (assert (= 5050 count))) + (when created + (pg-exec conn "DROP TABLE count_test"))))))) +
(defun test () (with-test-connection (conn) @@ -304,7 +340,8 @@ (test-notifications) (test-lo) (test-lo-read) - #+cmu (test-lo-import)) + #+cmu (test-lo-import) + (test-pbe))
;; EOF