Advertisement
JeffGrigg

2nd Test Fails

Feb 8th, 2024
1,401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.71 KB | Software | 0 0
  1. import junit.framework.TestCase;
  2.  
  3. import java.util.Arrays;
  4. import java.util.stream.Collectors;
  5.  
  6. public class NBottlesOfBeerOnTheWallTest extends TestCase {
  7.  
  8.     private static String[] lyricsForBottlesOfBeer(final int numberOfBottlesOfBeer) {
  9.         return new String[]{
  10.                 "No more bottles of beer on the wall, no more bottles of beer.",
  11.                 "Go to the store and buy some more, 99 bottles of beer on the wall."};
  12.     }
  13.  
  14.     public void testZeroBottlesOfBeer() {
  15.         assertEqualsArrayValues(new String[]{
  16.                         "No more bottles of beer on the wall, no more bottles of beer.",
  17.                         "Go to the store and buy some more, 99 bottles of beer on the wall."},
  18.                 lyricsForBottlesOfBeer(0));
  19.     }
  20.  
  21.     public void testOneBottleOfBeer() {
  22.         assertEqualsArrayValues(new String[]{
  23.                         "1 bottle of beer on the wall, 1 bottle of beer.",
  24.                         "Take one down and pass it around, no more bottles of beer on the wall.",
  25.                         "",
  26.                         "No more bottles of beer on the wall, no more bottles of beer.",
  27.                         "Go to the store and buy some more, 99 bottles of beer on the wall."
  28.                 },
  29.                 lyricsForBottlesOfBeer(1));
  30.     }
  31.  
  32.     private static void assertEqualsArrayValues(final String[] expectedLines, final String[] actualLines) {
  33.         final var expectedAsString = Arrays.stream(expectedLines).collect(Collectors.joining(System.lineSeparator()));
  34.         final var actualAsString = Arrays.stream(actualLines).collect(Collectors.joining(System.lineSeparator()));
  35.         assertEquals(expectedAsString, actualAsString);
  36.     }
  37.  
  38. }
  39.  
Tags: 99 Bottles
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement