os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/split.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# Commands covered:  split
sl@0
     2
#
sl@0
     3
# This file contains a collection of tests for one or more of the Tcl
sl@0
     4
# built-in commands.  Sourcing this file into Tcl runs the tests and
sl@0
     5
# generates output for errors.  No output means no errors were found.
sl@0
     6
#
sl@0
     7
# Copyright (c) 1991-1993 The Regents of the University of California.
sl@0
     8
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
sl@0
     9
# Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
    10
#
sl@0
    11
# See the file "license.terms" for information on usage and redistribution
sl@0
    12
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    13
#
sl@0
    14
# RCS: @(#) $Id: split.test,v 1.8 2002/11/12 02:25:24 hobbs Exp $
sl@0
    15
sl@0
    16
if {[lsearch [namespace children] ::tcltest] == -1} {
sl@0
    17
    package require tcltest
sl@0
    18
    namespace import -force ::tcltest::*
sl@0
    19
}
sl@0
    20
sl@0
    21
test split-1.1 {basic split commands} {
sl@0
    22
    split "a\n b\t\r c\n "
sl@0
    23
} {a {} b {} {} c {} {}}
sl@0
    24
test split-1.2 {basic split commands} {
sl@0
    25
    split "word 1xyzword 2zword 3" xyz
sl@0
    26
} {{word 1} {} {} {word 2} {word 3}}
sl@0
    27
test split-1.3 {basic split commands} {
sl@0
    28
    split "12345" {}
sl@0
    29
} {1 2 3 4 5}
sl@0
    30
test split-1.4 {basic split commands} {
sl@0
    31
    split "a\}b\[c\{\]\$"
sl@0
    32
} "a\\}b\\\[c\\{\\\]\\\$"
sl@0
    33
test split-1.5 {basic split commands} {
sl@0
    34
    split {} {}
sl@0
    35
} {}
sl@0
    36
test split-1.6 {basic split commands} {
sl@0
    37
    split {}
sl@0
    38
} {}
sl@0
    39
test split-1.7 {basic split commands} {
sl@0
    40
    split {   }
sl@0
    41
} {{} {} {} {}}
sl@0
    42
test split-1.8 {basic split commands} {
sl@0
    43
    proc foo {} {
sl@0
    44
        set x {}
sl@0
    45
        foreach f [split {]\n} {}] {
sl@0
    46
            append x $f
sl@0
    47
        }
sl@0
    48
        return $x	
sl@0
    49
    }
sl@0
    50
    foo
sl@0
    51
} {]\n}
sl@0
    52
test split-1.9 {basic split commands} {
sl@0
    53
    proc foo {} {
sl@0
    54
        set x ab\000c
sl@0
    55
        set y [split $x {}]
sl@0
    56
        return $y
sl@0
    57
    }
sl@0
    58
    foo
sl@0
    59
} "a b \000 c"
sl@0
    60
test split-1.10 {basic split commands} {
sl@0
    61
    split "a0ab1b2bbb3\000c4" ab\000c
sl@0
    62
} {{} 0 {} 1 2 {} {} 3 {} 4}
sl@0
    63
test split-1.11 {basic split commands} {
sl@0
    64
    split "12,3,45" {,}
sl@0
    65
} {12 3 45}
sl@0
    66
test split-1.12 {basic split commands} {
sl@0
    67
    split "\u0001ab\u0001cd\u0001\u0001ef\u0001" \1
sl@0
    68
} {{} ab cd {} ef {}}
sl@0
    69
test split-1.13 {basic split commands} {
sl@0
    70
    split "12,34,56," {,}
sl@0
    71
} {12 34 56 {}}
sl@0
    72
test split-1.14 {basic split commands} {
sl@0
    73
    split ",12,,,34,56," {,}
sl@0
    74
} {{} 12 {} {} 34 56 {}}
sl@0
    75
sl@0
    76
test split-2.1 {split errors} {
sl@0
    77
    list [catch split msg] $msg $errorCode
sl@0
    78
} {1 {wrong # args: should be "split string ?splitChars?"} NONE}
sl@0
    79
test split-2.2 {split errors} {
sl@0
    80
    list [catch {split a b c} msg] $msg $errorCode
sl@0
    81
} {1 {wrong # args: should be "split string ?splitChars?"} NONE}
sl@0
    82
sl@0
    83
# cleanup
sl@0
    84
catch {rename foo {}}
sl@0
    85
::tcltest::cleanupTests
sl@0
    86
return
sl@0
    87
sl@0
    88
sl@0
    89
sl@0
    90
sl@0
    91
sl@0
    92
sl@0
    93
sl@0
    94
sl@0
    95
sl@0
    96
sl@0
    97
sl@0
    98