~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/time/src.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-06-11 15:45:24 UTC
  • mfrom: (1.2.1) (2.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130611154524-rppb3w6tixlegv4n
Tags: 1.4.7~20130611~a1eb425-1
* New snapshot release
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include <stdlib.h>
3
3
#include <time.h>
4
4
#include <string.h>
 
5
#include <assert.h>
 
6
#include <math.h>
5
7
 
6
8
int main() {
7
9
  time_t xmas2002 = 1040786563ll;
64
66
  // Verify time() returns reasonable value (between 2011 and 2030).
65
67
  time_t t4 = 0;
66
68
  time(&t4);
 
69
  timespec ts;
 
70
  assert(clock_gettime(0, &ts) == 0);
 
71
  assert(abs(ts.tv_sec - t4) <= 2);
67
72
  printf("time: %d\n", t4 > 1309635200ll && t4 < 1893362400ll);
68
73
 
69
74
  // Verify difftime() calculates accurate time difference.