Skip to content

Commit

Permalink
test added
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkaspa committed Aug 14, 2016
1 parent 41008c6 commit 53a8a70
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/exstreme/graph.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/exstreme/.#graph_test.exs

This file was deleted.

40 changes: 40 additions & 0 deletions test/exstreme/graph_test.exs
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 53a8a70

Please sign in to comment.