StringArrayUtilsTest.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.zipcodewilmington;
  2. import org.junit.Assert;
  3. import org.junit.Test;
  4. /**
  5. * Created by leon on 1/29/18.
  6. */
  7. public class StringArrayUtilsTest {
  8. private static final String[] testArray = {"the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"};
  9. @Test
  10. public void testContains() {
  11. for (String s : testArray) {
  12. boolean outcome = StringArrayUtils.contains(testArray, s);
  13. Assert.assertTrue(outcome);
  14. }
  15. }
  16. @Test
  17. public void testRemoveValue() {
  18. String[] expected = {"quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"};
  19. String[] actual = StringArrayUtils.removeValue(expected, "The");
  20. Assert.assertEquals(expected, actual);
  21. }
  22. @Test
  23. public void testRemoveValue1() {
  24. String[] expected = {"the", "brown", "fox", "jumps", "over", "the", "lazy", "dog"};
  25. String[] actual = StringArrayUtils.removeValue(expected, "quick");
  26. Assert.assertEquals(expected, actual);
  27. }
  28. @Test
  29. public void testRemoveValue2() {
  30. String[] expected = {"the", "quick", "fox", "jumps", "over", "the", "lazy", "dog"};
  31. String[] actual = StringArrayUtils.removeValue(expected, "brown");
  32. Assert.assertEquals(expected, actual);
  33. }
  34. @Test
  35. public void testGetNumberOfOccurrences1() {
  36. int expected = 2;
  37. int actual = StringArrayUtils.getNumberOfOccurrences(testArray, "the");
  38. Assert.assertEquals(expected, actual);
  39. }
  40. @Test
  41. public void testGetNumberOfOccurrences2() {
  42. int expected = 1;
  43. int actual = StringArrayUtils.getNumberOfOccurrences(testArray, "quick");
  44. Assert.assertEquals(expected, actual);
  45. }
  46. }