summaryrefslogtreecommitdiffstats
path: root/tests/imgPPM.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/imgPPM.test')
-rw-r--r--tests/imgPPM.test211
1 files changed, 103 insertions, 108 deletions
diff --git a/tests/imgPPM.test b/tests/imgPPM.test
index e3a738a..8dec8c2 100644
--- a/tests/imgPPM.test
+++ b/tests/imgPPM.test
@@ -6,12 +6,11 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
-package require tcltest 2.2
-namespace import ::tcltest::*
+package require tcltest 2.1
eval tcltest::configure $argv
tcltest::loadTestedCommands
-imageInit
+eval image delete [image names]
# Note that we do not use [tcltest::makeFile] because it is
# only suitable for text files
@@ -22,145 +21,141 @@ proc put {file data} {
close $f
}
-test imgPPM-1.1 {FileReadPPM procedure} -body {
+test imgPPM-1.1 {FileReadPPM procedure} {
put test.ppm "P6\n0 256\n255\nabcdef"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {PPM image file "test.ppm" has dimension(s) <= 0}
-test imgPPM-1.2 {FileReadPPM procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
+test imgPPM-1.2 {FileReadPPM procedure} {
put test.ppm "P6\n-2 256\n255\nabcdef"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {PPM image file "test.ppm" has dimension(s) <= 0}
-test imgPPM-1.3 {FileReadPPM procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
+test imgPPM-1.3 {FileReadPPM procedure} {
put test.ppm "P6\n10 0\n255\nabcdef"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {PPM image file "test.ppm" has dimension(s) <= 0}
-test imgPPM-1.4 {FileReadPPM procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
+test imgPPM-1.4 {FileReadPPM procedure} {
put test.ppm "P6\n10 -2\n255\nabcdef"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {PPM image file "test.ppm" has dimension(s) <= 0}
-test imgPPM-1.5 {FileReadPPM procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
+test imgPPM-1.5 {FileReadPPM procedure} {
put test.ppm "P6\n10 20\n100000\nabcdef"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {PPM image file "test.ppm" has bad maximum intensity value 100000}
-test imgPPM-1.6 {FileReadPPM procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {PPM image file "test.ppm" has bad maximum intensity value 100000}}
+test imgPPM-1.6 {FileReadPPM procedure} {
put test.ppm "P6\n10 20\n0\nabcdef"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {PPM image file "test.ppm" has bad maximum intensity value 0}
-test imgPPM-1.7 {FileReadPPM procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {PPM image file "test.ppm" has bad maximum intensity value 0}}
+test imgPPM-1.7 {FileReadPPM procedure} {
put test.ppm "P6\n10 10\n255\nabcdef"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {error reading PPM image file "test.ppm": not enough data}
-test imgPPM-1.8 {FileReadPPM procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {error reading PPM image file "test.ppm": not enough data}}
+test imgPPM-1.8 {FileReadPPM procedure} {
put test.ppm "P6\n5 4\n255\n01234567890123456789012345678901234567890123456789012345678"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {error reading PPM image file "test.ppm": not enough data}
-test imgPPM-1.9 {FileReadPPM procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {error reading PPM image file "test.ppm": not enough data}}
+test imgPPM-1.9 {FileReadPPM procedure} {
put test.ppm "P6\n5 4\n150\n012345678901234567890123456789012345678901234567890123456789"
- list [image create photo p1 -file test.ppm] \
- [image width p1] [image height p1]
-} -returnCodes ok -result {p1 5 4}
+ list [catch {image create photo p1 -file test.ppm} msg] $msg \
+ [image width p1] [image height p1]
+} {0 p1 5 4}
-
-test imgPPM-2.1 {FileWritePPM procedure} -setup {
- catch {image delete p1}
-} -body {
- put test.ppm "P6\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
+catch {image delete p1}
+put test.ppm "P6\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
+image create photo p1 -file test.ppm
+test imgPPM-2.1 {FileWritePPM procedure} {
list [catch {p1 write not_a_dir/bar/baz/gorp} msg] [string tolower $msg] \
- [string tolower $errorCode]
-} -cleanup {
- image delete p1
-} -result {1 {couldn't open "not_a_dir/bar/baz/gorp": no such file or directory} {posix enoent {no such file or directory}}}
-
-test imgPPM-2.2 {FileWritePPM procedure} -setup {
- catch {image delete p1}
+ [string tolower $errorCode]
+} {1 {couldn't open "not_a_dir/bar/baz/gorp": no such file or directory} {posix enoent {no such file or directory}}}
+test imgPPM-2.2 {FileWritePPM procedure} {
catch {unset data}
-} -body {
- put test.ppm "P6\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
p1 write -format ppm test.ppm
set fd [open test.ppm]
set data [read $fd]
close $fd
set data
-} -cleanup {
- image delete p1
-} -result {P6
+} {P6
5 4
255
012345678901234567890123456789012345678901234567890123456789}
-
-test imgPPM-3.1 {ReadPPMFileHeader procedure} -body {
+test imgPPM-3.1 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "# \n#\n#\nP6\n#\n##\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -cleanup {
- image delete p1
-} -returnCodes ok -result p1
-test imgPPM-3.2 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {0 p1}
+test imgPPM-3.2 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P6\n5\n 4 255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -cleanup {
- image delete p1
-} -returnCodes ok -result p1
-test imgPPM-3.3 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {0 p1}
+test imgPPM-3.3 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P6\n# asdfasdf\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -cleanup {
- image delete p1
-} -returnCodes ok -result p1
-test imgPPM-3.4 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {0 p1}
+test imgPPM-3.4 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P6 \n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -cleanup {
- image delete p1
-} -returnCodes ok -result p1
-test imgPPM-3.5 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {0 p1}
+test imgPPM-3.5 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P5\n5 4\n255\n01234567890123456789"
- image create photo p1 -file test.ppm
-} -cleanup {
- image delete p1
-} -returnCodes ok -result p1
-test imgPPM-3.6 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {0 p1}
+test imgPPM-3.6 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P3\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-test imgPPM-3.7 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {couldn't recognize data in image file "test.ppm"}}
+test imgPPM-3.7 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P6x\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-test imgPPM-3.8 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {couldn't recognize data in image file "test.ppm"}}
+test imgPPM-3.8 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P6\nxy5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-test imgPPM-3.9 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {couldn't recognize data in image file "test.ppm"}}
+test imgPPM-3.9 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P6\n5\n255\n!012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-test imgPPM-3.10 {ReadPPMFileHeader procedure} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {couldn't recognize data in image file "test.ppm"}}
+test imgPPM-3.10 {ReadPPMFileHeader procedure} {
+ catch {image delete p1}
put test.ppm "P6\n5 4\nzz255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-test imgPPM-3.11 {ReadPPMFileHeader procedure, empty file} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {couldn't recognize data in image file "test.ppm"}}
+test imgPPM-3.11 {ReadPPMFileHeader procedure, empty file} {
+ catch {image delete p1}
put test.ppm " "
- image create photo p1 -file test.ppm
-} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-test imgPPM-3.12 {ReadPPMFileHeader procedure, file ends too soon} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {couldn't recognize data in image file "test.ppm"}}
+test imgPPM-3.12 {ReadPPMFileHeader procedure, file ends too soon} {
+ catch {image delete p1}
put test.ppm "P6\n566"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-test imgPPM-3.13 {ReadPPMFileHeader procedure, file ends too soon} -body {
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {couldn't recognize data in image file "test.ppm"}}
+test imgPPM-3.13 {ReadPPMFileHeader procedure, file ends too soon} {
+ catch {image delete p1}
put test.ppm "P6\n566\n#asdf"
- image create photo p1 -file test.ppm
-} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-
+ list [catch {image create photo p1 -file test.ppm} msg] $msg
+} {1 {couldn't recognize data in image file "test.ppm"}}
-test imgPPM-4.1 {StringReadPPM procedure, data too short [Bug 1822391]} -body {
- image create photo I -width 1103 -height 997
- I put "P5\n1103 997\n255\n"
-} -cleanup {
- image delete I
-} -returnCodes error -result {truncated PPM data}
+test imgPPM-4.1 {StringReadPPM procedure, data too short [Bug 1822391]} \
+ -setup {
+ image create photo I -width 1103 -height 997
+ } \
+ -cleanup {
+ image delete I
+ } \
+ -body {
+ I put "P5\n1103 997\n255\n"
+ } \
+ -returnCodes error \
+ -result {truncated PPM data}
test imgPPM-5.1 {StringReadPPM procedure} -setup {
image create photo ppm
@@ -227,7 +222,7 @@ test imgPPM-5.9 {StringReadPPM procedure} -setup {
image delete ppm
} -result {5 4}
-imageFinish
+eval image delete [image names]
# cleanup
catch {file delete test.ppm}