-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathalgorithms_test.rb
More file actions
31 lines (26 loc) · 870 Bytes
/
algorithms_test.rb
File metadata and controls
31 lines (26 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'minitest/autorun'
require './lib/visual_graphs/algorithms'
require './lib/visual_graphs/weighted_graph'
module VisualGraphs
class AlgorithmsTest < Minitest::Test
def setup
@filepathToWeighted = 'test/resources/test_weighted_graph.json'
@filepath = 'test/resources/test_data.json'
end
def basic_test_Dijkstra
graph = WeightedGraph.load_from_json(@filepathToWeighted)
dist = Algorithms.dijkstra(graph, "1")
assert_equal [0, 3, 5], dist, 'wrong dist'
end
def wrong_graph_Dijkstra
assert_raises WrongParamsForAlgorithm do
graph = Graph.load_from_json(@filepath)
Algorithms.dijkstra(graph, "1")
end
assert_raises WrongParamsForAlgorithm do
graph = WeightedGraph.load_from_json(@filepathToWeighted)
Algorithms.dijkstra(graph, "120")
end
end
end
end