@Test public void testCheckSumNormalString() { int expected = 2874; String input = "Hello world\nOh, and goodbye, too!"; StringReader chr = new StringReader(input); BufferedReader is = new BufferedReader(chr); int actual = CheckSum.process(is); assertEquals("cksum test", expected, actual); }
public static int process(BufferedReader is) { int sum = 0; try { String inputLine; while ((inputLine = is.readLine()) != null) { for (char c : inputLine.toCharArray()) { sum += c; } } } catch (IOException e) { throw new RuntimeException("IOException: " + e); } return sum; }
CheckSum { public static int process(BufferedReader is) { int sum = 0; try { String inputLine; while ((inputLine = is.readLine()) != null) { for (char c : inputLine.toCharArray()) { sum += c; } } } catch (IOException e) { throw new RuntimeException("IOException: " + e); } return sum; } }
CheckSum { public static int process(BufferedReader is) { int sum = 0; try { String inputLine; while ((inputLine = is.readLine()) != null) { for (char c : inputLine.toCharArray()) { sum += c; } } } catch (IOException e) { throw new RuntimeException("IOException: " + e); } return sum; }  }
CheckSum { public static int process(BufferedReader is) { int sum = 0; try { String inputLine; while ((inputLine = is.readLine()) != null) { for (char c : inputLine.toCharArray()) { sum += c; } } } catch (IOException e) { throw new RuntimeException("IOException: " + e); } return sum; }  static void main(String[] args); static int process(BufferedReader is); }
CheckSum { public static int process(BufferedReader is) { int sum = 0; try { String inputLine; while ((inputLine = is.readLine()) != null) { for (char c : inputLine.toCharArray()) { sum += c; } } } catch (IOException e) { throw new RuntimeException("IOException: " + e); } return sum; }  static void main(String[] args); static int process(BufferedReader is);  }