GitBucket
4.20.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
4
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
Jonathan
/
KA-Visual
Browse code
Fixed the 'correct' variable not having all correct results.
master
1 parent
60e014b
commit
3cbc2ec9d1026081e4bca6fba7dbf8804097f61f
Jonathan Ström
authored
on 21 Feb 2017
Patch
Showing
1 changed file
src/getUrlResultsTest.java
Ignore Space
Show notes
View
src/getUrlResultsTest.java
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class getUrlResultsTest { public static void runAll() { printInfo("runOfflineTest", !getUrlResultsTest.runOfflineTest()); //printInfo("runOnlineTest", !getUrlResultsTest.runOnlineTest()); } public static boolean runOnlineTest() { String correct = "EXEMPELSEXEMPLAREXEMPLENEXEMPLET"; String result = ""; for (String line : getUrlResults.getSearchResults("EXEMP???")) { result += line; } return (correct.equals(result)); } public static boolean runOfflineTest() { String correct = "EXEMPELSEXEMPLAREXEMPLENEXEMPLET"; String result = ""; for (String line : getUrlResults.getWordsList(getUrlListFromFile(), "EXEMP???")) { result += line; } return (correct.equals(result)); } private static List<String> getUrlListFromFile() { List<String> linesList = new ArrayList<String>(); try(BufferedReader br = new BufferedReader(new FileReader("getUrlResultsTestContent"))) { String line = br.readLine(); while (line != null) { linesList.add(line); line = br.readLine(); } } catch (IOException ioe) {} return linesList; } private static void printInfo(String testMethod) { System.out.println("GetUrlResultsTest->" + testMethod + "(): [OK] Test completed successfully!"); } private static void printError(String testMethod) { System.err.println("GetUrlResultsTest->" + testMethod + "(): [ERROR] Test did not complete successfully!"); } private static void printInfo(String testMethod, boolean error) { if (error) printError(testMethod); else printInfo(testMethod); } }
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class getUrlResultsTest { public static void runAll() { printInfo("runOfflineTest", !getUrlResultsTest.runOfflineTest()); //printInfo("runOnlineTest", !getUrlResultsTest.runOnlineTest()); } public static boolean runOnlineTest() { String correct = "EXEMPELSEXEMPLAR"; String answer = ""; for (String line : getUrlResults.getSearchResults("EXEMP???")) { answer += line; } return (correct.equals(answer)); } public static boolean runOfflineTest() { String correct = "EXEMPELSEXEMPLAR"; String answer = ""; for (String line : getUrlResults.getWordsList(getUrlListFromFile(), "EXEMP???")) { answer += line; } return (correct.equals(answer)); } private static List<String> getUrlListFromFile() { List<String> linesList = new ArrayList<String>(); try(BufferedReader br = new BufferedReader(new FileReader("getUrlResultsTestContent"))) { String line = br.readLine(); while (line != null) { linesList.add(line); line = br.readLine(); } } catch (IOException ioe) {} return linesList; } private static void printInfo(String testMethod) { System.out.println("GetUrlResultsTest->" + testMethod + "(): [OK] Test completed successfully!"); } private static void printError(String testMethod) { System.err.println("GetUrlResultsTest->" + testMethod + "(): [ERROR] Test did not complete successfully!"); } private static void printInfo(String testMethod, boolean error) { if (error) printError(testMethod); else printInfo(testMethod); } }
Show line notes below