FormatterTest.java revision 89c1feb0a69a7707b271086e749975b3f7acacf7
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements.  See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License.  You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.apache.harmony.luni.tests.java.util;
18
19import dalvik.annotation.TestInfo;
20import dalvik.annotation.TestLevel;
21import dalvik.annotation.TestTarget;
22import dalvik.annotation.TestTargetClass;
23
24import junit.framework.TestCase;
25
26import java.util.Formatter.BigDecimalLayoutForm;
27
28@TestTargetClass(java.util.    Formatter.BigDecimalLayoutForm.class)
29public class FormatterTest extends TestCase {
30
31    /**
32     * @tests java.util.Formatter.BigDecimalLayoutForm#values()
33     */
34    @TestInfo(
35      level = TestLevel.COMPLETE,
36      purpose = "",
37      targets = {
38        @TestTarget(
39          methodName = "values",
40          methodArgs = {}
41        )
42    })
43    public void test_values() {
44        BigDecimalLayoutForm[] vals = BigDecimalLayoutForm.values();
45        assertEquals("Invalid length of enum values", 2, vals.length);
46        assertEquals("Wrong scientific value in enum",
47                                      BigDecimalLayoutForm.SCIENTIFIC, vals[0]);
48        assertEquals("Wrong dec float value in enum",
49                                   BigDecimalLayoutForm.DECIMAL_FLOAT, vals[1]);
50    }
51
52    /**
53     * @tests java.util.Formatter.BigDecimalLayoutForm#valueOf(String)
54     */
55    @TestInfo(
56      level = TestLevel.PARTIAL,
57      purpose = "Doesn't verify IllegalArgumentException.",
58      targets = {
59        @TestTarget(
60          methodName = "valueOf",
61          methodArgs = {java.lang.String.class}
62        )
63    })
64    public void test_valueOfLjava_lang_String() {
65        BigDecimalLayoutForm sci = BigDecimalLayoutForm.valueOf("SCIENTIFIC");
66        assertEquals("Wrong scientific value in enum", BigDecimalLayoutForm.SCIENTIFIC, sci);
67
68        BigDecimalLayoutForm decFloat = BigDecimalLayoutForm.valueOf("DECIMAL_FLOAT");
69        assertEquals("Wrong dec float value from valueOf ", BigDecimalLayoutForm.DECIMAL_FLOAT, decFloat);
70    }
71}
72