aboutsummaryrefslogtreecommitdiff
path: root/testsuite/date/date-works-1
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-04-27 20:58:43 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-04-27 20:58:43 +0000
commit4809a9f78eecc7346e5d73b7f60ae6c51e057632 (patch)
tree774025c8be941f3db0c2c9cbeb037331d6f6ac84 /testsuite/date/date-works-1
parent7dff4333d61a2157a1bec9affd34a328c520ef40 (diff)
downloadbusybox-4809a9f78eecc7346e5d73b7f60ae6c51e057632.tar.gz
date: fix date-works test, add date-works-1 one (currently fails)
Diffstat (limited to 'testsuite/date/date-works-1')
-rw-r--r--testsuite/date/date-works-1128
1 files changed, 128 insertions, 0 deletions
diff --git a/testsuite/date/date-works-1 b/testsuite/date/date-works-1
new file mode 100644
index 000000000..11d8b2b7c
--- /dev/null
+++ b/testsuite/date/date-works-1
@@ -0,0 +1,128 @@
+dt=`busybox date -d 1:2 +%T`
+test x"$dt" = x"01:02:00"
+
+dt=`busybox date -d 1:2:3 +%T`
+test x"$dt" = x"01:02:03"
+
+host_date=/bin/date
+
+# date (GNU coreutils) 6.10 reports:
+# date: invalid date '1.2-3:4'
+# busybox 1.11.0.svn date reports:
+# date: invalid date '1/2 3:4'
+
+hdt=`$host_date -d '1/2 3:4'`
+dt=`busybox date -d 1.2-3:4`
+test x"$hdt" = x"$dt"
+
+hdt=`$host_date -d '1/2 3:4:5'`
+dt=`busybox date -d 1.2-3:4:5`
+test x"$hdt" = x"$dt"
+
+hdt=`$host_date -d '1/2/1999 3:4'`
+dt=`busybox date -d 1999.1.2-3:4`
+test x"$hdt" = x"$dt"
+
+hdt=`$host_date -d '1/2/1999 3:4:5'`
+dt=`busybox date -d 1999.1.2-3:4:5`
+test x"$hdt" = x"$dt"
+
+hdt=`$host_date -d '1999-1-2 3:4:5'`
+dt=`busybox date -d '1999-1-2 3:4:5'`
+test x"$hdt" = x"$dt"
+
+# Avoid using week day in this evaluation, as it's mostly different every year
+# date (GNU coreutils) 6.10 reports:
+# date: invalid date '01231133'
+dt=`busybox date -d 01231133 +%c`
+dt=`echo "$dt" | cut -b5-19`
+test x"$dt" = x"Jan 23 11:33:00"
+
+# date (GNU coreutils) 6.10 reports:
+# date: invalid date '012311332000'
+dt=`busybox date -d 012311332000 +%c`
+test x"$dt" = x"Sun Jan 23 11:33:00 2000"
+
+# date (GNU coreutils) 6.10 reports:
+# date: invalid date '012311332000'
+dt=`busybox date -d 012311332000.30 +%c`
+test x"$dt" = x"Sun Jan 23 11:33:30 2000"
+
+lcbbd="LC_ALL=C busybox date"
+wd=$(eval $lcbbd +%a) # weekday name
+mn=$(eval $lcbbd +%b) # month name
+dm=$(eval $lcbbd +%e) # day of month, space padded
+h=$(eval $lcbbd +%H) # hour, zero padded
+m=$(eval $lcbbd +%M) # minute, zero padded
+s=$(eval $lcbbd +%S) # second, zero padded
+z=$(eval $lcbbd -u +%Z) # time zone abbreviation
+y=$(eval $lcbbd +%Y) # year
+
+res=OK
+case $wd in
+ Sun)
+ ;;
+ Mon)
+ ;;
+ Tue)
+ ;;
+ Wed)
+ ;;
+ Thu)
+ ;;
+ Fri)
+ ;;
+ Sat)
+ ;;
+ *)
+ res=BAD
+ ;;
+esac
+
+case $mn in
+ Jan)
+ ;;
+ Feb)
+ ;;
+ Mar)
+ ;;
+ Apr)
+ ;;
+ May)
+ ;;
+ Jun)
+ ;;
+ Jul)
+ ;;
+ Aug)
+ ;;
+ Sep)
+ ;;
+ Oct)
+ ;;
+ Nov)
+ ;;
+ Dec)
+ ;;
+ *)
+ res=BAD
+ ;;
+esac
+
+dm=${dm# *}
+[ $dm -ge 1 ] && [ $dm -le 31 ] || res=BAD
+h=${h#0}
+[ $h -ge 0 ] && [ $h -le 23 ] || res=BAD
+m=${m#0}
+[ $m -ge 0 ] && [ $m -le 59 ] || res=BAD
+s=${s#0}
+[ $s -ge 0 ] && [ $s -le 59 ] || res=BAD
+[ $z = UTC ] || res=BAD
+[ $y -ge 1970 ] || res=BAD
+
+test x"$res" = xOK
+
+if dt=`busybox date -d 012311332000.30 %+c`; then
+ echo "Expected this to fail with: \"date: invalid date '%+c'\"" >&2
+ exit 1
+fi