From 798e38d5fa558761fa81936e670115924004ebd5 Mon Sep 17 00:00:00 2001 From: Anton Johansson Date: Sat, 18 Oct 2008 14:14:01 +0200 Subject: [PATCH] Made tests compile, changed merge error with MySearcherTest, changed MySearcherLatexTest to use loops. --- test/MySearcherLatexTest.java | 51 ++++++++++++ test/MySearcherTest.java | 182 ++++++++++++++---------------------------- test/MySearcherTestLaTeX.java | 124 ---------------------------- 3 files changed, 109 insertions(+), 248 deletions(-) create mode 100644 test/MySearcherLatexTest.java rewrite test/MySearcherTest.java (74%) delete mode 100644 test/MySearcherTestLaTeX.java diff --git a/test/MySearcherLatexTest.java b/test/MySearcherLatexTest.java new file mode 100644 index 0000000..4c3cdc6 --- /dev/null +++ b/test/MySearcherLatexTest.java @@ -0,0 +1,51 @@ +import java.io.File; +import junit.framework.*; + +public class MySearcherLatexTest extends TestCase { + String[] from = {"Tegsbron" , "Flygplatsen" , "MIT" , "Nydala" , "Teg"}; + String[] to = {"Nydala" , "Begbilar" , "Flygplatsen" , "Gamlia" , "Foa"}; + + public MySearcherLatexTest(String name) { + super(name); + } + + public void testBreadthFirst() { + for (int i = 0; i < from.length; i++) { + MySearcher my = new MySearcher(); + my.setMap(new File("maps/umea_map.xml")); + System.out.println("\\subsection{Test Bredden-först}"); + System.out.println("\\subsubsection{From: " + from[i] + " to " + to[i] + "}"); + System.out.println(my.breadthFirst(from[i], to[i])); + } + } + + public void testDepthFirst() { + for (int i = 0; i < from.length; i++) { + MySearcher my = new MySearcher(); + my.setMap(new File("maps/umea_map.xml")); + System.out.println("\\subsection{Test Djupet-först}"); + System.out.println("\\subsubsection{From: " + from[i] + " to " + to[i] + "}"); + System.out.println(my.depthFirst(from[i], to[i])); + } + } + + public void testAStar() { + for (int i = 0; i < from.length; i++) { + MySearcher my = new MySearcher(); + my.setMap(new File("maps/umea_map.xml")); + System.out.println("\\subsection{Test A*}"); + System.out.println("\\subsubsection{From: " + from[i] + " to " + to[i] + "}"); + System.out.println(my.aStar(from[i], to[i], true)); + } + } + + public void testGreedy() { + for (int i = 0; i < from.length; i++) { + MySearcher my = new MySearcher(); + my.setMap(new File("maps/umea_map.xml")); + System.out.println("\\subsection{Test Girig sökning}"); + System.out.println("\\subsubsection{From: " + from[i] + " to " + to[i] + "}"); + System.out.println(my.greedySearch(from[i], to[i])); + } + } +} \ No newline at end of file diff --git a/test/MySearcherTest.java b/test/MySearcherTest.java dissimilarity index 74% index 4bdfa34..a0c75f8 100644 --- a/test/MySearcherTest.java +++ b/test/MySearcherTest.java @@ -1,124 +1,58 @@ -import java.io.File; -import junit.framework.*; - -public class MySearcherTest extends TestCase -{ - String from1 = "Tegsbron"; - String to1 = "Nydala"; - - String from2 = "Flygplatsen"; - String to2 = "Begbilar"; - - String from3 = "MIT"; - String to3 = "Flygplatsen"; - - String from4 = "Nydala"; - String to4 = "Gamlia"; - - String from5 = "Teg"; - String to5 = "Foa"; - - MySearcher my; - public MySearcherTest(String name) { - super (name); - my = new MySearcher(); - my.setMap(new File("maps/umea_map.xml")); - } - - public void testMap() { - System.out.println("----------Test Map-------------"); - System.out.println(my.toString()); - } - - public void testBreadthFirst() { - System.out.println("\\subsection{Test Breadthfirst}"); - System.out.println("\\subsubsection{From: " + from1 + " to " + to1 + "}"); - System.out.println(my.breadthFirst(from1, to1)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from2 + " to " + to2 + "}"); - System.out.println(my.breadthFirst(from2, to2)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from3 + " to " + to3 + "}"); - System.out.println(my.breadthFirst(from3, to3)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from4 + " to " + to4 + "}"); - System.out.println(my.breadthFirst(from4, to4)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from5 + " to " + to5 + "}"); - System.out.println(my.breadthFirst(from5, to5)); - - } - - public void testDepthFirst() { - System.out.println("\\subsection{Test Depthfirst}"); - System.out.println("\\subsubsection{From: " + from1 + " to " + to1 + "}"); - System.out.println(my.depthFirst(from1, to1)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from2 + " to " + to2 + "}"); - System.out.println(my.depthFirst(from2, to2)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from3 + " to " + to3 + "}"); - System.out.println(my.depthFirst(from3, to3)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from4 + " to " + to4 + "}"); - System.out.println(my.depthFirst(from4, to4)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from5 + " to " + to5 + "}"); - System.out.println(my.depthFirst(from5, to5)); - - } - - public void testAStar() { - System.out.println("\\subsection{Test A*}"); - System.out.println("\\subsubsection{From: " + from1 + " to " + to1 + "}"); - System.out.println(my.aStar(from1, to1, true)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from2 + " to " + to2 + "}"); - System.out.println(my.aStar(from2, to2, true)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from3 + " to " + to3 + "}"); - System.out.println(my.aStar(from3, to3, true)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from4 + " to " + to4 + "}"); - System.out.println(my.aStar(from4, to4, true)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from5 + " to " + to5 + "}"); - System.out.println(my.aStar(from5, to5, true)); - - } - - public void testGreedy() { - System.out.println("\\subsection{Test GreedySearch}"); - System.out.println("\\subsubsection{From: " + from1 + " to " + to1 + "}"); - System.out.println(my.greedySearch(from1, to1)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from2 + " to " + to2 + "}"); - System.out.println(my.greedySearch(from2, to2)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from3 + " to " + to3 + "}"); - System.out.println(my.greedySearch(from3, to3)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from4 + " to " + to4 + "}"); - System.out.println(my.greedySearch(from4, to4)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from5 + " to " + to5 + "}"); - System.out.println(my.greedySearch(from5, to5)); - - } -} +import java.io.File; +import junit.framework.*; + +public class MySearcherTest extends TestCase +{ + String from1 = "Nydala"; + String to1 = "Kyrkan"; + String from2 = "Berghem"; + String to2 = "Nydala"; + + MySearcher my; + public MySearcherTest(String name) { + super (name); + my = new MySearcher(); + my.setMap(new File("maps/umea_map.xml")); + } + + public void testMap() { + System.out.println("----------Test Map-------------"); + System.out.println(my.toString()); + } + + public void testBreadthFirst() { + System.out.println("----------Test Breadthfirst-------------"); + System.out.println("From: " + from1 + " to " + to1); + System.out.println(my.breadthFirst(from1, to1)); + my.setMap(new File("maps/umea_map.xml")); + System.out.println("From: " + from2 + " to " + to2); + System.out.println(my.breadthFirst(from2, to2)); + } + + public void testDepthFirst() { + System.out.println("----------Test Depthfirst-------------"); + System.out.println("From: " + from1 + " to " + to1); + System.out.println(my.depthFirst(from1, to1)); + my.setMap(new File("maps/umea_map.xml")); + System.out.println("From: " + from2 + " to " + to2); + System.out.println(my.depthFirst(from2, to2)); + } + + public void testAStar() { + System.out.println("----------Test A*-------------"); + System.out.println("From: " + from1 + " to " + to1); + System.out.println(my.aStar(from1, to1, true)); + my.setMap(new File("maps/umea_map.xml")); + System.out.println("From: " + from2 + " to " + to2); + System.out.println(my.aStar(from2, to2, true)); + } + + public void testGreedy() { + System.out.println("----------Test GreedySearch-------------"); + System.out.println("From: " + from1 + " to " + to1); + System.out.println(my.greedySearch(from1, to1)); + my.setMap(new File("maps/umea_map.xml")); + System.out.println("From: " + from2 + " to " + to2); + System.out.println(my.greedySearch(from2, to2)); + } +} \ No newline at end of file diff --git a/test/MySearcherTestLaTeX.java b/test/MySearcherTestLaTeX.java deleted file mode 100644 index 1dd3537..0000000 --- a/test/MySearcherTestLaTeX.java +++ /dev/null @@ -1,124 +0,0 @@ -import java.io.File; -import junit.framework.*; - -public class MySearcherTest extends TestCase -{ - String from1 = "Tegsbron"; - String to1 = "Nydala"; - - String from2 = "Flygplatsen"; - String to2 = "Begbilar"; - - String from3 = "MIT"; - String to3 = "Flygplatsen"; - - String from4 = "Nydala"; - String to4 = "Gamlia"; - - String from5 = "Teg"; - String to5 = "Foa"; - - MySearcher my; - public MySearcherTest(String name) { - super (name); - my = new MySearcher(); - my.setMap(new File("maps/umea_map.xml")); - } - - public void testMap() { - System.out.println("----------Test Map-------------"); - System.out.println(my.toString()); - } - - public void testBreadthFirst() { - System.out.println("\\subsection{Test Breadthfirst}"); - System.out.println("\\subsubsection{From: " + from1 + " to " + to1 + "}"); - System.out.println(my.breadthFirst(from1, to1)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from2 + " to " + to2 + "}"); - System.out.println(my.breadthFirst(from2, to2)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from3 + " to " + to3 + "}"); - System.out.println(my.breadthFirst(from3, to3)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from4 + " to " + to4 + "}"); - System.out.println(my.breadthFirst(from4, to4)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from5 + " to " + to5 + "}"); - System.out.println(my.breadthFirst(from5, to5)); - - } - - public void testDepthFirst() { - System.out.println("\\subsection{Test Depthfirst}"); - System.out.println("\\subsubsection{From: " + from1 + " to " + to1 + "}"); - System.out.println(my.depthFirst(from1, to1)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from2 + " to " + to2 + "}"); - System.out.println(my.depthFirst(from2, to2)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from3 + " to " + to3 + "}"); - System.out.println(my.depthFirst(from3, to3)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from4 + " to " + to4 + "}"); - System.out.println(my.depthFirst(from4, to4)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from5 + " to " + to5 + "}"); - System.out.println(my.depthFirst(from5, to5)); - - } - - public void testAStar() { - System.out.println("\\subsection{Test A*}"); - System.out.println("\\subsubsection{From: " + from1 + " to " + to1 + "}"); - System.out.println(my.aStar(from1, to1, true)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from2 + " to " + to2 + "}"); - System.out.println(my.aStar(from2, to2, true)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from3 + " to " + to3 + "}"); - System.out.println(my.aStar(from3, to3, true)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from4 + " to " + to4 + "}"); - System.out.println(my.aStar(from4, to4, true)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from5 + " to " + to5 + "}"); - System.out.println(my.aStar(from5, to5, true)); - - } - - public void testGreedy() { - System.out.println("\\subsection{Test GreedySearch}"); - System.out.println("\\subsubsection{From: " + from1 + " to " + to1 + "}"); - System.out.println(my.greedySearch(from1, to1)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from2 + " to " + to2 + "}"); - System.out.println(my.greedySearch(from2, to2)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from3 + " to " + to3 + "}"); - System.out.println(my.greedySearch(from3, to3)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from4 + " to " + to4 + "}"); - System.out.println(my.greedySearch(from4, to4)); - - my.setMap(new File("maps/umea_map.xml")); - System.out.println("\\subsubsection{From: " + from5 + " to " + to5 + "}"); - System.out.println(my.greedySearch(from5, to5)); - - } -} -- 2.11.4.GIT