cmdr
Check-in [c502011735]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Expanded VT testing.
Timelines: family | ancestors | descendants | both | vtype-testing
Files: files | file ages | folders
SHA1:c502011735ab19ebbc43e2d5a1214d86a57cae31
User & Date: aku 2015-07-03 04:20:15
Context
2015-07-03
04:23
Merged VT work from trunk and vt-minute. Updated bool/percent failure messages. check-in: dec47d85c3 user: aku tags: vtype-testing
04:20
Expanded VT testing. check-in: c502011735 user: aku tags: vtype-testing
04:19
Fixed missing trap clause needed for some inputs (number out of range) check-in: 8772a8cd12 user: aku tags: vtype-testing
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added tests/v_posint.test.





























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (sub: posint (integer > 0)).

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::posint

# # ## ### ##### ######## ############# #####################
## Basic API.

set vtype cmdr::validate::posint
set vtdef 1
kt source vtype.tcl

# # ## ### ##### ######## ############# #####################
## Specific behaviour - validation

test vt-${vtype}-validate-2.0 "$vtype validate, fail" -body {
    $vtype validate P bogus
} -returnCodes error -result {Expected a positive integer for T "P", got "bogus"}

test vt-${vtype}-validate-2.1 "$vtype validate, fail, strict" -body {
    $vtype validate P {}
} -returnCodes error -result {Expected a positive integer for T "P", got ""}

test vt-${vtype}-validate-2.2 "$vtype validate, fail, negative" -body {
    $vtype validate P -2
} -returnCodes error -result {Expected a positive integer for T "P", got "-2"}

test vt-${vtype}-validate-2.3 "$vtype validate, fail, negative" -body {
    $vtype validate P -1
} -returnCodes error -result {Expected a positive integer for T "P", got "-1"}

test vt-${vtype}-validate-2.4 "$vtype validate, fail, zero" -body {
    $vtype validate P 0
} -returnCodes error -result {Expected a positive integer for T "P", got "0"}

test vt-${vtype}-validate-2.5 "$vtype validate, ok, positive" -body {
    $vtype validate P 1
} -result 1

test vt-${vtype}-validate-2.6 "$vtype validate, ok, decimal" -body {
    $vtype validate P 33
} -result 33

test vt-${vtype}-validate-2.7 "$vtype validate, ok, octal" -body {
    $vtype validate P 010
} -result 8

test vt-${vtype}-validate-2.8 "$vtype validate, ok, hex" -body {
    $vtype validate P 0xff
} -result 255

# # ## ### ##### ######## ############# #####################
cleanupTests
return

Added tests/v_weekday.test.



































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (ISO year number).

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::year

# # ## ### ##### ######## ############# #####################
## Basic API.

set vtype cmdr::validate::year
set vtdef [clock format [clock seconds] -format %Y] ;# current year. [**]
kt source vtype.tcl

# (Ad **): Race condition possible in the tests, here. If the tests
# are run across a tear border (Dec 31 into Jan 1 Midnight) bogus
# failure will appear in the standard API tests.

# # ## ### ##### ######## ############# #####################
## Specific behaviour - validation

## Print table of short years, to determine where the border
## current/previous lies.
# for {set i 0} {$i <99} {incr i} { puts  "SHORT $i == [$vtype validate P $i]" }
# Border 37/38

test vt-${vtype}-validate-2.0 "$vtype validate, fail" -body {
    $vtype validate P bogus
} -returnCodes error -result {Expected a year for T "P", got "bogus"}

test vt-${vtype}-validate-2.1 "$vtype validate, fail, strict" -body {
    $vtype validate P {}
} -returnCodes error -result {Expected a year for T "P", got ""}

test vt-${vtype}-validate-2.2 "$vtype validate, fail, octal" -body {
    $vtype validate P 010
} -returnCodes error -result {Expected a year for T "P", got "010"}

test vt-${vtype}-validate-2.3 "$vtype validate, fail, hex" -body {
    $vtype validate P 0xff
} -returnCodes error -result {Expected a year for T "P", got "0xff"}

test vt-${vtype}-validate-2.4 "$vtype validate, fail, negative" -body {
    $vtype validate P -2
} -returnCodes error -result {Expected a year for T "P", got "-2"}

test vt-${vtype}-validate-2.5 "$vtype validate, fail, negative" -body {
    $vtype validate P -1
} -returnCodes error -result {Expected a year for T "P", got "-1"}

test vt-${vtype}-validate-2.6 "$vtype validate, fail, neither short nor long year" -body {
    $vtype validate P 333
} -returnCodes error -result {Expected a year for T "P", got "333"}

