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);  }
@Test public void testCheckSumEmptyString() { assertEquals(0, CheckSum.process(new BufferedReader(new StringReader("")))); }
@Test public void testCheckSumOneCharString() { assertEquals(0x42, CheckSum.process(new BufferedReader(new StringReader("\u0042")))); }
@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); }