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

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

set icodata \
{AAABAAEAICAAAAEACACoCAAAFgAAACgAAAAgAAAAQAAAAAEACAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAD/AYCAAAH//wABAP//AQAAgAEAgAABAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/////////wYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgb/////////BgYGBgYGBgYGBgYGBgYG
BgYGBgYGBgYGBv////////8GBgYGBv8GBgYGBgYGBgYGBgYGBgYGBgYG/////////wMDAwMD
/wMDAwMDAwMFBQUFBQUFBQMDAwP/////////AwMDAwP/AwMDAwMDAwUFBQUFBQUFAwMDA///
//////8DAwMDAwH/AwMDAwMDBQUFBQUFBQUDAwMD/////////wMDAwMDAf8BAQMDAwMFBQUF
BQUFBQMDAwP/////////AwMDAwMB/wEBAwMDAwUFBQUFBQUFAwMDA/////////8DAwMDAwEB
/wEBAwMDAwUFBQUFBQMDAwMD/////////wMDAwMDAwH//wEBAwMDAwUFBQUDAwMDAwP/////
////AwMDAwMDAQH//wEDAwMDAwUFAwMDAwMDA/////////8DAwMDAwMBAQH/AQEDAwMDAwMD
AwMDAwMD/////////wMDAwMDAwMBAQH/AQMDAwMDAwMDAwMDAwP/////////AwMDBAQDAwMB
Af8BAQMDAwMDAwMDAwMDA/////////8DAwMEBAMDAwEB//8BAwMDAwMDAwMDAwMD////////
/wMDAwMDAwMDAQEB/wEBAwMDAwMDAwMDAwP/////////AwMDAwMDAwMDAQH//wEBAwMDAwMD
AwMDA///////////////////////AQH/AQH///////////////////////////////////8B
Af8BAQH//////////////////////////////////wEBAf8BAQH/////////////////////
/////////////wEBAf8BAQH/////////////////////////////////AQEBAf8BAQH/////
/////////////////////////////wEBAf//AQL/////////////////////////////////
AgEBAf8BAf///////////////////////////////////wEBAf8B////////////////////
//////////////////8BAf//////////////////////////////////////////////////
///////////////////////////AAAAHwAAAB8AAAAfAAAAHwAAAB8AAAAfAAAAHwAAAB8AA
AAfAAAAHwAAAB8AAAAfAAAAHwAAAB8AAAAfAAAAHwAAAB8AAAAfAAAAH+fgfP/54DP//nAP/
/+QD///5Af///gH////B////8f//////}

test ico-1.1 {} {
    catch {image delete i}
    image create photo i -file img.ico
    i data -format ico
} $icodata
test ico-1.2 {} {
    catch {image delete i}
    image create photo i -data $icodata
    set data [i data -format ico]
} $icodata
test ico-1.3 {} {
    i blank
    i put $icodata
    set data [i data -format ico]
} $icodata
test ico-1.4 {} {
    i blank
    i put $icodata -format ico
    set data [i data -format ico]
} $icodata

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

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