Source Code Cross Referenced for TimeScaleAPITest.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » test » timescale » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.dev.test.timescale 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 1996-2005, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         *
007:         */
008:
009:        package com.ibm.icu.dev.test.timescale;
010:
011:        import com.ibm.icu.math.BigDecimal;
012:        import com.ibm.icu.util.UniversalTimeScale;
013:        import com.ibm.icu.dev.test.TestFmwk;
014:
015:        /**
016:         * @author Owner
017:         *
018:         * TODO To change the template for this generated type comment go to
019:         * Window - Preferences - Java - Code Style - Code Templates
020:         */
021:        public class TimeScaleAPITest extends TestFmwk {
022:
023:            /**
024:             * 
025:             */
026:            public TimeScaleAPITest() {
027:            }
028:
029:            public void TestBigDecimalFromBigDecimal() {
030:                BigDecimal bigZero = new BigDecimal(0);
031:                BigDecimal result;
032:
033:                try {
034:                    result = UniversalTimeScale.bigDecimalFrom(bigZero, -1);
035:                    errln("bigDecimalFrom(bigZero, -1) did not throw IllegalArgumentException.");
036:                } catch (IllegalArgumentException iae) {
037:                    logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
038:                }
039:
040:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
041:                    try {
042:                        result = UniversalTimeScale.bigDecimalFrom(bigZero,
043:                                scale);
044:                    } catch (IllegalArgumentException iae) {
045:                        errln("bigDecimalFrom(bigZero, " + scale
046:                                + ") threw IllegalArgumentException.");
047:                    }
048:                }
049:
050:                try {
051:                    result = UniversalTimeScale.bigDecimalFrom(bigZero,
052:                            UniversalTimeScale.MAX_SCALE);
053:                    errln("from(bigZero, MAX_SCALE) did not throw IllegalArgumetException.");
054:                } catch (IllegalArgumentException iae) {
055:                    logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
056:                }
057:            }
058:
059:            public void TestBigDecimalFromDouble() {
060:                BigDecimal result;
061:
062:                try {
063:                    result = UniversalTimeScale.bigDecimalFrom(0.0, -1);
064:                    errln("bigDecimalFrom(0.0, -1) did not throw IllegalArgumentException.");
065:                } catch (IllegalArgumentException iae) {
066:                    logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
067:                }
068:
069:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
070:                    try {
071:                        result = UniversalTimeScale.bigDecimalFrom(0.0, scale);
072:                    } catch (IllegalArgumentException iae) {
073:                        errln("bigDecimalFrom(0.0, " + scale
074:                                + ") threw IllegalArgumentException.");
075:                    }
076:                }
077:
078:                try {
079:                    result = UniversalTimeScale.bigDecimalFrom(0.0,
080:                            UniversalTimeScale.MAX_SCALE);
081:                    errln("from(0.0, MAX_SCALE) did not throw IllegalArgumetException.");
082:                } catch (IllegalArgumentException iae) {
083:                    logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
084:                }
085:            }
086:
087:            public void TestBigDecimalFromLong() {
088:                BigDecimal result;
089:
090:                try {
091:                    result = UniversalTimeScale.bigDecimalFrom(0L, -1);
092:                    errln("bigDecimalFrom(0L, -1) did not throw IllegalArgumentException.");
093:                } catch (IllegalArgumentException iae) {
094:                    logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
095:                }
096:
097:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
098:                    try {
099:                        result = UniversalTimeScale.bigDecimalFrom(0L, scale);
100:                    } catch (IllegalArgumentException iae) {
101:                        errln("bigDecimalFrom(0L, " + scale
102:                                + ") threw IllegalArgumentException.");
103:                    }
104:                }
105:
106:                try {
107:                    result = UniversalTimeScale.bigDecimalFrom(0L,
108:                            UniversalTimeScale.MAX_SCALE);
109:                    errln("from(0L, MAX_SCALE) did not throw IllegalArgumetException.");
110:                } catch (IllegalArgumentException iae) {
111:                    logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
112:                }
113:            }
114:
115:            public void TestFromLong() {
116:                long result;
117:
118:                try {
119:                    result = UniversalTimeScale.from(0L, -1);
120:                    errln("from(0L, -1) did not throw IllegalArgumentException.");
121:                } catch (IllegalArgumentException iae) {
122:                    logln("PASS: UniversalTimeScale.from failed as expected");
123:                }
124:
125:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
126:                    long fromMin = UniversalTimeScale.getTimeScaleValue(scale,
127:                            UniversalTimeScale.FROM_MIN_VALUE);
128:                    long fromMax = UniversalTimeScale.getTimeScaleValue(scale,
129:                            UniversalTimeScale.FROM_MAX_VALUE);
130:
131:                    try {
132:                        result = UniversalTimeScale.from(0L, scale);
133:                    } catch (IllegalArgumentException iae) {
134:                        errln("from(0L, " + scale
135:                                + ") threw IllegalArgumentException.");
136:                    }
137:
138:                    try {
139:                        result = UniversalTimeScale.from(fromMin, scale);
140:                    } catch (IllegalArgumentException iae) {
141:                        errln("from(fromMin, " + scale
142:                                + ") threw IllegalArgumentException.");
143:                    }
144:
145:                    if (fromMin > Long.MIN_VALUE) {
146:                        try {
147:                            result = UniversalTimeScale
148:                                    .from(fromMin - 1, scale);
149:                            errln("from(fromMin - 1, "
150:                                    + scale
151:                                    + ") did not throw IllegalArgumentException.");
152:                        } catch (IllegalArgumentException iae) {
153:                            logln("PASS: UniversalTimeScale.from failed as expected");
154:                        }
155:                    }
156:
157:                    try {
158:                        result = UniversalTimeScale.from(fromMax, scale);
159:                    } catch (IllegalArgumentException iae) {
160:                        errln("from(fromMax, " + scale
161:                                + ") threw IllegalArgumentException.");
162:                    }
163:
164:                    if (fromMax < Long.MAX_VALUE) {
165:                        try {
166:                            result = UniversalTimeScale
167:                                    .from(fromMax + 1, scale);
168:                            errln("from(fromMax + 1, "
169:                                    + scale
170:                                    + ") did not throw IllegalArgumentException.");
171:                        } catch (IllegalArgumentException iae) {
172:                            logln("PASS: UniversalTimeScale.from failed as expected");
173:                        }
174:                    }
175:                }
176:
177:                try {
178:                    result = UniversalTimeScale.from(0L,
179:                            UniversalTimeScale.MAX_SCALE);
180:                    errln("from(0L, MAX_SCALE) did not throw IllegalArgumetException.");
181:                } catch (IllegalArgumentException iae) {
182:                    logln("PASS: UniversalTimeScale.from failed as expected");
183:                }
184:            }
185:
186:            public void TestGetTimeScale() {
187:                long value;
188:
189:                try {
190:                    value = UniversalTimeScale.getTimeScaleValue(-1, 0);
191:                    errln("getTimeScaleValue(-1, 0) did not throw IllegalArgumentException.");
192:                } catch (IllegalArgumentException iae) {
193:                    logln("PASS: UniversalTimeScale.getTimeScaleValue failed as expected");
194:                }
195:
196:                try {
197:                    value = UniversalTimeScale.getTimeScaleValue(0, -1);
198:                    errln("getTimeScaleValue(0, -1) did not throw IllegalArgumentException.");
199:                } catch (IllegalArgumentException iae) {
200:                    logln("PASS: UniversalTimeScale.getTimeScaleValue failed as expected");
201:                }
202:
203:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
204:                    try {
205:                        value = UniversalTimeScale.getTimeScaleValue(scale, 0);
206:                    } catch (IllegalArgumentException iae) {
207:                        errln("getTimeScaleValue(" + scale
208:                                + ", 0) threw IllegalArgumentException.");
209:                    }
210:                }
211:
212:                try {
213:                    value = UniversalTimeScale.getTimeScaleValue(
214:                            UniversalTimeScale.MAX_SCALE, 0);
215:                    errln("getTimeScaleValue(MAX_SCALE, 0) did not throw IllegalArgumentException");
216:                } catch (IllegalArgumentException iae) {
217:                    logln("PASS: UniversalTimeScale.getTimeScaleValue failed as expected");
218:                }
219:
220:                try {
221:                    value = UniversalTimeScale.getTimeScaleValue(0,
222:                            UniversalTimeScale.MAX_SCALE_VALUE);
223:                    errln("getTimeScaleValue(0, MAX_SCALE_VALUE) did not throw IllegalArgumentException");
224:                } catch (IllegalArgumentException iae) {
225:                    logln("PASS: UniversalTimeScale.getTimeScaleValue failed as expected");
226:                }
227:            }
228:
229:            public void TestToBigDecimalFromBigDecimal() {
230:                BigDecimal bigZero = new BigDecimal(0);
231:                BigDecimal result;
232:
233:                try {
234:                    result = UniversalTimeScale.toBigDecimal(bigZero, -1);
235:                    errln("toBigDecimal(bigZero, -1) did not throw IllegalArgumentException.");
236:                } catch (IllegalArgumentException iae) {
237:                    logln("PASS: UniversalTimeScale.toBigDecimal failed as expected");
238:                }
239:
240:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
241:                    try {
242:                        result = UniversalTimeScale
243:                                .toBigDecimal(bigZero, scale);
244:                    } catch (IllegalArgumentException iae) {
245:                        errln("toBigDecimal(bigZero, " + scale
246:                                + ") threw IllegalArgumentException.");
247:                    }
248:                }
249:
250:                try {
251:                    result = UniversalTimeScale.toBigDecimal(bigZero,
252:                            UniversalTimeScale.MAX_SCALE);
253:                    errln("toBigDecimal(bigZero, MAX_SCALE) did not throw IllegalArgumetException.");
254:                } catch (IllegalArgumentException iae) {
255:                    logln("PASS: UniversalTimeScale.toBigDecimal failed as expected");
256:                }
257:            }
258:
259:            public void TestToBigDecimalTrunc() {
260:                BigDecimal bigZero = new BigDecimal(0);
261:                BigDecimal result;
262:
263:                try {
264:                    result = UniversalTimeScale.toBigDecimalTrunc(bigZero, -1);
265:                    errln("toBigDecimalTrunc(bigZero, -1) did not throw IllegalArgumentException.");
266:                } catch (IllegalArgumentException iae) {
267:                    logln("PASS: UniversalTimeScale.toBigDecimalTrunc failed as expected");
268:                }
269:
270:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
271:                    try {
272:                        result = UniversalTimeScale.toBigDecimalTrunc(bigZero,
273:                                scale);
274:                    } catch (IllegalArgumentException iae) {
275:                        errln("toBigDecimalTrunc(bigZero, " + scale
276:                                + ") threw IllegalArgumentException.");
277:                    }
278:                }
279:
280:                try {
281:                    result = UniversalTimeScale.toBigDecimalTrunc(bigZero,
282:                            UniversalTimeScale.MAX_SCALE);
283:                    errln("toBigDecimalTrunc(bigZero, MAX_SCALE) did not throw IllegalArgumetException.");
284:                } catch (IllegalArgumentException iae) {
285:                    logln("PASS: UniversalTimeScale.toBigDecimalTrunc failed as expected");
286:                }
287:            }
288:
289:            public void TestToBigDecimalFromLong() {
290:                BigDecimal result;
291:
292:                try {
293:                    result = UniversalTimeScale.toBigDecimal(0L, -1);
294:                    errln("toBigDecimal(0L, -1) did not throw IllegalArgumentException.");
295:                } catch (IllegalArgumentException iae) {
296:                    logln("PASS: UniversalTimeScale.toBigDecimal failed as expected");
297:                }
298:
299:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
300:                    try {
301:                        result = UniversalTimeScale.toBigDecimal(0L, scale);
302:                    } catch (IllegalArgumentException iae) {
303:                        errln("toBigDecimal(0L, " + scale
304:                                + ") threw IllegalArgumentException.");
305:                    }
306:                }
307:
308:                try {
309:                    result = UniversalTimeScale.toBigDecimal(0L,
310:                            UniversalTimeScale.MAX_SCALE);
311:                    errln("toBigDecimal(0L, MAX_SCALE) did not throw IllegalArgumetException.");
312:                } catch (IllegalArgumentException iae) {
313:                    logln("PASS: UniversalTimeScale.toBigDecimal failed as expected");
314:                }
315:            }
316:
317:            public void TestToLong() {
318:                long result;
319:
320:                try {
321:                    result = UniversalTimeScale.toLong(0L, -1);
322:                    errln("toLong(0L, -1) did not throw IllegalArgumentException.");
323:                } catch (IllegalArgumentException iae) {
324:                    logln("PASS: UniversalTimeScale.toLong failed as expected");
325:                }
326:
327:                for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
328:                    long toMin = UniversalTimeScale.getTimeScaleValue(scale,
329:                            UniversalTimeScale.TO_MIN_VALUE);
330:                    long toMax = UniversalTimeScale.getTimeScaleValue(scale,
331:                            UniversalTimeScale.TO_MAX_VALUE);
332:
333:                    try {
334:                        result = UniversalTimeScale.toLong(0L, scale);
335:                    } catch (IllegalArgumentException iae) {
336:                        errln("toLong(0L, " + scale
337:                                + ") threw IllegalArgumentException.");
338:                    }
339:
340:                    try {
341:                        result = UniversalTimeScale.toLong(toMin, scale);
342:                    } catch (IllegalArgumentException iae) {
343:                        errln("toLong(toMin, " + scale
344:                                + ") threw IllegalArgumentException.");
345:                    }
346:
347:                    if (toMin > Long.MIN_VALUE) {
348:                        try {
349:                            result = UniversalTimeScale
350:                                    .toLong(toMin - 1, scale);
351:                            errln("toLong(toMin - 1, "
352:                                    + scale
353:                                    + ") did not throw IllegalArgumentException.");
354:                        } catch (IllegalArgumentException iae) {
355:                            logln("PASS: UniversalTimeScale.toLong failed as expected");
356:                        }
357:                    }
358:
359:                    try {
360:                        result = UniversalTimeScale.toLong(toMax, scale);
361:                    } catch (IllegalArgumentException iae) {
362:                        errln("toLong(toMax, " + scale
363:                                + ") threw IllegalArgumentException.");
364:                    }
365:
366:                    if (toMax < Long.MAX_VALUE) {
367:                        try {
368:                            result = UniversalTimeScale
369:                                    .toLong(toMax + 1, scale);
370:                            errln("toLong(toMax + 1, "
371:                                    + scale
372:                                    + ") did not throw IllegalArgumentException.");
373:                        } catch (IllegalArgumentException iae) {
374:                            logln("PASS: UniversalTimeScale.toLong failed as expected");
375:                        }
376:                    }
377:                }
378:
379:                try {
380:                    result = UniversalTimeScale.toLong(0L,
381:                            UniversalTimeScale.MAX_SCALE);
382:                    errln("toLong(0L, MAX_SCALE) did not throw IllegalArgumetException.");
383:                } catch (IllegalArgumentException iae) {
384:                    logln("PASS: UniversalTimeScale.toLong failed as expected");
385:                }
386:            }
387:
388:            public static void main(String[] args) {
389:                new TimeScaleAPITest().run(args);
390:            }
391:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.