File: ps.test

package info (click to toggle)
libtk-img 1%3A2.0.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 47,852 kB
  • sloc: ansic: 224,696; sh: 20,589; tcl: 8,921; makefile: 2,272; cpp: 1,933; ada: 1,681; pascal: 1,139; cs: 879; awk: 794; asm: 587; python: 542; xml: 95
file content (186 lines) | stat: -rwxr-xr-x 6,153 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# This file is a Tcl script to test PostScript reading.
# Writing is not supported for PostScript.
# It is organized in the standard fashion for Tcl tests.

package require Tk

package require tcltest
tcltest::configure {*}$argv
source [file join [file dirname [info script]] constraints.tcl]

imageInit

namespace eval ::ps::test {
    namespace import ::tcltest::*

    set fmt     "ps"
    set ext     "ps"
    set inFile  "testimgs/img.$ext"
    set outFile "testimgs/img_out.$ext"

    set imgdata [readFile $inFile]

    test ps-0.1 {package require img::ps} -setup {
    } -body {
        set pkgLoaded [catch {package require img::ps}]
    } -result 0

    # Execute the follwing tests only, if the format handler could be loaded.
    if { $pkgLoaded == 0 } {
        test ps-1.1 {Read photo from file using option \"-file\"} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile
            imageSize i
        } -constraints {
            Ghostscript
        } -result [refSize]

        test ps-1.2 {Read photo from string using option \"-data\"} -setup {
            catch {image delete i}
        } -body {
            image create photo i -data $imgdata
            imageSize i
        } -cleanup {
            image delete i
        } -constraints {
            Ghostscript
        } -result [refSize]

        test ps-1.3 {Read photo from string using command \"put\"} -setup {
            catch {image delete i}
        } -body {
            image create photo i
            i put $imgdata
            imageSize i
        } -cleanup {
            image delete i
        } -constraints {
            Ghostscript
        } -result [refSize]

        test ps-1.4 {Read photo from string using command \"put -format\"} -setup {
            catch {image delete i}
        } -body {
            image create photo i
            i put $imgdata -format $fmt
            imageSize i
        } -cleanup {
            image delete i
        } -constraints {
            Ghostscript
        } -result [refSize]

        test ps-1.5 {Compare 2 photos read from file and from string} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile
            image create photo j -data $imgdata
            imageCompare i j
        } -cleanup {
            image delete i
            image delete j
        } -constraints {
            Ghostscript
        } -result 1


        test ps-2.1 {Read photo from file without resolution information} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile
            imageResolution i
        } -cleanup {
            image delete i
        } -constraints {
            Tk87 Ghostscript
        } -result {0 0}

        test ps-2.2 {Read photo from file using single -zoom value} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile -format [list $fmt -zoom 2.0]
            imageSize i
        } -constraints {
            Tk87 Ghostscript
        } -result [refSize2]

        test ps-2.2 {Read photo from file using two -zoom values} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile -format [list $fmt -zoom 2 2.0]
            imageSize i
        } -constraints {
            Tk87 Ghostscript
        } -result [refSize2]

        # PS does not support writing.


        test ps-5.1 {Read photo from file using invalid option \"-invalidoption\"} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile -format [list $fmt -invalidoption 1]
        } -returnCodes {
            error
        } -result "bad format option \"-invalidoption\": must be -verbose, -index, -zoom, or -gs"

        test ps-5.2 {Read photo from file using option without value} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile -format [list $fmt -verbose]
        } -returnCodes {
            error
        } -result "No value specified for option \"-verbose\"."

        test ps-5.3 {Read photo from file using invalid -verbose value} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile -format [list $fmt -verbose "asdf"]
        } -returnCodes {
            error
        } -result "Invalid verbose mode \"asdf\": must be 1 or 0, on or off, true or false."

        test ps-5.4 {Read photo from file using invalid -zoom value} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile -format [list $fmt -zoom "asdf" "asdf"]
        } -returnCodes {
            error
        } -result "Invalid x zoom value \"asdf\": must be a double value greater than zero."

        test ps-5.5 {Read photo from file using invalid -zoom value} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile -format [list $fmt -zoom 1 "asdf"]
        } -returnCodes {
            error
        } -result "Invalid y zoom value \"asdf\": must be a double value greater than zero."

        test ps-5.6 {Read photo from file using invalid -index value} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile -format [list $fmt -index "asdf"]
        } -returnCodes {
            error
        } -result "Invalid index value \"asdf\": must be an integer value greater or equal to zero."

        test ps-5.7 {Write photo to file using invalid option \"-invalidoption\"} -setup {
            catch {image delete i}
        } -body {
            image create photo i -file $inFile
            i write $outFile -format [list $fmt -invalidoption 1]
        } -cleanup {
            image delete i
            file delete -force $outFile
        } -constraints {
            Ghostscript
        } -returnCodes {
            error
        } -result "Writing not supported for format ps"
    }
}

imageFinish
tcltest::cleanupTests
namespace delete ::ps::test