From 46dc073919f9c43c4c17059d8b6c84cc2d1729e3 Mon Sep 17 00:00:00 2001 From: Gary King Date: Sat, 6 Sep 2008 20:59:33 -0400 Subject: [PATCH] Add test-api.lisp; re-organize cl-graph-test.asd darcs-hash:20080907005933-3cc5d-f89f39ab5829c9d33c96febfc52e77eb3c2d25cc.gz --- cl-graph-test.asd | 21 ++++++++++++++------- unit-tests/test-api.lisp | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 unit-tests/test-api.lisp diff --git a/cl-graph-test.asd b/cl-graph-test.asd index 529501a..b5532ed 100644 --- a/cl-graph-test.asd +++ b/cl-graph-test.asd @@ -5,20 +5,27 @@ (in-package #:cl-graph-test-system) (defsystem cl-graph-test - :version "0.1" :author "Gary Warren King " :maintainer "Gary Warren King " :licence "MIT Style License" :description "Tests for CL-Graph" - :components ((:module - "unit-tests" + :components ((:module + "setup" + :pathname "unit-tests/" :components ((:file "package") (:file "test-graph" :depends-on ("package")) - (:file "test-graph-container" :depends-on ("test-graph")) - (:file "test-connected-components" :depends-on ("test-graph")) - (:file "test-graph-metrics" :depends-on ("test-graph")) - (:file "test-graph-algorithms" :depends-on ("test-graph")) + )) + (:module + "unit-tests" + :pathname "unit-tests/" + :depends-on ("setup") + :components + ((:file "test-graph-container") + (:file "test-connected-components") + (:file "test-graph-metrics") + ;;(:file "test-graph-algorithms") + (:file "test-api") )) (:module diff --git a/unit-tests/test-api.lisp b/unit-tests/test-api.lisp new file mode 100644 index 0000000..c712543 --- /dev/null +++ b/unit-tests/test-api.lisp @@ -0,0 +1,39 @@ +(in-package #:cl-graph-test) + +(defun build-single-diamond-graph (style) +;;;; /- c -\ +;;;; a - b d - e +;;;; \- i -/ + (let ((g (make-container 'graph-container))) + (loop for (source . target) in '((a . b) + (b . c) (b . i) (c . d) (i . d) + (d . e)) do + (add-edge-between-vertexes g source target :edge-type style)) + g)) + +(defun build-three-way-graph () + (let ((g (make-container 'graph-container))) + (loop for (source . target) in '((a . b) + (b . c) (b . d) (b . e) + (c . f) (d . f) (e . f) + (f . g)) do + (add-edge-between-vertexes g source target)) + g)) + +(deftestsuite test-api (cl-graph-test) + (g)) + +(addtest (test-api + :documentation "case 214") + source-edges + (let* ((g (build-single-diamond-graph :directed)) + (b (find-vertex g 'b)) + (target-edges (target-edges b)) + (source-edges (source-edges b))) + (ensure (every (lambda (edge) + (eq b (source-vertex edge))) + source-edges) :report "sources") + (ensure (every (lambda (edge) + (eq b (target-vertex edge))) + target-edges) :report "targets"))) + -- 1.7.10.4