### Question:
CharacterLiteral implements LexEater { @Override public LexicalElement.CharacterLiteral apply(StringBuilder sb) { if (sb.length() == 0 || sb.charAt(0) != ENCLOSING) { return null; } final StringBuilder output = createOutput(sb, CHARACTER); final StringBuilder original = createOutput(sb, CHARACTER); sb.deleteCharAt(0); while (sb.length() > 0 && sb.charAt(0) != ENCLOSING) { final char ch = sb.charAt(0); if (ch == '\\') { handleEscape(sb, output,original); } else { handleNormalCharacter(sb, output,original); } } if (sb.length() == 0) { throw new IllegalArgumentException("Character is not terminated before eol"); } sb.deleteCharAt(0); return new LexicalElement.CharacterLiteral(output.toString(),original.toString()); }  @Override LexicalElement.CharacterLiteral apply(StringBuilder sb);  }### Answer:
@Test @DisplayName("Test character literals that are syntactically correct") void testStringLiterals(){ final var sut = new CharacterLiteral(); Assertions.assertEquals("",sut.apply(character("")).lexeme); Assertions.assertEquals("a",sut.apply(character("a")).lexeme); Assertions.assertEquals("\r",sut.apply(character("\\r")).lexeme); Assertions.assertEquals("\n",sut.apply(character("\\n")).lexeme); Assertions.assertEquals("\b",sut.apply(character("\\b")).lexeme); Assertions.assertEquals("\t",sut.apply(character("\\t")).lexeme); Assertions.assertEquals("\f",sut.apply(character("\\f")).lexeme); Assertions.assertEquals("\'",sut.apply(character("\\'")).lexeme); Assertions.assertEquals("\"",sut.apply(character("\\\"")).lexeme); Assertions.assertEquals("\77",sut.apply(character("\\77")).lexeme); Assertions.assertEquals("\073",sut.apply(character("\\073")).lexeme); Assertions.assertEquals("\07",sut.apply(character("\\07")).lexeme); }
@Test @DisplayName("Test character literals that are syntactically incorrect") void testBadStringLiterals() { final var sut = new CharacterLiteral(); Assertions.assertThrows(GeciException.class, () -> sut.apply(character("\n"))); Assertions.assertThrows(GeciException.class, () -> sut.apply(character("\r"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(character("\\z"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(character("\\"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(new StringBuilder("\'"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(new StringBuilder("\'\\"))); Assertions.assertThrows(IllegalArgumentException.class, () -> sut.apply(new StringBuilder("\'b"))); }