# Test error cases using the pawt package.
#
# Copyright: 2021-2024 Paul Obermeier (obermeier@poSoft.de)
# Distributed under BSD license.

if { [file exists "TestUtils.tcl"] } {
    source "TestUtils.tcl"
}

package require pawt

if { ! [pawt::HavePkg "Img"] } {
    puts "Error: pawt test suite needs the Img extension."
    exit 1
}

if { ! [file isdirectory "testOut"] } {
    file mkdir "testOut"
}

set testCase "01_Basic-ErrorCases"
pawtTest AddImgDicts -title $testCase

set retVal [catch { pawt CreateImage -asdf } imgDict]
pawtTest CheckNumber 1 $retVal "Create image with invalid option: $imgDict"

set retVal [catch { pawt CreateImage -scanorder } imgDict]
pawtTest CheckNumber 1 $retVal "Create image with missing option value: $imgDict"

set retVal [catch { pawt CreateImage -numchan 0 } imgDict]
pawtTest CheckNumber 1 $retVal "Create image with invalid -numchan: $imgDict"

set retVal [catch { pawt CreateImage -byteorder intel } imgDict]
pawtTest CheckNumber 1 $retVal "Create image with invalid -byteorder: $imgDict"

set retVal [catch { pawt CreateImage -scanorder topdown } imgDict]
pawtTest CheckNumber 1 $retVal "Create image with invalid -scanorder: $imgDict"

set retVal [catch { pawt CreateImage -pixeltype shorty } imgDict]
pawtTest CheckNumber 1 $retVal "Create image with invalid -pixeltype: $imgDict"

set retVal [catch { pawt CreateImage -width 0 } imgDict]
pawtTest CheckNumber 1 $retVal "Create image with zero width: $imgDict"

set retVal [catch { pawt CreateImage -height 0 } imgDict]
pawtTest CheckNumber 1 $retVal "Create image with zero height: $imgDict"

if { [lindex $argv 0] eq "auto" } {
    update
    after 500
    exit 0
}
