diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_gmtime.in | 28 | ||||
-rw-r--r-- | tests/core/test_gmtime.out | 1 | ||||
-rw-r--r-- | tests/test_core.py | 31 |
3 files changed, 32 insertions, 28 deletions
diff --git a/tests/core/test_gmtime.in b/tests/core/test_gmtime.in new file mode 100644 index 00000000..41ce87f9 --- /dev/null +++ b/tests/core/test_gmtime.in @@ -0,0 +1,28 @@ + + #include <stdio.h> + #include <stdlib.h> + #include <time.h> + #include <assert.h> + + int main(void) + { + time_t t=time(NULL); + struct tm *ptm=gmtime(&t); + struct tm tmCurrent=*ptm; + int hour=tmCurrent.tm_hour; + + t-=hour*3600; // back to midnight + int yday = -1; + for(hour=0;hour<24;hour++) + { + ptm=gmtime(&t); + // tm_yday must be constant all day... + printf("yday: %d, hour: %d\n", ptm->tm_yday, hour); + if (yday == -1) yday = ptm->tm_yday; + else assert(yday == ptm->tm_yday); + t+=3600; // add one hour + } + printf("ok!\n"); + return(0); + } +
\ No newline at end of file diff --git a/tests/core/test_gmtime.out b/tests/core/test_gmtime.out new file mode 100644 index 00000000..e036282a --- /dev/null +++ b/tests/core/test_gmtime.out @@ -0,0 +1 @@ +ok!
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 0b073b08..545e990d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2456,35 +2456,10 @@ The current type of b is: 9 self.do_run_from_file(src, output) def test_gmtime(self): - src = r''' - #include <stdio.h> - #include <stdlib.h> - #include <time.h> - #include <assert.h> + test_path = path_from_root('tests', 'core', 'test_gmtime') + src, output = (test_path + s for s in ('.in', '.out')) - int main(void) - { - time_t t=time(NULL); - struct tm *ptm=gmtime(&t); - struct tm tmCurrent=*ptm; - int hour=tmCurrent.tm_hour; - - t-=hour*3600; // back to midnight - int yday = -1; - for(hour=0;hour<24;hour++) - { - ptm=gmtime(&t); - // tm_yday must be constant all day... - printf("yday: %d, hour: %d\n", ptm->tm_yday, hour); - if (yday == -1) yday = ptm->tm_yday; - else assert(yday == ptm->tm_yday); - t+=3600; // add one hour - } - printf("ok!\n"); - return(0); - } - ''' - self.do_run(src, '''ok!''') + self.do_run_from_file(src, output) def test_strptime_tm(self): src=r''' |