Mercurial > octave
diff src/DLD-FUNCTIONS/time.cc @ 7562:c827f5673321
move tests to individual source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 06 Mar 2008 02:27:55 -0500 |
parents | e8c94e473c68 |
children | a2d9f325b65a |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/time.cc Thu Mar 06 01:56:55 2008 -0500 +++ b/src/DLD-FUNCTIONS/time.cc Thu Mar 06 02:27:55 2008 -0500 @@ -96,6 +96,12 @@ return retval; } +/* + +%!assert(time () > 0); + +*/ + DEFUN_DLD (gmtime, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} gmtime (@var{t})\n\ @@ -138,6 +144,28 @@ return retval; } +/* + +%!test +%! ts = gmtime (time ()); +%! assert((isstruct (ts) +%! && struct_contains (ts, "usec") +%! && struct_contains (ts, "year") +%! && struct_contains (ts, "mon") +%! && struct_contains (ts, "mday") +%! && struct_contains (ts, "sec") +%! && struct_contains (ts, "min") +%! && struct_contains (ts, "wday") +%! && struct_contains (ts, "hour") +%! && struct_contains (ts, "isdst") +%! && struct_contains (ts, "yday"))); + +%!error <Invalid call to gmtime.*> gmtime (); + +%!error <Invalid call to gmtime.*> gmtime (1, 2); + +*/ + DEFUN_DLD (localtime, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} localtime (@var{t})\n\ @@ -180,6 +208,28 @@ return retval; } +/* + +%!test +%! ts = localtime (time ()); +%! assert((isstruct (ts) +%! && struct_contains (ts, "usec") +%! && struct_contains (ts, "year") +%! && struct_contains (ts, "mon") +%! && struct_contains (ts, "mday") +%! && struct_contains (ts, "sec") +%! && struct_contains (ts, "min") +%! && struct_contains (ts, "wday") +%! && struct_contains (ts, "hour") +%! && struct_contains (ts, "isdst") +%! && struct_contains (ts, "yday"))); + +%!error <Invalid call to localtime.*> localtime (); + +%!error <Invalid call to localtime.*> localtime (1, 2); + +*/ + DEFUN_DLD (mktime, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} mktime (@var{tm_struct})\n\ @@ -219,6 +269,18 @@ return retval; } +/* + +%!test +%! t = time (); +%! assert(fix (mktime (localtime (t))) == fix (t)); + +%!error <Invalid call to mktime.*> mktime (); + +%!error <Invalid call to mktime.*> mktime (1, 2, 3); + +*/ + DEFUN_DLD (strftime, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} strftime (@var{fmt}, @var{tm_struct})\n\ @@ -403,6 +465,20 @@ return retval; } +/* + +%!assert((isstr (strftime ("%%%n%t%H%I%k%l", localtime (time ()))) +%! && isstr (strftime ("%M%p%r%R%s%S%T", localtime (time ()))) +%! && isstr (strftime ("%X%Z%z%a%A%b%B", localtime (time ()))) +%! && isstr (strftime ("%c%C%d%e%D%h%j", localtime (time ()))) +%! && isstr (strftime ("%m%U%w%W%x%y%Y", localtime (time ()))))); + +%!error <Invalid call to strftime.*> strftime (); + +%!error <Invalid call to strftime.*> strftime ("foo", localtime (time ()), 1); + +*/ + DEFUN_DLD (strptime, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{tm_struct}, @var{nchars}] =} strptime (@var{str}, @var{fmt})\n\