summaryrefslogtreecommitdiff
path: root/examples/Reactor/Misc/test_time_value.cpp
blob: 4806b8e9c6c379546a48605727ce4304ed5fb224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "ace/ACE.h"
// $Id$


inline int my_abs (int d) { return d > 0 ? d : -d; }

ostream &
operator<< (ostream &stream, const ACE_Time_Value &tv)
{
  if (tv.usec () < 0 || tv.sec () < 0)
    stream << "-";

  stream << dec << my_abs (int (tv.sec ())) << "."
//	 << setw (6) << setfill ('0') 
	 << dec << my_abs (int (tv.usec ()));
  return stream;
}

int
main (int argc, char *argv[])
{
  ACE_Time_Value tv1;
  ACE_Time_Value tv2 (2);
  ACE_Time_Value tv3 (100);  
  ACE_Time_Value tv4 (1, 1000000);
  ACE_Time_Value tv5 (2);
  ACE_Time_Value tv6 (1, -1000000);

  ACE_ASSERT (tv1 == ACE_Time_Value (0));
  ACE_ASSERT (tv2 < tv3);
  ACE_ASSERT (tv2 <= tv2);
  ACE_ASSERT (tv2 >= tv4);
  ACE_ASSERT (tv5 >= tv6);
  ACE_ASSERT (tv2 == ACE_Time_Value (1, 1000000));
  ACE_ASSERT (tv5 == tv4);
  ACE_ASSERT (tv2 == tv4);
  ACE_ASSERT (tv1 != tv2);
  ACE_ASSERT (tv6 == tv1);

  cout << "0,0 :\t\t"        << ACE_Time_Value (0,0) << endl;
  cout << "-0,0 :\t\t"       << ACE_Time_Value (-0,0) << endl;
  cout << "0,-0 :\t\t"       << ACE_Time_Value (0,-0) << endl;
  cout << "-0,-0 :\t\t"      << ACE_Time_Value (-0,-0) << endl;
  cout << endl;

  cout << "0,1 :\t\t"        << ACE_Time_Value (0,1) << endl;
  cout << "1,0 :\t\t"        << ACE_Time_Value (1,0) << endl;
  cout << "-1,0 :\t\t"       << ACE_Time_Value (-1,0) << endl;
  cout << "-1,-0 :\t\t"      << ACE_Time_Value (-1,-0) << endl;
  cout << endl;

  cout << "1,1 :\t\t"        << ACE_Time_Value (1,1) << endl;
  cout << "-1,1 :\t\t"       << ACE_Time_Value (-1,1) << endl;
  cout << "1,-1 :\t\t"       << ACE_Time_Value (1,-1) << endl;
  cout << "-1,-1 :\t\t"      << ACE_Time_Value (-1,-1) << endl;
  cout << endl;

  cout << "1,-1111111 :\t"   << ACE_Time_Value (1,-1111111) << endl;
  cout << "1,-100000 :\t"    << ACE_Time_Value (1,-100000) << endl;
  cout << "1,-1000000 :\t"   << ACE_Time_Value (1,-1000000) << endl;
  cout << "-1,1000000 :\t"   << ACE_Time_Value (-1,1000000) << endl;
  cout << "5,-1000000 :\t"   << ACE_Time_Value (5,-1000000) << endl;
  cout << "5,-1500000 :\t"   << ACE_Time_Value (5,-1500000) << endl;
  cout << "2,-2500000 :\t"   << ACE_Time_Value (2,-2500000) << endl;
  cout << "2,-4500000 :\t"   << ACE_Time_Value (2,-4500000) << endl;

  return 0;
}