]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - tools/regression/bin/date/regress.sh
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / tools / regression / bin / date / regress.sh
1 #!/bin/sh
2
3 #
4 # Regression tests for date(1)
5 #
6 # Submitted by Edwin Groothuis <edwin@FreeBSD.org>
7 #
8 # $FreeBSD$
9 #
10
11 #
12 # These two date/times have been chosen carefully, they
13 # create both the single digit and double/multidigit version of
14 # the values.
15 #
16 # To create a new one, make sure you are using the UTC timezone!
17 #
18
19 TEST1=3222243           # 1970-02-07 07:04:03
20 TEST2=1005600000        # 2001-11-12 21:11:12
21
22 export LANG=C
23 export TZ=UTC
24 count=0
25
26 check()
27 {
28         S=$1
29         A1=$2
30         A2=$3
31
32         count=`expr ${count} + 1`
33
34         if [ -z "${A2}" ]; then A2=${A1}; fi
35
36         R=`date -r ${TEST1} +%${S}`
37         if [ "${R}" = "${A1}" ]; then
38                 echo "${count}a. ${S} - ok"
39         else
40                 echo "${count}a. ${S} - not ok (got ${R}, expected ${A1})"
41         fi
42
43         R=`date -r ${TEST2} +%${S}`
44         if [ "${R}" = "${A2}" ]; then
45                 echo "${count}b. ${S} - ok"
46         else
47                 echo "${count}b. ${S} - not ok (got ${R}, expected ${A2})"
48         fi
49 }
50
51 check A Saturday Monday
52 check a Sat Mon
53 check B February November
54 check b Feb Nov
55 check C 19 20
56 check c "Sat Feb  7 07:04:03 1970" "Mon Nov 12 21:20:00 2001"
57 check D 02/07/70 11/12/01
58 check d 07 12
59 check e " 7" 12
60 check F "1970-02-07" "2001-11-12"
61 check G 1970 2001
62 check g 70 01
63 check H 07 21
64 check h Feb Nov
65 check I 07 09
66 check j 038 316
67 check k " 7" 21
68 check l " 7" " 9"
69 check M 04 20
70 check m 02 11
71 check p AM PM
72 check R 07:04 21:20
73 check r "07:04:03 AM" "09:20:00 PM"
74 check S 03 00
75 check s ${TEST1} ${TEST2}
76 check U 05 45
77 check u 6 1
78 check V 06 46
79 check v " 7-Feb-1970" "12-Nov-2001"
80 check W 05 46
81 check w 6 1
82 check X "07:04:03" "21:20:00"
83 check x "02/07/70" "11/12/01"
84 check Y 1970 2001
85 check y 70 01
86 check Z UTC UTC
87 check z +0000 +0000
88 check % % %
89 check + "Sat Feb  7 07:04:03 UTC 1970" "Mon Nov 12 21:20:00 UTC 2001"