Subversion Repository Public Repository

litesoft

Diff Revisions 897 vs 912 for /trunk/Java/core/Anywhere/tests/org/litesoft/core/simpletypes/temporal/UtilDateAdaptorTest.java

Diff revisions: vs.
  @@ -24,29 +24,8 @@
24 24 junit.textui.TestRunner.run( suite() );
25 25 }
26 26
27 - public void test_DST()
28 - {
29 - // UtilDateAdaptor zOrigAdaptor = UtilDateAdaptor.wall( 2013, 3, 17, 20 ); // DST!
30 - // Date zOrigDate = zOrigAdaptor.getWallDate();
31 - // UtilDateAdaptor zRT_Adaptor = new UtilDateAdaptor( zOrigDate, TemporalResolution.ToHour );
32 - // Date zRT_Date = zRT_Adaptor.getWallDate();
33 - // System.out.println( "UtilDateAdaptorTest.test_DST\nCW: " + zOrigDate + " | " + zOrigAdaptor + "\nRT: " + zRT_Date + " | " + zRT_Adaptor );
34 - //
35 - // zOrigAdaptor = UtilDateAdaptor.wall( 2013, 2, 14, 10 ); // !DST
36 - // zOrigDate = zOrigAdaptor.getWallDate();
37 - // zRT_Adaptor = new UtilDateAdaptor( zOrigDate, TemporalResolution.ToHour );
38 - // zRT_Date = zRT_Adaptor.getWallDate();
39 - // System.out.println( "UtilDateAdaptorTest.test_DST\nCW: " + zOrigDate + " | " + zOrigAdaptor + "\nRT: " + zRT_Date + " | " + zRT_Adaptor );
40 -
41 - chkRT( 2013, 3, 17, 20 ); // DST!
42 - chkRT( 2013, 2, 14, 10 ); // !DST
43 - }
44 -
45 27 public void test_RoundTrip()
46 28 {
47 - chkRT( 2013, 2, 15, 12 ); // !DST
48 - chkRT( 2013, 3, 15, 12 ); // DST!
49 -
50 29 chkRT( 1957 );
51 30 chkRT( 1957, 1 );
52 31 chkRT( 1957, 1, 4 );
  @@ -88,76 +67,58 @@
88 67
89 68 public void test_RT_Years()
90 69 {
91 - for ( int zYear = 1800; zYear < 2100; zYear++ )
70 + for ( int i = 1800; i < 2100; i++ )
92 71 {
93 - chkRT( zYear );
72 + chkRT( i );
94 73 }
95 74 }
96 75
97 76 public void test_RT_Months()
98 77 {
99 - for ( int zMonth = 1; zMonth < 12; zMonth++ )
78 + for ( int i = 1; i < 12; i++ )
100 79 {
101 - chkRT( 1957, zMonth );
102 - chkRT( 2000, zMonth );
80 + chkRT( 1957, i );
103 81 }
104 82 }
105 83
106 84 public void test_RT_Days()
107 85 {
108 - for ( int zMonth = 1; zMonth <= 12; zMonth++ )
86 + for ( int i = 1; i < 12; i++ )
109 87 {
110 - chkDays( 1957, zMonth );
111 - chkDays( 2000, zMonth );
88 + chkDays( 1957, i );
89 + chkDays( 2000, i );
112 90 }
113 91 }
114 92
115 93 public void test_RT_Hours()
116 94 {
117 - for ( int zMonth = 1; zMonth <= 12; zMonth++ )
95 + for ( int i = 0; i < 23; i++ )
118 96 {
119 - for ( int zDay = 1; zDay <= 28; zDay++ )
120 - {
121 - for ( int zHour = 0; zHour < 23; zHour++ )
122 - {
123 - chkRT( 1957, zMonth, zDay, zHour );
124 - chkRT( 2000, zMonth, zDay, zHour );
125 - }
126 - }
97 + chkRT( 1957, 1, 4, i );
127 98 }
128 99 }
129 100
130 101 public void test_RT_Mins()
131 102 {
132 - for ( int zMonth = 1; zMonth <= 12; zMonth++ )
103 + for ( int i = 0; i < 59; i++ )
133 104 {
134 - for ( int zDay = 1; zDay <= 28; zDay++ )
135 - {
136 - for ( int zHour = 0; zHour < 23; zHour++ )
137 - {
138 - for ( int zMin = 0; zMin < 59; zMin++ )
139 - {
140 - chkRT( 1957, zMonth, zDay, zHour, zMin );
141 - chkRT( 2000, zMonth, zDay, zHour, zMin );
142 - }
143 - }
144 - }
105 + chkRT( 1957, 1, 4, 9, i );
145 106 }
146 107 }
147 108
148 109 public void test_RT_Secs()
149 110 {
150 - for ( int zSec = 0; zSec < 59; zSec++ )
111 + for ( int i = 0; i < 59; i++ )
151 112 {
152 - chkRT( 1957, 1, 4, 9, 8, zSec );
113 + chkRT( 1957, 1, 4, 9, 8, i );
153 114 }
154 115 }
155 116
156 117 public void test_RT_MilliSecs()
157 118 {
158 - for ( int zMilli = 0; zMilli < 999; zMilli++ )
119 + for ( int i = 0; i < 999; i++ )
159 120 {
160 - chkRT( 1957, 1, 4, 9, 8, 7, zMilli );
121 + chkRT( 1957, 1, 4, 9, 8, 7, i );
161 122 }
162 123 }
163 124
  @@ -172,43 +133,43 @@
172 133 private void chkRT( int pYear )
173 134 {
174 135 chkRT( TemporalResolution.ToYear, //
175 - UtilDateAdaptor.wall( pYear ) );
136 + UtilDateAdaptor.currentWall( pYear ) );
176 137 }
177 138
178 139 private void chkRT( int pYear, int pMonth )
179 140 {
180 141 chkRT( TemporalResolution.ToMonth, //
181 - UtilDateAdaptor.wall( pYear, pMonth ) );
142 + UtilDateAdaptor.currentWall( pYear, pMonth ) );
182 143 }
183 144
184 145 private void chkRT( int pYear, int pMonth, int pDay )
185 146 {
186 147 chkRT( TemporalResolution.ToDay, //
187 - UtilDateAdaptor.wall( pYear, pMonth, pDay ) );
148 + UtilDateAdaptor.currentWall( pYear, pMonth, pDay ) );
188 149 }
189 150
190 151 private void chkRT( int pYear, int pMonth, int pDay, int pHour )
191 152 {
192 153 chkRT( TimeRes.ToHOUR, TemporalResolution.ToHour, //
193 - UtilDateAdaptor.wall( pYear, pMonth, pDay, pHour ) );
154 + UtilDateAdaptor.currentWall( pYear, pMonth, pDay, pHour ) );
194 155 }
195 156
196 157 private void chkRT( int pYear, int pMonth, int pDay, int pHour, int pMin )
197 158 {
198 159 chkRT( TimeRes.ToMIN, TemporalResolution.ToMin, //
199 - UtilDateAdaptor.wall( pYear, pMonth, pDay, pHour, pMin ) );
160 + UtilDateAdaptor.currentWall( pYear, pMonth, pDay, pHour, pMin ) );
200 161 }
201 162
202 163 private void chkRT( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec )
203 164 {
204 165 chkRT( TimeRes.ToSEC, TemporalResolution.ToSec, //
205 - UtilDateAdaptor.wall( pYear, pMonth, pDay, pHour, pMin, pSec ) );
166 + UtilDateAdaptor.currentWall( pYear, pMonth, pDay, pHour, pMin, pSec ) );
206 167 }
207 168
208 169 private void chkRT( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pMilliSec )
209 170 {
210 171 chkRT( TimeRes.ToMSEC, TemporalResolution.ToMilliSec, //
211 - UtilDateAdaptor.wall( pYear, pMonth, pDay, pHour, pMin, pSec, pMilliSec ) );
172 + UtilDateAdaptor.currentWall( pYear, pMonth, pDay, pHour, pMin, pSec, pMilliSec ) );
212 173 }
213 174
214 175 private void chkRT( TimeRes pTimeRes, TemporalResolution pTemporalResolution, UtilDateAdaptor pOrigAdaptor )
  @@ -230,89 +191,17 @@
