aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMoritz Röhrich <moritz@ildefons.de>2021-01-07 17:40:20 +0100
committerRob Landley <rob@landley.net>2021-01-07 16:10:47 -0600
commitb6b5becf359370c7f32d8419bcf8f50a47fbe933 (patch)
tree4926ca2fe9180730dd9adfcb464d16c8d4ba2ffc /tests
parent824de078e4bdc752da9559cc64df627028310cc3 (diff)
downloadtoybox-b6b5becf359370c7f32d8419bcf8f50a47fbe933.tar.gz
new toy: base32
Add new toy `base32`. Add tests for `base32`. base32 is added by adapting the base64 encode/decode function to also do base32 encoding/decoding. Then their respective main functions set up the global parameter `n` to be the number of bits used in the encoding (5 for base32 and 6 for base64) and `align` to align the result to a certain length via padding. These are deliberately kept as parameters to enable future expansion for other bases easily.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/base32.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/base32.test b/tests/base32.test
new file mode 100755
index 00000000..00bcffa9
--- /dev/null
+++ b/tests/base32.test
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+# testing "name" "flags" "result" "infile" "stdin"
+
+testcmd "simple" "" "ONUW24DMMUFA====\n" "" "simple\n"
+testcmd "file" "input" "ONUW24DMMUFA====\n" "simple\n" ""
+testcmd "simple -d" "-d" "simple\n" "" "ONUW24DMMUFA====\n"
+testcmd "file -d" "-d input" "simple\n" "ONUW24DMMUFA====" ""
+testcmd "default wrap" "" \
+ "K5SSO5TFEBZGK4DMMFRWKZBAORUGKIDENFWGS5DINF2W2IDUNBSXSIDON5ZG2YLMNR4SA5LTMUQH\nO2LUNAQEM33MM5SXEJ3TEBBXE6LTORQWY4ZO\n" \
+ "" "We've replaced the dilithium they normally use with Folger's Crystals."
+testcmd "multiline -d " "-d" \
+ "We've replaced the dilithium they normally use with Folger's Crystals." "" \
+ "K5SSO5TFEBZGK4DMMFRWKZBAORUGKIDENFWGS5DINF2W2IDUNBSXSIDON5ZG2YLMNR4SA5LTMUQH\nO2LUNAQEM33MM5SXEJ3TEBBXE6LTORQWY4ZO\n"
+
+testcmd "-w" "-w 10" \
+ "JVQXEY3INF\nXGOIDUN4QH\nI2DFEBRGKY\nLUEBXWMIDB\nEBSGSZTGMV\nZGK3TUEBVW\nK5DUNRSSA3\n3GEBTGS43I\nFY======\n" \
+ "" "Marching to the beat of a different kettle of fish."
+
+testcmd "-w0" "-w0 input" \
+ "KZUWW2LOM5ZT6ICUNBSXEZJAMFUW4J3UEBXG6IDWNFVWS3THOMQGQZLSMUXCASTVON2CA5LTEBUG63TFON2CAZTBOJWWK4TTFYQFI2DFEB2G653OEB3WC4ZAMJ2XE3TJNZTSYIDUNBSSA5TJNRWGCZ3FOJZSA53FOJSSAZDFMFSC4ICUNBSXSIDENFSG4J3UEBXGKZLEEB2GQ33TMUQHG2DFMVYCAYLOPF3WC6JOEBKGQYLUE5ZSA33VOIQHG5DPOJ4SAYLOMQQHOZJHOJSSA43UNFRWW2LOM4QHI3ZANF2C4CQ=" \
+ "Vikings? There ain't no vikings here. Just us honest farmers. The town was burning, the villagers were dead. They didn't need those sheep anyway. That's our story and we're sticking to it.\n" ""