X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=tests%2Ftest-basic.lisp;h=4d277e358d14ba2c722940c36e02df888371048d;hp=5bdc0a3efbfeccbd156d01351e5b197a5bd286e7;hb=374df8f34a7214e08fc4cfc5d734d024acdbf9ca;hpb=4a2e3a71a1ce79482ba704ec815013de2c986274 diff --git a/tests/test-basic.lisp b/tests/test-basic.lisp index 5bdc0a3..4d277e3 100644 --- a/tests/test-basic.lisp +++ b/tests/test-basic.lisp @@ -7,9 +7,7 @@ ;;;; Author: Kevin M. Rosenberg ;;;; Created: Mar 2002 ;;;; -;;;; $Id$ -;;;; -;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg +;;;; This file, part of CLSQL, is Copyright (c) 2002-2010 by Kevin M. Rosenberg ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License @@ -192,12 +190,7 @@ results) (destructuring-bind (int bigint) row (push (list (integerp int) - (if (and (eq :odbc *test-database-type*) - (eq :postgresql *test-database-underlying-type*)) - ;; ODBC/Postgresql may return returns bigints as strings or integer - ;; depending upon the platform - t - (integerp bigint))) + (integerp bigint)) results))))) ((t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t) (t t))) @@ -215,18 +208,40 @@ )) nil) (deftest :basic/bigtext/2 - (dotimes (n 10) - (with-dataset *ds-bigtext* - (let* ((len (random 7500)) - (str (make-string len :initial-element #\a)) - (cmd (format nil "INSERT INTO testbigtext (a) VALUES ('~a')" str))) - (execute-command cmd) - (let ((a (first (query "SELECT a from testbigtext" - :flatp t :field-names nil)))) - (assert (string= str a) (str a) - "mismatch on a. inserted: ~a returned: ~a" len (length a))) - ))) - nil) + (flet ((random-char () + (let ((alphabet "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + (idx (random 52))) + (elt alphabet idx)))) + (dotimes (n 10) + (with-dataset *ds-bigtext* + (let* ((len (random 7500)) + (str (coerce (make-array len + :initial-contents (loop repeat len collect (random-char))) + 'string)) + (cmd (format nil "INSERT INTO testbigtext (a) VALUES ('~a')" str))) + (execute-command cmd) + (let ((a (first (query "SELECT a from testbigtext" + :flatp t :field-names nil)))) + (assert (string= str a) (str a) + "mismatch on randomized bigtext(~a) inserted: ~s returned: ~s" len str a)) + )))) + nil) + + (deftest :basic/reallybigintegers/1 + (with-dataset *ds-reallybigintegers* + (let* ((a (1- (expt 2 64))) + (b (- (expt 2 64) 2)) + (c (expt 2 63)) + (d (expt 2 62)) + (sql (format nil "INSERT INTO testreallybigintegers + VALUES (~A, ~A, ~A, ~A)" + a b c d))) + (query sql) + (let ((results + (query + (format nil "SELECT * FROM testreallybigintegers")))) + (equal `(,a ,b ,c ,d) (car results))))) + t) )) @@ -286,3 +301,14 @@ (def-dataset *ds-bigtext* (:setup "CREATE TABLE testbigtext(a varchar(7500))") (:cleanup "DROP TABLE testbigtext")) + +(def-dataset *ds-reallybigintegers* + (:setup (lambda () + (ignore-errors + (clsql:execute-command "DROP TABLE testreallybigintegers")) + (clsql:execute-command + "CREATE TABLE testreallybigintegers( a BIGINT UNSIGNED, + b BIGINT UNSIGNED, + c BIGINT UNSIGNED, + d BIGINT UNSIGNED )"))) + (:cleanup "DROP TABLE testreallybigintegers"))