From 53a8a70b59242746dc6e33f8d06d923a8327387c Mon Sep 17 00:00:00 2001 From: mrkaspa Date: Sun, 14 Aug 2016 18:51:54 -0500 Subject: [PATCH] test added --- lib/exstreme/graph.ex | 2 +- test/exstreme/.#graph_test.exs | 1 - test/exstreme/graph_test.exs | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) delete mode 120000 test/exstreme/.#graph_test.exs create mode 100644 test/exstreme/graph_test.exs diff --git a/lib/exstreme/graph.ex b/lib/exstreme/graph.ex index bf5dd50..0707a39 100644 --- a/lib/exstreme/graph.ex +++ b/lib/exstreme/graph.ex @@ -74,7 +74,7 @@ defmodule Exstreme.Graph do end @doc """ - Gets the nodes before the current one + Gets the nodes before the current one """ @spec get_before_nodes(t, atom) :: [atom] def get_before_nodes(%Graph{connections: connections}, gnode) do diff --git a/test/exstreme/.#graph_test.exs b/test/exstreme/.#graph_test.exs deleted file mode 120000 index a19afee..0000000 --- a/test/exstreme/.#graph_test.exs +++ /dev/null @@ -1 +0,0 @@ -michelperez@Michels-MacBook-Pro.local.86177 \ No newline at end of file diff --git a/test/exstreme/graph_test.exs b/test/exstreme/graph_test.exs new file mode 100644 index 0000000..ac2c8ac --- /dev/null +++ b/test/exstreme/graph_test.exs @@ -0,0 +1,40 @@ +defmodule Exstreme.GraphTest do + use ExUnit.Case + use Exstreme.Common + alias Exstreme.Graph + doctest Exstreme.Graph + + setup do + graph = graph_many_nodes + {:ok, graph: graph, n1: Graph.nid(graph, :n1), + n3: Graph.nid(graph, :n3), n4: Graph.nid(graph, :n4), + n5: Graph.nid(graph, :n5), f1: Graph.nid(graph, :f1)} + end + + test "graph with many nodes has 7 nodes and 7 connections", %{graph: graph} do + assert Graph.count_nodes(graph) == 7 + assert Graph.count_connections(graph) == 7 + end + + test "connection stats for graph with many nodes", %{graph: graph} do + assert Graph.connections_stats(graph) == %{begin: 1, connected: 5, end: 1} + end + + test "the start gnode is n1", %{graph: graph, n1: n1} do + assert Graph.find_start_node(graph) == [n1] + end + + test "the last gnode is n5", %{graph: graph, n5: n5} do + assert Graph.find_last_node(graph) == [n5] + end + + test "the nodes before f1 are n4 and n3", %{graph: graph, f1: f1, n3: n3, n4: n4} do + res = Graph.get_before_nodes(graph, f1) + assert res == [n4, n3] + end + + test "the nodes after f1 are n4 and n3", %{graph: graph, f1: f1, n5: n5} do + res = Graph.get_after_nodes(graph, f1) + assert res == [n5] + end +end