libubox
C utility functions for OpenWrt.
test_base64.t
Go to the documentation of this file.
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="grep Assertion output.log | sed 's;.*\‍(b64_.*code\‍).*\‍(Assertion.*$\‍);\1: \2;' | LC_ALL=C sort"
42 
43  $ test-b64_decode > output.log 2>&1; check
44  b64_decode: Assertion `dest && targsize > 0' failed.
45 
46  $ test-b64_encode > output.log 2>&1; check
47  b64_encode: Assertion `dest && targsize > 0' failed.
48 
49  $ test-b64_decode-san > output.log 2>&1; check
50  b64_decode: Assertion `dest && targsize > 0' failed.
51 
52  $ test-b64_encode-san > output.log 2>&1; check
53  b64_encode: Assertion `dest && targsize > 0' failed.