### Question:
LuhnCheckFunction { @Description("Checks that a string of digits is valid according to the Luhn algorithm") @ScalarFunction("luhn_check") @SqlType(StandardTypes.BOOLEAN) public static boolean LuhnCheck(@SqlType(StandardTypes.VARCHAR) Slice slice) { if (slice.length() == 0) { return false; } int nDigits = slice.length(); int sum = 0; boolean secondNumber = false; for (int i = nDigits - 1; i >= 0; i--) { byte b = slice.getByte(i); checkCondition(b >= '0' && b <= '9', INVALID_FUNCTION_ARGUMENT, "Input contains non-digit character"); int n = b - '0'; if (secondNumber) { n *= 2; } if (n > 9) { n -= 9; } sum += n; secondNumber = !secondNumber; } return (sum % 10 == 0); } private  LuhnCheckFunction(); @Description("Checks that a string of digits is valid according to the Luhn algorithm") @ScalarFunction("luhn_check") @SqlType(StandardTypes.BOOLEAN) static boolean LuhnCheck(@SqlType(StandardTypes.VARCHAR) Slice slice);  }### Answer:
@Test public void testLuhnCheck() { assertFunction("luhn_check('4242424242424242')", BOOLEAN, true); assertFunction("luhn_check('1234567891234567')", BOOLEAN, false); assertFunction("luhn_check('')", BOOLEAN, false); assertFunction("luhn_check(NULL)", BOOLEAN, null); assertInvalidFunction("luhn_check('abcd424242424242')", INVALID_FUNCTION_ARGUMENT); assertFunction("luhn_check('123456789')", BOOLEAN, false); assertInvalidFunction("luhn_check('\u4EA0\u4EFF\u4EA112345')", INVALID_FUNCTION_ARGUMENT); assertInvalidFunction("luhn_check('4242\u4FE124242424242')", INVALID_FUNCTION_ARGUMENT); }