1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
# -*- tcl -*-
# textutil.test: tests for the textutil package.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# -------------------------------------------------------------------------
source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]
testsNeedTcl 8.5
testsNeedTcltest 2.0
support {
useLocal string.tcl textutil::string
useLocal repeat.tcl textutil::repeat
useLocal adjust.tcl textutil::adjust
useLocal split.tcl textutil::split
useLocal tabify.tcl textutil::tabify
useLocal trim.tcl textutil::trim
useLocal trim.tcl textutil::trim
useLocal wcswidth.tcl textutil::wcswidth
}
testing {
useLocalKeep textutil.tcl textutil
}
# -------------------------------------------------------------------------
test textutil-1.0 {blank -1} {
textutil::blank -1
} {}
test textutil-1.1 {blank 0} {
textutil::blank 0
} {}
test textutil-1.2 {blank 1} {
textutil::blank 1
} { }
test textutil-1.3 {blank 10} {
textutil::blank 10
} { }
test textutil-2.0 {chop empty} {
textutil::chop {}
} {}
test textutil-2.1 {chop single} {
textutil::chop { }
} {}
test textutil-2.2 {chop long} {
textutil::chop {abcde}
} {abcd}
test textutil-3.0 {tail empty} {
textutil::tail {}
} {}
test textutil-3.1 {tail single} {
textutil::tail { }
} {}
test textutil-3.2 {tail long} {
textutil::tail {abcde}
} {bcde}
test textutil-4.0 {cap empty} {
textutil::cap {}
} {}
test textutil-4.1 {cap single} {
textutil::cap {a}
} {A}
test textutil-4.2 {cap long} {
textutil::cap {abcde}
} {Abcde}
test textutil-4.3 {cap capped} {
textutil::cap {Abcde}
} {Abcde}
test textutil-5.0 {uncap empty} {
textutil::uncap {}
} {}
test textutil-5.1 {uncap single} {
textutil::uncap {A}
} {a}
test textutil-5.2 {uncap long} {
textutil::uncap {Abcde}
} {abcde}
test textutil-5.3 {uncap uncapped} {
textutil::uncap {abcde}
} {abcde}
test textutil-6.0 {lcs, no strings} {
textutil::longestCommonPrefixList {}
} {}
test textutil-6.1 {lcs, one string} {
textutil::longestCommonPrefixList {foo}
} {foo}
test textutil-6.2 {lcs, two strings, no prefix} {
textutil::longestCommonPrefixList {foo bar}
} {}
test textutil-6.3 {lcs, two strings, small prefix} {
textutil::longestCommonPrefixList {foo fbar}
} {f}
test textutil-6.4 {lcs, two strings, common} {
textutil::longestCommonPrefixList {foo foo}
} {foo}
test textutil-6.5 {lcs, multiple strings} {
textutil::longestCommonPrefixList {foo fox fubar}
} {f}
# -------------------------------------------------------------------------
test textutil-7.0 {capEachWord, wrong args, not enough} -body {
textutil::capEachWord
} -returnCodes error -result {wrong # args: should be "textutil::capEachWord sentence"}
test textutil-7.1 {capEachWord, wrong args, too many} -body {
textutil::capEachWord S X
} -returnCodes error -result {wrong # args: should be "textutil::capEachWord sentence"}
test textutil-7.2 {capEachWord, empty} -body {
textutil::capEachWord {}
} -result {}
test textutil-7.3 {capEachWord, single word} -body {
textutil::capEachWord alpha
} -result Alpha
test textutil-7.4 {capEachWord, multiple words} -body {
textutil::capEachWord {here comes the sun}
} -result {Here Comes The Sun}
test textutil-7.5 {capEachWord, blocks} -body {
textutil::capEachWord {here \comes the $sun}
} -result {Here \comes The $sun}
# -------------------------------------------------------------------------
test textutil-8.0 {wcswidth} -body {
textutil::wcswidth {The Quick Brown Fox}
} -result 19
test textutil-8.1 {wcswidth} -body {
textutil::wcswidth {道德經}
} -result 6
test textutil-8.2 {wcswidth} -body {
textutil::wcswidth {道德經 of the fox}
} -result 17
# -------------------------------------------------------------------------
testsuiteCleanup
return
|