@@ -0,0 +1,2372 @@
+package chapter_5;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.collection.IsIterableContainingInOrder.contains;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.junit.AfterClass;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0A%0Aimport datastructures.util.InputUtil;%0A%0Apublic class TestDrawLine %7B%0A  private static String basePath = %22input_files/chapter_5/draw_line/%22;%0A  private static String%5B%5D testCases = new String%5B%5D %7B %22test_case_1%22, %22test_case_2%22, %22test_case_3%22, %22test_case_4%22 %7D;%0A  private static DrawLine drawLine;%0A  private static List%3CString%5B%5D%3E inputList = new ArrayList%3CString%5B%5D%3E();%0A%0A  @BeforeClass%0A  public static void setup() %7B%0A    drawLine = new DrawLine();%0A    for (String testCase : testCases) %7B%0A      String inputFile = basePath + testCase;%0A      inputList.add(InputUtil.readContents(inputFile));%0A    %7D%0A  %7D%0A%0A  @AfterClass%0A  public static void teardown() %7B%0A    drawLine = null;%0A    inputList = null;%0A  %7D%0A%0A  @Test%0A  public void testDrawLineTestCase1() %7B%0A    assertDrawLine(inputList.get(0));%0A  %7D%0A%0A  @Test%0A  public void testDrawLineTestCase2() %7B%0A    assertDrawLine(inputList.get(1));%0A  %7D%0A%0A  @Test%0A  public void testDrawLineTestCase3() %7B%0A    assertDrawLine(inputList.get(2));%0A  %7D%0A%0A  @Test%0A  public void testDrawLineTestCase4() %7B%0A    assertDrawLine(inputList.get(3));%0A  %7D%0A%0A  private void assertDrawLine(String%5B%5D input) %7B%0A    String%5B%5D values = input%5B0%5D.split(%22 %22);%0A    int i = 2;%0A    int width = Integer.parseInt(values%5B0%5D);%0A    int x1 = Integer.parseInt(values%5B1%5D);%0A    int x2 = Integer.parseInt(values%5B2%5D);%0A    int y = Integer.parseInt(values%5B3%5D);%0A    %0A    byte%5B%5D screen = new byte%5BInteger.parseInt(input%5B1%5D)%5D;%0A    readByteArray(i, input, width, screen);%0A%0A    byte%5B%5D output = new byte%5Bscreen.length%5D;%0A    readByteArray(i + ((screen.length * 8) / width) + 1, input, width, output);%0A%0A    assertThat(Arrays.asList(output), contains(drawLine.drawLine(screen, width, x1, x2, y)));%0A  %7D%0A%0A  private void readByteArray(int i, String%5B%5D input, int width, byte%5B%5D screen) %7B%0A    int j = 0;%0A    String line = %22%22;%0A    while (!(line = input%5Bi%5D).equals(%22---%22)) %7B%0A      int start = 0, end = 8;%0A      while (end %3C= width && j %3C screen.length) %7B%0A        screen%5Bj%5D = (byte) Integer.parseInt(line.substring(start, end), 2);%0A        start += 8;%0A        end += 8;%0A        j++;%0A      %7D%0A      i++;%0A    %7D%0A  %7D%0A%7D%0A

Add Test runner for DrawLine, TODO: Cleanup