[25] | 1 | # Commands covered: join |
---|
| 2 | # |
---|
| 3 | # This file contains a collection of tests for one or more of the Tcl |
---|
| 4 | # built-in commands. Sourcing this file into Tcl runs the tests and |
---|
| 5 | # generates output for errors. No output means no errors were found. |
---|
| 6 | # |
---|
| 7 | # Copyright (c) 1991-1993 The Regents of the University of California. |
---|
| 8 | # Copyright (c) 1994 Sun Microsystems, Inc. |
---|
| 9 | # Copyright (c) 1998-1999 by Scriptics Corporation. |
---|
| 10 | # |
---|
| 11 | # See the file "license.terms" for information on usage and redistribution |
---|
| 12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 13 | # |
---|
| 14 | # RCS: @(#) $Id: join.test,v 1.6 2004/05/19 10:51:06 dkf Exp $ |
---|
| 15 | |
---|
| 16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
| 17 | package require tcltest |
---|
| 18 | namespace import -force ::tcltest::* |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | test join-1.1 {basic join commands} { |
---|
| 22 | join {a b c} xyz |
---|
| 23 | } axyzbxyzc |
---|
| 24 | test join-1.2 {basic join commands} { |
---|
| 25 | join {a b c} {} |
---|
| 26 | } abc |
---|
| 27 | test join-1.3 {basic join commands} { |
---|
| 28 | join {} xyz |
---|
| 29 | } {} |
---|
| 30 | test join-1.4 {basic join commands} { |
---|
| 31 | join {12 34 56} |
---|
| 32 | } {12 34 56} |
---|
| 33 | |
---|
| 34 | test join-2.1 {join errors} { |
---|
| 35 | list [catch join msg] $msg $errorCode |
---|
| 36 | } {1 {wrong # args: should be "join list ?joinString?"} NONE} |
---|
| 37 | test join-2.2 {join errors} { |
---|
| 38 | list [catch {join a b c} msg] $msg $errorCode |
---|
| 39 | } {1 {wrong # args: should be "join list ?joinString?"} NONE} |
---|
| 40 | test join-2.3 {join errors} { |
---|
| 41 | list [catch {join "a \{ c" 111} msg] $msg $errorCode |
---|
| 42 | } {1 {unmatched open brace in list} NONE} |
---|
| 43 | |
---|
| 44 | test join-3.1 {joinString is binary ok} { |
---|
| 45 | string length [join {a b c} a\0b] |
---|
| 46 | } 9 |
---|
| 47 | |
---|
| 48 | test join-3.2 {join is binary ok} { |
---|
| 49 | string length [join "a\0b a\0b a\0b"] |
---|
| 50 | } 11 |
---|
| 51 | |
---|
| 52 | # cleanup |
---|
| 53 | ::tcltest::cleanupTests |
---|
| 54 | return |
---|