# Command covered: geomap::lnarr # # This script file tests the commands in the tclgeomap package. See the # tclgeomap man page for a description of the package. See the tcltest # man page for a description of Tcl's testing proc's. # # Copyright (c) 2004 Gordon D. Carrie. All rights reserved. # # Licensed under the Open Software License version 2.1 # # Please address questions and feedback to user0@tkgeomap.org # # @(#) $Id: tcl_geomap_lnarr.test,v 1.4 2004/09/22 21:57:51 tkgeomap Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import ::tcltest::* } package require tclgeomap 2 test tcl_geomap_lnarr-1.1 {lnarr fmlist, wrong number of arguments} { catch {::geomap::lnarr fmlist} msg set msg } {wrong # args: should be "::geomap::lnarr fmlist arrayName listValue"} test tcl_geomap_lnarr-1.2 {lnarr fmlist. One line} { ::geomap::lnarr fmlist gl1 {{-10 -10} {0 0} {10 10}} gl1 info } {{} {10.0 10.0 -10.0 -10.0} 1 3 3} test tcl_geomap_lnarr-1.3 {lnarr fmlist. Array of lines} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } gl1 info } {{} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-2.1 {lnarr fmascii, wrong number of arguments} { catch {::geomap::lnarr fmascii} msg set msg } {wrong # args: should be "::geomap::lnarr fmascii arrayName fileName ?-descrlen len? ?-format format?"} test tcl_geomap_lnarr-2.2 {lnarr toascii, fmascii} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } ::tcltest::makeFile {} lnarr.txt gl1 toascii lnarr.txt rename gl1 {} ::geomap::lnarr fmascii gl2 lnarr.txt gl2 info } {{} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-2.3 {lnarr toascii, fmascii, descriptor lines} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } gl1 descr "Two lines, three points each" ::tcltest::makeFile {} lnarr.txt gl1 toascii lnarr.txt rename gl1 {} ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen 1l gl2 info } {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-2.4 {lnarr toascii, fmascii, descriptor bytes} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } set descr "Two lines, three points each" gl1 descr $descr ::tcltest::makeFile {} lnarr.txt gl1 toascii lnarr.txt rename gl1 {} ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen [string length $descr] gl2 info } {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-2.5 {lnarr toascii, fmascii, descriptor bytes b} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } set descr "Two lines, three points each" gl1 descr $descr ::tcltest::makeFile {} lnarr.txt gl1 toascii lnarr.txt rename gl1 {} ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen [string length $descr]b gl2 info } {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-2.6 {lnarr toascii, fmascii, formatted points} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } set ofmt "{%.1f %.1f}" set ifmt "{%f %f}" set descr "Two lines, three points each" gl1 descr $descr ::tcltest::makeFile {} lnarr.txt gl1 toascii lnarr.txt -format $ofmt rename gl1 {} ::geomap::lnarr fmascii gl2 lnarr.txt -format $ifmt -descr 1l gl2 info } {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-2.7 {lnarr toascii, fmascii, output with ptperln} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } set descr "Two lines, three points each" gl1 descr $descr ::tcltest::makeFile {} lnarr.txt gl1 toascii lnarr.txt -ptperln 1 rename gl1 {} ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen 1l gl2 info } {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-2.8 {lnarr toascii, fmascii. ptperln and format} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } set descr "Two lines, three points each" gl1 descr $descr ::tcltest::makeFile {} lnarr.txt gl1 toascii lnarr.txt -ptperln 1 -format "{%.1f %.1f}" rename gl1 {} ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen 1l -format "{%f %f}" gl2 info } {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-3.1 {lnarr fmxdr, wrong number of arguments} { catch {::geomap::lnarr fmxdr} msg set msg } {wrong # args: should be "::geomap::lnarr fmxdr arrayName fileName"} test tcl_geomap_lnarr-3.2 {lnarr toxdr, fmxdr} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } set descr "Two lines, three points each" gl1 descr $descr ::tcltest::makeFile {} lnarr.xdr gl1 toxdr lnarr.xdr rename gl1 {} ::geomap::lnarr fmxdr gl2 lnarr.xdr gl2 info } {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-4.1 {lnarr fmbin, wrong number of arguments} { catch {::geomap::lnarr fmbin} msg set msg } {wrong # args: should be "::geomap::lnarr fmbin arrayName fileName"} test tcl_geomap_lnarr-4.2 {lnarr tobin, fmbin} { ::geomap::lnarr fmlist gl1 { {{-10 -10} {0 0} {10 10}} {{20 20} {20 30} {30 30}} } set descr "Two lines, three points each" gl1 descr $descr ::tcltest::makeFile {} lnarr.bin gl1 tobin lnarr.bin rename gl1 {} ::geomap::lnarr fmbin gl2 lnarr.bin gl2 info } {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} test tcl_geomap_lnarr-5.1 {arrayName tolist, wrong number of arguments} { ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} catch {gl1 tolist foo} msg set msg } {wrong # args: should be "gl1 tolist"} test tcl_geomap_lnarr-5.2 {arrayName tolist} { ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} gl1 tolist } {{0.0 0.0} {0.0 10.0} {10.0 10.0}} test tcl_geomap_lnarr-6.1 {arrayName toascii, wrong number of arguments} { ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} catch {gl1 toascii} msg set msg } {wrong # args: should be "gl1 toascii fileName ?-format format? ?-ptperln n?"} test tcl_geomap_lnarr-7.1 {arrayName toxdr, wrong number of arguments} { ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} catch {gl1 toxdr} msg set msg } {wrong # args: should be "gl1 toxdr fileName"} test tcl_geomap_lnarr-8.1 {arrayName tobin, wrong number of arguments} { ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} catch {gl1 tobin} msg set msg } {wrong # args: should be "gl1 tobin fileName"} test tcl_geomap_lnarr-9.1 {arrayName info, wrong number of arguments} { ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} catch {gl1 info wawa} msg set msg } {wrong # args: should be "gl1 info"} test tcl_geomap_lnarr-9.2 {lnarr info, with namespace} { ::geomap::lnarr fmlist gl1 { {{10 10} {10 20} {20 20}} } gl1 descr "global" ::geomap::lnarr fmlist n1::gl1 { {{-10 -10} {-10 -20} {-20 -20}} } namespace eval n1 { gl1 descr "n1" } namespace eval n1 { gl1 info } } {n1 {-10.0 -10.0 -20.0 -20.0} 1 3 3} test tcl_geomap_lnarr-10.1 {arrayName descr, wrong number of arguments} { ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} catch {gl1 descr foo foo} msg set msg } {wrong # args: should be "gl1 descr ?descriptor?"} test tcl_geomap_lnarr-10.2 {lnarr descr, with namespace} { ::geomap::lnarr fmlist gl1 { {{10 10} {10 20} {20 20}} } gl1 descr "global array" namespace eval n1 { ::geomap::lnarr fmlist gl1 { {{-10 -10} {-10 -20} {-20 -20}} } gl1 descr "n1 array" } namespace eval n1 { gl1 descr } } {n1 array} test tcl_geomap_lnarr-12.1 {arrayName containpt, wrong number of arguments} { ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} catch {gl1 containpt} msg set msg } {wrong # args: should be "gl1 containpt {lat lon}"} test tcl_geomap_lnarr-12.2 {arrayName containpt} { ::geomap::lnarr fmlist gl1 { {10 10} {60 10} {60 50} {30 50} {30 30} {40 30} {40 40} {50 40} {50 20} {20 20} {20 50} {10 50} } for {set lat 65;set pts {}} {$lat >= 5} {incr lat -5} { for {set lon 5} {$lon <= 55} {incr lon 5} { lappend pts [gl1 containpt [list $lat $lon]] } } set pts } {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0} cleanupTests