Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / tests / Date_Time_Test.cpp
blob31ea5b03665f9b81f8d7311ba22e223ca23e2f95
1 // ============================================================================
2 //
3 // = LIBRARY
4 // tests
5 //
6 // = DESCRIPTION
7 // This program verifies the ACE_Date_Time class.
8 //
9 // = AUTHOR
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.
19 int
20 run_main (int, ACE_TCHAR *[])
22 ACE_START_TEST (ACE_TEXT ("Date_Time_Test"));
24 int error = 0;
26 ACE_Date_Time dt;
28 long month = dt.month ();
29 long day = dt.day ();
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 ();
35 ACE_DEBUG ((LM_DEBUG,
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"),
43 month));
44 error = 1;
46 if (day < 1 || day > 31)
48 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Day (%d) out of range (1-31)\n"),
49 day));
50 error = 1;
52 if (year < 1900 || year > 2100)
54 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Year (%d) out of range (1900-2100)\n"),
55 year));
56 error = 1;
58 if (hour < 0 || hour > 23)
60 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Hour (%d) out of range (0-23)\n"),
61 hour));
62 error = 1;
64 if (minute < 0 || minute > 59)
66 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Minute (%d) out of range (0-59)\n"),
67 minute));
68 error = 1;
70 if (seconds < 0 || seconds > 59)
72 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Seconds (%d) out of range (0-59)\n"),
73 seconds));
74 error = 1;
76 if (usec < 0 || usec > 999999)
78 ACE_ERROR ((LM_ERROR,
79 ACE_TEXT ("Microseconds (%d) out of range (0-999999)\n"),
80 usec));
81 error = 1;
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
86 // legit as well.
87 if (static_dt.month () != month)
89 ACE_ERROR ((LM_ERROR,
90 ACE_TEXT ("Static month (%d) doesn't match %d\n"),
91 static_dt.month (), month));
92 error = 1;
94 if (static_dt.day () != day)
96 ACE_ERROR ((LM_ERROR,
97 ACE_TEXT ("Static day (%d) doesn't match %d\n"),
98 static_dt.day (), day));
99 error = 1;
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));
106 error = 1;
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));
113 error = 1;
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));
124 error = 1;
126 ACE_END_TEST;
127 return error;