1# Command covered: geomap::lnarr 2# 3# This script file tests the commands in the tclgeomap package. See the 4# tclgeomap man page for a description of the package. See the tcltest 5# man page for a description of Tcl's testing proc's. 6# 7# Copyright (c) 2004 Gordon D. Carrie. All rights reserved. 8# 9# Licensed under the Open Software License version 2.1 10# 11# Please address questions and feedback to user0@tkgeomap.org 12# 13# @(#) $Id: tcl_geomap_lnarr.test,v 1.4 2004/09/22 21:57:51 tkgeomap Exp $ 14 15if {[lsearch [namespace children] ::tcltest] == -1} { 16 package require tcltest 17 namespace import ::tcltest::* 18} 19 20package require tclgeomap 2 21 22test tcl_geomap_lnarr-1.1 {lnarr fmlist, wrong number of arguments} { 23 catch {::geomap::lnarr fmlist} msg 24 set msg 25} {wrong # args: should be "::geomap::lnarr fmlist arrayName listValue"} 26 27test tcl_geomap_lnarr-1.2 {lnarr fmlist. One line} { 28 ::geomap::lnarr fmlist gl1 {{-10 -10} {0 0} {10 10}} 29 gl1 info 30} {{} {10.0 10.0 -10.0 -10.0} 1 3 3} 31 32test tcl_geomap_lnarr-1.3 {lnarr fmlist. Array of lines} { 33 ::geomap::lnarr fmlist gl1 { 34 {{-10 -10} {0 0} {10 10}} 35 {{20 20} {20 30} {30 30}} 36 } 37 gl1 info 38} {{} {30.0 30.0 -10.0 -10.0} 2 6 3} 39 40test tcl_geomap_lnarr-2.1 {lnarr fmascii, wrong number of arguments} { 41 catch {::geomap::lnarr fmascii} msg 42 set msg 43} {wrong # args: should be "::geomap::lnarr fmascii arrayName fileName ?-descrlen len? ?-format format?"} 44 45test tcl_geomap_lnarr-2.2 {lnarr toascii, fmascii} { 46 ::geomap::lnarr fmlist gl1 { 47 {{-10 -10} {0 0} {10 10}} 48 {{20 20} {20 30} {30 30}} 49 } 50 ::tcltest::makeFile {} lnarr.txt 51 gl1 toascii lnarr.txt 52 rename gl1 {} 53 ::geomap::lnarr fmascii gl2 lnarr.txt 54 gl2 info 55} {{} {30.0 30.0 -10.0 -10.0} 2 6 3} 56 57test tcl_geomap_lnarr-2.3 {lnarr toascii, fmascii, descriptor lines} { 58 ::geomap::lnarr fmlist gl1 { 59 {{-10 -10} {0 0} {10 10}} 60 {{20 20} {20 30} {30 30}} 61 } 62 gl1 descr "Two lines, three points each" 63 ::tcltest::makeFile {} lnarr.txt 64 gl1 toascii lnarr.txt 65 rename gl1 {} 66 ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen 1l 67 gl2 info 68} {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} 69 70test tcl_geomap_lnarr-2.4 {lnarr toascii, fmascii, descriptor bytes} { 71 ::geomap::lnarr fmlist gl1 { 72 {{-10 -10} {0 0} {10 10}} 73 {{20 20} {20 30} {30 30}} 74 } 75 set descr "Two lines, three points each" 76 gl1 descr $descr 77 ::tcltest::makeFile {} lnarr.txt 78 gl1 toascii lnarr.txt 79 rename gl1 {} 80 ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen [string length $descr] 81 gl2 info 82} {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} 83 84test tcl_geomap_lnarr-2.5 {lnarr toascii, fmascii, descriptor bytes b} { 85 ::geomap::lnarr fmlist gl1 { 86 {{-10 -10} {0 0} {10 10}} 87 {{20 20} {20 30} {30 30}} 88 } 89 set descr "Two lines, three points each" 90 gl1 descr $descr 91 ::tcltest::makeFile {} lnarr.txt 92 gl1 toascii lnarr.txt 93 rename gl1 {} 94 ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen [string length $descr]b 95 gl2 info 96} {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} 97 98test tcl_geomap_lnarr-2.6 {lnarr toascii, fmascii, formatted points} { 99 ::geomap::lnarr fmlist gl1 { 100 {{-10 -10} {0 0} {10 10}} 101 {{20 20} {20 30} {30 30}} 102 } 103 set ofmt "{%.1f %.1f}" 104 set ifmt "{%f %f}" 105 set descr "Two lines, three points each" 106 gl1 descr $descr 107 ::tcltest::makeFile {} lnarr.txt 108 gl1 toascii lnarr.txt -format $ofmt 109 rename gl1 {} 110 ::geomap::lnarr fmascii gl2 lnarr.txt -format $ifmt -descr 1l 111 gl2 info 112} {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} 113 114test tcl_geomap_lnarr-2.7 {lnarr toascii, fmascii, output with ptperln} { 115 ::geomap::lnarr fmlist gl1 { 116 {{-10 -10} {0 0} {10 10}} 117 {{20 20} {20 30} {30 30}} 118 } 119 set descr "Two lines, three points each" 120 gl1 descr $descr 121 ::tcltest::makeFile {} lnarr.txt 122 gl1 toascii lnarr.txt -ptperln 1 123 rename gl1 {} 124 ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen 1l 125 gl2 info 126} {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} 127 128test tcl_geomap_lnarr-2.8 {lnarr toascii, fmascii. ptperln and format} { 129 ::geomap::lnarr fmlist gl1 { 130 {{-10 -10} {0 0} {10 10}} 131 {{20 20} {20 30} {30 30}} 132 } 133 set descr "Two lines, three points each" 134 gl1 descr $descr 135 ::tcltest::makeFile {} lnarr.txt 136 gl1 toascii lnarr.txt -ptperln 1 -format "{%.1f %.1f}" 137 rename gl1 {} 138 ::geomap::lnarr fmascii gl2 lnarr.txt -descrlen 1l -format "{%f %f}" 139 gl2 info 140} {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} 141 142test tcl_geomap_lnarr-3.1 {lnarr fmxdr, wrong number of arguments} { 143 catch {::geomap::lnarr fmxdr} msg 144 set msg 145} {wrong # args: should be "::geomap::lnarr fmxdr arrayName fileName"} 146 147test tcl_geomap_lnarr-3.2 {lnarr toxdr, fmxdr} { 148 ::geomap::lnarr fmlist gl1 { 149 {{-10 -10} {0 0} {10 10}} 150 {{20 20} {20 30} {30 30}} 151 } 152 set descr "Two lines, three points each" 153 gl1 descr $descr 154 ::tcltest::makeFile {} lnarr.xdr 155 gl1 toxdr lnarr.xdr 156 rename gl1 {} 157 ::geomap::lnarr fmxdr gl2 lnarr.xdr 158 gl2 info 159} {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} 160 161test tcl_geomap_lnarr-4.1 {lnarr fmbin, wrong number of arguments} { 162 catch {::geomap::lnarr fmbin} msg 163 set msg 164} {wrong # args: should be "::geomap::lnarr fmbin arrayName fileName"} 165 166test tcl_geomap_lnarr-4.2 {lnarr tobin, fmbin} { 167 ::geomap::lnarr fmlist gl1 { 168 {{-10 -10} {0 0} {10 10}} 169 {{20 20} {20 30} {30 30}} 170 } 171 set descr "Two lines, three points each" 172 gl1 descr $descr 173 ::tcltest::makeFile {} lnarr.bin 174 gl1 tobin lnarr.bin 175 rename gl1 {} 176 ::geomap::lnarr fmbin gl2 lnarr.bin 177 gl2 info 178} {{Two lines, three points each} {30.0 30.0 -10.0 -10.0} 2 6 3} 179 180test tcl_geomap_lnarr-5.1 {arrayName tolist, wrong number of arguments} { 181 ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} 182 catch {gl1 tolist foo} msg 183 set msg 184} {wrong # args: should be "gl1 tolist"} 185 186test tcl_geomap_lnarr-5.2 {arrayName tolist} { 187 ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} 188 gl1 tolist 189} {{0.0 0.0} {0.0 10.0} {10.0 10.0}} 190 191test tcl_geomap_lnarr-6.1 {arrayName toascii, wrong number of arguments} { 192 ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} 193 catch {gl1 toascii} msg 194 set msg 195} {wrong # args: should be "gl1 toascii fileName ?-format format? ?-ptperln n?"} 196 197test tcl_geomap_lnarr-7.1 {arrayName toxdr, wrong number of arguments} { 198 ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} 199 catch {gl1 toxdr} msg 200 set msg 201} {wrong # args: should be "gl1 toxdr fileName"} 202 203test tcl_geomap_lnarr-8.1 {arrayName tobin, wrong number of arguments} { 204 ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} 205 catch {gl1 tobin} msg 206 set msg 207} {wrong # args: should be "gl1 tobin fileName"} 208 209test tcl_geomap_lnarr-9.1 {arrayName info, wrong number of arguments} { 210 ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} 211 catch {gl1 info wawa} msg 212 set msg 213} {wrong # args: should be "gl1 info"} 214 215test tcl_geomap_lnarr-9.2 {lnarr info, with namespace} { 216 ::geomap::lnarr fmlist gl1 { 217 {{10 10} {10 20} {20 20}} 218 } 219 gl1 descr "global" 220 ::geomap::lnarr fmlist n1::gl1 { 221 {{-10 -10} {-10 -20} {-20 -20}} 222 } 223 namespace eval n1 { 224 gl1 descr "n1" 225 } 226 namespace eval n1 { 227 gl1 info 228 } 229} {n1 {-10.0 -10.0 -20.0 -20.0} 1 3 3} 230 231test tcl_geomap_lnarr-10.1 {arrayName descr, wrong number of arguments} { 232 ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} 233 catch {gl1 descr foo foo} msg 234 set msg 235} {wrong # args: should be "gl1 descr ?descriptor?"} 236 237test tcl_geomap_lnarr-10.2 {lnarr descr, with namespace} { 238 ::geomap::lnarr fmlist gl1 { 239 {{10 10} {10 20} {20 20}} 240 } 241 gl1 descr "global array" 242 namespace eval n1 { 243 ::geomap::lnarr fmlist gl1 { 244 {{-10 -10} {-10 -20} {-20 -20}} 245 } 246 gl1 descr "n1 array" 247 } 248 namespace eval n1 { 249 gl1 descr 250 } 251} {n1 array} 252 253test tcl_geomap_lnarr-12.1 {arrayName containpt, wrong number of arguments} { 254 ::geomap::lnarr fmlist gl1 {{0 0} {0 10} {10 10}} 255 catch {gl1 containpt} msg 256 set msg 257} {wrong # args: should be "gl1 containpt {lat lon}"} 258 259test tcl_geomap_lnarr-12.2 {arrayName containpt} { 260 ::geomap::lnarr fmlist gl1 { 261 {10 10} {60 10} {60 50} {30 50} {30 30} {40 30} {40 40} {50 40} 262 {50 20} {20 20} {20 50} {10 50} 263 } 264 for {set lat 65;set pts {}} {$lat >= 5} {incr lat -5} { 265 for {set lon 5} {$lon <= 55} {incr lon 5} { 266 lappend pts [gl1 containpt [list $lat $lon]] 267 } 268 } 269 set pts 270} {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} 271 272cleanupTests 273