litesoft
@ 942
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.core.simpletypes.temporal; import java.util.*; import junit.framework.*; import org.litesoft.commonfoundation.typeutils.gregorian.*; public class UtilDateAdaptorTest extends TestCase { public static TestSuite suite() { return new TestSuite( UtilDateAdaptorTest.class ); } public UtilDateAdaptorTest( String name ) { super( name ); } public static void main( String[] args ) { junit.textui.TestRunner.run( suite() ); } public void test_RoundTrip() { chkRT( 1957 ); chkRT( 1957, 1 ); chkRT( 1957, 1, 4 ); chkRT( 1957, 1, 4, 12 ); chkRT( 1957, 1, 4, 12, 3 ); chkRT( 1957, 1, 4, 12, 3, 4 ); chkRT( 1957, 1, 4, 12, 3, 4, 567 ); chkRT( 1969 ); chkRT( 1969, 12 ); chkRT( 1969, 12, 31 ); chkRT( 1969, 12, 31, 23 ); chkRT( 1969, 12, 31, 23, 59 ); chkRT( 1969, 12, 31, 23, 59, 59 ); chkRT( 1970 ); chkRT( 1970, 1 ); chkRT( 1970, 1, 1 ); chkRT( 1970, 1, 1, 1 ); chkRT( 1970, 1, 1, 0, 1 ); chkRT( 1970, 1, 1, 0, 0, 1 ); chkRT( 1970, 1, 1, 0, 0, 0, 1 ); chkRT( 2007 ); chkRT( 2007, 1 ); chkRT( 2007, 1, 4 ); chkRT( 2007, 1, 4, 12 ); chkRT( 2007, 1, 4, 12, 3 ); chkRT( 2007, 1, 4, 12, 3, 4 ); chkRT( 2007, 1, 4, 12, 3, 4, 567 ); chkRT( 1957, 1, 4, 12, 30 ); chkRT( 1957, 1, 4, 12, 30, 15 ); chkRT( 1957, 1, 4, 12, 30, 15, 678 ); chkRT( 1969, 12, 31, 23, 59, 59, 999 ); chkRT( 1970, 1, 1, 0 ); } public void test_RT_Years() { for ( int i = 1800; i < 2100; i++ ) { chkRT( i ); } } public void test_RT_Months() { for ( int i = 1; i < 12; i++ ) { chkRT( 1957, i ); } } public void test_RT_Days() { for ( int i = 1; i < 12; i++ ) { chkDays( 1957, i ); chkDays( 2000, i ); } } public void test_RT_Hours() { for ( int i = 0; i < 23; i++ ) { chkRT( 1957, 1, 4, i ); } } public void test_RT_Mins() { for ( int i = 0; i < 59; i++ ) { chkRT( 1957, 1, 4, 9, i ); } } public void test_RT_Secs() { for ( int i = 0; i < 59; i++ ) { chkRT( 1957, 1, 4, 9, 8, i ); } } public void test_RT_MilliSecs() { for ( int i = 0; i < 999; i++ ) { chkRT( 1957, 1, 4, 9, 8, 7, i ); } } private void chkDays( int pYear, int pMonth ) { for ( int zDay = Month.daysIn( pYear, pMonth ); zDay > 0; zDay-- ) { chkRT( pYear, pMonth, zDay ); } } private void chkRT( int pYear ) { chkRT( TemporalResolution.ToYear, // UtilDateAdaptor.currentWall( pYear ) ); } private void chkRT( int pYear, int pMonth ) { chkRT( TemporalResolution.ToMonth, // UtilDateAdaptor.currentWall( pYear, pMonth ) ); } private void chkRT( int pYear, int pMonth, int pDay ) { chkRT( TemporalResolution.ToDay, // UtilDateAdaptor.currentWall( pYear, pMonth, pDay ) ); } private void chkRT( int pYear, int pMonth, int pDay, int pHour ) { chkRT( TemporalResolution.ToHour, // UtilDateAdaptor.currentWall( pYear, pMonth, pDay, pHour ) ); } private void chkRT( int pYear, int pMonth, int pDay, int pHour, int pMin ) { chkRT( TemporalResolution.ToMin, // UtilDateAdaptor.currentWall( pYear, pMonth, pDay, pHour, pMin ) ); } private void chkRT( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec ) { chkRT( TemporalResolution.ToSec, // UtilDateAdaptor.currentWall( pYear, pMonth, pDay, pHour, pMin, pSec ) ); } private void chkRT( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pMilliSec ) { chkRT( TemporalResolution.ToMilliSec, // UtilDateAdaptor.currentWall( pYear, pMonth, pDay, pHour, pMin, pSec, pMilliSec ) ); } private void chkRT( TemporalResolution pTemporalResolution, UtilDateAdaptor pOrigAdaptor ) { Date date = pOrigAdaptor.getWallDate(); UtilDateAdaptor zRT_Adaptor = new UtilDateAdaptor( date, pTemporalResolution ); chkRT( pTemporalResolution, pOrigAdaptor, zRT_Adaptor ); } private void chkRT( TemporalResolution pTemporalResolution, UtilDateAdaptor pOrigAdaptor, UtilDateAdaptor pRT_Adaptor ) { assertEquals( "TemporalResolution", pTemporalResolution, pOrigAdaptor.getTemporalResolution() ); assertEquals( "TemporalResolution", pOrigAdaptor.getTemporalResolution(), pRT_Adaptor.getTemporalResolution() ); assertEquals( "Year", pOrigAdaptor.getYear(), pRT_Adaptor.getYear() ); assertEquals( "Month", pOrigAdaptor.getMonth(), pRT_Adaptor.getMonth() ); assertEquals( "Day", pOrigAdaptor.getHour(), pRT_Adaptor.getHour() ); assertEquals( "Hour", pOrigAdaptor.getHour(), pRT_Adaptor.getHour() ); assertEquals( "Min", pOrigAdaptor.getMin(), pRT_Adaptor.getMin() ); assertEquals( "Sec", pOrigAdaptor.getSec(), pRT_Adaptor.getSec() ); assertEquals( "MilliSec", pOrigAdaptor.getMilliSec(), pRT_Adaptor.getMilliSec() ); } } |
Commits for litesoft/trunk/Java/core/Anywhere/tests/org/litesoft/core/simpletypes/temporal/UtilDateAdaptorTest.java
Revision | Author | Commited | Message |
---|---|---|---|
942 Diff | GeorgeS | Mon 02 Jun, 2014 23:41:46 +0000 | Extracting commonfoundation |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
912 Diff | GeorgeS | Fri 28 Jun, 2013 06:48:05 +0000 | Revert to mixed & Working (PEDS & Prioritizer) code! |
897 Diff | GeorgeS | Mon 25 Feb, 2013 02:04:34 +0000 | |
869 | GeorgeS | Mon 26 Nov, 2012 01:33:04 +0000 |