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/] [datefield.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] Datefield 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: datefield.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 Datefield-1.$c {Datefield construction} {
33
    iwidgets::Datefield .df -labeltext "Date Field"
34
    pack .df -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 Datefield-2.$o {configuration option} {
44
    llength [.df configure]
45
} {25}
46
 
47
incr o
48
 
49
foreach test {
50
    {-background #d9d9d9 #d9d9d9}
51
    {-borderwidth 4 4}
52
    {-borderwidth 2 2}
53
    {-command {.df configure -background red} {.df configure -background red}}
54
    {-cursor gumby gumby}
55
    {-exportselection 0 0}
56
    {-foreground Green Green}
57
    {-foreground Black Black}
58
    {-highlightcolor Red Red}
59
    {-highlightthickness 2 2}
60
    {-insertbackground Yellow Yellow}
61
    {-insertbackground Black Black}
62
    {-iq low low}
63
    {-iq average average}
64
    {-iq high high}
65
    {-justify right right}
66
    {-justify center center}
67
    {-justify left left}
68
    {-labelmargin 5 5}
69
    {-labelpos w w}
70
    {-labelpos nw nw}
71
    {-labelpos n n}
72
    {-labelpos ne ne}
73
    {-labelpos e e}
74
    {-labelpos se se}
75
    {-labelpos s s}
76
    {-labelpos sw sw}
77
    {-labeltext Label Label}
78
    {-relief raised raised}
79
    {-relief sunken sunken}
80
    {-textbackground GhostWhite GhostWhite}
81
    {-textbackground #d9d9d9 #d9d9d9}} {
82
        set option [lindex $test 0]
83
        test Datefield-2.$o "configuration options, $option" {
84
            .df configure $option [lindex $test 1]
85
            lindex [.df configure $option] 4
86
        } [lindex $test 2]
87
        update
88
        incr o
89
}
90
 
91
#
92
# Option tests which fail and produce errors.
93
#
94
foreach test {
95
  {-iq bogus {bad iq option "bogus": should be high, average or low}}
96
  {-childsitepos bogus {bad childsite option "bogus": should be n, e, s, or w}}} {
97
        set option [lindex $test 0]
98
        test Datefield-2.$o "configuration options, $option" {
99
            list [catch {.df configure $option [lindex $test 1]} msg] $msg
100
        } [list 1 [lindex $test 2]]
101
        incr o
102
}
103
 
104
#
105
# Method tests which are successful.
106
#
107
foreach test {
108
    {{.df childsite} {.df.lwchildsite}}
109
    {{.df show 03/03/1960} {}}
110
    {{.df get} {03/03/1960}}
111
    {{.df get -string} {03/03/1960}}
112
    {{.df isvalid} {1}}
113
    {{.df component date delete 0 end} {}}
114
    {{.df component date insert end 03/32/1960} {}}
115
    {{.df isvalid} {0}}
116
    {{.df show 03/03/1960} {}}
117
    {{.df show now} {}}} {
118
        set method [lindex [lindex $test 0] 1]
119
        test Datefield-3.$m "object methods, $method" {
120
            list [catch {eval [lindex $test 0]} msg] $msg
121
        } [list 0 [lindex $test 1]]
122
        update
123
        incr m
124
}
125
 
126
test Datefield-3.$m "object methods, clock clicks" {
127
    set clicks [clock scan "06/08/1964"]
128
    .df show $clicks
129
    update
130
    .df get
131
} {06/08/1964}
132
incr m
133
 
134
#
135
# Method tests which fail and produce errors
136
#
137
foreach test {
138
    {{.df get bogus} {bad format option "bogus": should be -string or -clicks}}
139
    {{.df show bogus} {bad date: "bogus", must be a valid date string, clock clicks value or the keyword now}}} {
140
        set method [lindex [lindex $test 0] 1]
141
        test Datefield-3.$m "object methods, $method" {
142
            list [catch {eval [lindex $test 0]} msg] $msg
143
        } [list 1 [lindex $test 1]]
144
        incr m
145
}
146
 
147
#
148
# Conclusion of constrcution/destruction tests
149
#
150
test Datefield-1.$c {Datefield destruction} {
151
    destroy .df
152
    update
153
} {}
154
 
155
incr c
156
 
157
test Datefield-1.$c {Datefield construction} {
158
    iwidgets::datefield .df
159
    pack .df -padx 10 -pady 10
160
    update
161
} {}
162
 
163
incr c
164
 
165
test Datefield-1.$c {Datefield destruction} {
166
    destroy .df
167
    update
168
} {}

powered by: WebSVN 2.1.0

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