230 191 chkRT( pTemporalResolution, pOrigAdaptor, zRT_Adaptor );
231 192 }
232 193
233 - private interface IntAccessor
234 - {
235 - int get( UtilDateAdaptor pAdaptor );
236 - }
237 -
238 194 private void chkRT( TemporalResolution pTemporalResolution, UtilDateAdaptor pOrigAdaptor, UtilDateAdaptor pRT_Adaptor )
239 195 {
240 - assertEquals( "TemporalResolution: " + pOrigAdaptor, pTemporalResolution, pOrigAdaptor.getTemporalResolution() );
241 - assertEquals( "TemporalResolution: " + pOrigAdaptor + " | " + pRT_Adaptor, pOrigAdaptor.getTemporalResolution(), pRT_Adaptor.getTemporalResolution() );
242 -
243 - chkRT( pOrigAdaptor, pRT_Adaptor, "Year", new IntAccessor()
244 - {
245 - @Override
246 - public int get( UtilDateAdaptor pAdaptor )
247 - {
248 - return pAdaptor.getYear();
249 - }
250 - } );
251 - chkRT( pOrigAdaptor, pRT_Adaptor, "Month", new IntAccessor()
252 - {
253 - @Override
254 - public int get( UtilDateAdaptor pAdaptor )
255 - {
256 - return pAdaptor.getMonth();
257 - }
258 - } );
259 - chkRT( pOrigAdaptor, pRT_Adaptor, "Day", new IntAccessor()
260 - {
261 - @Override
262 - public int get( UtilDateAdaptor pAdaptor )
263 - {
264 - return pAdaptor.getDay();
265 - }
266 - } );
267 - chkRT( pOrigAdaptor, pRT_Adaptor, "Hour", new IntAccessor()
268 - {
269 - @Override
270 - public int get( UtilDateAdaptor pAdaptor )
271 - {
272 - return pAdaptor.getHour();
273 - }
274 - } );
275 - chkRT( pOrigAdaptor, pRT_Adaptor, "Min", new IntAccessor()
276 - {
277 - @Override
278 - public int get( UtilDateAdaptor pAdaptor )
279 - {
280 - return pAdaptor.getMin();
281 - }
282 - } );
283 - chkRT( pOrigAdaptor, pRT_Adaptor, "Sec", new IntAccessor()
284 - {
285 - @Override
286 - public int get( UtilDateAdaptor pAdaptor )
287 - {
288 - return pAdaptor.getSec();
289 - }
290 - } );
291 - chkRT( pOrigAdaptor, pRT_Adaptor, "MilliSec", new IntAccessor()
292 - {
293 - @Override
294 - public int get( UtilDateAdaptor pAdaptor )
295 - {
296 - return pAdaptor.getMilliSec();
297 - }
298 - } );
299 - chkRT( pOrigAdaptor, pRT_Adaptor, "ZuluOffsetMins", new IntAccessor()
300 - {
301 - @Override
302 - public int get( UtilDateAdaptor pAdaptor )
303 - {
304 - return pAdaptor.getZuluOffsetMins();
305 - }
306 - } );
307 - }
196 + assertEquals( "TemporalResolution", pTemporalResolution, pOrigAdaptor.getTemporalResolution() );
197 + assertEquals( "TemporalResolution", pOrigAdaptor.getTemporalResolution(), pRT_Adaptor.getTemporalResolution() );
308 198
309 - private void chkRT( UtilDateAdaptor pOrigAdaptor, UtilDateAdaptor pRT_Adaptor, String pWhat, IntAccessor pAccessor )
310 - {
311 - int zOA_int = pAccessor.get( pOrigAdaptor );
312 - int zRA_int = pAccessor.get( pRT_Adaptor );
313 - if ( zOA_int != zRA_int )
314 - {
315 - assertEquals( "(" + pOrigAdaptor + " <> " + pRT_Adaptor + ") " + pWhat, zOA_int, zRA_int );
316 - }
199 + assertEquals( "Year", pOrigAdaptor.getYear(), pRT_Adaptor.getYear() );
200 + assertEquals( "Month", pOrigAdaptor.getMonth(), pRT_Adaptor.getMonth() );
201 + assertEquals( "Day", pOrigAdaptor.getHour(), pRT_Adaptor.getHour() );
202 + assertEquals( "Hour", pOrigAdaptor.getHour(), pRT_Adaptor.getHour() );
203 + assertEquals( "Min", pOrigAdaptor.getMin(), pRT_Adaptor.getMin() );
204 + assertEquals( "Sec", pOrigAdaptor.getSec(), pRT_Adaptor.getSec() );
205 + assertEquals( "MilliSec", pOrigAdaptor.getMilliSec(), pRT_Adaptor.getMilliSec() );
317 206 }
318 207 }