### Question:
ColorFunctions { @VisibleForTesting static int parseRgb(Slice color) { if (color.length() != 4 || color.getByte(0) != '#') { return -1; } int red = Character.digit((char) color.getByte(1), 16); int green = Character.digit((char) color.getByte(2), 16); int blue = Character.digit((char) color.getByte(3), 16); if (red == -1 || green == -1 || blue == -1) { return -1; } red = (red << 4) | red; green = (green << 4) | green; blue = (blue << 4) | blue; return (int) rgb(red, green, blue); } private  ColorFunctions(); @ScalarFunction @LiteralParameters("x") @SqlType(ColorType.NAME) static long color(@SqlType("varchar(x)") Slice color); @ScalarFunction @SqlType(ColorType.NAME) static long rgb(@SqlType(StandardTypes.BIGINT) long red, @SqlType(StandardTypes.BIGINT) long green, @SqlType(StandardTypes.BIGINT) long blue); @ScalarFunction @SqlType(ColorType.NAME) static long color(
            @SqlType(StandardTypes.DOUBLE) double value,
            @SqlType(StandardTypes.DOUBLE) double low,
            @SqlType(StandardTypes.DOUBLE) double high,
            @SqlType(ColorType.NAME) long lowColor,
            @SqlType(ColorType.NAME) long highColor); @ScalarFunction @SqlType(ColorType.NAME) static long color(@SqlType(StandardTypes.DOUBLE) double fraction, @SqlType(ColorType.NAME) long lowColor, @SqlType(ColorType.NAME) long highColor); @ScalarFunction @LiteralParameters({"x", "y"}) @Constraint(variable = "y", expression = "min(2147483647, x + 15)") // Color formatting uses 15 characters. Note that if the ansiColorEscape function implementation // changes, this value may be invalidated. @SqlType("varchar(y)") static Slice render(@SqlType("varchar(x)") Slice value, @SqlType(ColorType.NAME) long color); @ScalarFunction @SqlType("varchar(35)") static Slice render(@SqlType(StandardTypes.BIGINT) long value, @SqlType(ColorType.NAME) long color); @ScalarFunction @SqlType("varchar(41)") static Slice render(@SqlType(StandardTypes.DOUBLE) double value, @SqlType(ColorType.NAME) long color); @ScalarFunction @SqlType("varchar(16)") static Slice render(@SqlType(StandardTypes.BOOLEAN) boolean value); @ScalarFunction @SqlType(StandardTypes.VARCHAR) static Slice bar(@SqlType(StandardTypes.DOUBLE) double percent, @SqlType(StandardTypes.BIGINT) long width); @ScalarFunction @SqlType(StandardTypes.VARCHAR) static Slice bar(
            @SqlType(StandardTypes.DOUBLE) double percent,
            @SqlType(StandardTypes.BIGINT) long width,
            @SqlType(ColorType.NAME) long lowColor,
            @SqlType(ColorType.NAME) long highColor);  }### Answer:
@Test public void testParseRgb() { assertEquals(parseRgb(toSlice("#000")), 0x00_00_00); assertEquals(parseRgb(toSlice("#FFF")), 0xFF_FF_FF); assertEquals(parseRgb(toSlice("#F00")), 0xFF_00_00); assertEquals(parseRgb(toSlice("#0F0")), 0x00_FF_00); assertEquals(parseRgb(toSlice("#00F")), 0x00_00_FF); assertEquals(parseRgb(toSlice("#700")), 0x77_00_00); assertEquals(parseRgb(toSlice("#070")), 0x00_77_00); assertEquals(parseRgb(toSlice("#007")), 0x00_00_77); assertEquals(parseRgb(toSlice("#cde")), 0xCC_DD_EE); }