chiark / gitweb /
debugging for thing that crashed
[innduct.git] / tests / util / convdate.t
1 #! /bin/sh
2 # $Id: convdate.t 5754 2002-09-09 00:48:21Z rra $
3 #
4 # Test suite for convdate.
5
6 # The count starts at 1 and is updated each time ok is printed.  printcount
7 # takes "ok" or "not ok".
8 count=1
9 printcount () {
10     echo "$1 $count $2"
11     count=`expr $count + 1`
12 }
13
14 # Given the output from convdate and the expected output, compare them.
15 compare () {
16     status=$?
17     if [ $status = 0 ] && [ "$1" = "$2" ] ; then
18         printcount "ok"
19     else
20         echo "  $1"
21         echo "  $2"
22         printcount "not ok"
23     fi
24 }
25
26 # Find convdate.
27 convdate=false
28 for file in ../expire/convdate ../../expire/convdate expire/convdate ; do
29     [ -x $file ] && convdate=$file
30 done
31 if [ $convdate = "false" ] ; then
32     echo "Could not find convdate" >&2
33     exit 1
34 fi
35
36 # Print out the count of tests.
37 echo 7
38
39 # Run our tests.  These are all from the man page, but with time zones
40 # added.
41 TZ=EST5EDT; export TZ
42 compare "`$convdate 'feb 10, 1991 10am EST'`" 'Sun Feb 10 10:00:00 1991'
43 compare "`$convdate '12pm EST 12/13/91' '12am EDT 5/4/90'`" \
44     'Fri Dec 13 12:00:00 1991
45 Fri May  4 00:00:00 1990'
46 compare "`$convdate -n 'feb 10, 1991 10am-0500' '12am-0400 5/5/90'`" \
47     '666198000
48 641880000'
49 compare "`$convdate -c 666198000`" 'Sun Feb 10 10:00:00 1991'
50 compare "`$convdate -dc 666198000`" 'Sun, 10 Feb 1991 15:00:00 +0000 (UTC)'
51 compare "`env TZ=PST8PDT $convdate -dlc 666198000`" \
52     'Sun, 10 Feb 1991 07:00:00 -0800 (PST)'
53 compare "`env TZ=EST5EDT $convdate -dlc 666198000`" \
54     'Sun, 10 Feb 1991 10:00:00 -0500 (EST)'