;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Mar 2002
;;;;
-;;;; $Id: tester-clsql.cl,v 1.3 2002/04/08 03:50:00 kevin Exp $
+;;;; $Id: tester-clsql.cl,v 1.7 2002/04/24 16:10:55 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; *************************************************************************
+;;; This test suite looks for a configuration file named "test.config"
+;;; This file contains a single a-list that specifies the connection
+;;; specs for each database type to be tested. For example, to test all
+;;; platforms, a sample "test.config" may look like:
+;;;
+;;; ((:mysql ("localhost" "a-mysql-db" "user1" "secret"))
+;;; (:aodbc ("my-dsn" "a-user" "pass"))
+;;; (:postgresql ("localhost" "another-db" "user2" "dont-tell"))
+;;; (:postgresql-socket ("pg-server" "a-db-name" "user" "secret-password")))
+
+
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
(in-package :cl-user)
;;;; Testing functions
(defun transform-float-1 (i)
- (* i (abs (/ i 2)) (expt 10 (* 2 i))))
+ (coerce (* i (abs (/ i 2)) (expt 10 (* 2 i))) 'double-float))
(defun transform-bigint-1 (i)
(* i (expt 10 (* 3 (abs i)))))
(format nil "Invalid types field (~S) passed to test-table-row" types))))
(test (transform-float-1 int)
float
- :test #'=
+ :test #'eql
:fail-info
(format nil "Wrong float value ~A for int ~A (row ~S)" float int row))
- (test (parse-double str)
- float
- :test #'eql
- :fail-info (format nil "Wrong string value ~A" str))))
-
-
+ (test float
+ (parse-double str)
+ :test #'double-float-equal
+ :fail-info (format nil "Wrong string value ~A for double ~A~%Row: ~S"
+ str float row))))
+
+
+(defun double-float-equal (a b)
+ (if (zerop a)
+ (if (zerop b)
+ t
+ nil)
+ (let ((diff (abs (/ (- a b) a))))
+ (if (> diff (* 10 double-float-epsilon))
+ nil
+ t))))
+
(defun drop-test-table (db)
(clsql:execute-command "DROP TABLE test_clsql"))
(defun do-test ()
(let ((specs (read-specs)))
- (mysql-low-level specs)
- (mysql-table-test specs)
- (pgsql-table-test specs)
- (pgsql-socket-table-test specs)
- (aodbc-table-test specs)
- ))
+ (with-tests (:name "CLSQL")
+ (mysql-low-level specs)
+ (mysql-table-test specs)
+ (pgsql-table-test specs)
+ (pgsql-socket-table-test specs)
+ (aodbc-table-test specs)
+ )))
(do-test)