1 | ;;; Copyright (C) 2008 Magnus Henoch |
---|
2 | ;;; |
---|
3 | ;;; This program is free software; you can redistribute it and/or |
---|
4 | ;;; modify it under the terms of the GNU General Public License as |
---|
5 | ;;; published by the Free Software Foundation; either version 2 of the |
---|
6 | ;;; License, or (at your option) any later version. |
---|
7 | ;;; |
---|
8 | ;;; This program is distributed in the hope that it will be useful, |
---|
9 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | ;;; General Public License for more details. |
---|
12 | ;;; |
---|
13 | ;;; You should have received a copy of the GNU General Public License |
---|
14 | ;;; along with this program; if not, write to the Free Software |
---|
15 | ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
16 | |
---|
17 | (in-package :darcs-tests) |
---|
18 | |
---|
19 | (def-suite get-common-and-uncommon-suite :in darcs-suite) |
---|
20 | (in-suite get-common-and-uncommon-suite) |
---|
21 | |
---|
22 | (defun gen-patchinfo () |
---|
23 | (darcs::make-patchinfo :name (format nil "~A" (random 1000)))) |
---|
24 | |
---|
25 | (defmacro tri-equal (form one two three) |
---|
26 | `(multiple-value-bind (one two three) ,form |
---|
27 | (is (equal ,one one)) |
---|
28 | (is (equal ,two two)) |
---|
29 | (is (equal ,three three)))) |
---|
30 | |
---|
31 | (test gcau-nil |
---|
32 | (tri-equal (darcs::get-common-and-uncommon nil nil) |
---|
33 | nil nil nil)) |
---|
34 | |
---|
35 | (test gcau-only-common |
---|
36 | (for-all ((patchinfos (gen-list :elements #'gen-patchinfo))) |
---|
37 | (tri-equal (darcs::get-common-and-uncommon (list patchinfos) (list patchinfos)) |
---|
38 | patchinfos nil nil))) |
---|
39 | |
---|
40 | (test gcau-only-ours |
---|
41 | (for-all ((patchinfos (gen-list :elements #'gen-patchinfo))) |
---|
42 | (tri-equal (darcs::get-common-and-uncommon (list patchinfos) nil) |
---|
43 | nil patchinfos nil))) |
---|
44 | |
---|
45 | (test gcau-only-theirs |
---|
46 | (for-all ((patchinfos (gen-list :elements #'gen-patchinfo))) |
---|
47 | (tri-equal (darcs::get-common-and-uncommon nil (list patchinfos)) |
---|
48 | nil nil patchinfos))) |
---|
49 | |
---|
50 | (test gcau-both |
---|
51 | (for-all ((common (gen-list :elements #'gen-patchinfo)) |
---|
52 | (only-ours (gen-list :elements #'gen-patchinfo)) |
---|
53 | (only-theirs (gen-list :elements #'gen-patchinfo))) |
---|
54 | (let ((ours (list (append common only-ours))) |
---|
55 | (theirs (list (append common only-theirs)))) |
---|
56 | (tri-equal (darcs::get-common-and-uncommon ours theirs) |
---|
57 | common only-ours only-theirs)))) |
---|
58 | |
---|