-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·29 lines (24 loc) · 938 Bytes
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
#
# A few simple sanity tests to make sure it's correctly encoding and decoding
#
error=0
# test encoding a few simple strings
for str in "" "a" "ab" "abc" "abcd" "abcde" "abcdef" "abcdefg" "abcdefgh" "abcdefghi"; do
output_sys=$(echo -n $str | base64)
output_fb64=$(echo -n $str | ./fast-base64)
if [[ $output_sys != $output_fb64 ]]; then
echo "Failed to encode $str - System output is $output_sys but our output is $output_fb64"
error=1
fi
done
# test decoding a few simple strings
for str in "" "YQ==" "YWI=" "YWJj" "YWJjZA==" "YWJjZGU=" "YWJjZGVm" "YWJjZGVmZw==" "YWJjZGVmZ2g=" "YWJjZGVmZ2hp"; do
output_sys=$(echo -n $str | base64 -d)
output_fb64=$(echo -n $str | ./fast-base64 -d)
if [[ $output_sys != $output_fb64 ]]; then
echo "Failed to decode $str - System output is $output_sys but our output is $output_fb64"
error=1
fi
done
exit $error