Advertisement
bestgamer69

a

Mar 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.59 KB | None | 0 0
  1. package search;
  2.  
  3. import java.io.IOException;
  4.  
  5. /**
  6. * Test program for the Search class.
  7. */
  8. public class SearchTest {
  9.  
  10. /**
  11. * Test program for the Search class. Put whatever tests you like in the
  12. * body of the method.
  13. *
  14. * @param args the command line arguments
  15. * @throws java.io.IOException of error reading the input
  16. */
  17. public static void main(String[] args) throws IOException {
  18. // Don't change this line
  19. final Search search = new Search();
  20.  
  21. // You can set this to any of the text files in the data folder
  22. final FileStrings stringsTiny = new FileStrings("data/tiny.txt");
  23. final FileStrings stringsSmall = new FileStrings("data/small.txt");
  24. final FileStrings stringsMedium = new FileStrings("data/medium.txt");
  25. final FileStrings stringsLarge = new FileStrings("data/large.txt");
  26.  
  27. // add your tests here
  28. System.out.printf("Longest Word Tiny: %d expected 1%n", search.longestWord(stringsTiny));
  29. System.out.printf("Longest Word Small: %d expected 14%n", search.longestWord(stringsSmall));
  30. System.out.printf("Longest Word Medium: %d expected 592%n", search.longestWord(stringsMedium));
  31. System.out.printf("Longest Word Large: %d expected 12473%n", search.longestWord(stringsLarge));
  32. System.out.println();
  33.  
  34. System.out.printf("Count Unique Tiny: %d expected 7%n", search.countUnique(stringsTiny));
  35. System.out.printf("Count Unique Small: %d expected 100%n", search.countUnique(stringsSmall));
  36. System.out.printf("Count Unique Medium: %d expected 2293%n", search.countUnique(stringsMedium));
  37. System.out.printf("Count Unique Large: %d expected 62831%n", search.countUnique(stringsLarge));
  38. System.out.println();
  39.  
  40. System.out.printf("Most Frequent Tiny: %s expected them%n", search.mostFrequent(stringsTiny));
  41. System.out.printf("Most Frequent Small: %s expected come%n", search.mostFrequent(stringsSmall));
  42. System.out.printf("Most Frequent Medium: %s expected bicycle%n" , search.mostFrequent(stringsMedium));
  43. System.out.printf("Most Frequent Large: %s expected hungrier%n", search.mostFrequent(stringsLarge));
  44. System.out.println();
  45.  
  46. System.out.printf("Find Element Tiny (the): %d expected 5%n", search.findElement(stringsTiny, "the"));
  47. System.out.printf("Find Element Small (the): %d expected 85%n", search.findElement(stringsSmall, "the"));
  48. System.out.printf("Find Element Medium (the): %d expected 2056%n", search.findElement(stringsMedium, "the"));
  49. System.out.printf("Find Element Large (the): %d expected 57384%n", search.findElement(stringsLarge, "the"));
  50. System.out.println();
  51.  
  52. System.out.printf("Find Element Tiny (ziggurat): %d expected -1%n", search.findElement(stringsTiny, "ziggurat"));
  53. System.out.printf("Find Element Small (ziggurat): %d expected -1%n", search.findElement(stringsSmall, "ziggurat"));
  54. System.out.printf("Find Element Medium (ziggurat): %d expected -1%n", search.findElement(stringsMedium, "ziggurat"));
  55. System.out.printf("Find Element Large (ziggurat): %d expected -1%n", search.findElement(stringsLarge, "ziggurat"));
  56. System.out.println();
  57.  
  58. System.out.printf("Count Greater or Equal Tiny (its): %d expected 7%n", search.countGreaterOrEqual(stringsTiny, "its"));
  59. System.out.printf("Count Greater or Equal Small (its): %d expected 74%n", search.countGreaterOrEqual(stringsSmall, "its"));
  60. System.out.printf("Count Greater or Equal Medium (its): %d expected 1261%n", search.countGreaterOrEqual(stringsMedium, "its"));
  61. System.out.printf("Count Greater or Equal Large (its): %d expected 34032%n", search.countGreaterOrEqual(stringsLarge, "its"));
  62. System.out.println();
  63.  
  64. System.out.printf("Count Greater or Equal Tiny (orange): %d expected 5%n", search.countGreaterOrEqual(stringsTiny, "orange"));
  65. System.out.printf("Count Greater or Equal Small (orange): %d expected 50%n", search.countGreaterOrEqual(stringsSmall, "orange"));
  66. System.out.printf("Count Greater or Equal Medium (orange): %d expected 941%n", search.countGreaterOrEqual(stringsMedium, "orange"));
  67. System.out.printf("Count Greater or Equal Large (orange): %d expected 25916%n", search.countGreaterOrEqual(stringsLarge, "orange"));
  68. System.out.println();
  69.  
  70. System.out.printf("Count Greater Tiny (guardian): %d expected 7%n", search.countGreater(stringsTiny, "guardian"));
  71. System.out.printf("Count Greater Small (guardian): %d expected 85%n", search.countGreater(stringsSmall, "guardian"));
  72. System.out.printf("Count Greater Medium (guardian): %d expected 1419%n", search.countGreater(stringsMedium, "guardian"));
  73. System.out.printf("Count Greater Large (guardian): %d expected 39285%n", search.countGreater(stringsLarge, "guardian"));
  74. System.out.println();
  75.  
  76. System.out.printf("Count Greater Tiny (them): %d expected 1%n", search.countGreater(stringsTiny, "them"));
  77. System.out.printf("Count Greater Small (them): %d expected 31%n", search.countGreater(stringsSmall, "them"));
  78. System.out.printf("Count Greater Medium (them): %d expected 262%n", search.countGreater(stringsMedium, "them"));
  79. System.out.printf("Count Greater Large (them): %d expected 6980%n", search.countGreater(stringsLarge, "them"));
  80. System.out.println();
  81.  
  82. System.out.printf("Count Between Tiny (first, they): %d expected 8%n", search.countBetween(stringsTiny, "first", "they"));
  83. System.out.printf("Count Between Small (first, they): %d expected 67%n", search.countBetween(stringsSmall, "first", "they"));
  84. System.out.printf("Count Between Medium (first, they): %d expected 1280%n", search.countBetween(stringsMedium, "first", "they"));
  85. System.out.printf("Count Between Large (first, they): %d expected 36102%n", search.countBetween(stringsLarge, "first", "they"));
  86. System.out.println();
  87.  
  88. System.out.printf("Count Between Tiny (guardian, the): %d expected 3%n", search.countBetween(stringsTiny, "guardian", "the"));
  89. System.out.printf("Count Between Small (guardian, the): %d expected 51%n", search.countBetween(stringsSmall, "guardian", "the"));
  90. System.out.printf("Count Between Medium (guardian, the): %d expected 1152%n", search.countBetween(stringsMedium, "guardian", "the"));
  91. System.out.printf("Count Between Large (guardian, the): %d expected 32288%n", search.countBetween(stringsLarge, "guardian", "the"));
  92. System.out.println();
  93.  
  94. System.out.printf("Count Matches Tiny (on, l): %d expected 1%n", search.countMatches(stringsTiny, "on", "l"));
  95. System.out.printf("Count Matches Small (on, l): %d expected 1%n", search.countMatches(stringsSmall, "on", "l"));
  96. System.out.printf("Count Matches Medium (on, l): %d expected 1%n", search.countMatches(stringsMedium, "on", "l"));
  97. System.out.printf("Count Matches Large (on, l): %d expected 8%n", search.countMatches(stringsLarge, "on", "l"));
  98. System.out.println();
  99.  
  100. System.out.printf("Count Matches Tiny (the, em): %d expected 3%n", search.countMatches(stringsTiny, "the", "em"));
  101. System.out.printf("Count Matches Small (the, em): %d expected 1%n", search.countMatches(stringsSmall, "the", "em"));
  102. System.out.printf("Count Matches Medium (the, em): %d expected 1%n", search.countMatches(stringsMedium, "the", "em"));
  103. System.out.printf("Count Matches Large (the, em): %d expected 8%n", search.countMatches(stringsLarge, "the", "em"));
  104. System.out.println();
  105. }
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement