### Question:
UrlFunctions { @Description("Escape a string for use in URL query parameter names and values") @ScalarFunction @LiteralParameters({"x", "y"}) @Constraint(variable = "y", expression = "min(2147483647, x * 12)") @SqlType("varchar(y)") public static Slice urlEncode(@SqlType("varchar(x)") Slice value) { Escaper escaper = UrlEscapers.urlFormParameterEscaper(); return slice(escaper.escape(value.toStringUtf8())); } private  UrlFunctions(); @SqlNullable @Description("Extract protocol from url") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") static Slice urlExtractProtocol(@SqlType("varchar(x)") Slice url); @SqlNullable @Description("Extract host from url") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") static Slice urlExtractHost(@SqlType("varchar(x)") Slice url); @SqlNullable @Description("Extract port from url") @ScalarFunction @LiteralParameters("x") @SqlType(StandardTypes.BIGINT) static Long urlExtractPort(@SqlType("varchar(x)") Slice url); @SqlNullable @Description("Extract part from url") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") static Slice urlExtractPath(@SqlType("varchar(x)") Slice url); @SqlNullable @Description("Extract query from url") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") static Slice urlExtractQuery(@SqlType("varchar(x)") Slice url); @SqlNullable @Description("Extract fragment from url") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") static Slice urlExtractFragment(@SqlType("varchar(x)") Slice url); @SqlNullable @Description("Extract query parameter from url") @ScalarFunction @LiteralParameters({"x", "y"}) @SqlType("varchar(x)") static Slice urlExtractParameter(@SqlType("varchar(x)") Slice url, @SqlType("varchar(y)") Slice parameterName); @Description("Escape a string for use in URL query parameter names and values") @ScalarFunction @LiteralParameters({"x", "y"}) @Constraint(variable = "y", expression = "min(2147483647, x * 12)") @SqlType("varchar(y)") static Slice urlEncode(@SqlType("varchar(x)") Slice value); @Description("Unescape a URL-encoded string") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") static Slice urlDecode(@SqlType("varchar(x)") Slice value);  }### Answer:
@Test public void testUrlEncode() { String[][] outputInputPairs = { {"http%3A%2F%2Ftest", "http: {"http%3A%2F%2Ftest%3Fa%3Db%26c%3Dd", "http: {"http%3A%2F%2F%E3%83%86%E3%82%B9%E3%83%88", "http: {"%7E%40%3A.-*_%2B+%E2%98%83", "~@:.-*_+ \u2603"}, {"test", "test"}, }; for (String[] outputInputPair : outputInputPairs) { String input = outputInputPair[1]; String output = outputInputPair[0]; assertFunction("url_encode('" + input + "')", createVarcharType(input.length() * 12), output); } assertFunction("url_encode('\uD867\uDE3D')", createVarcharType(12), "%F0%A9%B8%BD"); }