# This file is a Tcl script to test out SUN reading and writing.
# It is organized in the standard fasion for Tcl tests.
#

if {[string compare test [info procs test]] == 1} {
    source defs
}

set sundata \
{WaZqlQAAABAAAAAMAAAAGAAAAkAAAAACAAAAAAAAAACACNmACwCAINmAAgCAAP/wgAD/8IAA
//CAAP/wgAIAgBrZgAIAgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAIAgBTZgCYAgAjZgAIA
gAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAgCACNmAAgCA
AP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IACAIAI2YACAIAA
//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAIAgAjZgAIAgAD/
8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAgCACNmAAgCAAP/w
gAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IACAIAI2YACAIAA//CA
AP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAIAgAjZgAIAgAD/8IAA
//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAP/wgAD/8IAA//CAAgCACNmAJgCACNk=}

test sun-1.1 {} {
    catch {image delete i}
    image create photo i -file folder.ras
    i data -format sun
} $sundata
test sun-1.2 {} {
    catch {image delete i}
    image create photo i -data $sundata
    set data [i data -format sun]
} $sundata
test sun-1.3 {} {
    i blank
    i put $data
    set data [i data -format sun]
} $sundata
test sun-1.4 {} {
    i blank
    i put $data -format sun
    set data [i data -format sun]
} $sundata

if {[info tclversion] < 8.0} {
    return
}

test sun-2.0 {Binary I/O with SUN images} {
    i blank
    set f [open folder.ras r]
    fconfigure $f -translation binary
    set return [catch {i put [read $f]} msg]
    close $f
    lappend return $msg
} {0 {}}
