(in-package #:cl-graph-test-system)
(defsystem cl-graph-test
- :version "0.1"
:author "Gary Warren King <gwking@metabang.com>"
:maintainer "Gary Warren King <gwking@metabang.com>"
: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
--- /dev/null
+(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")))
+