8c52458469d23e239a8325eca602ff02845ca807
[project/libubox.git] / tests / cram / test_base64.t
1 set test bin path:
2
3 $ [ -n "$TEST_BIN_DIR" ] && export PATH="$TEST_BIN_DIR:$PATH"
4
5 check that base64 is producing expected results:
6
7 $ valgrind --quiet --leak-check=full test-b64
8 0
9 4 Zg==
10 4 Zm8=
11 4 Zm9v
12 8 Zm9vYg==
13 8 Zm9vYmE=
14 8 Zm9vYmFy
15 0
16 1 f
17 2 fo
18 3 foo
19 4 foob
20 5 fooba
21 6 foobar
22
23 $ test-b64-san
24 0
25 4 Zg==
26 4 Zm8=
27 4 Zm9v
28 8 Zm9vYg==
29 8 Zm9vYmE=
30 8 Zm9vYmFy
31 0
32 1 f
33 2 fo
34 3 foo
35 4 foob
36 5 fooba
37 6 foobar
38
39 check that b64_encode and b64_decode assert invalid input
40
41 $ alias check="egrep '(dumped|Assertion)' output.log | sed 's;.*\(b64_.*code\).*\(Assertion.*$\);\1: \2;' | LC_ALL=C sort"
42
43 $ test-b64_decode 2> output.log; check
44 Aborted (core dumped)
45 b64_decode: Assertion `dest && targsize > 0' failed.
46
47 $ test-b64_encode 2> output.log; check
48 Aborted (core dumped)
49 b64_encode: Assertion `dest && targsize > 0' failed.
50
51 $ test-b64_decode-san > output.log 2>&1; check
52 Aborted (core dumped)
53 b64_decode: Assertion `dest && targsize > 0' failed.
54
55 $ test-b64_encode-san > output.log 2>&1; check
56 Aborted (core dumped)
57 b64_encode: Assertion `dest && targsize > 0' failed.