OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [tags/] [start/] [insight/] [itcl/] [iwidgets3.0.0/] [tests/] [dateentry.test] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# This file is a Tcl script to test out [incr Widgets] Dateentry class.
2
# It is organized in the standard fashion for Tcl tests with the following
3
# notation for test case labels:
4
#
5
#   1.x - Construction/Destruction tests
6
#   2.x - Configuration option tests
7
#   3.x - Method tests
8
#
9
# Copyright (c) 1995 DSC Technologies Corporation
10
#
11
# See the file "license.terms" for information on usage and redistribution
12
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
#
14
# @(#) $Id: dateentry.test,v 1.1.1.1 2002-01-16 10:24:51 markom Exp $
15
 
16
package require Iwidgets 3.0
17
 
18
if {[string compare test [info procs test]] == 1} {
19
    source defs
20
}
21
 
22
wm geometry . {}
23
raise .
24
 
25
set c 1
26
set o 1
27
set m 1
28
 
29
#
30
# Initial construction test
31
#
32
test Dateentry-1.$c {Dateentry construction} {
33
    iwidgets::Dateentry .de -labeltext "Date Field"
34
    pack .de -padx 10 -pady 10 -fill both -expand yes
35
    update
36
} {}
37
 
38
incr c
39
 
40
#
41
# Option tests which are successful.
42
#
43
test Dateentry-2.$o {configuration option} {
44
    llength [.de configure]
45
} {43}
46
 
47
incr o
48
 
49
foreach test {
50
    {-background #d9d9d9 #d9d9d9}
51
    {-buttonforeground green green}
52
    {-borderwidth 4 4}
53
    {-borderwidth 2 2}
54
    {-command {.de configure -background red} {.de configure -background red}}
55
    {-cursor gumby gumby}
56
    {-exportselection 0 0}
57
    {-foreground Green Green}
58
    {-foreground Black Black}
59
    {-highlightcolor Red Red}
60
    {-highlightthickness 2 2}
61
    {-insertbackground Yellow Yellow}
62
    {-insertbackground Black Black}
63
    {-iq low low}
64
    {-iq average average}
65
    {-iq high high}
66
    {-justify right right}
67
    {-justify center center}
68
    {-justify left left}
69
    {-labelmargin 5 5}
70
    {-labelpos w w}
71
    {-labelpos nw nw}
72
    {-labelpos n n}
73
    {-labelpos ne ne}
74
    {-labelpos e e}
75
    {-labelpos se se}
76
    {-labelpos s s}
77
    {-labelpos sw sw}
78
    {-labeltext Label Label}
79
    {-relief raised raised}
80
    {-relief sunken sunken}
81
    {-currentdatefont -*-helvetica-bold-r-normal--*-120-* -*-helvetica-bold-r-normal--*-120-*}
82
    {-datefont -*-helvetica-medium-r-normal--*-120-* -*-helvetica-medium-r-normal--*-120-*}
83
    {-dayfont -*-helvetica-medium-r-normal--*-120-* -*-helvetica-medium-r-normal--*-120-*}
84
    {-days {M T W T F S S} {M T W T F S S}}
85
    {-foreground black black}
86
    {-height 300 300}
87
    {-outline black black}
88
    {-selectcolor blue blue}
89
    {-selectthickness 2 2}
90
    {-startday monday monday}
91
    {-titlefont -*-helvetica-bold-r-normal--*-140-* -*-helvetica-bold-r-normal--*-140-*}
92
    {-weekdaybackground mistyrose mistyrose}
93
    {-weekendbackground white white}
94
    {-width 350 350}
95
    {-textbackground GhostWhite GhostWhite}
96
    {-textbackground #d9d9d9 #d9d9d9}} {
97
        set option [lindex $test 0]
98
        test Dateentry-2.$o "configuration options, $option" {
99
            .de configure $option [lindex $test 1]
100
            lindex [.de configure $option] 4
101
        } [lindex $test 2]
102
        update
103
        incr o
104
}
105
 
106
#
107
# Option tests which fail and produce errors.
108
#
109
foreach test {
110
  {-iq bogus {bad iq option "bogus": should be high, average or low}}
111
  {-childsitepos bogus {bad childsite option "bogus": should be n, e, s, or w}}} {
112
        set option [lindex $test 0]
113
        test Dateentry-2.$o "configuration options, $option" {
114
            list [catch {.de configure $option [lindex $test 1]} msg] $msg
115
        } [list 1 [lindex $test 2]]
116
        incr o
117
}
118
 
119
#
120
# Method tests which are successful.
121
#
122
foreach test {
123
    {{.de childsite} {.de.lwchildsite}}
124
    {{.de show 03/03/1960} {}}
125
    {{.de get} {03/03/1960}}
126
    {{.de get -string} {03/03/1960}}
127
    {{.de isvalid} {1}}
128
    {{.de component date delete 0 end} {}}
129
    {{.de component date insert end 03/32/1960} {}}
130
    {{.de isvalid} {0}}
131
    {{.de show 03/03/1960} {}}
132
    {{.de show now} {}}} {
133
        set method [lindex [lindex $test 0] 1]
134
        test Dateentry-3.$m "object methods, $method" {
135
            list [catch {eval [lindex $test 0]} msg] $msg
136
        } [list 0 [lindex $test 1]]
137
        update
138
        incr m
139
}
140
 
141
test Dateentry-3.$m "object methods, clock clicks" {
142
    set clicks [clock scan "06/08/1964"]
143
    .de show $clicks
144
    update
145
    .de get
146
} {06/08/1964}
147
incr m
148
 
149
#
150
# Method tests which fail and produce errors
151
#
152
foreach test {
153
    {{.de get bogus} {bad format option "bogus": should be -string or -clicks}}
154
    {{.de show bogus} {bad date: "bogus", must be a valid date string, clock clicks value or the keyword now}}} {
155
        set method [lindex [lindex $test 0] 1]
156
        test Dateentry-3.$m "object methods, $method" {
157
            list [catch {eval [lindex $test 0]} msg] $msg
158
        } [list 1 [lindex $test 1]]
159
        incr m
160
}
161
 
162
#
163
# Conclusion of constrcution/destruction tests
164
#
165
test Dateentry-1.$c {Dateentry destruction} {
166
    destroy .de
167
    update
168
} {}
169
 
170
incr c
171
 
172
test Dateentry-1.$c {Dateentry construction} {
173
    iwidgets::dateentry .de
174
    pack .de -padx 10 -pady 10
175
    update
176
} {}
177
 
178
incr c
179
 
180
test Dateentry-1.$c {Dateentry destruction} {
181
    destroy .de
182
    update
183
} {}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.