1994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes/*
2994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * Licensed to the Apache Software Foundation (ASF) under one or more
3994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * contributor license agreements.  See the NOTICE file distributed with
4994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * this work for additional information regarding copyright ownership.
5994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * The ASF licenses this file to You under the Apache License, Version 2.0
6994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * (the "License"); you may not use this file except in compliance with
7994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * the License.  You may obtain a copy of the License at
8994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes *
9994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes *     http://www.apache.org/licenses/LICENSE-2.0
10994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes *
11994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * Unless required by applicable law or agreed to in writing, software
12994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS,
13994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * See the License for the specific language governing permissions and
15994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes * limitations under the License.
16994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes */
17994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughespackage org.apache.harmony.tests.java.text;
18994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes
19994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughesimport java.text.DateFormat;
20994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughesimport java.text.ParseException;
21994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes
22994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes@SuppressWarnings("nls")
23994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughespublic class ParseExceptionTest extends junit.framework.TestCase {
24994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes
25994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes    /**
26994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes     * @tests java.text.ParseException#ParseException(java.lang.String, int)
27994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes     */
28994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes    public void test_ConstructorLjava_lang_StringI() {
29994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes        try {
30994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes            DateFormat df = DateFormat.getInstance();
31994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes            df.parse("HelloWorld");
32994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes            fail("ParseException not created/thrown.");
33994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes        } catch (ParseException e) {
34994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes            // expected
35994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes        }
36994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes    }
37994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes
38994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes    /**
39994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes     * @tests java.text.ParseException#getErrorOffset()
40994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes     */
41994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes    public void test_getErrorOffset() {
42994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes        try {
43994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes            DateFormat df = DateFormat.getInstance();
44994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes            df.parse("1999HelloWorld");
45994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes        } catch (ParseException e) {
46994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes            assertEquals("getErrorOffsetFailed.", 4, e.getErrorOffset());
47994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes        }
48994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes    }
49994e4e5ded616a100ca42b16cffa36aa9f595f64Elliott Hughes}
50