aboutsummaryrefslogtreecommitdiff
path: root/tests/base64.test
blob: 2058198b0dbea65cf253e0a1bbdb3369f96555e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

[ -f testing.sh ] && . testing.sh

#testing "name" "command" "result" "infile" "stdin"

testing "simple" "base64" "c2ltcGxlCg==\n" "" "simple\n"
testing "file" "base64 input" "c2ltcGxlCg==\n" "simple\n" ""
testing "simple -d" "base64 -d" "simple\n" "" "c2ltcGxlCg==\n"
testing "simple -d" "base64 -d input" "simple\n" "c2ltcGxlCg==" ""
testing "default wrap" "base64" \
  "V2UndmUgcmVwbGFjZWQgdGhlIGRpbGl0aGl1bSB0aGV5IG5vcm1hbGx5IHVzZSB3aXRoIEZvbGdl\ncidzIENyeXN0YWxzLg==\n" \
  "" "We've replaced the dilithium they normally use with Folger's Crystals."
testing "multiline -d " "base64 -d" \
 "We've replaced the dilithium they normally use with Folger's Crystals." "" \
  "V2UndmUgcmVwbGFjZWQgdGhlIGRpbGl0aGl1bSB0aGV5IG5vcm1hbGx5IHVzZSB3aXRoIEZvbGdl\ncidzIENyeXN0YWxzLg==\n"

testing "-w" "base64 -w 10" \
  "TWFyY2hpbm\ncgdG8gdGhl\nIGJlYXQgb2\nYgYSBkaWZm\nZXJlbnQga2\nV0dGxlIG9m\nIGZpc2guCg\n==\n" \
  "" "Marching to the beat of a different kettle of fish.\n"

testing "-w0" "base64 -w0 input" \
  "VmlraW5ncz8gVGhlcmUgYWluJ3Qgbm8gdmlraW5ncyBoZXJlLiBKdXN0IHVzIGhvbmVzdCBmYXJtZXJzLiBUaGUgdG93biB3YXMgYnVybmluZywgdGhlIHZpbGxhZ2VycyB3ZXJlIGRlYWQuIFRoZXkgZGlkbid0IG5lZWQgdGhvc2Ugc2hlZXAgYW55d2F5LiBUaGF0J3Mgb3VyIHN0b3J5IGFuZCB3ZSdyZSBzdGlja2luZyB0byBpdC4K" \
 "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" ""