From: Abhinav Gupta <mail@abhinavg.net>
Date: Wed, 12 Oct 2011 15:31:07 +0000 (+0000)
Subject: ICU-8876 added test for SelectFormat.format exception.
X-Git-Tag: milestone-59-0-1~4421
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab30e3c40029cd028951b5d0e289a4eff47109e3;p=icu

ICU-8876 added test for SelectFormat.format exception.

X-SVN-Rev: 30810
---

diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatAPITest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatAPITest.java
index f3a9565a52a..47ad7fe4e29 100644
--- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatAPITest.java
+++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatAPITest.java
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (c) 2004-2010, International Business Machines
+ * Copyright (c) 2004-2011, International Business Machines
  * Corporation and others.  All Rights Reserved.
  * Copyright (C) 2010 , Yahoo! Inc.                                            
  *******************************************************************************
@@ -136,6 +136,16 @@ public class SelectFormatAPITest extends TestFmwk {
         assertEquals("Failed in TestFormat with unexpected output 2"
                      , expected
                      , (selFmt1.format("other", strBuf, new FieldPosition(0))).toString());
+       
+        //Check format throws exception on invalid argument.
+        boolean threwException = false;
+        try {
+            StringBuffer buf = new StringBuffer("AppendHere-");
+            selFmt1.format(Integer.valueOf(0), buf, new FieldPosition(0));
+        } catch (IllegalArgumentException e) {
+            threwException = true;
+        }
+        assertTrue("Did not throw IllegalArgumentException.", threwException);
     }
 
     /**