X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=unit-tests%2Ftest-api.lisp;fp=unit-tests%2Ftest-api.lisp;h=c7125436fbba11bb195989f15910a634c1f3ebf0;hb=46dc073919f9c43c4c17059d8b6c84cc2d1729e3;hp=0000000000000000000000000000000000000000;hpb=363f6a0a95ffb2e6c7883c37b1fe999ffe28db1f;p=cl-graph.git 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"))) +