Skip to content
Snippets Groups Projects
Commit 73b746a0 authored by pfdietz's avatar pfdietz
Browse files

Begin adding tests for decode-universal-time, encode-universal-time

parent 771d3512
No related branches found
No related tags found
No related merge requests found
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat May 7 07:00:58 2005
;;;; Contains: Tests of DECODE-UNIVERSAL-TIME
(in-package :cl-test)
(deftest decode-universal-time.1
(decode-universal-time 0 0)
0 0 0 1 1 1900 0 nil 0)
(deftest decode-universal-time.2
(decode-universal-time 0 -1)
0 0 1 1 1 1900 0 nil -1)
(deftest decode-universal-time.3
(let ((count 0))
(loop for time = (random 10000000000)
for tz = (- (random 49) 24)
for (second minute hour date month year day daylight-p zone)
= (multiple-value-list (decode-universal-time time tz))
for time2 = (encode-universal-time second minute hour date month year zone)
repeat 1000
unless (and (eql tz zone) (eql time time2) (null daylight-p))
collect (progn (incf count)
(list time tz (list second minute hour date month year day daylight-p zone) time2))
until (>= count 100)))
nil)
(deftest decode-universal-time.4
(let ((count 0))
(loop for time = (random 10000000000)
for tz = (/ (- (random (1+ (* 48 3600))) (* 24 3600)) 3600)
for (second minute hour date month year day daylight-p zone)
= (multiple-value-list (decode-universal-time time tz))
for time2 = (encode-universal-time second minute hour date month year zone)
repeat 1000
unless (and (eql tz zone) (eql time time2) (null daylight-p))
collect (progn (incf count)
(list time tz (list second minute hour date month year day daylight-p zone) time2))
until (>= count 100)))
nil)
(deftest decode-universal-time.5
(let ((count 0))
(loop for time = (let ((x (random 10000000000))) (print x) x)
for (second minute hour date month year day daylight-p zone)
= (multiple-value-list (decode-universal-time time))
for time2 = (encode-universal-time second minute hour date month year)
repeat 1000
unless (eql time time2)
collect (progn (incf count)
(list time (list second minute hour date month year day daylight-p zone) time2))
until (>= count 100)))
nil)
;;; Error tests
(deftest decode-universal-time.error.1
(signals-error (decode-universal-time) program-error)
t)
(deftest decode-universal-time.error.2
(signals-error (decode-universal-time 0 0 nil) program-error)
t)
...@@ -12,3 +12,5 @@ ...@@ -12,3 +12,5 @@
(load "time.lsp") (load "time.lsp")
(load "trace.lsp") (load "trace.lsp")
(load "user-homedir-pathname.lsp") (load "user-homedir-pathname.lsp")
(load "decode-universal-time.lsp")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment