summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-01-29 20:09:10 +0100
committerPatrick Simianer <p@simianer.de>2014-01-29 20:09:10 +0100
commit9f0689fe2ba4ff3cd48e9b0418ec3fb9eb0ac7ee (patch)
tree6807c77589543921be8f616476ca6f9cbb8b505f
parent648f2f583d37f7921a5e6d5fb9d70cc1a31fb837 (diff)
rake test
-rw-r--r--Makefile3
-rw-r--r--Rakefile10
-rwxr-xr-xtest/test_dags.rb (renamed from test/dags.rb)12
3 files changed, 19 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index e6e5fbe..b351904 100644
--- a/Makefile
+++ b/Makefile
@@ -10,3 +10,6 @@ install:
clean:
gem uninstall nlp_ruby -v $(version)
+rake_test:
+ rake test
+
diff --git a/Rakefile b/Rakefile
index e69de29..f9f6615 100644
--- a/Rakefile
+++ b/Rakefile
@@ -0,0 +1,10 @@
+require 'rake/testtask'
+
+
+Rake::TestTask.new do |t|
+ t.libs << 'test'
+end
+
+desc "Run tests"
+task :default => :test
+
diff --git a/test/dags.rb b/test/test_dags.rb
index 0e90d1b..08a96a2 100755
--- a/test/dags.rb
+++ b/test/test_dags.rb
@@ -8,7 +8,7 @@ class TestDAG < Test::Unit::TestCase
def test_viterbi
semiring = ViterbiSemiring.new
- graph, nodes_by_label = DAG::read_graph_from_json('dags/example.json', semiring)
+ graph, nodes_by_label = DAG::read_graph_from_json('test/dags/example.json', semiring)
DAG::viterbi(graph, semiring, nodes_by_label['0'])
assert_equal(nodes_by_label['100'].score, 0.003)
end
@@ -16,31 +16,31 @@ class TestDAG < Test::Unit::TestCase
# no negative weights here!
def test_dijkstra
semiring = RealSemiring.new
- graph, nodes_by_label = DAG::read_graph_from_json('dags/example.json', semiring)
+ graph, nodes_by_label = DAG::read_graph_from_json('test/dags/example.json', semiring)
DAG::dijkstra(graph, semiring, nodes_by_label['0'])
assert_equal(nodes_by_label['100'].score, 0.5)
end
def test_bellman_ford
semiring = RealSemiring.new
- graph, nodes_by_label = DAG::read_graph_from_json('dags/example.json', semiring)
+ graph, nodes_by_label = DAG::read_graph_from_json('test/dags/example.json', semiring)
DAG::bellman_ford(graph, semiring, nodes_by_label['0'])
assert_equal(nodes_by_label['100'].score, 0.5)
end
def test_floyd
- graph, nodes_by_label = DAG::read_graph_from_json('dags/example.json')
+ graph, nodes_by_label = DAG::read_graph_from_json('test/dags/example.json')
d = DAG::floyd(graph)
assert_equal(d[0][graph.size-1], 0.5)
end
def test_dfs
- graph, nodes_by_label = DAG::read_graph_from_json('dags/example.json')
+ graph, nodes_by_label = DAG::read_graph_from_json('test/dags/example.json')
assert_equal(nodes_by_label['100'], DAG::dfs(nodes_by_label['0'], '100'))
end
def test_bfs
- graph, nodes_by_label = DAG::read_graph_from_json('dags/example.json')
+ graph, nodes_by_label = DAG::read_graph_from_json('test/dags/example.json')
assert_equal(nodes_by_label['100'], DAG::bfs(nodes_by_label['0'], '100'))
end
end