]> granicus.if.org Git - icu/commitdiff
ICU-9508 Make test name that tests withTender() more descriptive. Add test for using...
authorTravis Keep <keep94@gmail.com>
Wed, 9 Jan 2013 20:45:39 +0000 (20:45 +0000)
committerTravis Keep <keep94@gmail.com>
Wed, 9 Jan 2013 20:45:39 +0000 (20:45 +0000)
X-SVN-Rev: 33029

icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java

index f33c9a436eef3c4b8c1c4109016f17e4b8ac7e5c..1623b152317b56f1852b6f9cbb43f3e51c15923a 100644 (file)
@@ -378,7 +378,39 @@ public class CurrencyTest extends TestFmwk {
         assertEquals("millisecond is 0", 0, cal.get(GregorianCalendar.MILLISECOND));
     }
     
-    public void TestTicket9508() {
+    public void testCurrencyMetaInfoRangesWithLongs() {
+        CurrencyMetaInfo metainfo = CurrencyMetaInfo.getInstance(true);
+        assertNotNull("have metainfo", metainfo);
+    
+        CurrencyFilter filter = CurrencyFilter.onRegion("DE"); // must be capitalized
+        List<CurrencyInfo> currenciesInGermany = metainfo.currencyInfo(filter);
+        logln("currencies: " + currenciesInGermany.size());
+        long demLastDate = Long.MAX_VALUE;
+        long eurFirstDate = Long.MIN_VALUE;
+        for (CurrencyInfo info : currenciesInGermany) {
+            logln(info.toString());
+            if (info.code.equals("DEM")) {
+                demLastDate = info.to;
+            } else if (info.code.equals("EUR")) {
+                eurFirstDate = info.from;
+            }
+        }
+        // the Euro and Deutschmark overlapped for several years
+        assertEquals("DEM available at last date", 2, metainfo.currencyInfo(filter.withDate(demLastDate)).size());
+        
+        // demLastDate + 1 millisecond is not the start of the last day, we consider it the next day, so...
+        long demLastDatePlus1ms = demLastDate + 1;
+        assertEquals("DEM not available after very start of last date", 1, metainfo.currencyInfo(filter.withDate(demLastDatePlus1ms)).size());
+        
+        // both available for start of euro
+        assertEquals("EUR available on start of first date", 2, metainfo.currencyInfo(filter.withDate(eurFirstDate)).size());
+        
+        // but not one millisecond before the start of the first day
+        long eurFirstDateMinus1ms = eurFirstDate - 1;
+        assertEquals("EUR not avilable before very start of first date", 1, metainfo.currencyInfo(filter.withDate(eurFirstDateMinus1ms)).size());
+    }
+    
+    public void TestWithTender() {
         CurrencyMetaInfo metainfo = CurrencyMetaInfo.getInstance();
         if (metainfo == null) {
             errln("Unable to get CurrencyMetaInfo instance.");