@Test public void testReplace() { ReplaceStringMain rs = new ReplaceStringMain(); assertEquals("\\\n", rs.replace("\n")); assertEquals("\\\n\\\t", rs.replace("\n\t")); assertEquals("\\\naaa\\\t", rs.replace("\naaa\t")); assertEquals("\\\n\\\t\\\b\\\r\\\f\\\\\\\'\\\"", rs.replace("\n\t\b\r\f\\\'\"")); }
@Test public void testReplaceException() { ReplaceStringMain rs = new ReplaceStringMain(); try { rs.replace(null); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); assertEquals("str must not be null.", e.getMessage()); } }