Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package search;
- import java.io.IOException;
- /**
- * Test program for the Search class.
- */
- public class SearchTest {
- /**
- * Test program for the Search class. Put whatever tests you like in the
- * body of the method.
- *
- * @param args the command line arguments
- * @throws java.io.IOException of error reading the input
- */
- public static void main(String[] args) throws IOException {
- // Don't change this line
- final Search search = new Search();
- // You can set this to any of the text files in the data folder
- final FileStrings stringsTiny = new FileStrings("data/tiny.txt");
- final FileStrings stringsSmall = new FileStrings("data/small.txt");
- final FileStrings stringsMedium = new FileStrings("data/medium.txt");
- final FileStrings stringsLarge = new FileStrings("data/large.txt");
- // add your tests here
- System.out.printf("Longest Word Tiny: %d expected 1%n", search.longestWord(stringsTiny));
- System.out.printf("Longest Word Small: %d expected 14%n", search.longestWord(stringsSmall));
- System.out.printf("Longest Word Medium: %d expected 592%n", search.longestWord(stringsMedium));
- System.out.printf("Longest Word Large: %d expected 12473%n", search.longestWord(stringsLarge));
- System.out.println();
- System.out.printf("Count Unique Tiny: %d expected 7%n", search.countUnique(stringsTiny));
- System.out.printf("Count Unique Small: %d expected 100%n", search.countUnique(stringsSmall));
- System.out.printf("Count Unique Medium: %d expected 2293%n", search.countUnique(stringsMedium));
- System.out.printf("Count Unique Large: %d expected 62831%n", search.countUnique(stringsLarge));
- System.out.println();
- System.out.printf("Most Frequent Tiny: %s expected them%n", search.mostFrequent(stringsTiny));
- System.out.printf("Most Frequent Small: %s expected come%n", search.mostFrequent(stringsSmall));
- System.out.printf("Most Frequent Medium: %s expected bicycle%n" , search.mostFrequent(stringsMedium));
- System.out.printf("Most Frequent Large: %s expected hungrier%n", search.mostFrequent(stringsLarge));
- System.out.println();
- System.out.printf("Find Element Tiny (the): %d expected 5%n", search.findElement(stringsTiny, "the"));
- System.out.printf("Find Element Small (the): %d expected 85%n", search.findElement(stringsSmall, "the"));
- System.out.printf("Find Element Medium (the): %d expected 2056%n", search.findElement(stringsMedium, "the"));
- System.out.printf("Find Element Large (the): %d expected 57384%n", search.findElement(stringsLarge, "the"));
- System.out.println();
- System.out.printf("Find Element Tiny (ziggurat): %d expected -1%n", search.findElement(stringsTiny, "ziggurat"));
- System.out.printf("Find Element Small (ziggurat): %d expected -1%n", search.findElement(stringsSmall, "ziggurat"));
- System.out.printf("Find Element Medium (ziggurat): %d expected -1%n", search.findElement(stringsMedium, "ziggurat"));
- System.out.printf("Find Element Large (ziggurat): %d expected -1%n", search.findElement(stringsLarge, "ziggurat"));
- System.out.println();
- System.out.printf("Count Greater or Equal Tiny (its): %d expected 7%n", search.countGreaterOrEqual(stringsTiny, "its"));
- System.out.printf("Count Greater or Equal Small (its): %d expected 74%n", search.countGreaterOrEqual(stringsSmall, "its"));
- System.out.printf("Count Greater or Equal Medium (its): %d expected 1261%n", search.countGreaterOrEqual(stringsMedium, "its"));
- System.out.printf("Count Greater or Equal Large (its): %d expected 34032%n", search.countGreaterOrEqual(stringsLarge, "its"));
- System.out.println();
- System.out.printf("Count Greater or Equal Tiny (orange): %d expected 5%n", search.countGreaterOrEqual(stringsTiny, "orange"));
- System.out.printf("Count Greater or Equal Small (orange): %d expected 50%n", search.countGreaterOrEqual(stringsSmall, "orange"));
- System.out.printf("Count Greater or Equal Medium (orange): %d expected 941%n", search.countGreaterOrEqual(stringsMedium, "orange"));
- System.out.printf("Count Greater or Equal Large (orange): %d expected 25916%n", search.countGreaterOrEqual(stringsLarge, "orange"));
- System.out.println();
- System.out.printf("Count Greater Tiny (guardian): %d expected 7%n", search.countGreater(stringsTiny, "guardian"));
- System.out.printf("Count Greater Small (guardian): %d expected 85%n", search.countGreater(stringsSmall, "guardian"));
- System.out.printf("Count Greater Medium (guardian): %d expected 1419%n", search.countGreater(stringsMedium, "guardian"));
- System.out.printf("Count Greater Large (guardian): %d expected 39285%n", search.countGreater(stringsLarge, "guardian"));
- System.out.println();
- System.out.printf("Count Greater Tiny (them): %d expected 1%n", search.countGreater(stringsTiny, "them"));
- System.out.printf("Count Greater Small (them): %d expected 31%n", search.countGreater(stringsSmall, "them"));
- System.out.printf("Count Greater Medium (them): %d expected 262%n", search.countGreater(stringsMedium, "them"));
- System.out.printf("Count Greater Large (them): %d expected 6980%n", search.countGreater(stringsLarge, "them"));
- System.out.println();
- System.out.printf("Count Between Tiny (first, they): %d expected 8%n", search.countBetween(stringsTiny, "first", "they"));
- System.out.printf("Count Between Small (first, they): %d expected 67%n", search.countBetween(stringsSmall, "first", "they"));
- System.out.printf("Count Between Medium (first, they): %d expected 1280%n", search.countBetween(stringsMedium, "first", "they"));
- System.out.printf("Count Between Large (first, they): %d expected 36102%n", search.countBetween(stringsLarge, "first", "they"));
- System.out.println();
- System.out.printf("Count Between Tiny (guardian, the): %d expected 3%n", search.countBetween(stringsTiny, "guardian", "the"));
- System.out.printf("Count Between Small (guardian, the): %d expected 51%n", search.countBetween(stringsSmall, "guardian", "the"));
- System.out.printf("Count Between Medium (guardian, the): %d expected 1152%n", search.countBetween(stringsMedium, "guardian", "the"));
- System.out.printf("Count Between Large (guardian, the): %d expected 32288%n", search.countBetween(stringsLarge, "guardian", "the"));
- System.out.println();
- System.out.printf("Count Matches Tiny (on, l): %d expected 1%n", search.countMatches(stringsTiny, "on", "l"));
- System.out.printf("Count Matches Small (on, l): %d expected 1%n", search.countMatches(stringsSmall, "on", "l"));
- System.out.printf("Count Matches Medium (on, l): %d expected 1%n", search.countMatches(stringsMedium, "on", "l"));
- System.out.printf("Count Matches Large (on, l): %d expected 8%n", search.countMatches(stringsLarge, "on", "l"));
- System.out.println();
- System.out.printf("Count Matches Tiny (the, em): %d expected 3%n", search.countMatches(stringsTiny, "the", "em"));
- System.out.printf("Count Matches Small (the, em): %d expected 1%n", search.countMatches(stringsSmall, "the", "em"));
- System.out.printf("Count Matches Medium (the, em): %d expected 1%n", search.countMatches(stringsMedium, "the", "em"));
- System.out.printf("Count Matches Large (the, em): %d expected 8%n", search.countMatches(stringsLarge, "the", "em"));
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement