;;; Copyright (C) 2008 Magnus Henoch ;;; ;;; This program is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU General Public License as ;;; published by the Free Software Foundation; either version 2 of the ;;; License, or (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program; if not, write to the Free Software ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA (in-package :darcs-tests) (def-suite get-common-and-uncommon-suite :in darcs-suite) (in-suite get-common-and-uncommon-suite) (defun gen-patchinfo () (darcs::make-patchinfo :name (format nil "~A" (random 1000)))) (defmacro tri-equal (form one two three) `(multiple-value-bind (one two three) ,form (is (equal ,one one)) (is (equal ,two two)) (is (equal ,three three)))) (test gcau-nil (tri-equal (darcs::get-common-and-uncommon nil nil) nil nil nil)) (test gcau-only-common (for-all ((patchinfos (gen-list :elements #'gen-patchinfo))) (tri-equal (darcs::get-common-and-uncommon (list patchinfos) (list patchinfos)) patchinfos nil nil))) (test gcau-only-ours (for-all ((patchinfos (gen-list :elements #'gen-patchinfo))) (tri-equal (darcs::get-common-and-uncommon (list patchinfos) nil) nil patchinfos nil))) (test gcau-only-theirs (for-all ((patchinfos (gen-list :elements #'gen-patchinfo))) (tri-equal (darcs::get-common-and-uncommon nil (list patchinfos)) nil nil patchinfos))) (test gcau-both (for-all ((common (gen-list :elements #'gen-patchinfo)) (only-ours (gen-list :elements #'gen-patchinfo)) (only-theirs (gen-list :elements #'gen-patchinfo))) (let ((ours (list (append common only-ours))) (theirs (list (append common only-theirs)))) (tri-equal (darcs::get-common-and-uncommon ours theirs) common only-ours only-theirs))))