[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-commit] [2353] tests/simulate/time
From: |
Mike Rice |
Subject: |
[avr-libc-commit] [2353] tests/simulate/time |
Date: |
Fri, 19 Apr 2013 21:35:53 +0000 |
Revision: 2353
http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2353
Author: swfltek
Date: 2013-04-19 21:35:53 +0000 (Fri, 19 Apr 2013)
Log Message:
-----------
tests/simulate/time
Edited to test all 'key', non-trivial functions. See the individual files for
descriptions of what is being tested.
Modified Paths:
--------------
trunk/avr-libc/tests/simulate/time/declination.c
trunk/avr-libc/tests/simulate/time/equation.c
trunk/avr-libc/tests/simulate/time/isotime.c
trunk/avr-libc/tests/simulate/time/mktime.c
trunk/avr-libc/tests/simulate/time/tick.c
Added Paths:
-----------
trunk/avr-libc/tests/simulate/time/aux.c
trunk/avr-libc/tests/simulate/time/sidereal.c
Added: trunk/avr-libc/tests/simulate/time/aux.c
===================================================================
--- trunk/avr-libc/tests/simulate/time/aux.c (rev 0)
+++ trunk/avr-libc/tests/simulate/time/aux.c 2013-04-19 21:35:53 UTC (rev
2353)
@@ -0,0 +1,48 @@
+/*
+ * (c)2012 Michael Duane Rice All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution. Neither the name of the copyright holders
+ * nor the names of contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* $Id$ */
+
+/*
+ This tests a few of the key 'helpers'.
+*/
+
+#include <time.h>
+
+int main(){
+
+
+ if(month_length(2100,2) != 28) return (__LINE__);
+
+ if(month_length(2136,2) != 29) return (__LINE__);
+
+
+
+ return 0;
+
+}
Property changes on: trunk/avr-libc/tests/simulate/time/aux.c
___________________________________________________________________
Added: svn:keywords
+ ID
Modified: trunk/avr-libc/tests/simulate/time/declination.c
===================================================================
--- trunk/avr-libc/tests/simulate/time/declination.c 2013-04-19 20:12:51 UTC
(rev 2352)
+++ trunk/avr-libc/tests/simulate/time/declination.c 2013-04-19 21:35:53 UTC
(rev 2353)
@@ -1,5 +1,5 @@
/*
- * (C)2012 Michael Duane Rice All rights reserved.
+ * (c)2012 Michael Duane Rice All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,17 +28,57 @@
/* $Id$ */
+/*
+ Declination test. We test the result at the moment of the equinoxes and
solstices of
+ the year 2020, as provided by the U.S. Naval Observatory.
+ We consider a difference greater than 0.01 degree as an error.
+
+*/
+
#include <time.h>
#include <math.h>
int main(){
time_t t;
+struct tm calendar;
double e;
- time(&t);
+ calendar.tm_year = 2020 - 1900;
+ calendar.tm_mon = 2;
+ calendar.tm_mday = 20;
+ calendar.tm_hour = 3;
+ calendar.tm_min = 50;
+ calendar.tm_sec = 0;
+ t = mk_gmtime(&calendar);
+ e = fabs(solar_declination(&t) * 57.295779513082325);
+ if(e > 0.01) return (__LINE__);
+
+ calendar.tm_mon = 5;
+ calendar.tm_mday = 20;
+ calendar.tm_hour = 21;
+ calendar.tm_min = 44;
+ t = mk_gmtime(&calendar);
e = solar_declination(&t) * 57.295779513082325;
- e = fabs(e + 23.01);
- if(e > 0.1) return (__LINE__);
+ e = fabs(e - 23.44);
+ if(e > 0.01) return (__LINE__);
+
+ calendar.tm_mon = 8;
+ calendar.tm_mday = 22;
+ calendar.tm_hour = 13;
+ calendar.tm_min = 31;
+ t = mk_gmtime(&calendar);
+ e = fabs(solar_declination(&t) * 57.295779513082325);
+ if(e > 0.01) return (__LINE__);
+
+ calendar.tm_mon = 11;
+ calendar.tm_mday = 21;
+ calendar.tm_hour = 10;
+ calendar.tm_min = 2;
+ t = mk_gmtime(&calendar);
+ e = solar_declination(&t) * 57.295779513082325;
+ e = fabs(e + 23.44);
+ if(e > 0.01) return (__LINE__);
+
return 0;
}
Modified: trunk/avr-libc/tests/simulate/time/equation.c
===================================================================
--- trunk/avr-libc/tests/simulate/time/equation.c 2013-04-19 20:12:51 UTC
(rev 2352)
+++ trunk/avr-libc/tests/simulate/time/equation.c 2013-04-19 21:35:53 UTC
(rev 2353)
@@ -1,5 +1,5 @@
/*
- * (C)2012 Michael Duane Rice All rights reserved.
+ * (c)2012 Michael Duane Rice All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,16 +28,57 @@
/* $Id$ */
+/*
+ Equation of time test. We test the equation at the zeroes of the year
2013, as
+ reported by the U.S. Naval Observatory. We consider a difference greater
than
+ ten seconds to be an error.
+*/
+
#include <time.h>
#include <math.h>
int main(){
time_t t;
+struct tm calendar;
int e;
- time(&t);
- e = abs(equation_of_time(&t) + 205);
- if(e > 35) return (__LINE__);
+ calendar.tm_year = 2013 - 1900;
+ calendar.tm_mon = 3;
+ calendar.tm_mday = 15;
+ calendar.tm_hour = 9;
+ calendar.tm_min = 55;
+ calendar.tm_sec = 0;
+ t = mk_gmtime(&calendar);
+ e = equation_of_time(&t);
+ e = abs(e);
+ if( e > 10 ) return (__LINE__);
+
+ calendar.tm_mon = 5;
+ calendar.tm_mday = 13;
+ calendar.tm_hour = 2;
+ calendar.tm_min = 40;
+ t = mk_gmtime(&calendar);
+ e = equation_of_time(&t);
+ e = abs(e);
+ if( e > 10 ) return (__LINE__);
+
+ calendar.tm_mon = 8;
+ calendar.tm_mday = 1;
+ calendar.tm_hour = 6;
+ calendar.tm_min = 21;
+ t = mk_gmtime(&calendar);
+ e = equation_of_time(&t);
+ e = abs(e);
+ if( e > 10 ) return (__LINE__);
+
+ calendar.tm_mon = 11;
+ calendar.tm_mday = 25;
+ calendar.tm_hour = 5;
+ calendar.tm_min = 14;
+ t = mk_gmtime(&calendar);
+ e = equation_of_time(&t);
+ e = abs(e);
+ if( e > 10 ) return (__LINE__);
return 0;
}
Modified: trunk/avr-libc/tests/simulate/time/isotime.c
===================================================================
--- trunk/avr-libc/tests/simulate/time/isotime.c 2013-04-19 20:12:51 UTC
(rev 2352)
+++ trunk/avr-libc/tests/simulate/time/isotime.c 2013-04-19 21:35:53 UTC
(rev 2353)
@@ -1,5 +1,5 @@
/*
- * (C)2012 Michael Duane Rice All rights reserved.
+ * (c)2012 Michael Duane Rice All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,10 +28,16 @@
/* $Id$ */
+/*
+ This test ensures that the process of breaking down time is correct as
well as
+ testing isotime() itself.
+*/
+
#include <time.h>
#include <string.h>
char *Y2K_isostring = "2000-01-01 00:00:00";
+char *end_isostring = "2136-02-07 06:28:15";
int
main()
@@ -43,10 +49,13 @@
time(&t);
tmptr = localtime(&t);
+ cp = isotime(tmptr);
+ if (strcmp(Y2K_isostring, cp)) return (__LINE__);
+ t = 0xffffffff;
+ tmptr = localtime(&t);
cp = isotime(tmptr);
+ if (strcmp(end_isostring, cp)) return (__LINE__);
- if (strcmp(Y2K_isostring, cp)) return (__LINE__);
-
return 0;
}
Modified: trunk/avr-libc/tests/simulate/time/mktime.c
===================================================================
--- trunk/avr-libc/tests/simulate/time/mktime.c 2013-04-19 20:12:51 UTC (rev
2352)
+++ trunk/avr-libc/tests/simulate/time/mktime.c 2013-04-19 21:35:53 UTC (rev
2353)
@@ -1,5 +1,5 @@
/*
- * (C)2012 Michael Duane Rice All rights reserved.
+ * (c)2012 Michael Duane Rice All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,6 +28,10 @@
/* $Id$ */
+/*
+ This tests that the results of converting to and from 'binary' and 'broken
down'
+ time are consistent.
+*/
#include <time.h>
int main(){
Added: trunk/avr-libc/tests/simulate/time/sidereal.c
===================================================================
--- trunk/avr-libc/tests/simulate/time/sidereal.c
(rev 0)
+++ trunk/avr-libc/tests/simulate/time/sidereal.c 2013-04-19 21:35:53 UTC
(rev 2353)
@@ -0,0 +1,63 @@
+/*
+ * (c)2012 Michael Duane Rice All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution. Neither the name of the copyright holders
+ * nor the names of contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* $Id$ */
+
+/*
+ This test allows for 1 second error in calculation of sidereal time 136
years after
+ the epoch. The 'correct' value is 24004.8 seconds.
+*/
+
+#include <time.h>
+#include <string.h>
+
+int
+main()
+{
+
+ time_t t;
+ struct tm calendar;
+ long e;
+
+
+ calendar.tm_year = 2136 - 1900;
+ calendar.tm_mon = 0;
+ calendar.tm_mday = 1;
+ calendar.tm_hour = 0;
+ calendar.tm_min = 0;
+ calendar.tm_sec = 0;
+
+ t = mk_gmtime(&calendar);
+ t = gm_sidereal(&t);
+ e = t - 24005L;
+ e = labs(e);
+
+ if ( e > 1 ) return (__LINE__);
+ return 0;
+
+}
Property changes on: trunk/avr-libc/tests/simulate/time/sidereal.c
___________________________________________________________________
Added: svn:keywords
+ ID
Modified: trunk/avr-libc/tests/simulate/time/tick.c
===================================================================
--- trunk/avr-libc/tests/simulate/time/tick.c 2013-04-19 20:12:51 UTC (rev
2352)
+++ trunk/avr-libc/tests/simulate/time/tick.c 2013-04-19 21:35:53 UTC (rev
2353)
@@ -1,5 +1,5 @@
/*
- * (C)2012 Michael Duane Rice All rights reserved.
+ * (c)2012 Michael Duane Rice All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,10 +28,16 @@
/* $Id$ */
+/*
+ 'Tick' test. This actually tests system_tick(), gmtime_r(),
set_system_time(), and
+ time().
+*/
+
#include <time.h>
int main(){
time_t t, tt;
+struct tm calendar;
time(&t);
system_tick();
@@ -40,6 +46,16 @@
if(t != tt ) return (__LINE__);
+ t = 0xffffffff;
+ gmtime_r(&t, &calendar);
+ set_system_time(&calendar);
+
+ t++;
+ system_tick();
+ time(&tt);
+
+ if(t != tt ) return (__LINE__);
+
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-commit] [2353] tests/simulate/time,
Mike Rice <=