# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0 # # ## ### ##### ######## ############# ##################### ## Testing the cmdr::validate package (sub: valtype::luhn). kt check Tcl 8.5 kt check tcltest 2 kt require support debug kt require support debug::caller kt local support cmdr::validate::common kt local testing cmdr::validate::valtype::luhn # # ## ### ##### ######## ############# ##################### ## Basic API. set vtype cmdr::validate::valtype::luhn set vtdef {} kt source vtype.tcl # # ## ### ##### ######## ############# ##################### ## Specific behaviour test vt-${vtype}-validate-2.0 {luhn validation failure, bad char} -body { $vtype validate P A } -returnCodes error \ -result {Not a LUHN number, expected only digits} foreach {n in} { 1 49999999 2 37 3 49927398717 4 1234567812345678 } { test vt-${vtype}-validate-2.1.$n {luhn validation failure, bad check} -body { $vtype validate P $in } -returnCodes error \ -result {Not a LUHN number, the check digit is incorrect} } # ------------------------------------------------------------------------- foreach {n in check} { 1 4999999 8 2 3 4 3 35 6 4 4992739871 6 5 123456781234567 0 } { test vt-${vtype}-validate-4.$n {luhn validation} -body { $vtype validate P $in$check } -result $in$check } # # ## ### ##### ######## ############# ##################### cleanupTests return