1 // ============================================================================
7 // This program verifies the ACE_Date_Time class.
10 // Steve Huston <shuston@riverace.com>
12 // ============================================================================
14 #include "ace/Date_Time.h"
15 #include "test_config.h"
17 static ACE_Date_Time static_dt
; // Making sure it doesn't crash.
20 run_main (int, ACE_TCHAR
*[])
22 ACE_START_TEST (ACE_TEXT ("Date_Time_Test"));
28 long month
= dt
.month ();
30 long year
= dt
.year ();
31 long hour
= dt
.hour ();
32 long minute
= dt
.minute ();
33 long seconds
= dt
.second ();
34 long usec
= dt
.microsec ();
36 ACE_TEXT ("ACE_Date_Time (m/d/y, h:m:s.u): %d/%d/%d, %d:%d:%d.%d\n"),
37 month
, day
, year
, hour
, minute
, seconds
, usec
));
38 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("ACE_Log thinks it is: %D\n")));
40 if (month
< 1 || month
> 12)
42 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Month (%d) out of range (1-12)\n"),
46 if (day
< 1 || day
> 31)
48 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Day (%d) out of range (1-31)\n"),
52 if (year
< 1900 || year
> 2100)
54 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Year (%d) out of range (1900-2100)\n"),
58 if (hour
< 0 || hour
> 23)
60 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Hour (%d) out of range (0-23)\n"),
64 if (minute
< 0 || minute
> 59)
66 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Minute (%d) out of range (0-59)\n"),
70 if (seconds
< 0 || seconds
> 59)
72 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Seconds (%d) out of range (0-59)\n"),
76 if (usec
< 0 || usec
> 999999)
79 ACE_TEXT ("Microseconds (%d) out of range (0-999999)\n"),
84 // The static ACE_Date_Time object is primarily to be sure it doesn't
85 // crash; However, let's do some sanity checks on it to be sure it's
87 if (static_dt
.month () != month
)
90 ACE_TEXT ("Static month (%d) doesn't match %d\n"),
91 static_dt
.month (), month
));
94 if (static_dt
.day () != day
)
97 ACE_TEXT ("Static day (%d) doesn't match %d\n"),
98 static_dt
.day (), day
));
101 if (static_dt
.year () != year
)
103 ACE_ERROR ((LM_ERROR
,
104 ACE_TEXT ("Static year (%d) doesn't match %d\n"),
105 static_dt
.year (), year
));
108 if (static_dt
.hour () != hour
)
110 ACE_ERROR ((LM_ERROR
,
111 ACE_TEXT ("Static hour (%d) doesn't match %d\n"),
112 static_dt
.hour (), hour
));
116 // There's a rare instance where the starting seconds is 59 and the
117 // minute roles over during the test run.
118 if (!(static_dt
.minute () == minute
||
119 (static_dt
.minute () + 1 == minute
&& static_dt
.second () > seconds
)))
121 ACE_ERROR ((LM_ERROR
,
122 ACE_TEXT ("Static minute (%d) doesn't match %d\n"),
123 static_dt
.minute (), minute
));