Home | History | Annotate | Download | only in lang
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     14  * License for the specific language governing permissions and limitations under
     15  * the License.
     16  */
     17 
     18 package org.apache.harmony.tests.java.lang;
     19 
     20 import junit.framework.TestCase;
     21 
     22 public class AssertionErrorTest extends TestCase {
     23 
     24     public void test_Constructor() {
     25         AssertionError e = new AssertionError();
     26         assertNull(e.getMessage());
     27         assertNull(e.getCause());
     28     }
     29 
     30     public void test_ConstructorObject() {
     31         Object obj = "toString";
     32         AssertionError e = new AssertionError(obj);
     33         assertEquals("toString", e.getMessage());
     34         assertNull(e.getCause());
     35 
     36         NullPointerException npe = new NullPointerException("null value");
     37         e = new AssertionError(npe);
     38         assertEquals(npe.toString(), e.getMessage());
     39         assertSame(npe, e.getCause());
     40     }
     41 
     42     public void test_ConstructorBoolean() {
     43         AssertionError e = new AssertionError(true);
     44         assertEquals("true", e.getMessage());
     45         assertNull(e.getCause());
     46     }
     47 
     48     public void test_ConstructorChar() {
     49         AssertionError e = new AssertionError('a');
     50         assertEquals("a", e.getMessage());
     51         assertNull(e.getCause());
     52     }
     53 
     54     public void test_ConstructorInt() {
     55         AssertionError e = new AssertionError(1);
     56         assertEquals("1", e.getMessage());
     57         assertNull(e.getCause());
     58     }
     59 
     60     public void test_ConstructorLong() {
     61         AssertionError e = new AssertionError(1L);
     62         assertEquals("1", e.getMessage());
     63         assertNull(e.getCause());
     64     }
     65 
     66     public void test_ConstructorFloat() {
     67         AssertionError e = new AssertionError(1.0F);
     68         assertEquals("1.0", e.getMessage());
     69         assertNull(e.getCause());
     70     }
     71 
     72     public void test_ConstructorDouble() {
     73         AssertionError e = new AssertionError(1.0D);
     74         assertEquals("1.0", e.getMessage());
     75         assertNull(e.getCause());
     76     }
     77 
     78 }
     79