test vt-${vtype}-validate-2.7 "$vtype validate, fail, neither short nor long year" -body {
    $vtype validate P 33333
} -returnCodes error -result {Expected a year for T "P", got "33333"}

# # ## ### ##### ######## ############# #####################

test vt-${vtype}-validate-2.8 "$vtype validate, ok, zero, short year, current century" -body {
    $vtype validate P 0
} -result 2000

test vt-${vtype}-validate-2.9 "$vtype validate, ok, positive, short year, current century" -body {
    $vtype validate P 1
} -result 2001

test vt-${vtype}-validate-2.10 "$vtype validate, ok, positive, short year, current century" -body {
    $vtype validate P 33
} -result 2033

test vt-${vtype}-validate-2.11 "$vtype validate, ok, positive, short year, previous century" -body {
    $vtype validate P 37
} -result 2037

test vt-${vtype}-validate-2.12 "$vtype validate, ok, positive, short year, previous century" -body {
    $vtype validate P 38
} -result 1938

test vt-${vtype}-validate-2.13 "$vtype validate, ok, positive, short year, previous century" -body {
    $vtype validate P 99
} -result 1999

test vt-${vtype}-validate-2.14 "$vtype validate, ok, positive, long year" -body {
    $vtype validate P 1923
} -result 1923

# # ## ### ##### ######## ############# #####################
cleanupTests
return

Added tests/v_year.test.

























































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::validate package (ISO year number).

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::weekday

# # ## ### ##### ######## ############# #####################
## Basic API.

set vtype cmdr::validate::weekday
set vtdef [clock format [clock seconds] -format %u] ;# current weekday. [**]
kt source vtype.tcl

# (Ad **): Race condition possible in the tests, here. If the tests
# are run across a day border (23:59 -> 00:00) bogus failure will
# appear in the standard API tests.

# # ## ### ##### ######## ############# #####################
## Specific behaviour - validation

## Inputs: 0-sun,1...6,7-sun
## long an short names.

test vt-${vtype}-validate-2.0 "$vtype validate, fail" -body {
    $vtype validate P bogus
} -returnCodes error -result {Expected a weekday for T "P", got "bogus"}

test vt-${vtype}-validate-2.1 "$vtype validate, fail, strict" -body {
    $vtype validate P {}
} -returnCodes error -result {Expected a weekday for T "P", got ""}

test vt-${vtype}-validate-2.2 "$vtype validate, fail, octal" -body {
    $vtype validate P 010
} -returnCodes error -result {Expected a weekday for T "P", got "010"}

test vt-${vtype}-validate-2.3 "$vtype validate, fail, hex" -body {
    $vtype validate P 0xff
} -returnCodes error -result {Expected a weekday for T "P", got "0xff"}

test vt-${vtype}-validate-2.4 "$vtype validate, fail, negative" -body {
    $vtype validate P -2
} -returnCodes error -result {Expected a weekday for T "P", got "-2"}

test vt-${vtype}-validate-2.5 "$vtype validate, fail, negative" -body {
    $vtype validate P -1
} -returnCodes error -result {Expected a weekday for T "P", got "-1"}

test vt-${vtype}-validate-2.6 "$vtype validate, fail, too large" -body {
    $vtype validate P 8
} -returnCodes error -result {Expected a weekday for T "P", got "8"}

# # ## ### ##### ######## ############# #####################

foreach {wdaye wdayi shortname longname} {
    0 7 sun sunday
    1 1 mon monday
    2 2 tue tuesday
    3 3 wed wednesday
    4 4 thu thursday
    5 5 fri friday
    6 6 sat saturday
    7 7 sun sunday
} {
    test vt-${vtype}-validate-3.$wdaye "$vtype validate, ok, weekday number" -body {
	$vtype validate P $wdaye
    } -result $wdayi

    test vt-${vtype}-validate-4.$wdaye "$vtype validate, ok, short weekday name" -body {
	$vtype validate P $shortname
    } -result $wdayi

    test vt-${vtype}-validate-5.$wdaye "$vtype validate, ok, long weekday name" -body {
	$vtype validate P $longname
    } -result $wdayi

    # # ## ### ##### ######## ############# #####################

    test vt-${vtype}-2external-6.$wdaye "$vtype 2external, ok, long weekday name" -body {
	$vtype 2external $wdayi
    } -result [string totitle $longname]
}

# # ## ### ##### ######## ############# #####################
cleanupTests
return