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/] [calendar.test] - Blame information for rev 579

Go to most recent revision | 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] Calendar 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: calendar.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 Calendar-1.$c {Calendar construction} {
33
    iwidgets::Calendar .cal
34
    pack .cal -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 Calendar-2.$o {configuration option} {
44
    llength [.cal configure]
45
} {21}
46
 
47
incr o
48
 
49
foreach test {
50
    {-background #d9d9d9 #d9d9d9}
51
    {-buttonforeground green green}
52
    {-command {.cal configure -background red} {.cal configure -background red}}
53
    {-currentdatefont -*-helvetica-bold-r-normal--*-120-* -*-helvetica-bold-r-normal--*-120-*}
54
    {-cursor gumby gumby}
55
    {-datefont -*-helvetica-medium-r-normal--*-120-* -*-helvetica-medium-r-normal--*-120-*}
56
    {-dayfont -*-helvetica-medium-r-normal--*-120-* -*-helvetica-medium-r-normal--*-120-*}
57
    {-days {M T W T F S S} {M T W T F S S}}
58
    {-foreground black black}
59
    {-height 300 300}
60
    {-outline black black}
61
    {-selectcolor blue blue}
62
    {-selectthickness 2 2}
63
    {-startday monday monday}
64
    {-titlefont -*-helvetica-bold-r-normal--*-140-* -*-helvetica-bold-r-normal--*-140-*}
65
    {-weekdaybackground mistyrose mistyrose}
66
    {-weekendbackground white white}
67
    {-width 350 350}} {
68
        set option [lindex $test 0]
69
        test Calendar-2.$o "configuration options, $option" {
70
            .cal configure $option [lindex $test 1]
71
            lindex [.cal configure $option] 4
72
        } [lindex $test 2]
73
        update
74
        incr o
75
}
76
 
77
#
78
# Option tests which fail and produce errors.
79
#
80
foreach test {
81
  {-backwardimage bogus {bad image name "bogus": image does not exist}}
82
  {-forwardimage bogus {bad image name "bogus": image does not exist}}
83
  {-startday bogus {bad startday option "bogus": should be sunday, monday, tuesday, wednesday, thursday, friday, or saturday}}} {
84
        set option [lindex $test 0]
85
        test Calendar-2.$o "configuration options, $option" {
86
            list [catch {.cal configure $option [lindex $test 1]} msg] $msg
87
        } [list 1 [lindex $test 2]]
88
        incr o
89
}
90
 
91
#
92
# Method tests which are successful.
93
#
94
foreach test {
95
    {{.cal select 03/03/1960} {}}
96
    {{.cal get} {03/03/1960}}
97
    {{.cal show 03/03/1960} {}}
98
    {{.cal get -string} {03/03/1960}}
99
    {{.cal select now} {}}
100
    {{.cal show now} {}}} {
101
        set method [lindex [lindex $test 0] 1]
102
        test Calendar-3.$m "object methods, $method" {
103
            list [catch {eval [lindex $test 0]} msg] $msg
104
        } [list 0 [lindex $test 1]]
105
        update
106
        incr m
107
}
108
 
109
test Calendar-3.$m "object methods, clock clicks" {
110
    set clicks [clock scan "06/08/1964"]
111
    .cal show $clicks
112
    .cal select $clicks
113
    update
114
    .cal get
115
} {06/08/1964}
116
incr m
117
 
118
#
119
# Method tests which fail and produce errors
120
#
121
foreach test {
122
    {{.cal get bogus} {bad format option "bogus": should be -string or -clicks}}
123
    {{.cal select bogus} {bad date: "bogus", must be a valid date string, clock clicks value or the keyword now}}
124
    {{.cal show bogus} {bad date: "bogus", must be a valid date string, clock clicks value or the keyword now}}} {
125
        set method [lindex [lindex $test 0] 1]
126
        test Calendar-3.$m "object methods, $method" {
127
            list [catch {eval [lindex $test 0]} msg] $msg
128
        } [list 1 [lindex $test 1]]
129
        incr m
130
}
131
 
132
#
133
# Conclusion of constrcution/destruction tests
134
#
135
test Calendar-1.$c {Calendar destruction} {
136
    destroy .cal
137
    update
138
} {}
139
 
140
incr c
141
 
142
test Calendar-1.$c {Calendar construction} {
143
    iwidgets::calendar .cal
144
    pack .cal -padx 10 -pady 10
145
    update
146
} {}
147
 
148
incr c
149
 
150
test Calendar-1.$c {Calendar destruction} {
151
    destroy .cal
152
    update
153
} {}

powered by: WebSVN 2.1.0

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