# -*- 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.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}	

#source [ file join [ file dirname [ info script ] ] [ file rootname [ file tail [ info script ] ] ].tcl ]
#source [ file join [ file dirname [ info script ] ] adjust.test ]
#source [ file join [ file dirname [ info script ] ] split.test ]
#source [ file join [ file dirname [ info script ] ] tabify.test ]
#source [ file join [ file dirname [ info script ] ] trim.test ]
#source [ file join [ file dirname [ info script ] ] repeat.test ]


test textutil-1.0 {blank -1} {
    textutil::blank -1
} {}

test textutil-1.0 {blank 0} {
    textutil::blank 0
} {}

test textutil-1.0 {blank 1} {
    textutil::blank 1
} { }

test textutil-1.0 {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}




::tcltest::cleanupTests
