2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: no-fasttest
|
|
|
|
|
2020-06-20 11:29:01 +00:00
|
|
|
SET send_logs_level = 'fatal';
|
2022-09-27 08:52:08 +00:00
|
|
|
|
2023-11-17 11:31:52 +00:00
|
|
|
SELECT base64Encode(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
SELECT base64Decode(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
SELECT tryBase64Decode(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
SELECT base64Encode('foo', 'excess argument'); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
SELECT base64Decode('foo', 'excess argument'); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
SELECT tryBase64Decode('foo', 'excess argument'); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
|
|
|
|
-- test with valid inputs
|
2022-09-27 08:52:08 +00:00
|
|
|
|
2023-11-17 11:31:52 +00:00
|
|
|
SELECT base64Encode(val) FROM (select arrayJoin(['', 'f', 'fo', 'foo', 'foob', 'fooba', 'foobar']) val);
|
2018-10-10 01:04:07 +00:00
|
|
|
SELECT base64Decode(val) FROM (select arrayJoin(['', 'Zg==', 'Zm8=', 'Zm9v', 'Zm9vYg==', 'Zm9vYmE=', 'Zm9vYmFy']) val);
|
2023-09-07 09:50:49 +00:00
|
|
|
SELECT tryBase64Decode(val) FROM (select arrayJoin(['', 'Zg==', 'Zm8=', 'Zm9v', 'Zm9vYg==', 'Zm9vYmE=', 'Zm9vYmFy']) val);
|
2022-09-27 08:52:08 +00:00
|
|
|
|
2023-09-07 09:50:49 +00:00
|
|
|
SELECT base64Decode(base64Encode('foo')) = 'foo', base64Encode(base64Decode('Zm9v')) == 'Zm9v';
|
|
|
|
SELECT tryBase64Decode(base64Encode('foo')) = 'foo', base64Encode(tryBase64Decode('Zm9v')) == 'Zm9v';
|
2022-09-27 08:52:08 +00:00
|
|
|
|
2023-11-17 11:31:52 +00:00
|
|
|
-- test with invalid inputs
|
2022-09-27 08:52:08 +00:00
|
|
|
|
2023-09-07 09:50:49 +00:00
|
|
|
SELECT base64Decode('Zm9vYmF=Zm9v'); -- { serverError INCORRECT_DATA }
|
|
|
|
SELECT tryBase64Decode('Zm9vYmF=Zm9v');
|
2022-10-14 18:11:08 +00:00
|
|
|
|
2023-09-07 19:18:13 +00:00
|
|
|
SELECT base64Decode('foo'); -- { serverError INCORRECT_DATA }
|
|
|
|
SELECT tryBase64Decode('foo');
|
|
|
|
|
2023-11-17 11:31:52 +00:00
|
|
|
SELECT base64Decode('aoeo054640eu='); -- { serverError INCORRECT_DATA }
|
|
|
|
SELECT tryBase64Decode('aoeo054640eu=');
|
|
|
|
|
|
|
|
-- test FixedString arguments
|
|
|
|
|
2022-10-14 18:11:08 +00:00
|
|
|
select base64Encode(toFixedString('foo', 3));
|
|
|
|
select base64Decode(toFixedString('Zm9v', 4));
|
2023-09-07 09:50:49 +00:00
|
|
|
select tryBase64Decode(toFixedString('Zm9v', 4));
|