mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
03167_base64_url_functions_sh.sh make test simpler
This commit is contained in:
parent
05e1e0f601
commit
1c82488eca
@ -132,51 +132,30 @@ base64URLDecode() {
|
|||||||
echo "$result" | tr '_-' '/+' | base64 -w0 -d
|
echo "$result" | tr '_-' '/+' | base64 -w0 -d
|
||||||
}
|
}
|
||||||
|
|
||||||
test_compare_to_gold_encode() {
|
test() {
|
||||||
local input="$1"
|
local input="$1"
|
||||||
local encode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLEncode('$input')")
|
local encode_ch=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLEncode('$input')")
|
||||||
local encode_gold=$(base64URLEncode $input)
|
local encode_gold=$(base64URLEncode $input)
|
||||||
|
|
||||||
if [ "$encode" != "$encode_gold" ]; then
|
local decode_ch=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLDecode('$encode_gold')")
|
||||||
echo "Input: $input"
|
|
||||||
echo "Expected: $encode_gold"
|
|
||||||
echo "Got: $encode"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
test_compare_to_gold_decode() {
|
|
||||||
local input="$1"
|
|
||||||
local encode_gold=$(base64URLEncode $input)
|
|
||||||
local decode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLDecode('$encode_gold')")
|
|
||||||
local decode_gold=$(base64URLDecode $encode_gold)
|
local decode_gold=$(base64URLDecode $encode_gold)
|
||||||
|
|
||||||
if [ "$decode" != "$decode_gold" ]; then
|
if [ "$encode_ch" != "$encode_gold" ]; then
|
||||||
echo "Input: $input"
|
echo "Input: $input"
|
||||||
echo "Expected: $decode_gold"
|
echo "Expected: $encode_gold"
|
||||||
echo "Got: $decode"
|
echo "Got: $encode_ch"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$decode_ch" != "$input" ] || [ "$decode_ch" != "$decode_gold" ]; then
|
||||||
|
echo "Input: $input"
|
||||||
|
echo "Decode gold: $decode_gold"
|
||||||
|
echo "Got: $decode_ch"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test_compare_to_self() {
|
|
||||||
local input="$1"
|
|
||||||
local decode=$(${CLICKHOUSE_CLIENT} --query="SELECT base64URLDecode(base64URLEncode('$input'))")
|
|
||||||
|
|
||||||
if [ "$decode" != "$input" ]; then
|
|
||||||
echo "Input: $input"
|
|
||||||
echo "Got: $decode"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
for url in "${urls[@]}"; do
|
for url in "${urls[@]}"; do
|
||||||
test_compare_to_gold_encode "$url"
|
test "$url"
|
||||||
done
|
|
||||||
|
|
||||||
for url in "${urls[@]}"; do
|
|
||||||
test_compare_to_gold_decode "$url"
|
|
||||||
done
|
|
||||||
|
|
||||||
for url in "${urls[@]}"; do
|
|
||||||
test_compare_to_self "$url"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# special case for '
|
# special case for '
|
||||||
|
Loading…
Reference in New Issue
Block a user