diff --git a/git-graph-tests.el b/git-graph-tests.el new file mode 100644 index 0000000..3141f69 --- /dev/null +++ b/git-graph-tests.el @@ -0,0 +1,51 @@ +;;; git-graph-tests.el ---Tests for git-graph.el -*- lexical-binding: t -*- + +;; Copyright (c) 2015 Correl Roush + +;;; License: + +;; 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 3, 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 GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'git-graph) + +;; 1---2---5---6---7 [master] +;; \ / +;; 3---4 [topic] +(ert-deftest automatically-group-nodes () + (let* ((example-graph + (git-graph/group-topo + (list (git-graph/make-node 7 '(6) '((label . master))) + (git-graph/make-node 6 '(5 4)) + (git-graph/make-node 5 '(2)) + (git-graph/make-node 4 '(3) '((label . topic))) + (git-graph/make-node 3 '(2)) + (git-graph/make-node 2 '(1)) + (git-graph/make-node 1 '())))) + (master-nodes (seq-map #'git-graph/node-id + (seq-filter (lambda (node) (eq 7 (git-graph/node-group node))) + example-graph))) + (topic-nodes (seq-map #'git-graph/node-id + (seq-filter (lambda (node) (eq 4 (git-graph/node-group node))) + example-graph)))) + (should (equal '(7 6 5 2 1) master-nodes)) + (should (equal '(4 3) topic-nodes)))) + +;;; git-graph-tests.el ends here