summaryrefslogtreecommitdiffstats
path: root/tests/imgPNG.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/imgPNG.test')
-rw-r--r--tests/imgPNG.test20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/imgPNG.test b/tests/imgPNG.test
index 7fb2622..1cfaad0 100644
--- a/tests/imgPNG.test
+++ b/tests/imgPNG.test
@@ -8,7 +8,7 @@
# Copyright (c) 2008 Donal K. Fellows
# All rights reserved.
#
-# RCS: @(#) $Id: imgPNG.test,v 1.2 2009/01/13 01:46:06 patthoyts Exp $
+# RCS: @(#) $Id: imgPNG.test,v 1.3 2010/04/12 08:40:17 dkf Exp $
package require tcltest 2.2
namespace import ::tcltest::*
@@ -19,16 +19,20 @@ imageInit
namespace eval png {
variable encoded
# Key names are from the names of the source images, which come from
- # http://www.schaik.com/pngsuite/pngsuite.html
+ # http://www.schaik.com/pngsuite/pngsuite.html
+ # The exception is "BadX", which is used to test handling badly compressed
+ # images.
array set encoded {
basn0g08 "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAAAAABWESUoAAAABGdBTUEAAYagMeiWXwAAAEFJREFUeJxjZGAkABQIyLMMBQWMDwgp+PcfP2B5MBwUMMoRkGdkonlcDAYFjI/wyv7/z/iH5nExGBQwyuCVZWQEAFDl/nE14thZAAAAAElFTkSuQmCC"
basn2c08 "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAABGdBTUEAAYagMeiWXwAAAEhJREFUeJzt1cEJADAMAkCF7JH9t3ITO0Qr9KH4zuErtA0EO4AKFPgcoO3kfUx4QIECD0qHH8KEBxQo8KB0OCOpQIG7cHejwAGCsfleD0DPSwAAAABJRU5ErkJggg=="
basn3p08 "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAAYagMeiWXwAAAwBQTFRFIkQA9f/td/93y///EQoAOncAIiL//xH/EQAAIiIA/6xVZv9m/2Zm/wH/IhIA3P//zP+ZRET/AFVVIg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xKP8yD6iPMXITjP+oTdfsp14lTJMJjGtOMFQfiFe4wWK8BP7qUd31hBNqMos2tKYFbRnJdGGjTzPz2yjEA1ZSKymKCM5ylaWcJrZxCZK8jgfU4vc/MW3xE7K8RUvsZb3Wc/XxCEqk4v/qMQlFvMZcZIafMOnLKM13zGceJNqPMU4KnCQAqQgbrKHpXSgFK/Qn6REO9YxjWE8Sx2SMJD4jfl8wgzy0YgPuEeUJQcD6EoWWpCaHsQkHuY9RpGON/icK0RyrvE680jG22TlHaIbx6jLnySkF+M5QxzmD6pwkTsMoSAdidqsojipuMyHzOQ4sYgfyElpzjKGErQkqvMyC7jFv9xmBM2JuTzDRDLxN4l4jF1EZjIwmhfZzSOMpT4xiH70IQG/k5En2UKcowudycsG8jCBmtwHgRv+EIeWyOAAAAAASUVORK5CYII="
basn6a08 "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAAYagMeiWXwAAAG9JREFUeJzt1jEKgDAMRuEnZGhPofc/VQSPIcTdxUV4HVLoUCj8H00o2YoBMF57fpz/ujODHXUFRwPKBqj5DVigB041HiJ9gFyCVOMbsEIPXNwuAHkgiJL/4qABNqB7QAeUPBAE2QAZUDZAfwEb8ABSIBqcFg+4TAAAAABJRU5ErkJggg=="
+
+ BadX "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAABHNCSVQICAgIfAhkiAAAABN0RVh0U29mdHdhcmUAVGsgOC42YjEuMcrtT1oAAAAcSURBVHicYmBgYPjPgAr+ozP+o0uj68BUiWEmAAAA//8SozfjAAAAAElFTkSuQmCC"
}
# $encoded(basn0g08), $encoded(basn2c08), $encoded(basn3p08), $encoded(basn6a08)
-test png-1.1 {reading basic images; grayscale} -setup {
+test imgPNG-1.1 {reading basic images; grayscale} -setup {
catch {rename foo ""}
} -body {
image create photo foo -data $encoded(basn0g08)
@@ -36,7 +40,7 @@ test png-1.1 {reading basic images; grayscale} -setup {
} -cleanup {
rename foo ""
} -result {32 32}
-test png-1.2 {reading basic images; color} -setup {
+test imgPNG-1.2 {reading basic images; color} -setup {
catch {rename foo ""}
} -body {
image create photo foo -data $encoded(basn2c08)
@@ -44,7 +48,7 @@ test png-1.2 {reading basic images; color} -setup {
} -cleanup {
rename foo ""
} -result {32 32}
-test png-1.3 {reading basic images; color with palette} -setup {
+test imgPNG-1.3 {reading basic images; color with palette} -setup {
catch {rename foo ""}
} -body {
image create photo foo -data $encoded(basn3p08)
@@ -52,7 +56,7 @@ test png-1.3 {reading basic images; color with palette} -setup {
} -cleanup {
rename foo ""
} -result {32 32}
-test png-1.4 {reading basic images; alpha} -setup {
+test imgPNG-1.4 {reading basic images; alpha} -setup {
catch {rename foo ""}
} -body {
image create photo foo -data $encoded(basn6a08)
@@ -60,6 +64,10 @@ test png-1.4 {reading basic images; alpha} -setup {
} -cleanup {
rename foo ""
} -result {32 32}
+
+test imgPNG-2.1 {reading a bad image} -body {
+ image create photo -data $encoded(BadX)
+} -returnCodes error -result {unfinalized data stream in PNG data}
}
namespace delete png