Permalink
Browse files

Refactor tests.

  • Loading branch information...
1 parent a307fc0 commit 61f6b170e93ba2dbb834b0df2bbe6359e214ae10 @filonenko-mikhail committed Jun 8, 2011
Showing with 36 additions and 20 deletions.
  1. +3 −2 README
  2. +7 −2 cl-ewkb.asd
  3. +26 −16 test/tests.lisp
View
5 README
@@ -1,10 +1,11 @@
cl-ewkb is a geospatial library, based on cl-wkb, that implements the OGC Well-Known Binary geographic geometry data model with PostGIS 3d, 4d extensions, and provides WKB and EWKB encoding and decoding functionality. cl-wkb author is J.P. Larocue.
+Library also provide module cl-wkb, which has CLOS-based API like http://enroutesystems.com/software/cl-wkb/ with PostGIS extensions.
Depends on:
ieee-floats
flexi-streams
-PostGIS extension WKB described in postgis-1.5/doc/ZMSgeoms.txt
+PostGIS extension WKB is described in postgis-1.5/doc/ZMSgeoms.txt
All extensions are supported: 3dz, 3dm, 4d, embedded SRID.
Exported structs
@@ -49,7 +50,7 @@ Example:
Getting data from postgresql and decode it:
-(decode (caar (query (:select (:ST_AsEWKB "SRID=4326;LINESTRING(0 0 1 2, 1 1 2 3, 2 2 3 4)")))))
+(decode (caar (postmodern:query (:select (:ST_AsEWKB "SRID=4326;LINESTRING(0 0 1 2, 1 1 2 3, 2 2 3 4)")))))
Result:
View
@@ -4,7 +4,7 @@
(in-package :cl-ewkb-system)
(defsystem :cl-ewkb
- :version "0.1"
+ :version "0.2"
:maintainer "Michael Filonenko <filonenko.mikhail@gmail.com>"
:author "Michael Filonenko <filonenko.mikhail@gmail.com>"
:licence "MIT"
@@ -18,8 +18,13 @@
:components ((:file "package")
(:file "wkb" :depends-on ("package"))))))
+(defpackage :cl-ewkb-tests-system
+ (:use :common-lisp :asdf))
+
+(in-package :cl-ewkb-tests-system)
+
(defsystem :cl-ewkb-tests
:depends-on (:cl-ewkb :postmodern)
:components
- ((:module :cl-ewkb
+ ((:module :test
:components ((:file "tests")))))
View
@@ -1,14 +1,22 @@
-;;(defpackage :cl-postgis-tests
-;; (:use :common-lisp :postmodern)
-;; (:export #:prompt-connection))
+(defpackage :cl-ewkb-tests
+ (:use :common-lisp :postmodern :cl-ewkb) ;; or cl-wkb
+ (:export #:test-cl-ewkb))
-;;(in-package :cl-postgis-tests)
+(in-package :cl-ewkb-tests)
+(defparameter *test-connection* '("osm" "guest" "guest" "gis-lab.info"))
-(require :postmodern)
-(use-package :postmodern)
-
-;;(connect-toplevel "michael" "michael" "xxx" "localhost")
+(defun prompt-connection (&optional (list *test-connection*))
+ (flet ((ask (name pos)
+ (format *query-io* "~a (enter to keep '~a'): " name (nth pos list))
+ (finish-output *query-io*)
+ (let ((answer (read-line *query-io*)))
+ (unless (string= answer "") (setf (nth pos list) answer)))))
+ (format *query-io* "~%To run this test, you must configure a database connection.~%")
+ (ask "Database name" 0)
+ (ask "User" 1)
+ (ask "Password" 2)
+ (ask "Hostname" 3)))
(defmacro with-gensyms ((&rest names) &body body)
`(let ,(loop for n in names collect `(,n (gensym)))
@@ -124,12 +132,14 @@ cases."
(check
(equalp geometrycollection (encode (decode geometrycollection))))))
-(deftest test-postgis ()
+(deftest test-cl-ewkb ()
+ (prompt-connection)
+ (with-connection *test-connection*
(combine-results
- (gispoint-test)
- (gislinestring-test)
- (gispolygon-test)
- (gismultipoint-test)
- (gismultilinestring-test)
- (gismultipolygon-test)
- (gisgeometrycollection-test)))
+ (gispoint-test)
+ (gislinestring-test)
+ (gispolygon-test)
+ (gismultipoint-test)
+ (gismultilinestring-test)
+ (gismultipolygon-test)
+ (gisgeometrycollection-test))))

0 comments on commit 61f6b17

Please sign in to comment.