ADDED tests/random.csv Index: tests/random.csv ================================================================== --- /dev/null +++ tests/random.csv @@ -0,0 +1,16 @@ +# Group,Name,Constraints,Setup,Body,Cleanup,Match,Result,Output,Error Output,Return Codes +command,package require tls,,,,,,,,, +,,,,,,,,,, +command,# Random command,,,,,,,,, +Random,Min Length,,,string length [::tls::random 0],,,0,,, +Random,Example 1,,,string length [::tls::random 42],,,42,,, +Random,Example 2,,,string length [::tls::random 1000],,,1000,,, +Random,Private Option,,,string length [::tls::random -private 42],,,42,,, +,,,,,,,,,, +command,# Random command errors,,,,,,,,, +Random Errors,Too few args,,,::tls::random,,,"wrong # args: should be ""tls::random ?-private? length""",,,1 +Random Errors,Too many args,,,::tls::random too many command line args to pass the test without an error or failing,,,"wrong # args: should be ""tls::random ?-private? length""",,,1 +Random Errors,Invalid length value,,,::tls::random bogus,,,"expected integer but got ""bogus""",,,1 +Random Errors,Negative length,,,::tls::random -1,,,"bad count ""-1"": must be integer >= 0",,,1 +Random Errors,Invalid option,,,::tls::random -bogus 42,,,"bad option ""-bogus"": must be -private",,,1 +Random Errors,Invalid length with option,,,::tls::random -private bogus,,,"expected integer but got ""bogus""",,,1 ADDED tests/random.test Index: tests/random.test ================================================================== --- /dev/null +++ tests/random.test @@ -0,0 +1,61 @@ +# Auto generated test cases for random.csv + +# Load Tcl Test package +if {[lsearch [namespace children] ::tcltest] == -1} { + package require tcltest + namespace import ::tcltest::* +} + +set auto_path [concat [list [file dirname [file dirname [info script]]]] $auto_path] + +package require tls + +# Random command + + +test Random-1.1 {Min Length} -body { + string length [::tls::random 0] + } -result {0} + +test Random-1.2 {Example 1} -body { + string length [::tls::random 42] + } -result {42} + +test Random-1.3 {Example 2} -body { + string length [::tls::random 1000] + } -result {1000} + +test Random-1.4 {Private Option} -body { + string length [::tls::random -private 42] + } -result {42} + +# Random command errors + + +test Random_Errors-2.1 {Too few args} -body { + ::tls::random + } -result {wrong # args: should be "tls::random ?-private? length"} -returnCodes {1} + +test Random_Errors-2.2 {Too many args} -body { + ::tls::random too many command line args to pass the test without an error or failing + } -result {wrong # args: should be "tls::random ?-private? length"} -returnCodes {1} + +test Random_Errors-2.3 {Invalid length value} -body { + ::tls::random bogus + } -result {expected integer but got "bogus"} -returnCodes {1} + +test Random_Errors-2.4 {Negative length} -body { + ::tls::random -1 + } -result {bad count "-1": must be integer >= 0} -returnCodes {1} + +test Random_Errors-2.5 {Invalid option} -body { + ::tls::random -bogus 42 + } -result {bad option "-bogus": must be -private} -returnCodes {1} + +test Random_Errors-2.6 {Invalid length with option} -body { + ::tls::random -private bogus + } -result {expected integer but got "bogus"} -returnCodes {1} + +# Cleanup +::tcltest::cleanupTests +return