### Question:
HiveSyntax { public static String quoteLiteral(char quote, String string) { StringBuilder buf = new StringBuilder(); buf.append(quote); for (int i = 0, n = string.length(); i < n; i++) { char c = string.charAt(i); if (c == quote || c == LITERAL_ESCAPE) { buf.append(LITERAL_ESCAPE); buf.append(c); } else if (Character.isISOControl(c)) { buf.append(String.format("\\%03o", (int) c)); } else { buf.append(c); } } buf.append(quote); return buf.toString(); } private  HiveSyntax(); static boolean isDdlKeyword(String identifier); static String quoteIdentifier(String identifier); static String quoteLiteral(char quote, String string);  }### Answer:
@Test public void quote_string_single() { assertThat(HiveSyntax.quoteLiteral('\'', "HELLO"), is("'HELLO'")); assertThat(HiveSyntax.quoteLiteral('\'', "Hello"), is("'Hello'")); assertThat(HiveSyntax.quoteLiteral('\'', "Hello, world!"), is("'Hello, world!'")); assertThat(HiveSyntax.quoteLiteral('\'', "'Hello!'"), is("'\\'Hello!\\''")); assertThat(HiveSyntax.quoteLiteral('\'', "\"Hello!\""), is("'\"Hello!\"'")); assertThat(HiveSyntax.quoteLiteral('\'', "\\Hello/"), is("'\\\\Hello/'")); }
@Test public void quote_string_double() { assertThat(HiveSyntax.quoteLiteral('"', "HELLO"), is("\"HELLO\"")); assertThat(HiveSyntax.quoteLiteral('"', "Hello"), is("\"Hello\"")); assertThat(HiveSyntax.quoteLiteral('"', "Hello, world!"), is("\"Hello, world!\"")); assertThat(HiveSyntax.quoteLiteral('"', "'Hello!'"), is("\"'Hello!'\"")); assertThat(HiveSyntax.quoteLiteral('"', "\"Hello!\""), is("\"\\\"Hello!\\\"\"")); assertThat(HiveSyntax.quoteLiteral('"', "\\Hello/"), is("\"\\\\Hello/\"")); }