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, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.harmony.luni.tests.java.lang; 19 20 import dalvik.annotation.TestTargets; 21 import dalvik.annotation.TestLevel; 22 import dalvik.annotation.TestTargetNew; 23 import dalvik.annotation.TestTargetClass; 24 25 import junit.framework.TestCase; 26 27 @TestTargetClass(Character.Subset.class) 28 public class Character_SubsetTest extends TestCase { 29 30 /** 31 * @tests java.lang.Character.Subset#Character.Subset(java.lang.String) 32 */ 33 @TestTargetNew( 34 level = TestLevel.COMPLETE, 35 notes = "", 36 method = "Subset", 37 args = {java.lang.String.class} 38 ) 39 public void test_Ctor() { 40 41 try { 42 // Regression for HARMONY-888 43 new Character.Subset(null) { 44 }; 45 fail("No expected NullPointerException"); 46 } catch (NullPointerException e) { 47 } 48 } 49 50 /** 51 * @tests java.lang.Character.Subset#toString() 52 */ 53 @TestTargetNew( 54 level = TestLevel.COMPLETE, 55 notes = "", 56 method = "toString", 57 args = {} 58 ) 59 public void test_toString() { 60 61 String name = "name"; 62 Character.Subset subset = new Character.Subset(name) { 63 }; 64 assertSame(name, subset.toString()); 65 } 66 67 68 @TestTargetNew( 69 level = TestLevel.COMPLETE, 70 notes = "", 71 method = "equals", 72 args = {java.lang.Object.class} 73 ) 74 public void test_equals() { 75 Character.Subset subset1 = new Character.Subset("name") { }; 76 assertTrue(subset1.equals(subset1)); 77 assertFalse(subset1.equals(new Character.Subset("name") {})); 78 assertFalse(subset1.equals(new Character.Subset("name1") {})); 79 assertFalse(subset1.equals(new Integer(0))); 80 } 81 82 @TestTargetNew( 83 level = TestLevel.COMPLETE, 84 notes = "", 85 method = "hashCode", 86 args = {} 87 ) 88 public void test_hashCode() { 89 Character.Subset subset1 = new Character.Subset("name") {}; 90 Character.Subset subset2 = new Character.Subset("name") {}; 91 Character.Subset subset3 = new Character.Subset("name1") {}; 92 assertFalse(subset1.hashCode() == subset2.hashCode()); 93 assertFalse(subset1.hashCode() == subset3.hashCode()); 94 } 95 } 96