summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2018-11-15 22:18:29 (GMT)
committersebres <sebres@users.sourceforge.net>2018-11-15 22:18:29 (GMT)
commitdca8be01de6f8cc44135c0528bba0fc4d25c3a44 (patch)
treef6817438c1358ffa83d0e07c9dade8b91c3c5f15 /tests
parentf2d42d756e8aa1563d4f7336f2a3a9b9e3455b73 (diff)
downloadtcl-dca8be01de6f8cc44135c0528bba0fc4d25c3a44.zip
tcl-dca8be01de6f8cc44135c0528bba0fc4d25c3a44.tar.gz
tcl-dca8be01de6f8cc44135c0528bba0fc4d25c3a44.tar.bz2
test cases for decode base64, bug [00d04c4f12], unfulfilled base64 (strict and non-strict mode, etc).
Diffstat (limited to 'tests')
-rw-r--r--tests/binary.test40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/binary.test b/tests/binary.test
index 2a306a3..8c1dedb 100644
--- a/tests/binary.test
+++ b/tests/binary.test
@@ -2711,6 +2711,46 @@ test binary-73.30 {binary decode base64} -body {
test binary-73.31 {binary decode base64} -body {
list [string length [set r [binary decode base64 WA==WFla]]] $r
} -returnCodes error -match glob -result {invalid base64 character *}
+test binary-73.32 {binary decode base64, bug [00d04c4f12]} -body {
+ list \
+ [string length [binary decode base64 =]] \
+ [string length [binary decode base64 " ="]] \
+ [string length [binary decode base64 " ="]] \
+ [string length [binary decode base64 "\r\n\t="]] \
+} -result [lrepeat 4 0]
+test binary-73.33 {binary decode base64, bug [00d04c4f12]} -body {
+ list \
+ [string length [binary decode base64 ==]] \
+ [string length [binary decode base64 " =="]] \
+ [string length [binary decode base64 " =="]] \
+ [string length [binary decode base64 " =="]] \
+} -result [lrepeat 4 0]
+test binary-73.34 {binary decode base64, (compatibility) unfulfilled base64 (single char) in non-strict mode} -body {
+ list \
+ [expr {[binary decode base64 a] eq [binary decode base64 ""]}] \
+ [expr {[binary decode base64 abcda] eq [binary decode base64 "abcd"]}]
+} -result [lrepeat 2 1]
+test binary-73.35 {binary decode base64, bad base64 in strict mode} -body {
+ set r {}
+ foreach c {a " a" " a" " a" " a" abcda abcdabcda a= a== abcda= abcda==} {
+ lappend r \
+ [catch {binary decode base64 $c}] \
+ [catch {binary decode base64 -strict $c}]
+ }
+ set r
+} -result [lrepeat 11 0 1]
+test binary-73.36 {binary decode base64: check encoded & decoded equals original} -body {
+ set r {}
+ for {set i 0} {$i < 255 && [llength $r] < 20} {incr i} {
+ foreach c {1 2 3 4 5 6 7 8} {
+ set c [string repeat [format %c $i] $c]
+ if {[set a [binary decode base64 [set x [binary encode base64 $c]]]] ne $c} {
+ lappend r "encode & decode is wrong on string `$c` (encoded: $x): `$a` != `$c`"
+ }
+ }
+ }
+ join $r \n
+} -result {}
test binary-74.1 {binary encode uuencode} -body {
binary encode uuencode