am 0df432dd: Merge "Deduplicate java.lang tests from Harmony."
* commit '0df432dd5a1fedca44fba67c363b982b69b54899':
Deduplicate java.lang tests from Harmony.
diff --git a/expectations/brokentests.txt b/expectations/brokentests.txt
index 70c82cd..213b519 100644
--- a/expectations/brokentests.txt
+++ b/expectations/brokentests.txt
@@ -844,9 +844,9 @@
description: "These tests expect to be able to load resources from the file system",
result: EXEC_FAILED,
names: [
- "org.apache.harmony.luni.tests.java.lang.ClassTest#test_getResourceAsStreamLjava_lang_String",
- "org.apache.harmony.luni.tests.java.lang.ClassTest#test_getResourceAsStream_withSharpChar",
- "org.apache.harmony.luni.tests.java.lang.ClassTest#test_getResourceLjava_lang_String"
+ "libcore.java.lang.OldClassTest#test_getResourceAsStreamLjava_lang_String",
+ "libcore.java.lang.OldClassTest#test_getResourceAsStream_withSharpChar",
+ "libcore.java.lang.OldClassTest#test_getResourceLjava_lang_String"
]
},
{
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index d7a1a19..72df746 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -152,7 +152,7 @@
},
{
description: "Double.parseDouble().toString does wrong rounding",
- name: "org.apache.harmony.luni.tests.java.lang.DoubleTest#test_parseDoubleLjava_lang_String",
+ name: "libcore.java.lang.OldDoubleTest#test_parseDoubleLjava_lang_String",
bug: 1607938
},
{
@@ -226,18 +226,18 @@
{
description: "Defining classes from byte[] not supported in Android",
result: EXEC_FAILED,
- name: "org.apache.harmony.luni.tests.java.lang.ClassTest#test_getClasses_subtest0"
+ name: "libcore.java.lang.OldClassTest#test_getClasses_subtest0"
},
{
description: "There is no protection domain set in Android.",
result: EXEC_FAILED,
- name: "org.apache.harmony.luni.tests.java.lang.ClassTest#test_getProtectionDomain"
+ name: "libcore.java.lang.OldClassTest#test_getProtectionDomain"
},
{
description: "Fails in CTS but passes under run-core-tests",
result: EXEC_FAILED,
names: [
- "org.apache.harmony.luni.tests.java.lang.RuntimeTest#test_traceMethodCalls",
+ "libcore.java.lang.OldRuntimeTest#test_traceMethodCalls",
"tests.api.java.net.MulticastSocketTest#test_joinGroupLjava_net_SocketAddressLjava_net_NetworkInterface",
"tests.api.java.util.FormatterTest#test_formatLjava_lang_String$Ljava_lang_Object_DateTimeConversion"
]
diff --git a/luni/src/test/java/libcore/java/lang/OldCharacterSubsetTest.java b/luni/src/test/java/libcore/java/lang/OldCharacterSubsetTest.java
new file mode 100644
index 0000000..215747b
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldCharacterSubsetTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import junit.framework.TestCase;
+
+public class OldCharacterSubsetTest extends TestCase {
+
+ public void test_equals() {
+ Character.Subset subset1 = new Character.Subset("name") { };
+ assertTrue(subset1.equals(subset1));
+ assertFalse(subset1.equals(new Character.Subset("name") {}));
+ assertFalse(subset1.equals(new Character.Subset("name1") {}));
+ assertFalse(subset1.equals(new Integer(0)));
+ }
+
+ public void test_hashCode() {
+ Character.Subset subset1 = new Character.Subset("name") {};
+ Character.Subset subset2 = new Character.Subset("name") {};
+ Character.Subset subset3 = new Character.Subset("name1") {};
+ assertFalse(subset1.hashCode() == subset2.hashCode());
+ assertFalse(subset1.hashCode() == subset3.hashCode());
+ }
+}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OldCharacterTest.java b/luni/src/test/java/libcore/java/lang/OldCharacterTest.java
similarity index 98%
rename from luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OldCharacterTest.java
rename to luni/src/test/java/libcore/java/lang/OldCharacterTest.java
index 73e0405..8e6f9ab 100644
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OldCharacterTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldCharacterTest.java
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-package org.apache.harmony.luni.tests.java.lang;
+package libcore.java.lang;
import junit.framework.TestCase;
public class OldCharacterTest extends TestCase {
-
public void test_codePointCountLjava_lang_CharArrayII() {
assertEquals(1, Character.codePointCount("\uD800\uDC00".toCharArray(),
diff --git a/luni/src/test/java/libcore/java/lang/OldClassTest.java b/luni/src/test/java/libcore/java/lang/OldClassTest.java
new file mode 100644
index 0000000..c516467
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldClassTest.java
@@ -0,0 +1,1024 @@
+/*
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.AbstractList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Vector;
+import tests.support.Support_ClassLoader;
+import tests.support.resource.Support_Resources;
+
+@SuppressWarnings("deprecation")
+public class OldClassTest extends junit.framework.TestCase {
+
+ public static final String FILENAME =
+ OldClassTest.class.getPackage().getName().replace('.', '/') +
+ "/test#.properties";
+
+ final String packageName = getClass().getPackage().getName();
+ final String classNameInitError1 = packageName + ".TestClass1";
+ final String classNameInitError2 = packageName + ".TestClass1B";
+ final String classNameLinkageError = packageName + ".TestClass";
+ final String sourceJARfile = "illegalClasses.jar";
+ final String illegalClassName = "illegalClass";
+
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface TestAnnotation {
+ String value();
+ }
+
+ public static class TestClass1C {
+ static TestClass2 tc = new TestClass2(0);
+
+ TestClass1C() {
+ }
+
+ }
+
+ public static class TestClass2 {
+
+ public TestClass2(int i) throws IllegalArgumentException {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public static class TestClass3 {
+ private TestClass3() {}
+ }
+
+ interface TestInterface {
+ public static int TEST_INTERFACE_FIELD = 0;
+
+ int getCount();
+ void setCount(int value);
+ }
+
+ static class StaticMember$Class {
+ class Member2$A {
+ }
+ }
+
+ class Member$Class {
+ class Member3$B {
+ }
+ }
+
+ @Deprecated
+ @TestAnnotation("libcore.java.lang.OldClassTest$ExtendTestClass")
+ public static class ExtendTestClass extends PublicTestClass {
+
+ private static final long serialVersionUID = 1L;
+
+ public enum enumExm {ONE, TWO, THREE};
+ @Override
+ public void setCount(int value) {
+
+ }
+ }
+
+ public class ExtendTestClass1 extends ExtendTestClass {
+
+ }
+
+ @TestAnnotation("libcore.java.lang.OldClassTest$PublicTestClass")
+ public static class PublicTestClass implements TestInterface, Serializable, Cloneable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static String TEST_FIELD = "test field";
+
+ Object clazz;
+
+ public PublicTestClass() {
+ class LocalClass { }
+
+ clazz = new LocalClass();
+ }
+
+ public Object getLocalClass() {
+ class LocalClass {}
+ Object returnedObject = new LocalClass();
+ return returnedObject;
+ }
+
+ int count = 0;
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int value) {
+ count = value;
+ }
+
+ private class PrivateClass1 {
+
+ public String toString() {
+ return "PrivateClass0";
+ }
+ }
+
+ public class PrivateClass2 {
+
+ public String toString() {
+ return "PrivateClass1";
+ }
+ }
+ }
+
+ public static class TestClass {
+ @SuppressWarnings("unused")
+ private int privField = 1;
+
+ public int pubField = 2;
+
+ private Object cValue = null;
+
+ public Object ack = new Object();
+
+ @SuppressWarnings("unused")
+ private int privMethod() {
+ return 1;
+ }
+
+ public int pubMethod() {
+ return 2;
+ }
+
+ public Object cValue() {
+ return cValue;
+ }
+
+ public TestClass() {
+ }
+
+ @SuppressWarnings("unused")
+ private TestClass(Object o) {
+ }
+ }
+
+ public static class SubTestClass extends TestClass {
+ }
+
+ interface Intf1 {
+ public int field1 = 1;
+ public int field2 = 1;
+ void test();
+ }
+
+ interface Intf2 {
+ public int field1 = 1;
+ void test();
+ }
+
+ interface Intf3 extends Intf1 {
+ public int field1 = 1;
+ }
+
+ interface Intf4 extends Intf1, Intf2 {
+ public int field1 = 1;
+ void test2(int a, Object b);
+ }
+
+ interface Intf5 extends Intf1 {
+ }
+
+ class Cls1 implements Intf2 {
+ public int field1 = 2;
+ public int field2 = 2;
+ public void test() {
+ }
+ }
+
+ class Cls2 extends Cls1 implements Intf1 {
+ public int field1 = 2;
+ @Override
+ public void test() {
+ }
+ }
+
+ class Cls3 implements Intf3, Intf4 {
+ public void test() {
+ }
+ public void test2(int a, Object b) {
+ }
+ }
+
+ static class Cls4 {
+
+ }
+
+ public void test_getAnnotations() {
+ Annotation [] annotations = PublicTestClass.class.getAnnotations();
+ assertEquals(1, annotations.length);
+ assertEquals(TestAnnotation.class, annotations[0].annotationType());
+
+ annotations = ExtendTestClass.class.getAnnotations();
+ assertEquals(2, annotations.length);
+
+ for(int i = 0; i < annotations.length; i++) {
+ Class<? extends Annotation> type = annotations[i].annotationType();
+ assertTrue("Annotation's type " + i + ": " + type,
+ type.equals(Deprecated.class) ||
+ type.equals(TestAnnotation.class));
+ }
+ }
+
+ public void test_forNameLjava_lang_StringLbooleanLClassLoader() throws Exception {
+
+ ClassLoader pcl = getClass().getClassLoader();
+
+ Class<?> [] classes = {PublicTestClass.class, ExtendTestClass.class,
+ ExtendTestClass1.class, TestInterface.class, String.class};
+
+ for(int i = 0; i < classes.length; i++) {
+ Class<?> clazz = Class.forName(classes[i].getName(), true, pcl);
+ assertEquals(classes[i], clazz);
+
+ clazz = Class.forName(classes[i].getName(), false, pcl);
+ assertEquals(classes[i], clazz);
+ }
+
+ Class<?> [] systemClasses = {String.class, Integer.class, Object.class,
+ Object[].class};
+
+ for(int i = 0; i < systemClasses.length; i++) {
+ Class<?> clazz = Class.forName(systemClasses[i].getName(), true,
+ ClassLoader.getSystemClassLoader());
+ assertEquals(systemClasses[i], clazz);
+
+ clazz = Class.forName(systemClasses[i].getName(), false,
+ ClassLoader.getSystemClassLoader());
+ assertEquals(systemClasses[i], clazz);
+ }
+
+ try {
+ Class.forName(null, true, pcl);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+
+ try {
+ Class.forName("NotExistClass", true, pcl);
+ fail("ClassNotFoundException is not thrown for non existent class.");
+ } catch(ClassNotFoundException cnfe) {
+ //expected
+ }
+
+ try {
+ Class.forName("String", false, pcl);
+ fail("ClassNotFoundException is not thrown for non existent class.");
+ } catch(ClassNotFoundException cnfe) {
+ //expected
+ }
+
+ try {
+ Class.forName("libcore.java.lang.NonexistentClass", false, pcl);
+ fail("ClassNotFoundException is not thrown for non existent class.");
+ } catch(ClassNotFoundException cnfe) {
+ //expected
+ }
+ }
+
+ // AndroidOnly: Class.forName method throws ClassNotFoundException on Android.
+ public void test_forNameLjava_lang_StringLbooleanLClassLoader_AndroidOnly() throws Exception {
+
+ // Android doesn't support loading class files from a jar.
+ try {
+
+ URL url = getClass().getClassLoader().getResource(
+ packageName.replace(".", "/") + "/" + sourceJARfile);
+
+ ClassLoader loader = new URLClassLoader(new URL[] { url },
+ getClass().getClassLoader());
+ try {
+ Class.forName(classNameLinkageError, true, loader);
+ fail("LinkageError or ClassNotFoundException expected.");
+ } catch (java.lang.LinkageError le) {
+ // Expected for the RI.
+ } catch (java.lang.ClassNotFoundException ce) {
+ // Expected for Android.
+ }
+ } catch(Exception e) {
+ fail("Unexpected exception was thrown: " + e.toString());
+ }
+
+ try {
+ Class.forName(classNameInitError2,
+ true, getClass().getClassLoader());
+ fail("ExceptionInInitializerError or ClassNotFoundException " +
+ "should be thrown.");
+ } catch (java.lang.ExceptionInInitializerError ie) {
+ // Expected for the RI.
+ // Remove this comment to let the test pass on Android.
+ } catch (java.lang.ClassNotFoundException ce) {
+ // Expected for Android.
+ }
+ }
+
+ public void test_getAnnotation() {
+ TestAnnotation target = PublicTestClass.class.getAnnotation(TestAnnotation.class);
+ assertEquals(target.value(), PublicTestClass.class.getName());
+
+ assertNull(PublicTestClass.class.getAnnotation(Deprecated.class));
+
+ Deprecated target2 = ExtendTestClass.class.getAnnotation(Deprecated.class);
+ assertNotNull(target2);
+ }
+
+ public void test_getDeclaredAnnotations() {
+ Annotation [] annotations = PublicTestClass.class.getDeclaredAnnotations();
+ assertEquals(1, annotations.length);
+
+ annotations = ExtendTestClass.class.getDeclaredAnnotations();
+ assertEquals(2, annotations.length);
+
+ annotations = TestInterface.class.getDeclaredAnnotations();
+ assertEquals(0, annotations.length);
+
+ annotations = String.class.getDeclaredAnnotations();
+ assertEquals(0, annotations.length);
+ }
+
+ public void test_getEnclosingClass() {
+ Class clazz = OldClassTest.class.getEnclosingClass();
+ assertNull(clazz);
+
+ assertEquals(getClass(), Cls1.class.getEnclosingClass());
+ assertEquals(getClass(), Intf1.class.getEnclosingClass());
+ assertEquals(getClass(), Cls4.class.getEnclosingClass());
+ }
+
+ public void test_getEnclosingMethod() {
+ Method clazz = ExtendTestClass.class.getEnclosingMethod();
+ assertNull(clazz);
+
+ PublicTestClass ptc = new PublicTestClass();
+ try {
+ assertEquals("getEnclosingMethod returns incorrect method.",
+ PublicTestClass.class.getMethod("getLocalClass",
+ (Class []) null),
+ ptc.getLocalClass().getClass().getEnclosingMethod());
+ } catch(NoSuchMethodException nsme) {
+ fail("NoSuchMethodException was thrown.");
+ }
+ }
+
+ public void test_getEnclosingConstructor() {
+
+ PublicTestClass ptc = new PublicTestClass();
+
+ assertEquals("getEnclosingConstructor method returns incorrect class.",
+ PublicTestClass.class.getConstructors()[0],
+ ptc.clazz.getClass().getEnclosingConstructor());
+
+ assertNull("getEnclosingConstructor should return null for local " +
+ "class declared in method.",
+ ptc.getLocalClass().getClass().getEnclosingConstructor());
+
+ assertNull("getEnclosingConstructor should return null for local " +
+ "class declared in method.",
+ ExtendTestClass.class.getEnclosingConstructor());
+ }
+
+
+ public void test_getEnumConstants() {
+ Object [] clazz = ExtendTestClass.class.getEnumConstants();
+ assertNull(clazz);
+ Object [] constants = TestEnum.class.getEnumConstants();
+ assertEquals(TestEnum.values().length, constants.length);
+ for(int i = 0; i < constants.length; i++) {
+ assertEquals(TestEnum.values()[i], constants[i]);
+ }
+ assertEquals(0, TestEmptyEnum.class.getEnumConstants().length);
+ }
+ public enum TestEnum {
+ ONE, TWO, THREE
+ }
+ public enum TestEmptyEnum {
+ }
+
+ public void test_getGenericInterfaces() {
+ Type [] types = ExtendTestClass1.class.getGenericInterfaces();
+ assertEquals(0, types.length);
+
+ Class [] interfaces = {TestInterface.class, Serializable.class,
+ Cloneable.class};
+ types = PublicTestClass.class.getGenericInterfaces();
+ assertEquals(interfaces.length, types.length);
+ for(int i = 0; i < types.length; i++) {
+ assertEquals(interfaces[i], types[i]);
+ }
+
+ types = TestInterface.class.getGenericInterfaces();
+ assertEquals(0, types.length);
+
+ types = List.class.getGenericInterfaces();
+ assertEquals(1, types.length);
+ assertEquals(Collection.class, ((ParameterizedType)types[0]).getRawType());
+
+ assertEquals(0, int.class.getGenericInterfaces().length);
+ assertEquals(0, void.class.getGenericInterfaces().length);
+ }
+
+ public void test_getGenericSuperclass () {
+ assertEquals(PublicTestClass.class,
+ ExtendTestClass.class.getGenericSuperclass());
+ assertEquals(ExtendTestClass.class,
+ ExtendTestClass1.class.getGenericSuperclass());
+ assertEquals(Object.class, PublicTestClass.class.getGenericSuperclass());
+ assertEquals(Object.class, String.class.getGenericSuperclass());
+ assertEquals(null, TestInterface.class.getGenericSuperclass());
+
+ ParameterizedType type = (ParameterizedType) Vector.class.getGenericSuperclass();
+ assertEquals(AbstractList.class, type.getRawType());
+ }
+
+ // AndroidOnly: Uses dalvik.system.PathClassLoader.
+ // Different behavior between cts host and run-core-test")
+ public void test_getPackage() {
+
+ Package thisPackage = getClass().getPackage();
+ assertEquals("libcore.java.lang",
+ thisPackage.getName());
+
+ Package stringPackage = String.class.getPackage();
+ assertNotNull("java.lang", stringPackage.getName());
+
+ String hyts_package_name = "hyts_package_dex.jar";
+ File resources = Support_Resources.createTempFolder();
+ Support_Resources.copyFile(resources, "Package", hyts_package_name);
+
+ String resPath = resources.toString();
+ if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\')
+ resPath = resPath.substring(1);
+
+ try {
+
+ URL resourceURL = new URL("file:/" + resPath + "/Package/"
+ + hyts_package_name);
+
+ ClassLoader cl = Support_ClassLoader.getInstance(resourceURL,
+ getClass().getClassLoader());
+
+ Class clazz = cl.loadClass("C");
+ assertNull("getPackage for C.class should return null",
+ clazz.getPackage());
+
+ clazz = cl.loadClass("a.b.C");
+ Package cPackage = clazz.getPackage();
+ assertNotNull("getPackage for a.b.C.class should not return null",
+ cPackage);
+
+ /*
+ * URLClassLoader doesn't work on Android for jar files
+ *
+ * URL url = getClass().getClassLoader().getResource(
+ * packageName.replace(".", "/") + "/" + sourceJARfile);
+ *
+ * ClassLoader loader = new URLClassLoader(new URL[] { url }, null);
+ *
+ * try {
+ * Class<?> clazz = loader.loadClass(illegalClassName);
+ * Package pack = clazz.getPackage();
+ * assertNull(pack);
+ * } catch(ClassNotFoundException cne) {
+ * fail("ClassNotFoundException was thrown for " + illegalClassName);
+ * }
+ */
+ } catch(Exception e) {
+ fail("Unexpected exception was thrown: " + e.toString());
+ }
+ }
+
+ public void test_getSigners() {
+ assertNull(void.class.getSigners());
+ assertNull(PublicTestClass.class.getSigners());
+ }
+
+ public void test_getSimpleName() {
+ assertEquals("PublicTestClass", PublicTestClass.class.getSimpleName());
+ assertEquals("void", void.class.getSimpleName());
+ assertEquals("int[]", int[].class.getSimpleName());
+ }
+
+ public void test_getTypeParameters() {
+ assertEquals(0, PublicTestClass.class.getTypeParameters().length);
+ TypeVariable [] tv = TempTestClass1.class.getTypeParameters();
+ assertEquals(1, tv.length);
+ assertEquals(Object.class, tv[0].getBounds()[0]);
+
+ TempTestClass2<String> tc = new TempTestClass2<String>();
+ tv = tc.getClass().getTypeParameters();
+ assertEquals(1, tv.length);
+ assertEquals(String.class, tv[0].getBounds()[0]);
+ }
+
+ class TempTestClass1<T> {
+ }
+
+ class TempTestClass2<S extends String> extends TempTestClass1<S> {
+ }
+
+ public void test_isAnnotation() {
+ assertTrue(Deprecated.class.isAnnotation());
+ assertTrue(TestAnnotation.class.isAnnotation());
+ assertFalse(PublicTestClass.class.isAnnotation());
+ assertFalse(String.class.isAnnotation());
+ }
+
+ public void test_isAnnotationPresent() {
+ assertTrue(PublicTestClass.class.isAnnotationPresent(TestAnnotation.class));
+ assertFalse(ExtendTestClass1.class.isAnnotationPresent(TestAnnotation.class));
+ assertFalse(String.class.isAnnotationPresent(Deprecated.class));
+ assertTrue(ExtendTestClass.class.isAnnotationPresent(TestAnnotation.class));
+ assertTrue(ExtendTestClass.class.isAnnotationPresent(Deprecated.class));
+ }
+
+ public void test_isAnonymousClass() {
+ assertFalse(PublicTestClass.class.isAnonymousClass());
+ assertTrue((new Thread() {}).getClass().isAnonymousClass());
+ }
+
+ public void test_isEnum() {
+ assertFalse(PublicTestClass.class.isEnum());
+ assertFalse(ExtendTestClass.class.isEnum());
+ assertTrue(TestEnum.ONE.getClass().isEnum());
+ assertTrue(TestEnum.class.isEnum());
+ }
+
+ public void test_isLocalClass() {
+ assertFalse(ExtendTestClass.class.isLocalClass());
+ assertFalse(TestInterface.class.isLocalClass());
+ assertFalse(TestEnum.class.isLocalClass());
+ class InternalClass {}
+ assertTrue(InternalClass.class.isLocalClass());
+ }
+
+ public void test_isMemberClass() {
+ assertFalse(OldClassTest.class.isMemberClass());
+ assertFalse(String.class.isMemberClass());
+ assertTrue(TestEnum.class.isMemberClass());
+ assertTrue(StaticMember$Class.class.isMemberClass());
+ }
+
+ public void test_isSynthetic() {
+ assertFalse("Returned true for non synthetic class.",
+ ExtendTestClass.class.isSynthetic());
+ assertFalse("Returned true for non synthetic class.",
+ TestInterface.class.isSynthetic());
+ assertFalse("Returned true for non synthetic class.",
+ String.class.isSynthetic());
+ }
+
+ public void test_getCanonicalName() {
+ Class [] classArray = { int.class, int[].class, String.class,
+ PublicTestClass.class, TestInterface.class,
+ ExtendTestClass.class };
+ String [] classNames = {"int", "int[]", "java.lang.String",
+ "libcore.java.lang.OldClassTest.PublicTestClass",
+ "libcore.java.lang.OldClassTest.TestInterface",
+ "libcore.java.lang.OldClassTest.ExtendTestClass"};
+
+ for(int i = 0; i < classArray.length; i++) {
+ assertEquals(classNames[i], classArray[i].getCanonicalName());
+ }
+ }
+
+ public void test_getClassLoader() {
+ assertEquals(ExtendTestClass.class.getClassLoader(),
+ PublicTestClass.class.getClassLoader());
+
+ assertNull(int.class.getClassLoader());
+ assertNull(void.class.getClassLoader());
+ }
+
+ public void test_getClasses() {
+ assertEquals("Incorrect class array returned",
+ 11, OldClassTest.class.getClasses().length);
+ }
+
+ public void test_getDeclaredClasses() {
+ Class [] declClasses = Object.class.getDeclaredClasses();
+ assertEquals("Incorrect length of declared classes array is returned " +
+ "for Object.", 0, declClasses.length);
+
+ declClasses = PublicTestClass.class.getDeclaredClasses();
+ assertEquals(2, declClasses.length);
+
+ assertEquals(0, int.class.getDeclaredClasses().length);
+ assertEquals(0, void.class.getDeclaredClasses().length);
+
+ for(int i = 0; i < declClasses.length; i++) {
+ Constructor<?> constr = declClasses[i].getDeclaredConstructors()[0];
+ constr.setAccessible(true);
+ PublicTestClass publicClazz = new PublicTestClass();
+ try {
+ Object o = constr.newInstance(publicClazz);
+ assertTrue("Returned incorrect class: " + o.toString(),
+ o.toString().startsWith("PrivateClass"));
+ } catch(Exception e) {
+ fail("Unexpected exception was thrown: " + e.toString());
+ }
+ }
+
+ declClasses = TestInterface.class.getDeclaredClasses();
+ assertEquals(0, declClasses.length);
+ }
+
+ public void test_getDeclaredConstructor$Ljava_lang_Class() throws Exception {
+ try {
+ TestClass.class.getDeclaredConstructor(String.class);
+ fail("NoSuchMethodException should be thrown.");
+ } catch(NoSuchMethodException nsme) {
+ //expected
+ }
+ }
+
+ public void test_getDeclaredFieldLjava_lang_String() throws Exception {
+ try {
+ TestClass.class.getDeclaredField(null);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+
+ try {
+ TestClass.class.getDeclaredField("NonExistentField");
+ fail("NoSuchFieldException is not thrown.");
+ } catch(NoSuchFieldException nsfe) {
+ //expected
+ }
+ }
+
+ public void test_getDeclaredMethodLjava_lang_String$Ljava_lang_Class() throws Exception {
+ try {
+ TestClass.class.getDeclaredMethod(null, new Class[0]);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+
+ try {
+ TestClass.class.getDeclaredMethod("NonExistentMethod", new Class[0]);
+ fail("NoSuchMethodException is not thrown.");
+ } catch(NoSuchMethodException nsme) {
+ //expected
+ }
+ }
+
+ public void test_getMethodLjava_lang_String$Ljava_lang_Class() throws Exception {
+ Method m = ExtendTestClass1.class.getMethod("getCount", new Class[0]);
+ assertEquals("Returned incorrect method", 0, ((Integer) (m.invoke(new ExtendTestClass1())))
+ .intValue());
+
+ try {
+ m = TestClass.class.getMethod("init", new Class[0]);
+ fail("Failed to throw exception accessing to init method");
+ } catch (NoSuchMethodException e) {
+ // Correct
+ return;
+ }
+
+ try {
+ TestClass.class.getMethod("pubMethod", new Class[0]);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ }
+
+ public void test_getDeclaringClass() {
+ assertNull(OldClassTest.class.getDeclaringClass());
+ assertNotNull(PublicTestClass.class.getDeclaringClass());
+ }
+
+ public void test_getFieldLjava_lang_String() throws Exception {
+ Field f = TestClass.class.getField("pubField");
+ assertEquals("Returned incorrect field", 2, f.getInt(new TestClass()));
+
+ f = PublicTestClass.class.getField("TEST_FIELD");
+ assertEquals("Returned incorrect field", "test field",
+ f.get(new PublicTestClass()));
+
+ f = PublicTestClass.class.getField("TEST_INTERFACE_FIELD");
+ assertEquals("Returned incorrect field", 0,
+ f.getInt(new PublicTestClass()));
+
+ try {
+ TestClass.class.getField(null);
+ fail("NullPointerException is thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ }
+
+ public void test_getFields2() throws Exception {
+ Field[] f;
+ Field expected = null;
+
+ f = PublicTestClass.class.getFields();
+ assertEquals("Test 1: Incorrect number of fields;", 2, f.length);
+
+ f = Cls2.class.getFields();
+ assertEquals("Test 2: Incorrect number of fields;", 6, f.length);
+
+ f = Cls3.class.getFields();
+ assertEquals("Test 2: Incorrect number of fields;", 5, f.length);
+
+ for (Field field : f) {
+ if (field.toString().equals("public static final int "
+ + "libcore.java.lang.OldClassTest$Intf3.field1")) {
+ expected = field;
+ break;
+ }
+ }
+ if (expected == null) {
+ fail("Test 3: getFields() did not return all fields.");
+ }
+ assertEquals("Test 4: Incorrect field;", expected,
+ Cls3.class.getField("field1"));
+
+ expected = null;
+ for (Field field : f) {
+ if(field.toString().equals("public static final int " +
+ "libcore.java.lang.OldClassTest$Intf1.field2")) {
+ expected = field;
+ break;
+ }
+ }
+ if (expected == null) {
+ fail("Test 5: getFields() did not return all fields.");
+ }
+ assertEquals("Test 6: Incorrect field;", expected,
+ Cls3.class.getField("field2"));
+ }
+
+ public void test_getFields() throws Exception {
+ Field expected = null;
+ Field[] fields = Cls2.class.getFields();
+ for (Field field : fields) {
+ if(field.toString().equals("public int libcore.java.lang.OldClassTest$Cls2.field1")) {
+ expected = field;
+ break;
+ }
+ }
+ if (expected == null) {
+ fail("getFields() did not return all fields");
+ }
+ assertEquals(expected, Cls2.class.getField("field1"));
+ }
+
+ public void test_getInterfaces() {
+ Class [] interfaces1 = Cls1.class.getInterfaces();
+ assertEquals(1, interfaces1.length);
+ assertEquals(Intf2.class, interfaces1[0]);
+
+ Class [] interfaces2 = Cls2.class.getInterfaces();
+ assertEquals(1, interfaces2.length);
+ assertEquals(Intf1.class, interfaces2[0]);
+
+ Class [] interfaces3 = Cls3.class.getInterfaces();
+ assertEquals(2, interfaces3.length);
+ assertEquals(Intf3.class, interfaces3[0]);
+ assertEquals(Intf4.class, interfaces3[1]);
+
+ Class [] interfaces4 = Cls4.class.getInterfaces();
+ assertEquals(0, interfaces4.length);
+ }
+
+ public void test_getMethods() throws Exception {
+ assertEquals("Incorrect number of methods", 10,
+ Cls2.class.getMethods().length);
+ assertEquals("Incorrect number of methods", 11,
+ Cls3.class.getMethods().length);
+
+ Method expected = null;
+ Method[] methods = Cls2.class.getMethods();
+ for (Method method : methods) {
+ if(method.toString().equals("public void libcore.java.lang.OldClassTest$Cls2.test()")) {
+ expected = method;
+ break;
+ }
+ }
+ if (expected == null) {
+ fail("getMethods() did not return all methods");
+ }
+ assertEquals(expected, Cls2.class.getMethod("test"));
+
+ expected = null;
+ methods = Cls3.class.getMethods();
+ for (Method method : methods) {
+ if(method.toString().equals("public void libcore.java.lang.OldClassTest$Cls3.test()")) {
+ expected = method;
+ break;
+ }
+ }
+ if (expected == null) {
+ fail("getMethods() did not return all methods");
+ }
+ assertEquals(expected, Cls3.class.getMethod("test"));
+
+ expected = null;
+ methods = Cls3.class.getMethods();
+ for (Method method : methods) {
+ if(method.toString().equals("public void libcore.java.lang.OldClassTest$Cls3.test2(int,"
+ + "java.lang.Object)")) {
+ expected = method;
+ break;
+ }
+ }
+ if (expected == null) {
+ fail("getMethods() did not return all methods");
+ }
+
+ assertEquals(expected, Cls3.class.getMethod("test2", int.class,
+ Object.class));
+
+ assertEquals("Incorrect number of methods", 1,
+ Intf5.class.getMethods().length);
+ }
+
+ public void test_getResourceLjava_lang_String() {
+ assertNull(getClass().getResource(
+ "libcore/java/lang/NonExistentResource"));
+ assertNull(getClass().getResource(getClass().getName() + "NonExistentResource"));
+ }
+
+ public void test_getResourceAsStreamLjava_lang_String() throws Exception {
+ String name = "/HelloWorld.txt";
+ assertNotNull("the file " + name + " can not be found in this " +
+ "directory", getClass().getResourceAsStream(name));
+
+ final String nameBadURI = "org/apache/harmony/luni/tests/test_resource.txt";
+ assertNull("the file " + nameBadURI + " should not be found in this directory",
+ getClass().getResourceAsStream(nameBadURI));
+
+ ClassLoader pcl = getClass().getClassLoader();
+ Class<?> clazz = pcl.loadClass("libcore.java.lang.OldClassTest");
+ assertNotNull(clazz.getResourceAsStream("HelloWorld1.txt"));
+
+ try {
+ getClass().getResourceAsStream(null);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ }
+
+ public void test_isAssignableFromLjava_lang_Class() {
+ assertFalse("returned true not assignable classes",
+ Integer.class.isAssignableFrom(String.class));
+
+ try {
+ Runnable.class.isAssignableFrom(null);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ }
+
+ public void test_newInstance() throws Exception {
+ try {
+ TestClass3.class.newInstance();
+ fail("IllegalAccessException is not thrown.");
+ } catch(IllegalAccessException iae) {
+ //expected
+ }
+
+ try {
+ TestClass1C.class.newInstance();
+ fail("ExceptionInInitializerError should be thrown.");
+ } catch (java.lang.ExceptionInInitializerError ie) {
+ //expected
+ }
+ }
+
+ public void test_asSubclass1() {
+ assertEquals(ExtendTestClass.class,
+ ExtendTestClass.class.asSubclass(PublicTestClass.class));
+
+ assertEquals(PublicTestClass.class,
+ PublicTestClass.class.asSubclass(TestInterface.class));
+
+ assertEquals(ExtendTestClass1.class,
+ ExtendTestClass1.class.asSubclass(PublicTestClass.class));
+
+ assertEquals(PublicTestClass.class,
+ PublicTestClass.class.asSubclass(PublicTestClass.class));
+ }
+
+ public void test_asSubclass2() {
+ try {
+ PublicTestClass.class.asSubclass(ExtendTestClass.class);
+ fail("Test 1: ClassCastException expected.");
+ } catch(ClassCastException cce) {
+ // Expected.
+ }
+
+ try {
+ PublicTestClass.class.asSubclass(String.class);
+ fail("Test 2: ClassCastException expected.");
+ } catch(ClassCastException cce) {
+ // Expected.
+ }
+ }
+
+ public void test_cast() {
+ Object o = PublicTestClass.class.cast(new ExtendTestClass());
+ assertTrue(o instanceof ExtendTestClass);
+
+ try {
+ ExtendTestClass.class.cast(new PublicTestClass());
+ fail("Test 1: ClassCastException expected.");
+ } catch(ClassCastException cce) {
+ //expected
+ }
+
+ try {
+ ExtendTestClass.class.cast(new String());
+ fail("ClassCastException is not thrown.");
+ } catch(ClassCastException cce) {
+ //expected
+ }
+ }
+
+ public void test_desiredAssertionStatus() {
+ Class [] classArray = { Object.class, Integer.class,
+ String.class, PublicTestClass.class,
+ ExtendTestClass.class, ExtendTestClass1.class};
+
+ for(int i = 0; i < classArray.length; i++) {
+ assertFalse("assertion status for " + classArray[i],
+ classArray[i].desiredAssertionStatus());
+ }
+ }
+
+ public void testGetResourceAsStream1() throws IOException {
+ Class clazz = getClass();
+
+ InputStream stream = clazz.getResourceAsStream("HelloWorld.txt");
+ assert(stream != null);
+
+ byte[] buffer = new byte[20];
+ int length = stream.read(buffer);
+ String s = new String(buffer, 0, length);
+ assert("Hello, World.".equals(s));
+
+ stream.close();
+ }
+
+ public void testGetResourceAsStream2() throws IOException {
+ Class clazz = getClass();
+
+ InputStream stream = clazz.getResourceAsStream("/libcore/java/lang/HelloWorld.txt");
+ assert(stream != null);
+
+ byte[] buffer = new byte[20];
+ int length = stream.read(buffer);
+ String s = new String(buffer, 0, length);
+ assert("Hello, World.".equals(s));
+
+ stream.close();
+
+ try {
+ clazz.getResourceAsStream(null);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ assertNull(clazz.getResourceAsStream("/NonExistentResource"));
+ assertNull(clazz.getResourceAsStream("libcore/java/lang/HelloWorld.txt"));
+ }
+}
diff --git a/luni/src/test/java/libcore/java/lang/OldDoubleTest.java b/luni/src/test/java/libcore/java/lang/OldDoubleTest.java
new file mode 100644
index 0000000..dacb521
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldDoubleTest.java
@@ -0,0 +1,79 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import junit.framework.TestCase;
+
+public class OldDoubleTest extends TestCase {
+
+ public void test_byteValue() {
+ Double d = new Double(Byte.MAX_VALUE);
+ assertEquals("Returned incorrect byte value", Byte.MAX_VALUE, d.byteValue());
+ d= new Double(Byte.MIN_VALUE);
+ assertEquals("Returned incorrect byte value", Byte.MIN_VALUE, d.byteValue());
+ d= new Double(Double.MAX_VALUE);
+ assertEquals("Returned incorrect byte value", -1, d.byteValue());
+ }
+
+ public void test_doubleToLongBitsD() {
+ assertEquals(0x7ff8000000000000L, Double.doubleToLongBits(Double.NaN));
+ assertEquals(0x7ff0000000000000L, Double.doubleToLongBits(Double.POSITIVE_INFINITY));
+ assertEquals(0xfff0000000000000L, Double.doubleToLongBits(Double.NEGATIVE_INFINITY));
+ }
+
+ public void test_doubleToRawLongBitsD() {
+ assertEquals(0x7ff8000000000000L, Double.doubleToLongBits(Double.NaN));
+ assertEquals(0x7ff0000000000000L, Double.doubleToLongBits(Double.POSITIVE_INFINITY));
+ assertEquals(0xfff0000000000000L, Double.doubleToLongBits(Double.NEGATIVE_INFINITY));
+ }
+
+ public void test_doubleValue() {
+ assertEquals(Double.POSITIVE_INFINITY, new Double("1.7976931348623159E308").doubleValue());
+ assertEquals(Double.NEGATIVE_INFINITY, new Double("-1.7976931348623159E308").doubleValue());
+ assertEquals(Double.MAX_VALUE, new Double("1.7976931348623157E308").doubleValue());
+ assertEquals(Double.MIN_VALUE, new Double("4.9E-324").doubleValue());
+ }
+
+ public void test_floatValue() {
+ assertEquals(Float.POSITIVE_INFINITY, new Double("3.4028236E38").floatValue());
+ assertEquals(Float.NEGATIVE_INFINITY, new Double("-3.4028236E38").floatValue());
+ assertEquals(Float.MAX_VALUE, new Double("3.4028235E38").floatValue());
+ assertEquals(Float.MIN_VALUE, new Double("1.4E-45").floatValue());
+ }
+
+ public void test_intValue() {
+ assertEquals("Returned incorrect int value", Integer.MAX_VALUE,
+ new Double(2147483648d).intValue());
+ assertEquals("Returned incorrect int value", Integer.MIN_VALUE,
+ new Double(-2147483649d).intValue());
+ }
+
+ public void test_isNaND() {
+ assertFalse("Doesn't return false value", Double.isNaN(new Double(Double.MAX_VALUE)));
+ }
+
+ // Regression test for hotfix in native code of double parser.
+ public void test_parseDouble_LString_AndroidRegression() {
+ // Android regression test
+ long startTime = System.currentTimeMillis();
+ double actual = Double.parseDouble("9e551027");
+ assertTrue("parsing double 9e551027 took too long.",
+ (System.currentTimeMillis() - startTime) < 1000);
+ assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY,
+ actual, 0.0D);
+ }
+}
diff --git a/luni/src/test/java/libcore/java/lang/OldFloatTest.java b/luni/src/test/java/libcore/java/lang/OldFloatTest.java
new file mode 100644
index 0000000..1bbac12
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldFloatTest.java
@@ -0,0 +1,92 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import junit.framework.TestCase;
+
+public class OldFloatTest extends TestCase {
+
+ public void test_ConstructorLjava_lang_String() {
+ try {
+ new Float("900.89ff");
+ fail("NumberFormatException is not thrown.");
+ } catch(NumberFormatException nfe) {
+ //expected
+ }
+ }
+
+ public void test_ConstructorD() {
+ Float f = new Float(Double.MAX_VALUE);
+ assertTrue("Created incorrect float", f.floatValue() == Float.POSITIVE_INFINITY);
+ }
+
+ public void test_parseFloatLExceptions() {
+ String [] incorrectStrings = {"", ";", "99999999EE999999", "99999l",
+ "0x1.f.ffffep127"};
+ for(int i = 0; i < incorrectStrings.length; i++) {
+ try {
+ Float.parseFloat(incorrectStrings[i]);
+ fail("NumberFormatException is not thrown for string: "
+ + incorrectStrings[i]);
+ } catch(NumberFormatException nfe) {
+ //expected
+ }
+ }
+ }
+
+ public void test_floatToIntBitsF() {
+ assertEquals(0x7f800000, Float.floatToIntBits(Float.POSITIVE_INFINITY));
+ assertEquals(0xff800000, Float.floatToIntBits(Float.NEGATIVE_INFINITY));
+ assertEquals(0x7fc00000, Float.floatToIntBits(Float.NaN));
+ }
+
+ public void test_floatToRawIntBitsF() {
+ assertEquals(0x7f800000, Float.floatToRawIntBits(Float.POSITIVE_INFINITY));
+ assertEquals(0xff800000, Float.floatToRawIntBits(Float.NEGATIVE_INFINITY));
+ assertEquals(0x7fc00000, Float.floatToRawIntBits(Float.NaN));
+ }
+
+ public void test_hashCode() {
+ assertTrue(new Float(Float.MAX_VALUE).hashCode() != new Float(Float.MIN_VALUE).hashCode());
+ }
+
+ public void test_intBitsToFloatI() {
+ assertEquals(Float.POSITIVE_INFINITY, Float.intBitsToFloat(0x7f800000));
+ assertEquals(Float.NEGATIVE_INFINITY, Float.intBitsToFloat(0xff800000));
+
+ assertEquals(Float.NaN, Float.intBitsToFloat(0x7f800001));
+ assertEquals(Float.NaN, Float.intBitsToFloat(0x7fffffff));
+ assertEquals(Float.NaN, Float.intBitsToFloat(0xff800001));
+ assertEquals(Float.NaN, Float.intBitsToFloat(0xffffffff));
+ }
+
+ public void test_intValue() {
+ assertEquals(Integer.MAX_VALUE, new Float(Float.MAX_VALUE).intValue());
+ assertEquals(0, new Float(Float.MIN_VALUE).intValue());
+ }
+
+ public void test_isNaNF() {
+ assertFalse(Float.isNaN(12.09f));
+ assertFalse(Float.isNaN(Float.MAX_VALUE));
+ assertFalse(Float.isNaN(Float.MIN_VALUE));
+ }
+
+ public void test_longValue() {
+ assertEquals(Long.MAX_VALUE, new Float(Float.MAX_VALUE).longValue());
+ assertEquals(0, new Float(Float.MIN_VALUE).longValue());
+ }
+}
diff --git a/luni/src/test/java/libcore/java/lang/OldInheritableThreadLocalTest.java b/luni/src/test/java/libcore/java/lang/OldInheritableThreadLocalTest.java
new file mode 100644
index 0000000..dd9b9f4
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldInheritableThreadLocalTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import junit.framework.TestCase;
+
+public class OldInheritableThreadLocalTest extends TestCase {
+
+ public void test_Ljava_lang_InheritableThreadLocal()
+ throws InterruptedException {
+ final Object value = new Object();
+ final Object inheritedValue = new Object();
+ final ThreadLocal<Object> threadLocal
+ = new InheritableThreadLocal<Object>() {
+ @Override
+ protected Object childValue(Object parentValue) {
+ assertSame(value, parentValue);
+ return inheritedValue;
+ }
+ };
+ threadLocal.set(value);
+ final Object[] holder = new Object[1];
+ Thread thread = new Thread() {
+ public void run() {
+ holder[0] = threadLocal.get();
+ }
+ };
+ thread.start();
+ thread.join();
+ assertSame(value, threadLocal.get());
+ assertSame(inheritedValue, holder[0]);
+
+ // Cleanup properly, so other tests are not affected.
+ threadLocal.remove();
+ }
+
+ public void test_childValue() {
+ InheritableThreadLocal<String> itl = new InheritableThreadLocal<String>() {
+ @Override
+ protected String initialValue() {
+ return "initial";
+ }
+ @Override
+ protected String childValue(String parentValue) {
+ return "childValue";
+ }
+ };
+ assertEquals("initial", itl.get());
+ }
+
+}
diff --git a/luni/src/test/java/libcore/java/lang/OldIntegerTest.java b/luni/src/test/java/libcore/java/lang/OldIntegerTest.java
new file mode 100644
index 0000000..462ee19
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldIntegerTest.java
@@ -0,0 +1,69 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import java.util.Properties;
+import junit.framework.TestCase;
+
+public class OldIntegerTest extends TestCase {
+ private Properties orgProps;
+
+ @Override
+ protected void setUp() {
+ orgProps = System.getProperties();
+ }
+
+ @Override
+ protected void tearDown() {
+ System.setProperties(orgProps);
+ }
+
+ public void test_getIntegerLjava_lang_StringI() {
+ // Test for method java.lang.Integer
+ // java.lang.Integer.getInteger(java.lang.String, int)
+ Properties tProps = new Properties();
+ tProps.put("testIncInt", "notInt");
+ System.setProperties(tProps);
+ assertTrue("returned incorrect default Integer", Integer.getInteger(
+ "testIncInt", 4).equals(new Integer(4)));
+ }
+
+ public void test_getIntegerLjava_lang_StringLjava_lang_Integer() {
+ // Test for method java.lang.Integer
+ // java.lang.Integer.getInteger(java.lang.String, java.lang.Integer)
+ Properties tProps = new Properties();
+ tProps.put("testIncInt", "notInt");
+ System.setProperties(tProps);
+ assertTrue("returned incorrect default Integer", Integer.getInteger(
+ "testIncInt", new Integer(4)).equals(new Integer(4)));
+ }
+
+ public void test_intValue() {
+ assertEquals(Integer.MAX_VALUE, new Integer(Integer.MAX_VALUE).intValue());
+ assertEquals(Integer.MIN_VALUE, new Integer(Integer.MIN_VALUE).intValue());
+ }
+
+ public void test_longValue() {
+ assertEquals(Integer.MAX_VALUE, new Integer(Integer.MAX_VALUE).longValue());
+ assertEquals(Integer.MIN_VALUE, new Integer(Integer.MIN_VALUE).longValue());
+ }
+
+ public void test_shortValue() {
+ assertEquals(-1, new Integer(Integer.MAX_VALUE).shortValue());
+ assertEquals(0, new Integer(Integer.MIN_VALUE).shortValue());
+ }
+}
diff --git a/luni/src/test/java/libcore/java/lang/OldLongTest.java b/luni/src/test/java/libcore/java/lang/OldLongTest.java
new file mode 100644
index 0000000..6fb7d49
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldLongTest.java
@@ -0,0 +1,83 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import java.util.Properties;
+import junit.framework.TestCase;
+
+public class OldLongTest extends TestCase {
+ private Properties orgProps;
+
+ @Override
+ protected void setUp() {
+ orgProps = System.getProperties();
+ }
+
+ @Override
+ protected void tearDown() {
+ System.setProperties(orgProps);
+ }
+
+ public void test_getLongLjava_lang_String() {
+ Properties tProps = new Properties();
+ tProps.put("testLong", "99");
+ tProps.put("testIncLong", "string");
+ System.setProperties(tProps);
+ assertNull("returned incorrect default Long",
+ Long.getLong("testIncLong"));
+ }
+
+ public void test_getLongLjava_lang_StringJ() {
+ // Test for method java.lang.Long
+ // java.lang.Long.getLong(java.lang.String, long)
+ Properties tProps = new Properties();
+ tProps.put("testIncLong", "string");
+ System.setProperties(tProps);
+ assertTrue("returned incorrect default Long", Long.getLong("testIncLong", 4L)
+ .equals(new Long(4)));
+ }
+
+ public void test_getLongLjava_lang_StringLjava_lang_Long() {
+ // Test for method java.lang.Long
+ // java.lang.Long.getLong(java.lang.String, java.lang.Long)
+ Properties tProps = new Properties();
+ tProps.put("testIncLong", "string");
+ System.setProperties(tProps);
+ assertTrue("returned incorrect default Long", Long.getLong("testIncLong",
+ new Long(4)).equals(new Long(4)));
+ }
+
+ public void test_floatValue() {
+ assertEquals(Long.MAX_VALUE, new Long(Long.MAX_VALUE).floatValue(), 0F);
+ assertEquals(Long.MIN_VALUE, new Long(Long.MIN_VALUE).floatValue(), 0F);
+ }
+
+ public void test_intValue() {
+ assertEquals(-1, new Long(Long.MAX_VALUE).intValue());
+ assertEquals(0, new Long(Long.MIN_VALUE).intValue());
+ }
+
+ public void test_longValue() {
+ assertEquals(Long.MAX_VALUE, new Long(Long.MAX_VALUE).longValue());
+ assertEquals(Long.MIN_VALUE, new Long(Long.MIN_VALUE).longValue());
+ }
+
+ public void test_shortValue() {
+ assertEquals(-1, new Long(Long.MAX_VALUE).shortValue());
+ assertEquals(0, new Long(Long.MIN_VALUE).shortValue());
+ }
+}
diff --git a/luni/src/test/java/libcore/java/lang/OldObjectTest.java b/luni/src/test/java/libcore/java/lang/OldObjectTest.java
new file mode 100644
index 0000000..dd0e217
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldObjectTest.java
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package libcore.java.lang;
+
+import dalvik.annotation.SideEffect;
+import java.util.Vector;
+import junit.framework.TestCase;
+
+public class OldObjectTest extends TestCase {
+
+ public boolean isCalled = false;
+
+ /**
+ * Test objects.
+ */
+ Object obj1 = new Object();
+
+ /**
+ * Generic state indicator.
+ */
+ int status = 0;
+
+ int ready = 0;
+ TestThread1 thr1;
+ TestThread2 thr2;
+
+
+ @SideEffect("Causes OutOfMemoryError to test finalization")
+ public void test_finalize() {
+ isCalled = false;
+ class TestObject extends Object {
+
+ Vector<StringBuffer> v = new Vector<StringBuffer>();
+ public void add() {
+ v.add(new StringBuffer(10000));
+ }
+
+ protected void finalize() throws Throwable {
+ isCalled = true;
+ super.finalize();
+ }
+ }
+
+ TestObject to = new TestObject();
+
+ try {
+ while(true) {
+ to.add();
+ }
+ } catch(OutOfMemoryError oome) {
+ //expected
+ to = null;
+ }
+ System.gc();
+ System.runFinalization();
+ assertTrue(isCalled);
+ }
+
+ public void test_clone() {
+ MockCloneableObject mco = new MockCloneableObject();
+ try {
+ assertFalse(mco.equals(mco.clone()));
+ assertEquals(mco.getClass(), mco.clone().getClass());
+ } catch(CloneNotSupportedException cnse) {
+ fail("CloneNotSupportedException was thrown.");
+ }
+
+ MockObject mo = new MockObject();
+ try {
+ mo.clone();
+ fail("CloneNotSupportedException was not thrown.");
+ } catch(CloneNotSupportedException cnse) {
+ //expected
+ }
+ }
+
+ class MockCloneableObject extends Object implements Cloneable {
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ }
+
+ class MockObject extends Object {
+
+ boolean isCalled = false;
+
+ public void finalize() throws Throwable {
+ super.finalize();
+ isCalled = true;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ }
+
+ public void test_notify() {
+ try {
+ Object obj = new Object();
+ obj.notify();
+ fail("IllegalMonitorStateException was not thrown.");
+ } catch(IllegalMonitorStateException imse) {
+ //expected
+ }
+ }
+
+ public void test_notifyAll() {
+ try {
+ Object obj = new Object();
+ obj.notifyAll();
+ fail("IllegalMonitorStateException was not thrown.");
+ } catch(IllegalMonitorStateException imse) {
+ //expected
+ }
+ }
+
+ public void test_wait() {
+
+ try {
+ Object obj = new Object();
+ obj.wait();
+ fail("IllegalMonitorStateException was not thrown.");
+ } catch(IllegalMonitorStateException imse) {
+ //expected
+ } catch(InterruptedException ex) {
+ fail("InterruptedException was thrown.");
+ }
+
+ try {
+ thr1 = new TestThread1(TestThread1.CASE_WAIT);
+ thr2 = new TestThread2();
+ thr1.start();
+ thr2.start();
+ thr2.join();
+ thr1.join();
+ thr1 = null;
+ thr2 = null;
+ } catch(InterruptedException e) {
+ fail("InterruptedException was thrown.");
+ }
+ assertEquals(3, status);
+ }
+
+ class TestThread1 extends Thread {
+
+ static final int CASE_WAIT = 0;
+ static final int CASE_WAIT_LONG = 1;
+ static final int CASE_WAIT_LONG_INT = 2;
+
+ int testCase = CASE_WAIT;
+
+ public TestThread1(int option) {
+ testCase = option;
+ }
+
+ public void run() {
+ synchronized (obj1) {
+ try {
+ switch(testCase) {
+ case CASE_WAIT:
+ obj1.wait();// Wait for ever.
+ break;
+ case CASE_WAIT_LONG:
+ obj1.wait(5000L);
+ break;
+ case CASE_WAIT_LONG_INT:
+ obj1.wait(10000L, 999999);
+ break;
+ }
+
+ } catch (InterruptedException ex) {
+ status = 3;
+ }
+ }
+ }
+ }
+
+ class TestThread2 extends Thread {
+ public void run() {
+ thr1.interrupt();
+ }
+ }
+
+ public void test_waitJI() {
+ try {
+ Object obj = new Object();
+ obj.wait(5000L, 1);
+ fail("IllegalMonitorStateException was not thrown.");
+ } catch(IllegalMonitorStateException imse) {
+ //expected
+ } catch(InterruptedException ex) {
+ fail("InterruptedException was thrown.");
+ }
+
+ try {
+ thr1 = new TestThread1(TestThread1.CASE_WAIT_LONG_INT);
+ thr2 = new TestThread2();
+ thr1.start();
+ thr2.start();
+ thr2.join();
+ thr1.join();
+ thr1 = null;
+ thr2 = null;
+ } catch(InterruptedException e) {
+ fail("InterruptedException was thrown.");
+ }
+ assertEquals(3, status);
+
+ }
+
+ public void test_waitJ() {
+ try {
+ Object obj = new Object();
+ obj.wait(5000L);
+ fail("IllegalMonitorStateException was not thrown.");
+ } catch(IllegalMonitorStateException imse) {
+ //expected
+ } catch(InterruptedException ex) {
+ fail("InterruptedException was thrown.");
+ }
+
+ try {
+ thr1 = new TestThread1(TestThread1.CASE_WAIT_LONG);
+ thr2 = new TestThread2();
+ thr1.start();
+ thr2.start();
+ thr2.join();
+ thr1.join();
+ thr1 = null;
+ thr2 = null;
+ } catch(InterruptedException e) {
+ fail("InterruptedException was thrown.");
+ }
+ assertEquals(3, status);
+ }
+}
diff --git a/luni/src/test/java/libcore/java/lang/OldRuntimeExceptionTest.java b/luni/src/test/java/libcore/java/lang/OldRuntimeExceptionTest.java
new file mode 100644
index 0000000..8004124
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldRuntimeExceptionTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import junit.framework.TestCase;
+
+public class OldRuntimeExceptionTest extends TestCase {
+
+ public void test_ConstructorLStringLThrowable() {
+ String message = "Test message";
+ NullPointerException npe = new NullPointerException();
+ RuntimeException re = new RuntimeException(message, npe);
+ assertEquals(message, re.getMessage());
+ assertEquals(npe, re.getCause());
+
+ re = new RuntimeException(null, npe);
+ assertNull(re.getMessage());
+
+ re = new RuntimeException(message, null);
+ assertNull(re.getCause());
+ }
+
+ public void test_ConstructorLThrowable() {
+ NullPointerException npe = new NullPointerException();
+ RuntimeException re = new RuntimeException(npe);
+ assertEquals(npe, re.getCause());
+
+ re = new RuntimeException((Throwable) null);
+ assertNull(re.getCause());
+ }
+}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java b/luni/src/test/java/libcore/java/lang/OldRuntimeTest.java
similarity index 71%
rename from luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java
rename to luni/src/test/java/libcore/java/lang/OldRuntimeTest.java
index f276ec7..4b692d7 100644
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldRuntimeTest.java
@@ -15,94 +15,26 @@
* limitations under the License.
*/
-package org.apache.harmony.luni.tests.java.lang;
+package libcore.java.lang;
import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
import java.security.Permission;
import java.util.Arrays;
import java.util.Vector;
-
import tests.support.resource.Support_Resources;
-@TestTargetClass(Runtime.class)
-public class RuntimeTest extends junit.framework.TestCase {
+public class OldRuntimeTest extends junit.framework.TestCase {
Runtime r = Runtime.getRuntime();
InputStream is;
- String s;
-
- static boolean flag = false;
-
- static boolean ranFinalize = false;
-
- int statusCode = -1;
-
- class HasFinalizer {
- String internalString;
-
- HasFinalizer(String s) {
- internalString = s;
- }
-
- @Override
- protected void finalize() {
- internalString = "hit";
- }
- }
-
- @Override
- protected void finalize() {
- if (flag)
- ranFinalize = true;
- }
-
- protected RuntimeTest createInstance() {
- return new RuntimeTest("FT");
- }
-
- @Override protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * @tests java.lang.Runtime#exec(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.ADDITIONAL,
- notes = "",
- method = "exec",
- args = {java.lang.String.class}
- )
- public void test_exec() {
- /* successful exec's are tested by java.lang.Process */
- try {
- Runtime.getRuntime().exec("AnInexistentProgram");
- fail("failed to throw IOException when exec'ed inexistent program");
- } catch (IOException e) { /* expected */ }
- }
-
- /**
- * @tests java.lang.Runtime#freeMemory()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "freeMemory",
- args = {}
- )
public void test_freeMemory() {
// Heap might grow or do GC at any time,
// so we can't really test a lot. Hence
@@ -125,97 +57,11 @@
after != before);
}
- /**
- * @tests java.lang.Runtime#gc()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "gc",
- args = {}
- )
- public void test_gc() {
- // Test for method void java.lang.Runtime.gc()
- try {
- r.gc(); // ensure all garbage objects have been collected
- r.gc(); // two GCs force collection phase to complete
- long firstRead = r.totalMemory() - r.freeMemory();
- Vector<StringBuffer> v = new Vector<StringBuffer>();
- for (int i = 1; i < 10; i++)
- v.addElement(new StringBuffer(10000));
- long secondRead = r.totalMemory() - r.freeMemory();
- v = null;
- r.gc();
- r.gc();
- assertTrue("object memory did not grow", secondRead > firstRead);
- assertTrue("space was not reclaimed", (r.totalMemory() - r
- .freeMemory()) < secondRead);
- } catch (Throwable t) {
- System.out.println("Out of memory during gc test");
- r.gc();
- r.gc();
- }
- }
-
- /**
- * @tests java.lang.Runtime#getRuntime()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "getRuntime method is verified in initial setup for other tests.",
- method = "getRuntime",
- args = {}
- )
public void test_getRuntime() {
// Test for method java.lang.Runtime java.lang.Runtime.getRuntime()
assertNotNull(Runtime.getRuntime());
}
- /**
- * @tests java.lang.Runtime#runFinalization()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "runFinalization",
- args = {}
- )
- public void test_runFinalization() {
- // Test for method void java.lang.Runtime.runFinalization()
-
- flag = true;
- createInstance();
- int count = 10;
- // the gc below likely bogosifies the test, but will have to do for
- // the moment
- while (!ranFinalize && count-- > 0) {
- r.gc();
- r.runFinalization();
- }
- assertTrue("Failed to run finalization", ranFinalize);
- }
-
- /**
- * @tests java.lang.Runtime#totalMemory()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "totalMemory",
- args = {}
- )
- public void test_totalMemory() {
- // Test for method long java.lang.Runtime.totalMemory()
- assertTrue("totalMemory returned nonsense value", r.totalMemory() >= r
- .freeMemory());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "addShutdownHook",
- args = {java.lang.Thread.class}
- )
public void test_addShutdownHook() {
Thread thrException = new Thread () {
public void run() {
@@ -260,24 +106,12 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "availableProcessors",
- args = {}
- )
public void test_availableProcessors() {
assertTrue(Runtime.getRuntime().availableProcessors() > 0);
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "exec",
- args = {java.lang.String.class, java.lang.String[].class}
- )
- public void test_execLjava_lang_StringLjava_lang_StringArray() {
+ public void test_execLjava_lang_StringLjava_lang_StringArray() {
String [] envp = getEnv();
checkExec(0, envp, null);
@@ -315,12 +149,6 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "exec",
- args = {java.lang.String[].class, java.lang.String[].class}
- )
public void test_execLjava_lang_StringArrayLjava_lang_StringArray() {
String [] envp = getEnv();
@@ -373,12 +201,6 @@
} catch (IOException e) { /* expected */ }
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "exec",
- args = {java.lang.String.class, java.lang.String[].class, java.io.File.class}
- )
public void test_execLjava_lang_StringLjava_lang_StringArrayLjava_io_File() {
String [] envp = getEnv();
@@ -420,12 +242,6 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "exec",
- args = {java.lang.String[].class, java.lang.String[].class, java.io.File.class}
- )
public void test_execLjava_lang_StringArrayLjava_lang_StringArrayLjava_io_File() {
String [] envp = getEnv();
@@ -530,12 +346,6 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "exec",
- args = {java.lang.String.class}
- )
public void test_execLjava_lang_String() {
checkExec(1, null, null);
@@ -558,12 +368,6 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "exec",
- args = {java.lang.String[].class}
- )
public void test_execLjava_lang_StringArray() {
checkExec(3, null, null);
@@ -603,22 +407,10 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "runFinalizersOnExit",
- args = {boolean.class}
- )
public void test_runFinalizersOnExit() {
Runtime.getRuntime().runFinalizersOnExit(true);
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "removeShutdownHook",
- args = {java.lang.Thread.class}
- )
public void test_removeShutdownHookLjava_lang_Thread() {
Thread thr1 = new Thread () {
public void run() {
@@ -660,34 +452,16 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "maxMemory",
- args = {}
- )
public void test_maxMemory() {
assertTrue(Runtime.getRuntime().maxMemory() < Long.MAX_VALUE);
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "traceInstructions",
- args = {boolean.class}
- )
public void test_traceInstructions() {
Runtime.getRuntime().traceInstructions(false);
Runtime.getRuntime().traceInstructions(true);
Runtime.getRuntime().traceInstructions(false);
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "traceMethodCalls",
- args = {boolean.class}
- )
@KnownFailure("Fails in CTS but passes under run-core-tests")
public void test_traceMethodCalls() {
try {
@@ -705,12 +479,6 @@
}
@SuppressWarnings("deprecation")
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getLocalizedInputStream",
- args = {java.io.InputStream.class}
- )
public void test_getLocalizedInputStream() throws Exception {
String simpleString = "Heart \u2f3c";
byte[] expected = simpleString.getBytes("UTF-8");
@@ -728,12 +496,6 @@
}
@SuppressWarnings("deprecation")
- @TestTargetNew(
- level = TestLevel.SUFFICIENT,
- notes = "",
- method = "getLocalizedOutputStream",
- args = {java.io.OutputStream.class}
- )
public void test_getLocalizedOutputStream() throws IOException {
String simpleString = "Heart \u2f3c";
byte[] expected = simpleString.getBytes("UTF-8");
@@ -754,14 +516,7 @@
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "load",
- args = {java.lang.String.class}
- )
public void test_load() {
-
try {
Runtime.getRuntime().load("nonExistentLibrary");
fail("UnsatisfiedLinkError was not thrown.");
@@ -777,12 +532,6 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "loadLibrary",
- args = {java.lang.String.class}
- )
public void test_loadLibrary() {
try {
Runtime.getRuntime().loadLibrary("nonExistentLibrary");
@@ -798,11 +547,4 @@
//expected
}
}
-
- public RuntimeTest() {
- }
-
- public RuntimeTest(String name) {
- super(name);
- }
}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackTraceElementTest.java b/luni/src/test/java/libcore/java/lang/OldStackTraceElementTest.java
similarity index 68%
rename from luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackTraceElementTest.java
rename to luni/src/test/java/libcore/java/lang/OldStackTraceElementTest.java
index f095a76..9a09c45 100644
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackTraceElementTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldStackTraceElementTest.java
@@ -14,22 +14,26 @@
* limitations under the License.
*/
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
+package libcore.java.lang;
import junit.framework.TestCase;
-@TestTargetClass(StackTraceElement.class)
-public class StackTraceElementTest extends TestCase {
- private StackTraceElementOriginal original;
+public class OldStackTraceElementTest extends TestCase {
+
+ public class Original extends TestCase {
+
+ public void pureJavaMethod(Object test) throws Exception {
+ throw new Exception("pure java method");
+ }
+
+ native public void pureNativeMethod(Object test);
+ }
+
+ private Original original;
@Override
protected void setUp() throws Exception {
- original = new StackTraceElementOriginal();
+ original = new Original();
super.setUp();
}
@@ -38,21 +42,11 @@
super.tearDown();
}
- /**
- * @tests java.lang.StackTraceElement#StackTraceElement(java.lang.String,
- * java.lang.String, java.lang.String, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "StackTraceElement",
- args = {java.lang.String.class, java.lang.String.class, java.lang.String.class, int.class}
- )
- public void
- test_ConstructorLjava_lang_StringLjava_lang_StringLjava_lang_StringI() {
+ public void test_ConstructorLjava_lang_StringLjava_lang_StringLjava_lang_StringI() {
StackTraceElement ste2 = null;
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
StackTraceElement ste1 = e.getStackTrace()[0];
ste2 = new StackTraceElement(ste1.getClassName(),
@@ -97,18 +91,10 @@
}
}
- /**
- * @tests java.lang.StackTraceElement#equals(java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "equals",
- args = {java.lang.Object.class}
- )
public void test_equalsLjava_lang_Object() {
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
StackTraceElement ste1 = e.getStackTrace()[0];
StackTraceElement ste2 =
@@ -120,82 +106,48 @@
}
}
- /**
- * @tests java.lang.StackTraceElement#getClassName()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getClassName",
- args = {}
- )
public void test_getClassName() {
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
assertEquals("Incorrect class name",
- getClass().getPackage().getName() +
- ".StackTraceElementOriginal",
+ "libcore.java.lang.OldStackTraceElementTest$Original",
e.getStackTrace()[0].getClassName());
assertEquals("Incorrect class name",
- getClass().getPackage().getName() +
- ".StackTraceElementTest",
+ "libcore.java.lang.OldStackTraceElementTest",
e.getStackTrace()[1].getClassName());
}
}
- /**
- * @tests java.lang.StackTraceElement#getFileName()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getFileName",
- args = {}
- )
public void test_getFileName() {
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
assertEquals("Incorrect file name",
- "StackTraceElementOriginal.java",
+ "OldStackTraceElementTest.java",
e.getStackTrace()[0].getFileName());
assertEquals("Incorrect file name",
- "StackTraceElementTest.java",
+ "OldStackTraceElementTest.java",
e.getStackTrace()[1].getFileName());
}
}
- /**
- * @tests java.lang.StackTraceElement#getLineNumber()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getLineNumber",
- args = {}
- )
public void test_getLineNumber() {
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
assertEquals("Incorrect line number",
26, e.getStackTrace()[0].getLineNumber());
}
}
- /**
- * @tests java.lang.StackTraceElement#getMethodName()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getMethodName",
- args = {}
- )
public void test_getMethodName() {
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
assertEquals("Incorrect method name",
"pureJavaMethod",
@@ -206,18 +158,10 @@
}
}
- /**
- * @tests java.lang.StackTraceElement#hashCode()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "hashCode",
- args = {}
- )
public void test_hashCode() {
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
StackTraceElement ste1 = e.getStackTrace()[0];
StackTraceElement ste2 =
@@ -232,50 +176,35 @@
}
}
- /**
- * @tests java.lang.StackTraceElement#isNativeMethod()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isNativeMethod",
- args = {}
- )
public void test_isNativeMethod() {
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
assertFalse("Incorrect method type",
e.getStackTrace()[0].isNativeMethod());
}
try {
original.pureNativeMethod(new Object());
+ fail();
} catch (Error e) {
assertTrue("Incorrect method type",
e.getStackTrace()[0].isNativeMethod());
}
}
- /**
- * @tests java.lang.StackTraceElement#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
public void test_toString() {
try {
original.pureJavaMethod(new Object());
+ fail();
} catch (Exception e) {
StackTraceElement ste = e.getStackTrace()[0];
assertTrue("String representation doesn't contain a package name",
ste.toString().contains(getClass().getPackage().getName()));
assertTrue("String representation doesn't contain a class name",
- ste.toString().contains("StackTraceElementOriginal"));
+ ste.toString().contains("Original"));
assertTrue("String representation doesn't contain a file name",
- ste.toString().contains("StackTraceElementOriginal.java"));
+ ste.toString().contains("OldStackTraceElementTest.java"));
assertTrue("String representation doesn't contain a line number",
ste.toString().contains("26"));
assertTrue("String representation doesn't contain a method name",
diff --git a/luni/src/test/java/libcore/java/lang/OldStringBufferTest.java b/luni/src/test/java/libcore/java/lang/OldStringBufferTest.java
new file mode 100644
index 0000000..84828c4
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldStringBufferTest.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+public class OldStringBufferTest extends junit.framework.TestCase {
+
+ StringBuffer testBuffer = new StringBuffer("This is a test buffer");
+
+ public void test_deleteCharAtI() {
+ try {
+ testBuffer.deleteCharAt(testBuffer.length() + 1);
+ fail("StringIndexOutOfBoundsException was not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.deleteCharAt(-1);
+ fail("StringIndexOutOfBoundsException was not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_ensureCapacityI() {
+ // Test for method void java.lang.StringBuffer.ensureCapacity(int)
+ StringBuffer sb = new StringBuffer(10);
+
+ sb.ensureCapacity(-2);
+ assertEquals("Failed to increase capacity.", 10, sb.capacity());
+
+
+ try {
+ sb.ensureCapacity(Integer.MAX_VALUE);
+ fail("OutOfMemoryError should be thrown.");
+ } catch(java.lang.OutOfMemoryError oome) {
+ //expected
+ }
+ }
+
+ public void test_getCharsII$CI() {
+ StringBuffer buf2 = new StringBuffer("");
+ try {
+ buf2.getChars(-1, 0, new char[5], 2);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch (IndexOutOfBoundsException e) {
+ //expected
+ }
+
+ try {
+ buf2.getChars(0, -1, new char[5], 2);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch (IndexOutOfBoundsException e) {
+ //expected
+ }
+
+ try {
+ buf2.getChars(0, -1, new char[5], 2);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch (IndexOutOfBoundsException e) {
+ //expected
+ }
+
+ try {
+ buf2.getChars(2, 1, new char[5], 2);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch (IndexOutOfBoundsException e) {
+ //expected
+ }
+
+ try {
+ buf2.getChars(0, 6, new char[5], 2);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch (IndexOutOfBoundsException e) {
+ //expected
+ }
+
+ try {
+ buf2.getChars(0, 6, new char[10], 5);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch (IndexOutOfBoundsException e) {
+ //expected
+ }
+ }
+
+ public void test_insertID() {
+ try {
+ testBuffer.insert(-1, Double.MAX_VALUE);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.insert(testBuffer.length() + 1, Double.MAX_VALUE);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_insertIF() {
+ try {
+ testBuffer.insert(-1, Float.MAX_VALUE);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.insert(testBuffer.length() + 1, Float.MAX_VALUE);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_insertII() {
+ try {
+ testBuffer.insert(-1, Integer.MAX_VALUE);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.insert(testBuffer.length() + 1, Integer.MAX_VALUE);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_insertIJ() {
+ try {
+ testBuffer.insert(-1, Long.MAX_VALUE);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.insert(testBuffer.length() + 1, Long.MAX_VALUE);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_insertILjava_lang_Object() {
+ Object obj1 = new Object();
+ try {
+ testBuffer.insert(-1, obj1);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.insert(testBuffer.length() + 1, obj1);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_insertILjava_lang_String() {
+ try {
+ testBuffer.insert(-1, "");
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.insert(testBuffer.length() + 1, "");
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_insertIZ() {
+ try {
+ testBuffer.insert(testBuffer.length() + 1, true);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.insert(-1, true);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_replaceIILjava_lang_String() {
+ try {
+ testBuffer.replace(-1, 0, "text");
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.replace(0, -1, "text");
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.replace(2, 1, "text");
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.replace(testBuffer.length() + 1, testBuffer.length() + 1,
+ "text");
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException sioobe) {
+ //expected
+ }
+ }
+
+ public void test_setCharAtIC() {
+ StringBuffer s = new StringBuffer("HelloWorld");
+ try {
+ s.setCharAt(-1, 'Z');
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+ try {
+ s.setCharAt(s.length() + 1, 'Z');
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+ }
+
+ public void test_substringI() {
+ try {
+ testBuffer.substring(testBuffer.length() + 1);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException oobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.substring(-1);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException oobe) {
+ //expected
+ }
+ }
+
+ public void test_substringII() {
+ try {
+ testBuffer.substring(-1, testBuffer.length());
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException oobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.substring(0, -1);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException oobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.substring(2, 1);
+ fail("StringIndexOutOfBoundsException is not thrown.");
+ } catch(StringIndexOutOfBoundsException oobe) {
+ //expected
+ }
+ }
+
+ public void test_subSequence() {
+ assertEquals("Incorrect substring returned", " is",
+ testBuffer.subSequence(4, 7));
+ assertEquals("Incorrect substring returned", "test buffer",
+ testBuffer.subSequence(10, 21));
+ assertEquals("not identical", "This is a test buffer",
+ testBuffer.subSequence(0, testBuffer.length()));
+
+ try {
+ testBuffer.subSequence(0, Integer.MAX_VALUE);
+ fail("IndexOutOfBoundsException was not thrown.");
+ } catch (IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.subSequence(Integer.MAX_VALUE, testBuffer.length());
+ fail("IndexOutOfBoundsException was not thrown.");
+ } catch (IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ testBuffer.subSequence(-1, testBuffer.length());
+ fail("IndexOutOfBoundsException was not thrown.");
+ } catch (IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+ }
+}
diff --git a/luni/src/test/java/libcore/java/lang/OldStringTest.java b/luni/src/test/java/libcore/java/lang/OldStringTest.java
index 42eb048..33c3215 100644
--- a/luni/src/test/java/libcore/java/lang/OldStringTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldStringTest.java
@@ -93,24 +93,21 @@
try {
"Hello World".getBytes(-1, 1, null, 0);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
- //expected
- } catch (NullPointerException e) {
- fail("Threw wrong exception");
+ } catch (IndexOutOfBoundsException expected) {
+ } catch (NullPointerException expected) {
}
try {
"Hello World".getBytes(6, 2, null, 0);
fail("IndexOutOfBoundsException was not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
+ } catch (IndexOutOfBoundsException expected) {
+ } catch (NullPointerException expected) {
}
try {
"Hello World".getBytes(2, 10, new byte[10], 4);
fail("IndexOutOfBoundsException was not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
+ } catch (IndexOutOfBoundsException expected) {
}
}
@@ -118,24 +115,21 @@
try {
"Hello World".getChars(-1, 1, null, 0);
fail("Expected IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
- //expected
- } catch (NullPointerException e) {
- fail("Threw wrong exception");
+ } catch (IndexOutOfBoundsException expected) {
+ } catch (NullPointerException expected) {
}
try {
"Hello World".getChars(6, 2, null, 0);
fail("IndexOutOfBoundsException was not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
+ } catch (IndexOutOfBoundsException expected) {
+ } catch (NullPointerException expected) {
}
try {
"Hello World".getChars(2, 10, new char[10], 4);
fail("IndexOutOfBoundsException was not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
+ } catch (IndexOutOfBoundsException expected) {
}
}
diff --git a/luni/src/test/java/libcore/java/lang/OldSystemTest.java b/luni/src/test/java/libcore/java/lang/OldSystemTest.java
new file mode 100644
index 0000000..dee5bdd
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldSystemTest.java
@@ -0,0 +1,362 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang;
+
+import java.io.IOException;
+import java.nio.channels.Channel;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Vector;
+
+public class OldSystemTest extends junit.framework.TestCase {
+
+ public void test_arraycopyLjava_lang_ObjectILjava_lang_ObjectII() {
+ // Test for method void java.lang.System.arraycopy(java.lang.Object,
+ // int, java.lang.Object, int, int)
+ Integer a[] = new Integer[20];
+ Integer b[] = new Integer[20];
+
+ try {
+ // copy from non array object into Object array
+ System.arraycopy(new Object(), 0, b, 0, 0);
+ fail("ArrayStoreException is not thrown.");
+ } catch(ArrayStoreException ase) {
+ //expected
+ }
+
+ try {
+ // copy from Object array into non array object
+ System.arraycopy(a, 0, new Object(), 0, 0);
+ fail("ArrayStoreException is not thrown.");
+ } catch(ArrayStoreException ase) {
+ //expected
+ }
+
+ try {
+ // copy from primitive array into object array
+ System.arraycopy(new char[] {'a'}, 0, new String[1], 0, 1);
+ fail("ArrayStoreException is not thrown.");
+ } catch(ArrayStoreException ase) {
+ //expected
+ }
+
+ try {
+ // copy from object array into primitive array
+ System.arraycopy(new String[] {"a"}, 0, new char[1], 0, 1);
+ fail("ArrayStoreException is not thrown.");
+ } catch(ArrayStoreException ase) {
+ //expected
+ }
+
+ try {
+ // copy from primitive array into an array of another primitive type
+ System.arraycopy(new char[] {'a'}, 0, new int[1], 0, 1);
+ fail("ArrayStoreException is not thrown.");
+ } catch(ArrayStoreException ase) {
+ //expected
+ }
+
+ try {
+ // copy from object array into an array of another Object type
+ System.arraycopy(new Character[] {'a'}, 0, new Integer[1], 0, 1);
+ fail("ArrayStoreException is not thrown.");
+ } catch(ArrayStoreException ase) {
+ //expected
+ }
+
+ try {
+ // copy from null into an array of a primitive type
+ System.arraycopy(null, 0, new int[1], 0, 1);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+
+ try {
+ // copy from a primitive array into null
+ System.arraycopy(new int[]{'1'}, 0, null, 0, 1);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+
+ try {
+ System.arraycopy(a, a.length + 1, b, 0, 1);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ System.arraycopy(a, -1, b, 0, 1);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ System.arraycopy(a, 0, b, -1, 1);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ System.arraycopy(a, 0, b, 0, -1);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ System.arraycopy(a, 11, b, 0, 10);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ System.arraycopy(a, Integer.MAX_VALUE, b, 0, 10);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ System.arraycopy(a, 0, b, Integer.MAX_VALUE, 10);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+
+ try {
+ System.arraycopy(a, 0, b, 10, Integer.MAX_VALUE);
+ fail("IndexOutOfBoundsException is not thrown.");
+ } catch(IndexOutOfBoundsException ioobe) {
+ //expected
+ }
+ }
+
+ public void test_currentTimeMillis() {
+ // Test for method long java.lang.System.currentTimeMillis()
+ try {
+ long firstRead = System.currentTimeMillis();
+ try {
+ Thread.sleep(150);
+ } catch (InterruptedException e) {
+ }
+ long secondRead = System.currentTimeMillis();
+ assertTrue("Incorrect times returned: " + firstRead + ", "
+ + secondRead, firstRead < secondRead);
+ } catch (Exception e) {
+ fail("Exception during test: " + e.toString());
+ }
+ }
+
+ public void test_getProperties() {
+ String [] props = {"java.vendor.url",
+ "java.class.path", "user.home",
+ "java.class.version", "os.version",
+ "java.vendor", "user.dir",
+ /*"user.timezone",*/ "path.separator",
+ "os.name", "os.arch",
+ "line.separator", "file.separator",
+ "user.name", "java.version", "java.home" };
+
+ Properties p = System.getProperties();
+ assertTrue(p.size() > 0);
+
+ // Ensure spec'ed properties are non-null. See System.getProperties()
+ // spec.
+
+ for (String prop : props) {
+ assertNotNull("There is no property among returned properties: "
+ + prop, p.getProperty(prop));
+ assertNotNull("System property is null: " + prop,
+ System.getProperty(prop));
+ }
+ }
+
+ public void test_getPropertyLjava_lang_String() {
+ try {
+ System.getProperty(null);
+ fail("NullPointerException should be thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+
+ try {
+ System.getProperty("");
+ fail("IllegalArgumentException should be thrown.");
+ } catch(IllegalArgumentException iae) {
+ //expected
+ }
+ }
+
+ public void test_getPropertyLjava_lang_StringLjava_lang_String() {
+ try {
+ System.getProperty(null, "0.0");
+ fail("NullPointerException should be thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+
+ try {
+ System.getProperty("", "0");
+ fail("IllegalArgumentException should be thrown.");
+ } catch(IllegalArgumentException iae) {
+ //expected
+ }
+ }
+
+ public void test_inheritedChannel() throws IOException {
+ Channel iChannel = System.inheritedChannel();
+ assertNull("Incorrect value of channel", iChannel);
+ SelectorProvider sp = SelectorProvider.provider();
+ assertEquals("Incorrect value of channel",
+ sp.inheritedChannel(), iChannel);
+ }
+
+ public void test_clearProperty() {
+ System.setProperty("test", "value");
+ System.clearProperty("test");
+ assertNull("Property was not deleted.", System.getProperty("test"));
+
+ try {
+ System.clearProperty(null);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+
+ try {
+ System.clearProperty("");
+ fail("IllegalArgumentException is not thrown.");
+ } catch(IllegalArgumentException iae) {
+ //expected
+ }
+ }
+
+ public void test_gc() {
+ Runtime rt = Runtime.getRuntime();
+ Vector<StringBuffer> vec = new Vector<StringBuffer>();
+ long beforeTest = rt.freeMemory();
+ while(rt.freeMemory() < beforeTest * 2/3) {
+ vec.add(new StringBuffer(1000));
+ }
+ long beforeGC = rt.freeMemory();
+ System.gc();
+ long afterGC = rt.freeMemory();
+ assertTrue("memory was not released after calling System.gc()." +
+ "before gc: " + beforeGC + "; after gc: " + afterGC,
+ beforeGC < afterGC);
+ }
+
+ public void test_getenv() {
+ // String[] props = { "PATH", "HOME", "USER"};
+ // only PATH of these three exists on android
+ String[] props = { "PATH" };
+
+ Map<String,String> envMap = System.getenv();
+ assertFalse("environment map is empty.", envMap.isEmpty());
+ assertTrue("env map contains less than 3 keys.",
+ props.length < envMap.keySet().size());
+ for (String prop : props) {
+ assertNotNull("There is no property: " + prop,
+ envMap.get(prop));
+ }
+ }
+
+ public void test_getenvLString() {
+ assertNotNull("PATH environment variable is not found",
+ System.getenv("PATH"));
+
+ assertNull("Doesn't return NULL for non existent property",
+ System.getenv("nonexistent.property"));
+
+ try {
+ System.getenv(null);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ }
+
+ public void test_load() {
+ try {
+ Runtime.getRuntime().load("nonExistentLibrary");
+ fail("UnsatisfiedLinkError was not thrown.");
+ } catch(UnsatisfiedLinkError e) {
+ //expected
+ }
+
+ try {
+ System.load("nonExistentLibrary");
+ fail("UnsatisfiedLinkError was not thrown.");
+ } catch(UnsatisfiedLinkError ule) {
+ //expected
+ }
+
+ try {
+ System.load(null);
+ fail("NullPointerException was not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ }
+
+ public void test_loadLibrary() {
+ try {
+ System.loadLibrary("nonExistentLibrary");
+ fail("UnsatisfiedLinkError was not thrown.");
+ } catch(UnsatisfiedLinkError ule) {
+ //expected
+ }
+
+ try {
+ System.loadLibrary(null);
+ fail("NullPointerException was not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ }
+
+ public void test_mapLibraryName() {
+ assertEquals("libname.so", System.mapLibraryName("name"));
+
+ try {
+ System.mapLibraryName(null);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException npe) {
+ //expected
+ }
+ }
+
+ public void test_nanoTime() {
+ long sleepTime = 5000;
+ long beginTime = System.nanoTime();
+ try {
+ Thread.sleep(sleepTime);
+ } catch(Exception e) {
+ fail("Unknown exception was thrown.");
+ }
+ long endTime = System.nanoTime();
+ assertTrue((endTime - beginTime) > sleepTime * 1000000);
+ }
+}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadStateTest.java b/luni/src/test/java/libcore/java/lang/OldThreadStateTest.java
similarity index 76%
rename from luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadStateTest.java
rename to luni/src/test/java/libcore/java/lang/OldThreadStateTest.java
index 1ae2c27..855655e 100644
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadStateTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldThreadStateTest.java
@@ -14,28 +14,16 @@
* limitations under the License.
*/
-package org.apache.harmony.luni.tests.java.lang;
+package libcore.java.lang;
import junit.framework.TestCase;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-@TestTargetClass(Thread.State.class)
-public class ThreadStateTest extends TestCase {
+public class OldThreadStateTest extends TestCase {
Thread.State [] exStates = { Thread.State.NEW, Thread.State.RUNNABLE,
Thread.State.BLOCKED, Thread.State.WAITING,
Thread.State.TIMED_WAITING, Thread.State.TERMINATED };
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {java.lang.String.class}
- )
public void test_valueOfLString(){
String [] spNames = {"NEW", "RUNNABLE", "BLOCKED", "WAITING",
"TIMED_WAITING", "TERMINATED"};
@@ -55,20 +43,12 @@
}
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "values",
- args = {}
- )
public void test_values() {
-
Thread.State [] thStates = Thread.State.values();
assertEquals(exStates.length, thStates.length);
for(Thread.State ts:thStates) {
assertTrue(isContain(ts));
}
-
}
boolean isContain(Thread.State state) {
diff --git a/luni/src/test/java/libcore/java/lang/OldThrowableTest.java b/luni/src/test/java/libcore/java/lang/OldThrowableTest.java
new file mode 100644
index 0000000..a616855
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/OldThrowableTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package libcore.java.lang;
+
+import junit.framework.TestCase;
+
+public class OldThrowableTest extends TestCase {
+
+ public void test_ConstructorLStringLThrowable() {
+ String message = "Test message";
+ NullPointerException npe = new NullPointerException();
+ Throwable thr = new Throwable(message, npe);
+ assertEquals("message is incorrect.", message, thr.getMessage());
+ assertEquals("cause is incorrect.", npe, thr.getCause());
+
+ thr = new Throwable(null, npe);
+ assertNull("message is not null.", thr.getMessage());
+ assertEquals("cause is incorrect.", npe, thr.getCause());
+
+ thr = new Throwable(message, null);
+ assertEquals("message is incorrect.", message, thr.getMessage());
+ assertNull("cause is not null.", thr.getCause());
+ }
+
+ public void test_ConstructorLThrowable() {
+
+ NullPointerException npe = new NullPointerException();
+ Throwable thr = new Throwable(npe);
+
+ assertEquals("Returned cause is incorrect.", npe, thr.getCause());
+
+ thr = new Throwable((Throwable) null);
+ assertNull("The cause is not null.", thr.getCause());
+ }
+
+ public void test_getLocalizedMessage() {
+ String testMessage = "Test message";
+ Throwable e = new Throwable(testMessage);
+ assertEquals("Returned incorrect localized message.",
+ testMessage, e.getLocalizedMessage());
+
+ TestThrowable tt = new TestThrowable(testMessage);
+ assertEquals("localized message", tt.getLocalizedMessage());
+ }
+
+ class TestThrowable extends Throwable {
+
+ public TestThrowable(String message) {
+ super(message);
+ }
+
+ public String getLocalizedMessage() {
+ return "localized message";
+ }
+ }
+
+ public void test_getStackTrace() {
+ String message = "Test message";
+ NullPointerException npe = new NullPointerException();
+ Throwable thr = new Throwable(message, npe);
+ StackTraceElement[] ste = thr.getStackTrace();
+ assertNotNull("Returned stack trace is empty", ste.length != 0);
+ }
+
+ public void test_initCause() {
+ String message = "Test message";
+ NullPointerException npe = new NullPointerException();
+ IllegalArgumentException iae = new IllegalArgumentException();
+ Throwable thr = new Throwable();
+ thr.initCause(iae);
+ assertEquals("getCause returns incorrect cause.", iae, thr.getCause());
+
+ thr = new Throwable("message");
+ thr.initCause(npe);
+ assertEquals("getCause returns incorrect cause.", npe, thr.getCause());
+
+ thr = new Throwable(message, npe);
+ try {
+ thr.initCause(iae);
+ fail("IllegalStateException was not thrown.");
+ } catch(IllegalStateException ise) {
+ //expected
+ }
+
+ thr = new Throwable(npe);
+ try {
+ thr.initCause(iae);
+ fail("IllegalStateException was not thrown.");
+ } catch(IllegalStateException ise) {
+ //expected
+ }
+
+ thr = new Throwable();
+ try {
+ thr.initCause(thr);
+ fail("IllegalArgumentException was not thrown.");
+ } catch(IllegalArgumentException ise) {
+ //expected
+ }
+ }
+
+ public void test_setStackTrace() {
+ NullPointerException npe = new NullPointerException();
+ Throwable thr = new Throwable(npe);
+ StackTraceElement[] ste = thr.getStackTrace();
+ Throwable thr1 = new Throwable(npe);
+ thr1.setStackTrace(ste);
+ assertEquals(ste.length, thr1.getStackTrace().length);
+
+ try {
+ thr.setStackTrace(null);
+ fail("NullPointerException is not thrown.");
+ } catch(NullPointerException np) {
+ //expected
+ }
+ }
+}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AllTests.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AllTests.java
deleted file mode 100644
index 9f5b1b3..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AllTests.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * Listing of all the tests that are to be run.
- */
-public class AllTests {
-
- public static void run() {
- TestRunner.main(new String[] { AllTests.class.getName() });
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Tests for java.lang");
-
- suite.addTestSuite(ArithmeticExceptionTest.class);
- suite.addTestSuite(ArrayIndexOutOfBoundsExceptionTest.class);
- suite.addTestSuite(ArrayStoreExceptionTest.class);
- suite.addTestSuite(AssertionErrorTest.class);
- suite.addTestSuite(BooleanTest.class);
- suite.addTestSuite(ByteTest.class);
- suite.addTestSuite(Character_SubsetTest.class);
- suite.addTestSuite(OldCharacterTest.class);
- suite.addTestSuite(Character_UnicodeBlockTest.class);
- suite.addTestSuite(ClassCastExceptionTest.class);
- suite.addTestSuite(ClassCircularityErrorTest.class);
- suite.addTestSuite(ClassFormatErrorTest.class);
- suite.addTestSuite(ClassLoaderTest.class);
- suite.addTestSuite(ClassNotFoundExceptionTest.class);
- suite.addTestSuite(ClassTest.class);
- suite.addTestSuite(ClassTest2.class);
- suite.addTestSuite(CloneNotSupportedExceptionTest.class);
- suite.addTestSuite(CompilerTest.class);
- suite.addTestSuite(DoubleTest.class);
- suite.addTestSuite(EnumConstantNotPresentExceptionTest.class);
- suite.addTestSuite(ErrorTest.class);
- suite.addTestSuite(ExceptionInInitializerErrorTest.class);
- suite.addTestSuite(ExceptionTest.class);
- suite.addTestSuite(FloatTest.class);
- suite.addTestSuite(IllegalAccessErrorTest.class);
- suite.addTestSuite(IllegalAccessExceptionTest.class);
- suite.addTestSuite(IllegalArgumentExceptionTest.class);
- suite.addTestSuite(IllegalMonitorStateExceptionTest.class);
- suite.addTestSuite(IllegalStateExceptionTest.class);
- suite.addTestSuite(IllegalThreadStateExceptionTest.class);
- suite.addTestSuite(IncompatibleClassChangeErrorTest.class);
- suite.addTestSuite(IndexOutOfBoundsExceptionTest.class);
- suite.addTestSuite(InheritableThreadLocalTest.class);
- suite.addTestSuite(InstantiationErrorTest.class);
- suite.addTestSuite(InstantiationExceptionTest.class);
- suite.addTestSuite(IntegerTest.class);
- suite.addTestSuite(InternalErrorTest.class);
- suite.addTestSuite(InterruptedExceptionTest.class);
- suite.addTestSuite(LinkageErrorTest.class);
- suite.addTestSuite(LongTest.class);
- suite.addTestSuite(MathTest.class);
- suite.addTestSuite(NegativeArraySizeExceptionTest.class);
- suite.addTestSuite(NoClassDefFoundErrorTest.class);
- suite.addTestSuite(NoSuchFieldErrorTest.class);
- suite.addTestSuite(NoSuchFieldExceptionTest.class);
- suite.addTestSuite(NoSuchMethodErrorTest.class);
- suite.addTestSuite(NoSuchMethodExceptionTest.class);
- suite.addTestSuite(NullPointerExceptionTest.class);
- suite.addTestSuite(NumberFormatExceptionTest.class);
- suite.addTestSuite(NumberTest.class);
- suite.addTestSuite(ObjectTest.class);
- suite.addTestSuite(OutOfMemoryErrorTest.class);
- suite.addTestSuite(RuntimeExceptionTest.class);
- suite.addTestSuite(RuntimePermissionTest.class);
- suite.addTestSuite(RuntimeTest.class);
- suite.addTestSuite(SecurityExceptionTest.class);
- suite.addTestSuite(SecurityManagerTest.class);
- suite.addTestSuite(ShortTest.class);
- suite.addTestSuite(StackOverflowErrorTest.class);
- suite.addTestSuite(StackTraceElementTest.class);
- suite.addTestSuite(StrictMathTest.class);
- suite.addTestSuite(StringBuffer2Test.class);
- suite.addTestSuite(StringBufferTest.class);
- suite.addTestSuite(StringBuilderTest.class);
- suite.addTestSuite(StringIndexOutOfBoundsExceptionTest.class);
- suite.addTestSuite(SystemTest.class);
- suite.addTestSuite(ThreadDeathTest.class);
- suite.addTestSuite(ThreadLocalTest.class);
- suite.addTestSuite(ThreadStateTest.class);
- suite.addTestSuite(ThrowableTest.class);
- suite.addTestSuite(TypeNotPresentExceptionTest.class);
- suite.addTestSuite(UnknownErrorTest.class);
- suite.addTestSuite(UnsatisfiedLinkErrorTest.class);
- suite.addTestSuite(UnsupportedOperationExceptionTest.class);
- suite.addTestSuite(UnsupportedClassVersionErrorTest.class);
- suite.addTestSuite(VerifyErrorTest.class);
- suite.addTestSuite(VirtualMachineErrorTest.class);
-
- return suite;
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArithmeticExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArithmeticExceptionTest.java
deleted file mode 100644
index f99be20..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArithmeticExceptionTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class ArithmeticExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.ArithmeticException#ArithmeticException()
- */
- public void test_Constructor() {
- ArithmeticException e = new ArithmeticException();
- assertNull(e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.ArithmeticException#ArithmeticException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- ArithmeticException e = new ArithmeticException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArrayIndexOutOfBoundsExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArrayIndexOutOfBoundsExceptionTest.java
deleted file mode 100644
index c7537c0..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArrayIndexOutOfBoundsExceptionTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class ArrayIndexOutOfBoundsExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException(int)
- */
- public void test_ConstructorI() {
- ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException(-1);
- assertNotNull(e.getMessage());
- assertTrue("Unable to find index value in 'message' property.", e.getMessage().indexOf(
- "-1", 0) >= 0);
-
- }
-
- /**
- * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException()
- */
- public void test_Constructor() {
- ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException();
- assertNull(e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArrayStoreExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArrayStoreExceptionTest.java
deleted file mode 100644
index c8979d0..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ArrayStoreExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class ArrayStoreExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.ArrayStoreException#ArrayStoreException()
- */
- public void test_Constructor() {
- ArrayStoreException e = new ArrayStoreException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.ArrayStoreException#ArrayStoreException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- ArrayStoreException e = new ArrayStoreException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java
deleted file mode 100644
index ce196ba..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class AssertionErrorTest extends TestCase {
-
- public void test_Constructor() {
- AssertionError e = new AssertionError();
- assertNull(e.getMessage());
- assertNull(e.getCause());
- }
-
- public void test_ConstructorObject() {
- Object obj = "toString";
- AssertionError e = new AssertionError(obj);
- assertEquals("toString", e.getMessage());
- assertNull(e.getCause());
-
- NullPointerException npe = new NullPointerException("null value");
- e = new AssertionError(npe);
- assertEquals(npe.toString(), e.getMessage());
- assertSame(npe, e.getCause());
- }
-
- public void test_ConstructorBoolean() {
- AssertionError e = new AssertionError(true);
- assertEquals("true", e.getMessage());
- assertNull(e.getCause());
- }
-
- public void test_ConstructorChar() {
- AssertionError e = new AssertionError('a');
- assertEquals("a", e.getMessage());
- assertNull(e.getCause());
- }
-
- public void test_ConstructorInt() {
- AssertionError e = new AssertionError(1);
- assertEquals("1", e.getMessage());
- assertNull(e.getCause());
- }
-
- public void test_ConstructorLong() {
- AssertionError e = new AssertionError(1L);
- assertEquals("1", e.getMessage());
- assertNull(e.getCause());
- }
-
- public void test_ConstructorFloat() {
- AssertionError e = new AssertionError(1.0F);
- assertEquals("1.0", e.getMessage());
- assertNull(e.getCause());
- }
-
- public void test_ConstructorDouble() {
- AssertionError e = new AssertionError(1.0D);
- assertEquals("1.0", e.getMessage());
- assertNull(e.getCause());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/BooleanTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/BooleanTest.java
deleted file mode 100644
index d6dbb64..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/BooleanTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class BooleanTest extends TestCase {
-
- /**
- * @tests java.lang.Boolean#hashCode()
- */
- public void test_hashCode() {
- assertEquals(1231, Boolean.TRUE.hashCode());
- assertEquals(1237, Boolean.FALSE.hashCode());
- }
-
- /**
- * @tests java.lang.Boolean#Boolean(String)
- */
- public void test_ConstructorLjava_lang_String() {
- assertEquals(Boolean.TRUE, new Boolean("TRUE"));
- assertEquals(Boolean.TRUE, new Boolean("true"));
- assertEquals(Boolean.TRUE, new Boolean("True"));
-
- assertEquals(Boolean.FALSE, new Boolean("yes"));
- assertEquals(Boolean.FALSE, new Boolean("false"));
- }
-
- /**
- * @tests java.lang.Boolean#Boolean(boolean)
- */
- public void test_ConstructorZ() {
- assertEquals(Boolean.TRUE, new Boolean(true));
- assertEquals(Boolean.FALSE, new Boolean(false));
- }
-
- /**
- * @tests java.lang.Boolean#booleanValue()
- */
- public void test_booleanValue() {
- assertTrue(Boolean.TRUE.booleanValue());
- assertFalse(Boolean.FALSE.booleanValue());
- }
-
- /**
- * @tests java.lang.Boolean#equals(Object)
- */
- public void test_equalsLjava_lang_Object() {
- assertTrue(Boolean.TRUE.equals(Boolean.TRUE));
- assertTrue(Boolean.TRUE.equals(new Boolean(true)));
- assertFalse(Boolean.TRUE.equals("true"));
- assertFalse(Boolean.TRUE.equals(null));
- assertFalse(Boolean.FALSE.equals(Boolean.TRUE));
- assertTrue(Boolean.FALSE.equals(Boolean.FALSE));
- assertTrue(Boolean.FALSE.equals(new Boolean(false)));
- }
-
- /**
- * @tests java.lang.Boolean#getBoolean(String)
- */
- public void test_getBooleanLjava_lang_String() {
- System.setProperty(getClass().getName(), "true");
- assertTrue(Boolean.getBoolean(getClass().getName()));
-
- System.setProperty(getClass().getName(), "TRUE");
- assertTrue(Boolean.getBoolean(getClass().getName()));
-
- System.setProperty(getClass().getName(), "false");
- assertFalse(Boolean.getBoolean(getClass().getName()));
- }
-
- /**
- * @tests java.lang.Boolean#toString()
- */
- public void test_toString() {
- assertEquals("true", Boolean.TRUE.toString());
- assertEquals("false", Boolean.FALSE.toString());
- }
-
- /**
- * @tests java.lang.Boolean#toString(boolean)
- */
- public void test_toStringZ() {
- assertEquals("true", Boolean.toString(true));
- assertEquals("false", Boolean.toString(false));
- }
-
- /**
- * @tests java.lang.Boolean#valueOf(String)
- */
- public void test_valueOfLjava_lang_String() {
- assertEquals(Boolean.TRUE, Boolean.valueOf("true"));
- assertEquals(Boolean.FALSE, Boolean.valueOf("false"));
-
- assertEquals(Boolean.TRUE, Boolean.valueOf("TRUE"));
- assertEquals(Boolean.FALSE, Boolean.valueOf("false"));
-
- assertEquals(Boolean.FALSE, Boolean.valueOf(null));
- assertEquals(Boolean.FALSE, Boolean.valueOf(""));
- assertEquals(Boolean.FALSE, Boolean.valueOf("invalid"));
-
- assertTrue("Failed to parse true to true", Boolean.valueOf("true").booleanValue());
- assertTrue("Failed to parse mixed case true to true", Boolean.valueOf("TrUe")
- .booleanValue());
- assertTrue("parsed non-true to true", !Boolean.valueOf("ddddd").booleanValue());
- }
-
- /**
- * @tests java.lang.Boolean#valueOf(boolean)
- */
- public void test_valueOfZ() {
- assertEquals(Boolean.TRUE, Boolean.valueOf(true));
- assertEquals(Boolean.FALSE, Boolean.valueOf(false));
- }
-
- /**
- * @tests java.lang.Boolean#parseBoolean(String)
- */
- public void test_parseBooleanLjava_lang_String() {
- assertTrue(Boolean.parseBoolean("true"));
- assertTrue(Boolean.parseBoolean("TRUE"));
- assertFalse(Boolean.parseBoolean("false"));
- assertFalse(Boolean.parseBoolean(null));
- assertFalse(Boolean.parseBoolean(""));
- assertFalse(Boolean.parseBoolean("invalid"));
- }
-
- /**
- * @tests java.lang.Boolean#compareTo(Boolean)
- */
- public void test_compareToLjava_lang_Boolean() {
- assertTrue(Boolean.TRUE.compareTo(Boolean.TRUE) == 0);
- assertTrue(Boolean.FALSE.compareTo(Boolean.FALSE) == 0);
- assertTrue(Boolean.TRUE.compareTo(Boolean.FALSE) > 0);
- assertTrue(Boolean.FALSE.compareTo(Boolean.TRUE) < 0);
-
- try {
- Boolean.TRUE.compareTo(null);
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ByteTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ByteTest.java
deleted file mode 100644
index 3e14b2b..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ByteTest.java
+++ /dev/null
@@ -1,672 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class ByteTest extends TestCase {
-
- /**
- * @tests java.lang.Byte#valueOf(byte)
- */
- public void test_valueOfB() {
- assertEquals(new Byte(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE));
- assertEquals(new Byte(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE));
- assertEquals(new Byte((byte) 0), Byte.valueOf((byte) 0));
-
- byte b = Byte.MIN_VALUE + 1;
- while (b < Byte.MAX_VALUE) {
- assertEquals(new Byte(b), Byte.valueOf(b));
- assertSame(Byte.valueOf(b), Byte.valueOf(b));
- b++;
- }
- }
-
- /**
- * @tests java.lang.Byte#hashCode()
- */
- public void test_hashCode() {
- assertEquals(1, new Byte((byte) 1).hashCode());
- assertEquals(2, new Byte((byte) 2).hashCode());
- assertEquals(0, new Byte((byte) 0).hashCode());
- assertEquals(-1, new Byte((byte) -1).hashCode());
- }
-
- /**
- * @tests java.lang.Byte#Byte(String)
- */
- public void test_ConstructorLjava_lang_String() {
- assertEquals(new Byte((byte) 0), new Byte("0"));
- assertEquals(new Byte((byte) 1), new Byte("1"));
- assertEquals(new Byte((byte) -1), new Byte("-1"));
-
- try {
- new Byte("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- new Byte("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- new Byte("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- new Byte(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#Byte(byte)
- */
- public void test_ConstructorB() {
- assertEquals(1, new Byte((byte) 1).byteValue());
- assertEquals(2, new Byte((byte) 2).byteValue());
- assertEquals(0, new Byte((byte) 0).byteValue());
- assertEquals(-1, new Byte((byte) -1).byteValue());
- }
-
- /**
- * @tests java.lang.Byte#byteValue()
- */
- public void test_booleanValue() {
- assertEquals(1, new Byte((byte) 1).byteValue());
- assertEquals(2, new Byte((byte) 2).byteValue());
- assertEquals(0, new Byte((byte) 0).byteValue());
- assertEquals(-1, new Byte((byte) -1).byteValue());
- }
-
- /**
- * @tests java.lang.Byte#equals(Object)
- */
- public void test_equalsLjava_lang_Object() {
- assertEquals(new Byte((byte) 0), Byte.valueOf((byte) 0));
- assertEquals(new Byte((byte) 1), Byte.valueOf((byte) 1));
- assertEquals(new Byte((byte) -1), Byte.valueOf((byte) -1));
-
- Byte fixture = new Byte((byte) 25);
- assertEquals(fixture, fixture);
- assertFalse(fixture.equals(null));
- assertFalse(fixture.equals("Not a Byte"));
- }
-
- /**
- * @tests java.lang.Byte#toString()
- */
- public void test_toString() {
- assertEquals("-1", new Byte((byte) -1).toString());
- assertEquals("0", new Byte((byte) 0).toString());
- assertEquals("1", new Byte((byte) 1).toString());
- assertEquals("-1", new Byte((byte) 0xFF).toString());
- }
-
- /**
- * @tests java.lang.Byte#toString(byte)
- */
- public void test_toStringB() {
- assertEquals("-1", Byte.toString((byte) -1));
- assertEquals("0", Byte.toString((byte) 0));
- assertEquals("1", Byte.toString((byte) 1));
- assertEquals("-1", Byte.toString((byte) 0xFF));
- }
-
- /**
- * @tests java.lang.Byte#valueOf(String)
- */
- public void test_valueOfLjava_lang_String() {
- assertEquals(new Byte((byte) 0), Byte.valueOf("0"));
- assertEquals(new Byte((byte) 1), Byte.valueOf("1"));
- assertEquals(new Byte((byte) -1), Byte.valueOf("-1"));
-
- try {
- Byte.valueOf("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.valueOf("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.valueOf("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.valueOf(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#valueOf(String,int)
- */
- public void test_valueOfLjava_lang_StringI() {
- assertEquals(new Byte((byte) 0), Byte.valueOf("0", 10));
- assertEquals(new Byte((byte) 1), Byte.valueOf("1", 10));
- assertEquals(new Byte((byte) -1), Byte.valueOf("-1", 10));
-
- //must be consistent with Character.digit()
- assertEquals(Character.digit('1', 2), Byte.valueOf("1", 2).byteValue());
- assertEquals(Character.digit('F', 16), Byte.valueOf("F", 16).byteValue());
-
- try {
- Byte.valueOf("0x1", 10);
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.valueOf("9.2", 10);
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.valueOf("", 10);
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.valueOf(null, 10);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#parseByte(String)
- */
- public void test_parseByteLjava_lang_String() {
- assertEquals(0, Byte.parseByte("0"));
- assertEquals(1, Byte.parseByte("1"));
- assertEquals(-1, Byte.parseByte("-1"));
-
- try {
- Byte.parseByte("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#parseByte(String,int)
- */
- public void test_parseByteLjava_lang_StringI() {
- assertEquals(0, Byte.parseByte("0", 10));
- assertEquals(1, Byte.parseByte("1", 10));
- assertEquals(-1, Byte.parseByte("-1", 10));
-
- //must be consistent with Character.digit()
- assertEquals(Character.digit('1', 2), Byte.parseByte("1", 2));
- assertEquals(Character.digit('F', 16), Byte.parseByte("F", 16));
-
- try {
- Byte.parseByte("0x1", 10);
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("9.2", 10);
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("", 10);
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte(null, 10);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#decode(String)
- */
- public void test_decodeLjava_lang_String() {
- assertEquals(new Byte((byte) 0), Byte.decode("0"));
- assertEquals(new Byte((byte) 1), Byte.decode("1"));
- assertEquals(new Byte((byte) -1), Byte.decode("-1"));
- assertEquals(new Byte((byte) 0xF), Byte.decode("0xF"));
- assertEquals(new Byte((byte) 0xF), Byte.decode("#F"));
- assertEquals(new Byte((byte) 0xF), Byte.decode("0XF"));
- assertEquals(new Byte((byte) 07), Byte.decode("07"));
-
- try {
- Byte.decode("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.decode("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.decode(null);
- //undocumented NPE, but seems consistent across JREs
- fail("Expected NullPointerException with null string.");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#doubleValue()
- */
- public void test_doubleValue() {
- assertEquals(-1D, new Byte((byte) -1).doubleValue(), 0D);
- assertEquals(0D, new Byte((byte) 0).doubleValue(), 0D);
- assertEquals(1D, new Byte((byte) 1).doubleValue(), 0D);
- }
-
- /**
- * @tests java.lang.Byte#floatValue()
- */
- public void test_floatValue() {
- assertEquals(-1F, new Byte((byte) -1).floatValue(), 0F);
- assertEquals(0F, new Byte((byte) 0).floatValue(), 0F);
- assertEquals(1F, new Byte((byte) 1).floatValue(), 0F);
- }
-
- /**
- * @tests java.lang.Byte#intValue()
- */
- public void test_intValue() {
- assertEquals(-1, new Byte((byte) -1).intValue());
- assertEquals(0, new Byte((byte) 0).intValue());
- assertEquals(1, new Byte((byte) 1).intValue());
- }
-
- /**
- * @tests java.lang.Byte#longValue()
- */
- public void test_longValue() {
- assertEquals(-1L, new Byte((byte) -1).longValue());
- assertEquals(0L, new Byte((byte) 0).longValue());
- assertEquals(1L, new Byte((byte) 1).longValue());
- }
-
- /**
- * @tests java.lang.Byte#shortValue()
- */
- public void test_shortValue() {
- assertEquals(-1, new Byte((byte) -1).shortValue());
- assertEquals(0, new Byte((byte) 0).shortValue());
- assertEquals(1, new Byte((byte) 1).shortValue());
- }
-
- /**
- * @tests java.lang.Byte#compareTo(Byte)
- */
- public void test_compareToLjava_lang_Byte() {
- final Byte min = new Byte(Byte.MIN_VALUE);
- final Byte zero = new Byte((byte) 0);
- final Byte max = new Byte(Byte.MAX_VALUE);
-
- assertTrue(max.compareTo(max) == 0);
- assertTrue(min.compareTo(min) == 0);
- assertTrue(zero.compareTo(zero) == 0);
-
- assertTrue(max.compareTo(zero) > 0);
- assertTrue(max.compareTo(min) > 0);
-
- assertTrue(zero.compareTo(max) < 0);
- assertTrue(zero.compareTo(min) > 0);
-
- assertTrue(min.compareTo(zero) < 0);
- assertTrue(min.compareTo(max) < 0);
-
- try {
- min.compareTo(null);
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#Byte(byte)
- */
- public void test_ConstructorB2() {
- // Test for method java.lang.Byte(byte)
-
- Byte b = new Byte((byte) 127);
- assertTrue("Byte creation failed", b.byteValue() == (byte) 127);
- }
-
- /**
- * @tests java.lang.Byte#Byte(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String2() {
- // Test for method java.lang.Byte(java.lang.String)
-
- Byte b = new Byte("127");
- Byte nb = new Byte("-128");
- assertTrue("Incorrect Byte Object created", b.byteValue() == (byte) 127
- && (nb.byteValue() == (byte) -128));
-
- }
-
- /**
- * @tests java.lang.Byte#byteValue()
- */
- public void test_byteValue() {
- // Test for method byte java.lang.Byte.byteValue()
- assertTrue("Returned incorrect byte value",
- new Byte((byte) 127).byteValue() == (byte) (127));
- }
-
- /**
- * @tests java.lang.Byte#compareTo(java.lang.Byte)
- */
- public void test_compareToLjava_lang_Byte2() {
- // Test for method int java.lang.Byte.compareTo(java.lang.Byte)
- assertTrue("Comparison failed", new Byte((byte) 1).compareTo(new Byte((byte) 2)) < 0);
- assertTrue("Comparison failed", new Byte((byte) 1).compareTo(new Byte((byte) -2)) > 0);
- assertEquals("Comparison failed", 0, new Byte((byte) 1).compareTo(new Byte((byte) 1)));
- }
-
- /**
- * @tests java.lang.Byte#decode(java.lang.String)
- */
- public void test_decodeLjava_lang_String2() {
- // Test for method java.lang.Byte
- // java.lang.Byte.decode(java.lang.String)
- assertTrue("String decoded incorrectly, wanted: 1 got: " + Byte.decode("1").toString(),
- Byte.decode("1").equals(new Byte((byte) 1)));
- assertTrue("String decoded incorrectly, wanted: -1 got: "
- + Byte.decode("-1").toString(), Byte.decode("-1").equals(new Byte((byte) -1)));
- assertTrue("String decoded incorrectly, wanted: 127 got: "
- + Byte.decode("127").toString(), Byte.decode("127")
- .equals(new Byte((byte) 127)));
- assertTrue("String decoded incorrectly, wanted: -128 got: "
- + Byte.decode("-128").toString(), Byte.decode("-128").equals(
- new Byte((byte) -128)));
- assertTrue("String decoded incorrectly, wanted: 127 got: "
- + Byte.decode("0x7f").toString(), Byte.decode("0x7f").equals(
- new Byte((byte) 127)));
- assertTrue("String decoded incorrectly, wanted: -128 got: "
- + Byte.decode("-0x80").toString(), Byte.decode("-0x80").equals(
- new Byte((byte) -128)));
-
- boolean exception = false;
- try {
- Byte.decode("128");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Byte.decode("-129");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Byte.decode("0x80");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Byte.decode("-0x81");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MIN_VALUE - 1", exception);
- }
-
- /**
- * @tests java.lang.Byte#doubleValue()
- */
- public void test_doubleValue2() {
- assertEquals(127D, new Byte((byte) 127).doubleValue(), 0.0);
- }
-
- /**
- * @tests java.lang.Byte#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object2() {
- // Test for method boolean java.lang.Byte.equals(java.lang.Object)
- Byte b1 = new Byte((byte) 90);
- Byte b2 = new Byte((byte) 90);
- Byte b3 = new Byte((byte) -90);
- assertTrue("Equality test failed", b1.equals(b2));
- assertTrue("Equality test failed", !b1.equals(b3));
- }
-
- /**
- * @tests java.lang.Byte#floatValue()
- */
- public void test_floatValue2() {
- assertEquals(127F, new Byte((byte) 127).floatValue(), 0.0);
- }
-
- /**
- * @tests java.lang.Byte#hashCode()
- */
- public void test_hashCode2() {
- // Test for method int java.lang.Byte.hashCode()
- assertEquals("Incorrect hash returned", 127, new Byte((byte) 127).hashCode());
- }
-
- /**
- * @tests java.lang.Byte#intValue()
- */
- public void test_intValue2() {
- // Test for method int java.lang.Byte.intValue()
- assertEquals("Returned incorrect int value", 127, new Byte((byte) 127).intValue());
- }
-
- /**
- * @tests java.lang.Byte#longValue()
- */
- public void test_longValue2() {
- // Test for method long java.lang.Byte.longValue()
- assertEquals("Returned incorrect long value", 127L, new Byte((byte) 127).longValue());
- }
-
- /**
- * @tests java.lang.Byte#parseByte(java.lang.String)
- */
- public void test_parseByteLjava_lang_String2() {
- assertEquals((byte)127, Byte.parseByte("127"));
- assertEquals((byte)-128, Byte.parseByte("-128"));
- assertEquals((byte)0, Byte.parseByte("0"));
- assertEquals((byte)0x80, Byte.parseByte("-128"));
- assertEquals((byte)0x7F, Byte.parseByte("127"));
-
- try {
- Byte.parseByte("-1000");
- fail("No NumberFormatException");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("128");
- fail("No NumberFormatException");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("-129");
- fail("No NumberFormatException");
- } catch (NumberFormatException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#parseByte(java.lang.String, int)
- */
- public void test_parseByteLjava_lang_StringI2() {
- // Test for method byte java.lang.Byte.parseByte(java.lang.String, int)
- byte b = Byte.parseByte("127", 10);
- byte bn = Byte.parseByte("-128", 10);
- assertTrue("Invalid parse of dec byte", b == (byte) 127 && (bn == (byte) -128));
- assertEquals("Failed to parse hex value", 10, Byte.parseByte("A", 16));
- assertEquals("Returned incorrect value for 0 hex", 0, Byte.parseByte("0", 16));
- assertTrue("Returned incorrect value for most negative value hex", Byte.parseByte(
- "-80", 16) == (byte) 0x80);
- assertTrue("Returned incorrect value for most positive value hex", Byte.parseByte("7f",
- 16) == 0x7f);
- assertEquals("Returned incorrect value for 0 decimal", 0, Byte.parseByte("0", 10));
- assertTrue("Returned incorrect value for most negative value decimal", Byte.parseByte(
- "-128", 10) == (byte) 0x80);
- assertTrue("Returned incorrect value for most positive value decimal", Byte.parseByte(
- "127", 10) == 0x7f);
-
- try {
- Byte.parseByte("-1000", 10);
- fail("Failed to throw exception");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("128", 10);
- fail("Failed to throw exception for MAX_VALUE + 1");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("-129", 10);
- fail("Failed to throw exception for MIN_VALUE - 1");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("80", 16);
- fail("Failed to throw exception for hex MAX_VALUE + 1");
- } catch (NumberFormatException e) {
- }
-
- try {
- Byte.parseByte("-81", 16);
- fail("Failed to throw exception for hex MIN_VALUE + 1");
- } catch (NumberFormatException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#shortValue()
- */
- public void test_shortValue2() {
- assertEquals((short)127, new Byte((byte)127).shortValue());
- }
-
- /**
- * @tests java.lang.Byte#toString()
- */
- public void test_toString2() {
- assertEquals("Returned incorrect String", "127", new Byte((byte) 127).toString());
- assertEquals("Returned incorrect String", "-127", new Byte((byte) -127).toString());
- assertEquals("Returned incorrect String", "-128", new Byte((byte) -128).toString());
- }
-
- /**
- * @tests java.lang.Byte#toString(byte)
- */
- public void test_toStringB2() {
- assertEquals("Returned incorrect String", "127", Byte.toString((byte) 127));
- assertEquals("Returned incorrect String", "-127", Byte.toString((byte) -127));
- assertEquals("Returned incorrect String", "-128", Byte.toString((byte) -128));
- }
-
- /**
- * @tests java.lang.Byte#valueOf(java.lang.String)
- */
- public void test_valueOfLjava_lang_String2() {
- assertEquals("Returned incorrect byte", 0, Byte.valueOf("0").byteValue());
- assertEquals("Returned incorrect byte", 127, Byte.valueOf("127").byteValue());
- assertEquals("Returned incorrect byte", -127, Byte.valueOf("-127").byteValue());
- assertEquals("Returned incorrect byte", -128, Byte.valueOf("-128").byteValue());
-
- try {
- Byte.valueOf("128");
- fail("Failed to throw exception when passes value > byte");
- } catch (NumberFormatException e) {
- }
- }
-
- /**
- * @tests java.lang.Byte#valueOf(java.lang.String, int)
- */
- public void test_valueOfLjava_lang_StringI2() {
- assertEquals("Returned incorrect byte", 10, Byte.valueOf("A", 16).byteValue());
- assertEquals("Returned incorrect byte", 127, Byte.valueOf("127", 10).byteValue());
- assertEquals("Returned incorrect byte", -127, Byte.valueOf("-127", 10).byteValue());
- assertEquals("Returned incorrect byte", -128, Byte.valueOf("-128", 10).byteValue());
- assertEquals("Returned incorrect byte", 127, Byte.valueOf("7f", 16).byteValue());
- assertEquals("Returned incorrect byte", -127, Byte.valueOf("-7f", 16).byteValue());
- assertEquals("Returned incorrect byte", -128, Byte.valueOf("-80", 16).byteValue());
-
- try {
- Byte.valueOf("128", 10);
- fail("Failed to throw exception when passes value > byte");
- } catch (NumberFormatException e) {
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/Character_SubsetTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/Character_SubsetTest.java
deleted file mode 100644
index 6845396..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/Character_SubsetTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-@TestTargetClass(Character.Subset.class)
-public class Character_SubsetTest extends TestCase {
-
- /**
- * @tests java.lang.Character.Subset#Character.Subset(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Subset",
- args = {java.lang.String.class}
- )
- public void test_Ctor() {
-
- try {
- // Regression for HARMONY-888
- new Character.Subset(null) {
- };
- fail("No expected NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Character.Subset#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() {
-
- String name = "name";
- Character.Subset subset = new Character.Subset(name) {
- };
- assertSame(name, subset.toString());
- }
-
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "equals",
- args = {java.lang.Object.class}
- )
- public void test_equals() {
- Character.Subset subset1 = new Character.Subset("name") { };
- assertTrue(subset1.equals(subset1));
- assertFalse(subset1.equals(new Character.Subset("name") {}));
- assertFalse(subset1.equals(new Character.Subset("name1") {}));
- assertFalse(subset1.equals(new Integer(0)));
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "hashCode",
- args = {}
- )
- public void test_hashCode() {
- Character.Subset subset1 = new Character.Subset("name") {};
- Character.Subset subset2 = new Character.Subset("name") {};
- Character.Subset subset3 = new Character.Subset("name1") {};
- assertFalse(subset1.hashCode() == subset2.hashCode());
- assertFalse(subset1.hashCode() == subset3.hashCode());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/Character_UnicodeBlockTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/Character_UnicodeBlockTest.java
deleted file mode 100644
index fa6bc9f..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/Character_UnicodeBlockTest.java
+++ /dev/null
@@ -1,879 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class Character_UnicodeBlockTest extends TestCase {
-
- public void test_ofC() {
- assertEquals(Character.UnicodeBlock.BASIC_LATIN, Character.UnicodeBlock.of((char)0x0));
- assertEquals(Character.UnicodeBlock.BASIC_LATIN, Character.UnicodeBlock.of((char)0x7f));
- assertEquals(Character.UnicodeBlock.LATIN_1_SUPPLEMENT, Character.UnicodeBlock.of((char)0x80));
- assertEquals(Character.UnicodeBlock.LATIN_1_SUPPLEMENT, Character.UnicodeBlock.of((char)0xff));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_A, Character.UnicodeBlock.of((char)0x100));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_A, Character.UnicodeBlock.of((char)0x17f));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_B, Character.UnicodeBlock.of((char)0x180));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_B, Character.UnicodeBlock.of((char)0x24f));
- assertEquals(Character.UnicodeBlock.IPA_EXTENSIONS, Character.UnicodeBlock.of((char)0x250));
- assertEquals(Character.UnicodeBlock.IPA_EXTENSIONS, Character.UnicodeBlock.of((char)0x2af));
- assertEquals(Character.UnicodeBlock.SPACING_MODIFIER_LETTERS, Character.UnicodeBlock.of((char)0x2b0));
- assertEquals(Character.UnicodeBlock.SPACING_MODIFIER_LETTERS, Character.UnicodeBlock.of((char)0x2ff));
- assertEquals(Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS, Character.UnicodeBlock.of((char)0x300));
- assertEquals(Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS, Character.UnicodeBlock.of((char)0x36f));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.of((char)0x370));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.of((char)0x3ff));
- assertEquals(Character.UnicodeBlock.CYRILLIC, Character.UnicodeBlock.of((char)0x400));
- assertEquals(Character.UnicodeBlock.CYRILLIC, Character.UnicodeBlock.of((char)0x4ff));
- assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.of((char)0x500));
- assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.of((char)0x52f));
- assertEquals(Character.UnicodeBlock.ARMENIAN, Character.UnicodeBlock.of((char)0x530));
- assertEquals(Character.UnicodeBlock.ARMENIAN, Character.UnicodeBlock.of((char)0x58f));
- assertEquals(Character.UnicodeBlock.HEBREW, Character.UnicodeBlock.of((char)0x590));
- assertEquals(Character.UnicodeBlock.HEBREW, Character.UnicodeBlock.of((char)0x5ff));
- assertEquals(Character.UnicodeBlock.ARABIC, Character.UnicodeBlock.of((char)0x600));
- assertEquals(Character.UnicodeBlock.ARABIC, Character.UnicodeBlock.of((char)0x6ff));
- assertEquals(Character.UnicodeBlock.SYRIAC, Character.UnicodeBlock.of((char)0x700));
- assertEquals(Character.UnicodeBlock.SYRIAC, Character.UnicodeBlock.of((char)0x74f));
- assertNull(Character.UnicodeBlock.of((char)0x750));
- assertNull(Character.UnicodeBlock.of((char)0x77f));
- assertEquals(Character.UnicodeBlock.THAANA, Character.UnicodeBlock.of((char)0x780));
- assertEquals(Character.UnicodeBlock.THAANA, Character.UnicodeBlock.of((char)0x7bf));
- assertNull(Character.UnicodeBlock.of((char)0x7c0));
- assertNull(Character.UnicodeBlock.of((char)0x8ff));
- assertEquals(Character.UnicodeBlock.DEVANAGARI, Character.UnicodeBlock.of((char)0x900));
- assertEquals(Character.UnicodeBlock.DEVANAGARI, Character.UnicodeBlock.of((char)0x97f));
- assertEquals(Character.UnicodeBlock.BENGALI, Character.UnicodeBlock.of((char)0x980));
- assertEquals(Character.UnicodeBlock.BENGALI, Character.UnicodeBlock.of((char)0x9ff));
- assertEquals(Character.UnicodeBlock.GURMUKHI, Character.UnicodeBlock.of((char)0xa00));
- assertEquals(Character.UnicodeBlock.GURMUKHI, Character.UnicodeBlock.of((char)0xa7f));
- assertEquals(Character.UnicodeBlock.GUJARATI, Character.UnicodeBlock.of((char)0xa80));
- assertEquals(Character.UnicodeBlock.GUJARATI, Character.UnicodeBlock.of((char)0xaff));
- assertEquals(Character.UnicodeBlock.ORIYA, Character.UnicodeBlock.of((char)0xb00));
- assertEquals(Character.UnicodeBlock.ORIYA, Character.UnicodeBlock.of((char)0xb7f));
- assertEquals(Character.UnicodeBlock.TAMIL, Character.UnicodeBlock.of((char)0xb80));
- assertEquals(Character.UnicodeBlock.TAMIL, Character.UnicodeBlock.of((char)0xbff));
- assertEquals(Character.UnicodeBlock.TELUGU, Character.UnicodeBlock.of((char)0xc00));
- assertEquals(Character.UnicodeBlock.TELUGU, Character.UnicodeBlock.of((char)0xc7f));
- assertEquals(Character.UnicodeBlock.KANNADA, Character.UnicodeBlock.of((char)0xc80));
- assertEquals(Character.UnicodeBlock.KANNADA, Character.UnicodeBlock.of((char)0xcff));
- assertEquals(Character.UnicodeBlock.MALAYALAM, Character.UnicodeBlock.of((char)0xd00));
- assertEquals(Character.UnicodeBlock.MALAYALAM, Character.UnicodeBlock.of((char)0xd7f));
- assertEquals(Character.UnicodeBlock.SINHALA, Character.UnicodeBlock.of((char)0xd80));
- assertEquals(Character.UnicodeBlock.SINHALA, Character.UnicodeBlock.of((char)0xdff));
- assertEquals(Character.UnicodeBlock.THAI, Character.UnicodeBlock.of((char)0xe00));
- assertEquals(Character.UnicodeBlock.THAI, Character.UnicodeBlock.of((char)0xe7f));
- assertEquals(Character.UnicodeBlock.LAO, Character.UnicodeBlock.of((char)0xe80));
- assertEquals(Character.UnicodeBlock.LAO, Character.UnicodeBlock.of((char)0xeff));
- assertEquals(Character.UnicodeBlock.TIBETAN, Character.UnicodeBlock.of((char)0xf00));
- assertEquals(Character.UnicodeBlock.TIBETAN, Character.UnicodeBlock.of((char)0xfff));
- assertEquals(Character.UnicodeBlock.MYANMAR, Character.UnicodeBlock.of((char)0x1000));
- assertEquals(Character.UnicodeBlock.MYANMAR, Character.UnicodeBlock.of((char)0x109f));
- assertEquals(Character.UnicodeBlock.GEORGIAN, Character.UnicodeBlock.of((char)0x10a0));
- assertEquals(Character.UnicodeBlock.GEORGIAN, Character.UnicodeBlock.of((char)0x10ff));
- assertEquals(Character.UnicodeBlock.HANGUL_JAMO, Character.UnicodeBlock.of((char)0x1100));
- assertEquals(Character.UnicodeBlock.HANGUL_JAMO, Character.UnicodeBlock.of((char)0x11ff));
- assertEquals(Character.UnicodeBlock.ETHIOPIC, Character.UnicodeBlock.of((char)0x1200));
- assertEquals(Character.UnicodeBlock.ETHIOPIC, Character.UnicodeBlock.of((char)0x137f));
- assertNull(Character.UnicodeBlock.of((char)0x1380));
- assertNull(Character.UnicodeBlock.of((char)0x139f));
- assertEquals(Character.UnicodeBlock.CHEROKEE, Character.UnicodeBlock.of((char)0x13a0));
- assertEquals(Character.UnicodeBlock.CHEROKEE, Character.UnicodeBlock.of((char)0x13ff));
- assertEquals(Character.UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, Character.UnicodeBlock.of((char)0x1400));
- assertEquals(Character.UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, Character.UnicodeBlock.of((char)0x167f));
- assertEquals(Character.UnicodeBlock.OGHAM, Character.UnicodeBlock.of((char)0x1680));
- assertEquals(Character.UnicodeBlock.OGHAM, Character.UnicodeBlock.of((char)0x169f));
- assertEquals(Character.UnicodeBlock.RUNIC, Character.UnicodeBlock.of((char)0x16a0));
- assertEquals(Character.UnicodeBlock.RUNIC, Character.UnicodeBlock.of((char)0x16ff));
- assertEquals(Character.UnicodeBlock.TAGALOG, Character.UnicodeBlock.of((char)0x1700));
- assertEquals(Character.UnicodeBlock.TAGALOG, Character.UnicodeBlock.of((char)0x171f));
- assertEquals(Character.UnicodeBlock.HANUNOO, Character.UnicodeBlock.of((char)0x1720));
- assertEquals(Character.UnicodeBlock.HANUNOO, Character.UnicodeBlock.of((char)0x173f));
- assertEquals(Character.UnicodeBlock.BUHID, Character.UnicodeBlock.of((char)0x1740));
- assertEquals(Character.UnicodeBlock.BUHID, Character.UnicodeBlock.of((char)0x175f));
- assertEquals(Character.UnicodeBlock.TAGBANWA, Character.UnicodeBlock.of((char)0x1760));
- assertEquals(Character.UnicodeBlock.TAGBANWA, Character.UnicodeBlock.of((char)0x177f));
- assertEquals(Character.UnicodeBlock.KHMER, Character.UnicodeBlock.of((char)0x1780));
- assertEquals(Character.UnicodeBlock.KHMER, Character.UnicodeBlock.of((char)0x17ff));
- assertEquals(Character.UnicodeBlock.MONGOLIAN, Character.UnicodeBlock.of((char)0x1800));
- assertEquals(Character.UnicodeBlock.MONGOLIAN, Character.UnicodeBlock.of((char)0x18af));
- assertNull(Character.UnicodeBlock.of((char)0x18b0));
- assertNull(Character.UnicodeBlock.of((char)0x18ff));
- assertEquals(Character.UnicodeBlock.LIMBU, Character.UnicodeBlock.of((char)0x1900));
- assertEquals(Character.UnicodeBlock.LIMBU, Character.UnicodeBlock.of((char)0x194f));
- assertEquals(Character.UnicodeBlock.TAI_LE, Character.UnicodeBlock.of((char)0x1950));
- assertEquals(Character.UnicodeBlock.TAI_LE, Character.UnicodeBlock.of((char)0x197f));
- assertNull(Character.UnicodeBlock.of((char)0x1980));
- assertNull(Character.UnicodeBlock.of((char)0x19df));
- assertEquals(Character.UnicodeBlock.KHMER_SYMBOLS, Character.UnicodeBlock.of((char)0x19e0));
- assertEquals(Character.UnicodeBlock.KHMER_SYMBOLS, Character.UnicodeBlock.of((char)0x19ff));
- assertNull(Character.UnicodeBlock.of((char)0x1a00));
- assertNull(Character.UnicodeBlock.of((char)0x1cff));
- assertEquals(Character.UnicodeBlock.PHONETIC_EXTENSIONS, Character.UnicodeBlock.of((char)0x1d00));
- assertEquals(Character.UnicodeBlock.PHONETIC_EXTENSIONS, Character.UnicodeBlock.of((char)0x1d7f));
- assertNull(Character.UnicodeBlock.of((char)0x1d80));
- assertNull(Character.UnicodeBlock.of((char)0x1dff));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, Character.UnicodeBlock.of((char)0x1e00));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, Character.UnicodeBlock.of((char)0x1eff));
- assertEquals(Character.UnicodeBlock.GREEK_EXTENDED, Character.UnicodeBlock.of((char)0x1f00));
- assertEquals(Character.UnicodeBlock.GREEK_EXTENDED, Character.UnicodeBlock.of((char)0x1fff));
- assertEquals(Character.UnicodeBlock.GENERAL_PUNCTUATION, Character.UnicodeBlock.of((char)0x2000));
- assertEquals(Character.UnicodeBlock.GENERAL_PUNCTUATION, Character.UnicodeBlock.of((char)0x206f));
- assertEquals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, Character.UnicodeBlock.of((char)0x2070));
- assertEquals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, Character.UnicodeBlock.of((char)0x209f));
- assertEquals(Character.UnicodeBlock.CURRENCY_SYMBOLS, Character.UnicodeBlock.of((char)0x20a0));
- assertEquals(Character.UnicodeBlock.CURRENCY_SYMBOLS, Character.UnicodeBlock.of((char)0x20cf));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.of((char)0x20d0));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.of((char)0x20ff));
- assertEquals(Character.UnicodeBlock.LETTERLIKE_SYMBOLS, Character.UnicodeBlock.of((char)0x2100));
- assertEquals(Character.UnicodeBlock.LETTERLIKE_SYMBOLS, Character.UnicodeBlock.of((char)0x214f));
- assertEquals(Character.UnicodeBlock.NUMBER_FORMS, Character.UnicodeBlock.of((char)0x2150));
- assertEquals(Character.UnicodeBlock.NUMBER_FORMS, Character.UnicodeBlock.of((char)0x218f));
- assertEquals(Character.UnicodeBlock.ARROWS, Character.UnicodeBlock.of((char)0x2190));
- assertEquals(Character.UnicodeBlock.ARROWS, Character.UnicodeBlock.of((char)0x21ff));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_OPERATORS, Character.UnicodeBlock.of((char)0x2200));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_OPERATORS, Character.UnicodeBlock.of((char)0x22ff));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_TECHNICAL, Character.UnicodeBlock.of((char)0x2300));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_TECHNICAL, Character.UnicodeBlock.of((char)0x23ff));
- assertEquals(Character.UnicodeBlock.CONTROL_PICTURES, Character.UnicodeBlock.of((char)0x2400));
- assertEquals(Character.UnicodeBlock.CONTROL_PICTURES, Character.UnicodeBlock.of((char)0x243f));
- assertEquals(Character.UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, Character.UnicodeBlock.of((char)0x2440));
- assertEquals(Character.UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, Character.UnicodeBlock.of((char)0x245f));
- assertEquals(Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS, Character.UnicodeBlock.of((char)0x2460));
- assertEquals(Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS, Character.UnicodeBlock.of((char)0x24ff));
- assertEquals(Character.UnicodeBlock.BOX_DRAWING, Character.UnicodeBlock.of((char)0x2500));
- assertEquals(Character.UnicodeBlock.BOX_DRAWING, Character.UnicodeBlock.of((char)0x257f));
- assertEquals(Character.UnicodeBlock.BLOCK_ELEMENTS, Character.UnicodeBlock.of((char)0x2580));
- assertEquals(Character.UnicodeBlock.BLOCK_ELEMENTS, Character.UnicodeBlock.of((char)0x259f));
- assertEquals(Character.UnicodeBlock.GEOMETRIC_SHAPES, Character.UnicodeBlock.of((char)0x25a0));
- assertEquals(Character.UnicodeBlock.GEOMETRIC_SHAPES, Character.UnicodeBlock.of((char)0x25ff));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS, Character.UnicodeBlock.of((char)0x2600));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS, Character.UnicodeBlock.of((char)0x26ff));
- assertEquals(Character.UnicodeBlock.DINGBATS, Character.UnicodeBlock.of((char)0x2700));
- assertEquals(Character.UnicodeBlock.DINGBATS, Character.UnicodeBlock.of((char)0x27bf));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, Character.UnicodeBlock.of((char)0x27c0));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, Character.UnicodeBlock.of((char)0x27ef));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_A, Character.UnicodeBlock.of((char)0x27f0));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_A, Character.UnicodeBlock.of((char)0x27ff));
- assertEquals(Character.UnicodeBlock.BRAILLE_PATTERNS, Character.UnicodeBlock.of((char)0x2800));
- assertEquals(Character.UnicodeBlock.BRAILLE_PATTERNS, Character.UnicodeBlock.of((char)0x28ff));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_B, Character.UnicodeBlock.of((char)0x2900));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_B, Character.UnicodeBlock.of((char)0x297f));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, Character.UnicodeBlock.of((char)0x2980));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, Character.UnicodeBlock.of((char)0x29ff));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_MATHEMATICAL_OPERATORS, Character.UnicodeBlock.of((char)0x2a00));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_MATHEMATICAL_OPERATORS, Character.UnicodeBlock.of((char)0x2aff));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_ARROWS, Character.UnicodeBlock.of((char)0x2b00));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_ARROWS, Character.UnicodeBlock.of((char)0x2bff));
- assertNull(Character.UnicodeBlock.of((char)0x2c00));
- assertNull(Character.UnicodeBlock.of((char)0x2e7f));
- assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT, Character.UnicodeBlock.of((char)0x2e80));
- assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT, Character.UnicodeBlock.of((char)0x2eff));
- assertEquals(Character.UnicodeBlock.KANGXI_RADICALS, Character.UnicodeBlock.of((char)0x2f00));
- assertEquals(Character.UnicodeBlock.KANGXI_RADICALS, Character.UnicodeBlock.of((char)0x2fdf));
- assertNull(Character.UnicodeBlock.of((char)0x2fe0));
- assertNull(Character.UnicodeBlock.of((char)0x2fef));
- assertEquals(Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, Character.UnicodeBlock.of((char)0x2ff0));
- assertEquals(Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, Character.UnicodeBlock.of((char)0x2fff));
- assertEquals(Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, Character.UnicodeBlock.of((char)0x3000));
- assertEquals(Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, Character.UnicodeBlock.of((char)0x303f));
- assertEquals(Character.UnicodeBlock.HIRAGANA, Character.UnicodeBlock.of((char)0x3040));
- assertEquals(Character.UnicodeBlock.HIRAGANA, Character.UnicodeBlock.of((char)0x309f));
- assertEquals(Character.UnicodeBlock.KATAKANA, Character.UnicodeBlock.of((char)0x30a0));
- assertEquals(Character.UnicodeBlock.KATAKANA, Character.UnicodeBlock.of((char)0x30ff));
- assertEquals(Character.UnicodeBlock.BOPOMOFO, Character.UnicodeBlock.of((char)0x3100));
- assertEquals(Character.UnicodeBlock.BOPOMOFO, Character.UnicodeBlock.of((char)0x312f));
- assertEquals(Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, Character.UnicodeBlock.of((char)0x3130));
- assertEquals(Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, Character.UnicodeBlock.of((char)0x318f));
- assertEquals(Character.UnicodeBlock.KANBUN, Character.UnicodeBlock.of((char)0x3190));
- assertEquals(Character.UnicodeBlock.KANBUN, Character.UnicodeBlock.of((char)0x319f));
- assertEquals(Character.UnicodeBlock.BOPOMOFO_EXTENDED, Character.UnicodeBlock.of((char)0x31a0));
- assertEquals(Character.UnicodeBlock.BOPOMOFO_EXTENDED, Character.UnicodeBlock.of((char)0x31bf));
- assertNull(Character.UnicodeBlock.of((char)0x31c0));
- assertNull(Character.UnicodeBlock.of((char)0x31ef));
- assertEquals(Character.UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, Character.UnicodeBlock.of((char)0x31f0));
- assertEquals(Character.UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, Character.UnicodeBlock.of((char)0x31ff));
- assertEquals(Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, Character.UnicodeBlock.of((char)0x3200));
- assertEquals(Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, Character.UnicodeBlock.of((char)0x32ff));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY, Character.UnicodeBlock.of((char)0x3300));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY, Character.UnicodeBlock.of((char)0x33ff));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, Character.UnicodeBlock.of((char)0x3400));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, Character.UnicodeBlock.of((char)0x4dbf));
- assertEquals(Character.UnicodeBlock.YIJING_HEXAGRAM_SYMBOLS, Character.UnicodeBlock.of((char)0x4dc0));
- assertEquals(Character.UnicodeBlock.YIJING_HEXAGRAM_SYMBOLS, Character.UnicodeBlock.of((char)0x4dff));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, Character.UnicodeBlock.of((char)0x4e00));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, Character.UnicodeBlock.of((char)0x9fff));
- assertEquals(Character.UnicodeBlock.YI_SYLLABLES, Character.UnicodeBlock.of((char)0xa000));
- assertEquals(Character.UnicodeBlock.YI_SYLLABLES, Character.UnicodeBlock.of((char)0xa48f));
- assertEquals(Character.UnicodeBlock.YI_RADICALS, Character.UnicodeBlock.of((char)0xa490));
- assertEquals(Character.UnicodeBlock.YI_RADICALS, Character.UnicodeBlock.of((char)0xa4cf));
- assertNull(Character.UnicodeBlock.of((char)0xa4d0));
- assertNull(Character.UnicodeBlock.of((char)0xabff));
- assertEquals(Character.UnicodeBlock.HANGUL_SYLLABLES, Character.UnicodeBlock.of((char)0xac00));
- assertEquals(Character.UnicodeBlock.HANGUL_SYLLABLES, Character.UnicodeBlock.of((char)0xd7af));
- assertNull(Character.UnicodeBlock.of((char)0xd7b0));
- assertNull(Character.UnicodeBlock.of((char)0xd7ff));
- assertEquals(Character.UnicodeBlock.HIGH_SURROGATES, Character.UnicodeBlock.of((char)0xd800));
- assertEquals(Character.UnicodeBlock.HIGH_SURROGATES, Character.UnicodeBlock.of((char)0xdb7f));
- assertEquals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, Character.UnicodeBlock.of((char)0xdb80));
- assertEquals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, Character.UnicodeBlock.of((char)0xdbff));
- assertEquals(Character.UnicodeBlock.LOW_SURROGATES, Character.UnicodeBlock.of((char)0xdc00));
- assertEquals(Character.UnicodeBlock.LOW_SURROGATES, Character.UnicodeBlock.of((char)0xdfff));
- assertEquals(Character.UnicodeBlock.PRIVATE_USE_AREA, Character.UnicodeBlock.of((char)0xe000));
- assertEquals(Character.UnicodeBlock.PRIVATE_USE_AREA, Character.UnicodeBlock.of((char)0xf8ff));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, Character.UnicodeBlock.of((char)0xf900));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, Character.UnicodeBlock.of((char)0xfaff));
- assertEquals(Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, Character.UnicodeBlock.of((char)0xfb00));
- assertEquals(Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, Character.UnicodeBlock.of((char)0xfb4f));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, Character.UnicodeBlock.of((char)0xfb50));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, Character.UnicodeBlock.of((char)0xfdff));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS, Character.UnicodeBlock.of((char)0xfe00));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS, Character.UnicodeBlock.of((char)0xfe0f));
- assertNull(Character.UnicodeBlock.of((char)0xfe10));
- assertNull(Character.UnicodeBlock.of((char)0xfe1f));
- assertEquals(Character.UnicodeBlock.COMBINING_HALF_MARKS, Character.UnicodeBlock.of((char)0xfe20));
- assertEquals(Character.UnicodeBlock.COMBINING_HALF_MARKS, Character.UnicodeBlock.of((char)0xfe2f));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS, Character.UnicodeBlock.of((char)0xfe30));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS, Character.UnicodeBlock.of((char)0xfe4f));
- assertEquals(Character.UnicodeBlock.SMALL_FORM_VARIANTS, Character.UnicodeBlock.of((char)0xfe50));
- assertEquals(Character.UnicodeBlock.SMALL_FORM_VARIANTS, Character.UnicodeBlock.of((char)0xfe6f));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, Character.UnicodeBlock.of((char)0xfe70));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, Character.UnicodeBlock.of((char)0xfeff));
- assertEquals(Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, Character.UnicodeBlock.of((char)0xff00));
- assertEquals(Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, Character.UnicodeBlock.of((char)0xffef));
- assertEquals(Character.UnicodeBlock.SPECIALS, Character.UnicodeBlock.of((char)0xfff0));
- assertEquals(Character.UnicodeBlock.SPECIALS, Character.UnicodeBlock.of((char)0xffff));
- }
- public void test_ofI() {
- assertEquals(Character.UnicodeBlock.BASIC_LATIN, Character.UnicodeBlock.of(0x0));
- assertEquals(Character.UnicodeBlock.BASIC_LATIN, Character.UnicodeBlock.of(0x7f));
- assertEquals(Character.UnicodeBlock.LATIN_1_SUPPLEMENT, Character.UnicodeBlock.of(0x80));
- assertEquals(Character.UnicodeBlock.LATIN_1_SUPPLEMENT, Character.UnicodeBlock.of(0xff));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_A, Character.UnicodeBlock.of(0x100));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_A, Character.UnicodeBlock.of(0x17f));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_B, Character.UnicodeBlock.of(0x180));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_B, Character.UnicodeBlock.of(0x24f));
- assertEquals(Character.UnicodeBlock.IPA_EXTENSIONS, Character.UnicodeBlock.of(0x250));
- assertEquals(Character.UnicodeBlock.IPA_EXTENSIONS, Character.UnicodeBlock.of(0x2af));
- assertEquals(Character.UnicodeBlock.SPACING_MODIFIER_LETTERS, Character.UnicodeBlock.of(0x2b0));
- assertEquals(Character.UnicodeBlock.SPACING_MODIFIER_LETTERS, Character.UnicodeBlock.of(0x2ff));
- assertEquals(Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS, Character.UnicodeBlock.of(0x300));
- assertEquals(Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS, Character.UnicodeBlock.of(0x36f));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.of(0x370));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.of(0x3ff));
- assertEquals(Character.UnicodeBlock.CYRILLIC, Character.UnicodeBlock.of(0x400));
- assertEquals(Character.UnicodeBlock.CYRILLIC, Character.UnicodeBlock.of(0x4ff));
- assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.of(0x500));
- assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.of(0x52f));
- assertEquals(Character.UnicodeBlock.ARMENIAN, Character.UnicodeBlock.of(0x530));
- assertEquals(Character.UnicodeBlock.ARMENIAN, Character.UnicodeBlock.of(0x58f));
- assertEquals(Character.UnicodeBlock.HEBREW, Character.UnicodeBlock.of(0x590));
- assertEquals(Character.UnicodeBlock.HEBREW, Character.UnicodeBlock.of(0x5ff));
- assertEquals(Character.UnicodeBlock.ARABIC, Character.UnicodeBlock.of(0x600));
- assertEquals(Character.UnicodeBlock.ARABIC, Character.UnicodeBlock.of(0x6ff));
- assertEquals(Character.UnicodeBlock.SYRIAC, Character.UnicodeBlock.of(0x700));
- assertEquals(Character.UnicodeBlock.SYRIAC, Character.UnicodeBlock.of(0x74f));
- assertNull(Character.UnicodeBlock.of(0x750));
- assertNull(Character.UnicodeBlock.of(0x77f));
- assertEquals(Character.UnicodeBlock.THAANA, Character.UnicodeBlock.of(0x780));
- assertEquals(Character.UnicodeBlock.THAANA, Character.UnicodeBlock.of(0x7bf));
- assertNull(Character.UnicodeBlock.of(0x7c0));
- assertNull(Character.UnicodeBlock.of(0x8ff));
- assertEquals(Character.UnicodeBlock.DEVANAGARI, Character.UnicodeBlock.of(0x900));
- assertEquals(Character.UnicodeBlock.DEVANAGARI, Character.UnicodeBlock.of(0x97f));
- assertEquals(Character.UnicodeBlock.BENGALI, Character.UnicodeBlock.of(0x980));
- assertEquals(Character.UnicodeBlock.BENGALI, Character.UnicodeBlock.of(0x9ff));
- assertEquals(Character.UnicodeBlock.GURMUKHI, Character.UnicodeBlock.of(0xa00));
- assertEquals(Character.UnicodeBlock.GURMUKHI, Character.UnicodeBlock.of(0xa7f));
- assertEquals(Character.UnicodeBlock.GUJARATI, Character.UnicodeBlock.of(0xa80));
- assertEquals(Character.UnicodeBlock.GUJARATI, Character.UnicodeBlock.of(0xaff));
- assertEquals(Character.UnicodeBlock.ORIYA, Character.UnicodeBlock.of(0xb00));
- assertEquals(Character.UnicodeBlock.ORIYA, Character.UnicodeBlock.of(0xb7f));
- assertEquals(Character.UnicodeBlock.TAMIL, Character.UnicodeBlock.of(0xb80));
- assertEquals(Character.UnicodeBlock.TAMIL, Character.UnicodeBlock.of(0xbff));
- assertEquals(Character.UnicodeBlock.TELUGU, Character.UnicodeBlock.of(0xc00));
- assertEquals(Character.UnicodeBlock.TELUGU, Character.UnicodeBlock.of(0xc7f));
- assertEquals(Character.UnicodeBlock.KANNADA, Character.UnicodeBlock.of(0xc80));
- assertEquals(Character.UnicodeBlock.KANNADA, Character.UnicodeBlock.of(0xcff));
- assertEquals(Character.UnicodeBlock.MALAYALAM, Character.UnicodeBlock.of(0xd00));
- assertEquals(Character.UnicodeBlock.MALAYALAM, Character.UnicodeBlock.of(0xd7f));
- assertEquals(Character.UnicodeBlock.SINHALA, Character.UnicodeBlock.of(0xd80));
- assertEquals(Character.UnicodeBlock.SINHALA, Character.UnicodeBlock.of(0xdff));
- assertEquals(Character.UnicodeBlock.THAI, Character.UnicodeBlock.of(0xe00));
- assertEquals(Character.UnicodeBlock.THAI, Character.UnicodeBlock.of(0xe7f));
- assertEquals(Character.UnicodeBlock.LAO, Character.UnicodeBlock.of(0xe80));
- assertEquals(Character.UnicodeBlock.LAO, Character.UnicodeBlock.of(0xeff));
- assertEquals(Character.UnicodeBlock.TIBETAN, Character.UnicodeBlock.of(0xf00));
- assertEquals(Character.UnicodeBlock.TIBETAN, Character.UnicodeBlock.of(0xfff));
- assertEquals(Character.UnicodeBlock.MYANMAR, Character.UnicodeBlock.of(0x1000));
- assertEquals(Character.UnicodeBlock.MYANMAR, Character.UnicodeBlock.of(0x109f));
- assertEquals(Character.UnicodeBlock.GEORGIAN, Character.UnicodeBlock.of(0x10a0));
- assertEquals(Character.UnicodeBlock.GEORGIAN, Character.UnicodeBlock.of(0x10ff));
- assertEquals(Character.UnicodeBlock.HANGUL_JAMO, Character.UnicodeBlock.of(0x1100));
- assertEquals(Character.UnicodeBlock.HANGUL_JAMO, Character.UnicodeBlock.of(0x11ff));
- assertEquals(Character.UnicodeBlock.ETHIOPIC, Character.UnicodeBlock.of(0x1200));
- assertEquals(Character.UnicodeBlock.ETHIOPIC, Character.UnicodeBlock.of(0x137f));
- assertNull(Character.UnicodeBlock.of(0x1380));
- assertNull(Character.UnicodeBlock.of(0x139f));
- assertEquals(Character.UnicodeBlock.CHEROKEE, Character.UnicodeBlock.of(0x13a0));
- assertEquals(Character.UnicodeBlock.CHEROKEE, Character.UnicodeBlock.of(0x13ff));
- assertEquals(Character.UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, Character.UnicodeBlock.of(0x1400));
- assertEquals(Character.UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, Character.UnicodeBlock.of(0x167f));
- assertEquals(Character.UnicodeBlock.OGHAM, Character.UnicodeBlock.of(0x1680));
- assertEquals(Character.UnicodeBlock.OGHAM, Character.UnicodeBlock.of(0x169f));
- assertEquals(Character.UnicodeBlock.RUNIC, Character.UnicodeBlock.of(0x16a0));
- assertEquals(Character.UnicodeBlock.RUNIC, Character.UnicodeBlock.of(0x16ff));
- assertEquals(Character.UnicodeBlock.TAGALOG, Character.UnicodeBlock.of(0x1700));
- assertEquals(Character.UnicodeBlock.TAGALOG, Character.UnicodeBlock.of(0x171f));
- assertEquals(Character.UnicodeBlock.HANUNOO, Character.UnicodeBlock.of(0x1720));
- assertEquals(Character.UnicodeBlock.HANUNOO, Character.UnicodeBlock.of(0x173f));
- assertEquals(Character.UnicodeBlock.BUHID, Character.UnicodeBlock.of(0x1740));
- assertEquals(Character.UnicodeBlock.BUHID, Character.UnicodeBlock.of(0x175f));
- assertEquals(Character.UnicodeBlock.TAGBANWA, Character.UnicodeBlock.of(0x1760));
- assertEquals(Character.UnicodeBlock.TAGBANWA, Character.UnicodeBlock.of(0x177f));
- assertEquals(Character.UnicodeBlock.KHMER, Character.UnicodeBlock.of(0x1780));
- assertEquals(Character.UnicodeBlock.KHMER, Character.UnicodeBlock.of(0x17ff));
- assertEquals(Character.UnicodeBlock.MONGOLIAN, Character.UnicodeBlock.of(0x1800));
- assertEquals(Character.UnicodeBlock.MONGOLIAN, Character.UnicodeBlock.of(0x18af));
- assertNull(Character.UnicodeBlock.of(0x18b0));
- assertNull(Character.UnicodeBlock.of(0x18ff));
- assertEquals(Character.UnicodeBlock.LIMBU, Character.UnicodeBlock.of(0x1900));
- assertEquals(Character.UnicodeBlock.LIMBU, Character.UnicodeBlock.of(0x194f));
- assertEquals(Character.UnicodeBlock.TAI_LE, Character.UnicodeBlock.of(0x1950));
- assertEquals(Character.UnicodeBlock.TAI_LE, Character.UnicodeBlock.of(0x197f));
- assertNull(Character.UnicodeBlock.of(0x1980));
- assertNull(Character.UnicodeBlock.of(0x19df));
- assertEquals(Character.UnicodeBlock.KHMER_SYMBOLS, Character.UnicodeBlock.of(0x19e0));
- assertEquals(Character.UnicodeBlock.KHMER_SYMBOLS, Character.UnicodeBlock.of(0x19ff));
- assertNull(Character.UnicodeBlock.of(0x1a00));
- assertNull(Character.UnicodeBlock.of(0x1cff));
- assertEquals(Character.UnicodeBlock.PHONETIC_EXTENSIONS, Character.UnicodeBlock.of(0x1d00));
- assertEquals(Character.UnicodeBlock.PHONETIC_EXTENSIONS, Character.UnicodeBlock.of(0x1d7f));
- assertNull(Character.UnicodeBlock.of(0x1d80));
- assertNull(Character.UnicodeBlock.of(0x1dff));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, Character.UnicodeBlock.of(0x1e00));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, Character.UnicodeBlock.of(0x1eff));
- assertEquals(Character.UnicodeBlock.GREEK_EXTENDED, Character.UnicodeBlock.of(0x1f00));
- assertEquals(Character.UnicodeBlock.GREEK_EXTENDED, Character.UnicodeBlock.of(0x1fff));
- assertEquals(Character.UnicodeBlock.GENERAL_PUNCTUATION, Character.UnicodeBlock.of(0x2000));
- assertEquals(Character.UnicodeBlock.GENERAL_PUNCTUATION, Character.UnicodeBlock.of(0x206f));
- assertEquals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, Character.UnicodeBlock.of(0x2070));
- assertEquals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, Character.UnicodeBlock.of(0x209f));
- assertEquals(Character.UnicodeBlock.CURRENCY_SYMBOLS, Character.UnicodeBlock.of(0x20a0));
- assertEquals(Character.UnicodeBlock.CURRENCY_SYMBOLS, Character.UnicodeBlock.of(0x20cf));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.of(0x20d0));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.of(0x20ff));
- assertEquals(Character.UnicodeBlock.LETTERLIKE_SYMBOLS, Character.UnicodeBlock.of(0x2100));
- assertEquals(Character.UnicodeBlock.LETTERLIKE_SYMBOLS, Character.UnicodeBlock.of(0x214f));
- assertEquals(Character.UnicodeBlock.NUMBER_FORMS, Character.UnicodeBlock.of(0x2150));
- assertEquals(Character.UnicodeBlock.NUMBER_FORMS, Character.UnicodeBlock.of(0x218f));
- assertEquals(Character.UnicodeBlock.ARROWS, Character.UnicodeBlock.of(0x2190));
- assertEquals(Character.UnicodeBlock.ARROWS, Character.UnicodeBlock.of(0x21ff));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_OPERATORS, Character.UnicodeBlock.of(0x2200));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_OPERATORS, Character.UnicodeBlock.of(0x22ff));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_TECHNICAL, Character.UnicodeBlock.of(0x2300));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_TECHNICAL, Character.UnicodeBlock.of(0x23ff));
- assertEquals(Character.UnicodeBlock.CONTROL_PICTURES, Character.UnicodeBlock.of(0x2400));
- assertEquals(Character.UnicodeBlock.CONTROL_PICTURES, Character.UnicodeBlock.of(0x243f));
- assertEquals(Character.UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, Character.UnicodeBlock.of(0x2440));
- assertEquals(Character.UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, Character.UnicodeBlock.of(0x245f));
- assertEquals(Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS, Character.UnicodeBlock.of(0x2460));
- assertEquals(Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS, Character.UnicodeBlock.of(0x24ff));
- assertEquals(Character.UnicodeBlock.BOX_DRAWING, Character.UnicodeBlock.of(0x2500));
- assertEquals(Character.UnicodeBlock.BOX_DRAWING, Character.UnicodeBlock.of(0x257f));
- assertEquals(Character.UnicodeBlock.BLOCK_ELEMENTS, Character.UnicodeBlock.of(0x2580));
- assertEquals(Character.UnicodeBlock.BLOCK_ELEMENTS, Character.UnicodeBlock.of(0x259f));
- assertEquals(Character.UnicodeBlock.GEOMETRIC_SHAPES, Character.UnicodeBlock.of(0x25a0));
- assertEquals(Character.UnicodeBlock.GEOMETRIC_SHAPES, Character.UnicodeBlock.of(0x25ff));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS, Character.UnicodeBlock.of(0x2600));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS, Character.UnicodeBlock.of(0x26ff));
- assertEquals(Character.UnicodeBlock.DINGBATS, Character.UnicodeBlock.of(0x2700));
- assertEquals(Character.UnicodeBlock.DINGBATS, Character.UnicodeBlock.of(0x27bf));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, Character.UnicodeBlock.of(0x27c0));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, Character.UnicodeBlock.of(0x27ef));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_A, Character.UnicodeBlock.of(0x27f0));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_A, Character.UnicodeBlock.of(0x27ff));
- assertEquals(Character.UnicodeBlock.BRAILLE_PATTERNS, Character.UnicodeBlock.of(0x2800));
- assertEquals(Character.UnicodeBlock.BRAILLE_PATTERNS, Character.UnicodeBlock.of(0x28ff));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_B, Character.UnicodeBlock.of(0x2900));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_B, Character.UnicodeBlock.of(0x297f));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, Character.UnicodeBlock.of(0x2980));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, Character.UnicodeBlock.of(0x29ff));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_MATHEMATICAL_OPERATORS, Character.UnicodeBlock.of(0x2a00));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_MATHEMATICAL_OPERATORS, Character.UnicodeBlock.of(0x2aff));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_ARROWS, Character.UnicodeBlock.of(0x2b00));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_ARROWS, Character.UnicodeBlock.of(0x2bff));
- assertNull(Character.UnicodeBlock.of(0x2c00));
- assertNull(Character.UnicodeBlock.of(0x2e7f));
- assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT, Character.UnicodeBlock.of(0x2e80));
- assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT, Character.UnicodeBlock.of(0x2eff));
- assertEquals(Character.UnicodeBlock.KANGXI_RADICALS, Character.UnicodeBlock.of(0x2f00));
- assertEquals(Character.UnicodeBlock.KANGXI_RADICALS, Character.UnicodeBlock.of(0x2fdf));
- assertNull(Character.UnicodeBlock.of(0x2fe0));
- assertNull(Character.UnicodeBlock.of(0x2fef));
- assertEquals(Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, Character.UnicodeBlock.of(0x2ff0));
- assertEquals(Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, Character.UnicodeBlock.of(0x2fff));
- assertEquals(Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, Character.UnicodeBlock.of(0x3000));
- assertEquals(Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, Character.UnicodeBlock.of(0x303f));
- assertEquals(Character.UnicodeBlock.HIRAGANA, Character.UnicodeBlock.of(0x3040));
- assertEquals(Character.UnicodeBlock.HIRAGANA, Character.UnicodeBlock.of(0x309f));
- assertEquals(Character.UnicodeBlock.KATAKANA, Character.UnicodeBlock.of(0x30a0));
- assertEquals(Character.UnicodeBlock.KATAKANA, Character.UnicodeBlock.of(0x30ff));
- assertEquals(Character.UnicodeBlock.BOPOMOFO, Character.UnicodeBlock.of(0x3100));
- assertEquals(Character.UnicodeBlock.BOPOMOFO, Character.UnicodeBlock.of(0x312f));
- assertEquals(Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, Character.UnicodeBlock.of(0x3130));
- assertEquals(Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, Character.UnicodeBlock.of(0x318f));
- assertEquals(Character.UnicodeBlock.KANBUN, Character.UnicodeBlock.of(0x3190));
- assertEquals(Character.UnicodeBlock.KANBUN, Character.UnicodeBlock.of(0x319f));
- assertEquals(Character.UnicodeBlock.BOPOMOFO_EXTENDED, Character.UnicodeBlock.of(0x31a0));
- assertEquals(Character.UnicodeBlock.BOPOMOFO_EXTENDED, Character.UnicodeBlock.of(0x31bf));
- assertNull(Character.UnicodeBlock.of(0x31c0));
- assertNull(Character.UnicodeBlock.of(0x31ef));
- assertEquals(Character.UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, Character.UnicodeBlock.of(0x31f0));
- assertEquals(Character.UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, Character.UnicodeBlock.of(0x31ff));
- assertEquals(Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, Character.UnicodeBlock.of(0x3200));
- assertEquals(Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, Character.UnicodeBlock.of(0x32ff));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY, Character.UnicodeBlock.of(0x3300));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY, Character.UnicodeBlock.of(0x33ff));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, Character.UnicodeBlock.of(0x3400));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, Character.UnicodeBlock.of(0x4dbf));
- assertEquals(Character.UnicodeBlock.YIJING_HEXAGRAM_SYMBOLS, Character.UnicodeBlock.of(0x4dc0));
- assertEquals(Character.UnicodeBlock.YIJING_HEXAGRAM_SYMBOLS, Character.UnicodeBlock.of(0x4dff));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, Character.UnicodeBlock.of(0x4e00));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, Character.UnicodeBlock.of(0x9fff));
- assertEquals(Character.UnicodeBlock.YI_SYLLABLES, Character.UnicodeBlock.of(0xa000));
- assertEquals(Character.UnicodeBlock.YI_SYLLABLES, Character.UnicodeBlock.of(0xa48f));
- assertEquals(Character.UnicodeBlock.YI_RADICALS, Character.UnicodeBlock.of(0xa490));
- assertEquals(Character.UnicodeBlock.YI_RADICALS, Character.UnicodeBlock.of(0xa4cf));
- assertNull(Character.UnicodeBlock.of(0xa4d0));
- assertNull(Character.UnicodeBlock.of(0xabff));
- assertEquals(Character.UnicodeBlock.HANGUL_SYLLABLES, Character.UnicodeBlock.of(0xac00));
- assertEquals(Character.UnicodeBlock.HANGUL_SYLLABLES, Character.UnicodeBlock.of(0xd7af));
- assertNull(Character.UnicodeBlock.of(0xd7b0));
- assertNull(Character.UnicodeBlock.of(0xd7ff));
- assertEquals(Character.UnicodeBlock.HIGH_SURROGATES, Character.UnicodeBlock.of(0xd800));
- assertEquals(Character.UnicodeBlock.HIGH_SURROGATES, Character.UnicodeBlock.of(0xdb7f));
- assertEquals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, Character.UnicodeBlock.of(0xdb80));
- assertEquals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, Character.UnicodeBlock.of(0xdbff));
- assertEquals(Character.UnicodeBlock.LOW_SURROGATES, Character.UnicodeBlock.of(0xdc00));
- assertEquals(Character.UnicodeBlock.LOW_SURROGATES, Character.UnicodeBlock.of(0xdfff));
- assertEquals(Character.UnicodeBlock.PRIVATE_USE_AREA, Character.UnicodeBlock.of(0xe000));
- assertEquals(Character.UnicodeBlock.PRIVATE_USE_AREA, Character.UnicodeBlock.of(0xf8ff));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, Character.UnicodeBlock.of(0xf900));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, Character.UnicodeBlock.of(0xfaff));
- assertEquals(Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, Character.UnicodeBlock.of(0xfb00));
- assertEquals(Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, Character.UnicodeBlock.of(0xfb4f));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, Character.UnicodeBlock.of(0xfb50));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, Character.UnicodeBlock.of(0xfdff));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS, Character.UnicodeBlock.of(0xfe00));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS, Character.UnicodeBlock.of(0xfe0f));
- assertNull(Character.UnicodeBlock.of(0xfe10));
- assertNull(Character.UnicodeBlock.of(0xfe1f));
- assertEquals(Character.UnicodeBlock.COMBINING_HALF_MARKS, Character.UnicodeBlock.of(0xfe20));
- assertEquals(Character.UnicodeBlock.COMBINING_HALF_MARKS, Character.UnicodeBlock.of(0xfe2f));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS, Character.UnicodeBlock.of(0xfe30));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS, Character.UnicodeBlock.of(0xfe4f));
- assertEquals(Character.UnicodeBlock.SMALL_FORM_VARIANTS, Character.UnicodeBlock.of(0xfe50));
- assertEquals(Character.UnicodeBlock.SMALL_FORM_VARIANTS, Character.UnicodeBlock.of(0xfe6f));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, Character.UnicodeBlock.of(0xfe70));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, Character.UnicodeBlock.of(0xfeff));
- assertEquals(Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, Character.UnicodeBlock.of(0xff00));
- assertEquals(Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, Character.UnicodeBlock.of(0xffef));
- assertEquals(Character.UnicodeBlock.SPECIALS, Character.UnicodeBlock.of(0xfff0));
- assertEquals(Character.UnicodeBlock.SPECIALS, Character.UnicodeBlock.of(0xffff));
- assertEquals(Character.UnicodeBlock.LINEAR_B_SYLLABARY, Character.UnicodeBlock.of(0x10000));
- assertEquals(Character.UnicodeBlock.LINEAR_B_SYLLABARY, Character.UnicodeBlock.of(0x1007f));
- assertEquals(Character.UnicodeBlock.LINEAR_B_IDEOGRAMS, Character.UnicodeBlock.of(0x10080));
- assertEquals(Character.UnicodeBlock.LINEAR_B_IDEOGRAMS, Character.UnicodeBlock.of(0x100ff));
- assertEquals(Character.UnicodeBlock.AEGEAN_NUMBERS, Character.UnicodeBlock.of(0x10100));
- assertEquals(Character.UnicodeBlock.AEGEAN_NUMBERS, Character.UnicodeBlock.of(0x1013f));
- assertNull(Character.UnicodeBlock.of(0x10140));
- assertNull(Character.UnicodeBlock.of(0x102ff));
- assertEquals(Character.UnicodeBlock.OLD_ITALIC, Character.UnicodeBlock.of(0x10300));
- assertEquals(Character.UnicodeBlock.OLD_ITALIC, Character.UnicodeBlock.of(0x1032f));
- assertEquals(Character.UnicodeBlock.GOTHIC, Character.UnicodeBlock.of(0x10330));
- assertEquals(Character.UnicodeBlock.GOTHIC, Character.UnicodeBlock.of(0x1034f));
- assertNull(Character.UnicodeBlock.of(0x10350));
- assertNull(Character.UnicodeBlock.of(0x1037f));
- assertEquals(Character.UnicodeBlock.UGARITIC, Character.UnicodeBlock.of(0x10380));
- assertEquals(Character.UnicodeBlock.UGARITIC, Character.UnicodeBlock.of(0x1039f));
- assertNull(Character.UnicodeBlock.of(0x103a0));
- assertNull(Character.UnicodeBlock.of(0x103ff));
- assertEquals(Character.UnicodeBlock.DESERET, Character.UnicodeBlock.of(0x10400));
- assertEquals(Character.UnicodeBlock.DESERET, Character.UnicodeBlock.of(0x1044f));
- assertEquals(Character.UnicodeBlock.SHAVIAN, Character.UnicodeBlock.of(0x10450));
- assertEquals(Character.UnicodeBlock.SHAVIAN, Character.UnicodeBlock.of(0x1047f));
- assertEquals(Character.UnicodeBlock.OSMANYA, Character.UnicodeBlock.of(0x10480));
- assertEquals(Character.UnicodeBlock.OSMANYA, Character.UnicodeBlock.of(0x104af));
- assertNull(Character.UnicodeBlock.of(0x104b0));
- assertNull(Character.UnicodeBlock.of(0x107ff));
- assertEquals(Character.UnicodeBlock.CYPRIOT_SYLLABARY, Character.UnicodeBlock.of(0x10800));
- assertEquals(Character.UnicodeBlock.CYPRIOT_SYLLABARY, Character.UnicodeBlock.of(0x1083f));
- assertNull(Character.UnicodeBlock.of(0x10840));
- assertNull(Character.UnicodeBlock.of(0x1cfff));
- assertEquals(Character.UnicodeBlock.BYZANTINE_MUSICAL_SYMBOLS, Character.UnicodeBlock.of(0x1d000));
- assertEquals(Character.UnicodeBlock.BYZANTINE_MUSICAL_SYMBOLS, Character.UnicodeBlock.of(0x1d0ff));
- assertEquals(Character.UnicodeBlock.MUSICAL_SYMBOLS, Character.UnicodeBlock.of(0x1d100));
- assertEquals(Character.UnicodeBlock.MUSICAL_SYMBOLS, Character.UnicodeBlock.of(0x1d1ff));
- assertNull(Character.UnicodeBlock.of(0x1d200));
- assertNull(Character.UnicodeBlock.of(0x1d2ff));
- assertEquals(Character.UnicodeBlock.TAI_XUAN_JING_SYMBOLS, Character.UnicodeBlock.of(0x1d300));
- assertEquals(Character.UnicodeBlock.TAI_XUAN_JING_SYMBOLS, Character.UnicodeBlock.of(0x1d35f));
- assertNull(Character.UnicodeBlock.of(0x1d360));
- assertNull(Character.UnicodeBlock.of(0x1d3ff));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_ALPHANUMERIC_SYMBOLS, Character.UnicodeBlock.of(0x1d400));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_ALPHANUMERIC_SYMBOLS, Character.UnicodeBlock.of(0x1d7ff));
- assertNull(Character.UnicodeBlock.of(0x1d800));
- assertNull(Character.UnicodeBlock.of(0x1ffff));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, Character.UnicodeBlock.of(0x20000));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, Character.UnicodeBlock.of(0x2a6df));
- assertNull(Character.UnicodeBlock.of(0x2a6e0));
- assertNull(Character.UnicodeBlock.of(0x2f7ff));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, Character.UnicodeBlock.of(0x2f800));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, Character.UnicodeBlock.of(0x2fa1f));
- assertNull(Character.UnicodeBlock.of(0x2fa20));
- assertNull(Character.UnicodeBlock.of(0xdffff));
- assertEquals(Character.UnicodeBlock.TAGS, Character.UnicodeBlock.of(0xe0000));
- assertEquals(Character.UnicodeBlock.TAGS, Character.UnicodeBlock.of(0xe007f));
- assertNull(Character.UnicodeBlock.of(0xe0080));
- assertNull(Character.UnicodeBlock.of(0xe00ff));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS_SUPPLEMENT, Character.UnicodeBlock.of(0xe0100));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS_SUPPLEMENT, Character.UnicodeBlock.of(0xe01ef));
- assertNull(Character.UnicodeBlock.of(0xe01f0));
- assertNull(Character.UnicodeBlock.of(0xeffff));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A, Character.UnicodeBlock.of(0xf0000));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A, Character.UnicodeBlock.of(0xfffff));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B, Character.UnicodeBlock.of(0x100000));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B, Character.UnicodeBlock.of(0x10ffff));
- }
-
- public void test_ofIExceptions() {
- try {
- Character.UnicodeBlock.of(Character.MAX_CODE_POINT + 1);
- fail("No illegal argument exception");
- } catch(IllegalArgumentException e) {
- }
- }
-
- @SuppressWarnings("deprecation")
- public void test_forNameLjava_lang_String() {
- assertEquals(Character.UnicodeBlock.SURROGATES_AREA, Character.UnicodeBlock.forName("SURROGATES_AREA"));
- assertEquals(Character.UnicodeBlock.BASIC_LATIN, Character.UnicodeBlock.forName("BASIC_LATIN"));
- assertEquals(Character.UnicodeBlock.BASIC_LATIN, Character.UnicodeBlock.forName("Basic Latin"));
- assertEquals(Character.UnicodeBlock.BASIC_LATIN, Character.UnicodeBlock.forName("BasicLatin"));
- assertEquals(Character.UnicodeBlock.LATIN_1_SUPPLEMENT, Character.UnicodeBlock.forName("LATIN_1_SUPPLEMENT"));
- assertEquals(Character.UnicodeBlock.LATIN_1_SUPPLEMENT, Character.UnicodeBlock.forName("Latin-1 Supplement"));
- assertEquals(Character.UnicodeBlock.LATIN_1_SUPPLEMENT, Character.UnicodeBlock.forName("Latin-1Supplement"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_A, Character.UnicodeBlock.forName("LATIN_EXTENDED_A"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_A, Character.UnicodeBlock.forName("Latin Extended-A"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_A, Character.UnicodeBlock.forName("LatinExtended-A"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_B, Character.UnicodeBlock.forName("LATIN_EXTENDED_B"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_B, Character.UnicodeBlock.forName("Latin Extended-B"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_B, Character.UnicodeBlock.forName("LatinExtended-B"));
- assertEquals(Character.UnicodeBlock.IPA_EXTENSIONS, Character.UnicodeBlock.forName("IPA_EXTENSIONS"));
- assertEquals(Character.UnicodeBlock.IPA_EXTENSIONS, Character.UnicodeBlock.forName("IPA Extensions"));
- assertEquals(Character.UnicodeBlock.IPA_EXTENSIONS, Character.UnicodeBlock.forName("IPAExtensions"));
- assertEquals(Character.UnicodeBlock.SPACING_MODIFIER_LETTERS, Character.UnicodeBlock.forName("SPACING_MODIFIER_LETTERS"));
- assertEquals(Character.UnicodeBlock.SPACING_MODIFIER_LETTERS, Character.UnicodeBlock.forName("Spacing Modifier Letters"));
- assertEquals(Character.UnicodeBlock.SPACING_MODIFIER_LETTERS, Character.UnicodeBlock.forName("SpacingModifierLetters"));
- assertEquals(Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS, Character.UnicodeBlock.forName("COMBINING_DIACRITICAL_MARKS"));
- assertEquals(Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS, Character.UnicodeBlock.forName("Combining Diacritical Marks"));
- assertEquals(Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS, Character.UnicodeBlock.forName("CombiningDiacriticalMarks"));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.forName("GREEK"));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.forName("Greek and Coptic"));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.forName("GreekandCoptic"));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.forName("Greek"));
- assertEquals(Character.UnicodeBlock.GREEK, Character.UnicodeBlock.forName("Greek"));
- assertEquals(Character.UnicodeBlock.CYRILLIC, Character.UnicodeBlock.forName("CYRILLIC"));
- assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.forName("CYRILLIC_SUPPLEMENTARY"));
- assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.forName("Cyrillic Supplementary"));
- assertEquals(Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY, Character.UnicodeBlock.forName("CyrillicSupplementary"));
- assertEquals(Character.UnicodeBlock.ARMENIAN, Character.UnicodeBlock.forName("ARMENIAN"));
- assertEquals(Character.UnicodeBlock.HEBREW, Character.UnicodeBlock.forName("HEBREW"));
- assertEquals(Character.UnicodeBlock.ARABIC, Character.UnicodeBlock.forName("ARABIC"));
- assertEquals(Character.UnicodeBlock.SYRIAC, Character.UnicodeBlock.forName("SYRIAC"));
- assertEquals(Character.UnicodeBlock.THAANA, Character.UnicodeBlock.forName("THAANA"));
- assertEquals(Character.UnicodeBlock.DEVANAGARI, Character.UnicodeBlock.forName("DEVANAGARI"));
- assertEquals(Character.UnicodeBlock.BENGALI, Character.UnicodeBlock.forName("BENGALI"));
- assertEquals(Character.UnicodeBlock.GURMUKHI, Character.UnicodeBlock.forName("GURMUKHI"));
- assertEquals(Character.UnicodeBlock.GUJARATI, Character.UnicodeBlock.forName("GUJARATI"));
- assertEquals(Character.UnicodeBlock.ORIYA, Character.UnicodeBlock.forName("ORIYA"));
- assertEquals(Character.UnicodeBlock.TAMIL, Character.UnicodeBlock.forName("TAMIL"));
- assertEquals(Character.UnicodeBlock.TELUGU, Character.UnicodeBlock.forName("TELUGU"));
- assertEquals(Character.UnicodeBlock.KANNADA, Character.UnicodeBlock.forName("KANNADA"));
- assertEquals(Character.UnicodeBlock.MALAYALAM, Character.UnicodeBlock.forName("MALAYALAM"));
- assertEquals(Character.UnicodeBlock.SINHALA, Character.UnicodeBlock.forName("SINHALA"));
- assertEquals(Character.UnicodeBlock.THAI, Character.UnicodeBlock.forName("THAI"));
- assertEquals(Character.UnicodeBlock.LAO, Character.UnicodeBlock.forName("LAO"));
- assertEquals(Character.UnicodeBlock.TIBETAN, Character.UnicodeBlock.forName("TIBETAN"));
- assertEquals(Character.UnicodeBlock.MYANMAR, Character.UnicodeBlock.forName("MYANMAR"));
- assertEquals(Character.UnicodeBlock.GEORGIAN, Character.UnicodeBlock.forName("GEORGIAN"));
- assertEquals(Character.UnicodeBlock.HANGUL_JAMO, Character.UnicodeBlock.forName("HANGUL_JAMO"));
- assertEquals(Character.UnicodeBlock.HANGUL_JAMO, Character.UnicodeBlock.forName("Hangul Jamo"));
- assertEquals(Character.UnicodeBlock.HANGUL_JAMO, Character.UnicodeBlock.forName("HangulJamo"));
- assertEquals(Character.UnicodeBlock.ETHIOPIC, Character.UnicodeBlock.forName("ETHIOPIC"));
- assertEquals(Character.UnicodeBlock.CHEROKEE, Character.UnicodeBlock.forName("CHEROKEE"));
- assertEquals(Character.UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, Character.UnicodeBlock.forName("UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS"));
- assertEquals(Character.UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, Character.UnicodeBlock.forName("Unified Canadian Aboriginal Syllabics"));
- assertEquals(Character.UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, Character.UnicodeBlock.forName("UnifiedCanadianAboriginalSyllabics"));
- assertEquals(Character.UnicodeBlock.OGHAM, Character.UnicodeBlock.forName("OGHAM"));
- assertEquals(Character.UnicodeBlock.RUNIC, Character.UnicodeBlock.forName("RUNIC"));
- assertEquals(Character.UnicodeBlock.TAGALOG, Character.UnicodeBlock.forName("TAGALOG"));
- assertEquals(Character.UnicodeBlock.HANUNOO, Character.UnicodeBlock.forName("HANUNOO"));
- assertEquals(Character.UnicodeBlock.BUHID, Character.UnicodeBlock.forName("BUHID"));
- assertEquals(Character.UnicodeBlock.TAGBANWA, Character.UnicodeBlock.forName("TAGBANWA"));
- assertEquals(Character.UnicodeBlock.KHMER, Character.UnicodeBlock.forName("KHMER"));
- assertEquals(Character.UnicodeBlock.MONGOLIAN, Character.UnicodeBlock.forName("MONGOLIAN"));
- assertEquals(Character.UnicodeBlock.LIMBU, Character.UnicodeBlock.forName("LIMBU"));
- assertEquals(Character.UnicodeBlock.TAI_LE, Character.UnicodeBlock.forName("TAI_LE"));
- assertEquals(Character.UnicodeBlock.TAI_LE, Character.UnicodeBlock.forName("Tai Le"));
- assertEquals(Character.UnicodeBlock.TAI_LE, Character.UnicodeBlock.forName("TaiLe"));
- assertEquals(Character.UnicodeBlock.KHMER_SYMBOLS, Character.UnicodeBlock.forName("KHMER_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.KHMER_SYMBOLS, Character.UnicodeBlock.forName("Khmer Symbols"));
- assertEquals(Character.UnicodeBlock.KHMER_SYMBOLS, Character.UnicodeBlock.forName("KhmerSymbols"));
- assertEquals(Character.UnicodeBlock.PHONETIC_EXTENSIONS, Character.UnicodeBlock.forName("PHONETIC_EXTENSIONS"));
- assertEquals(Character.UnicodeBlock.PHONETIC_EXTENSIONS, Character.UnicodeBlock.forName("Phonetic Extensions"));
- assertEquals(Character.UnicodeBlock.PHONETIC_EXTENSIONS, Character.UnicodeBlock.forName("PhoneticExtensions"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, Character.UnicodeBlock.forName("LATIN_EXTENDED_ADDITIONAL"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, Character.UnicodeBlock.forName("Latin Extended Additional"));
- assertEquals(Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, Character.UnicodeBlock.forName("LatinExtendedAdditional"));
- assertEquals(Character.UnicodeBlock.GREEK_EXTENDED, Character.UnicodeBlock.forName("GREEK_EXTENDED"));
- assertEquals(Character.UnicodeBlock.GREEK_EXTENDED, Character.UnicodeBlock.forName("Greek Extended"));
- assertEquals(Character.UnicodeBlock.GREEK_EXTENDED, Character.UnicodeBlock.forName("GreekExtended"));
- assertEquals(Character.UnicodeBlock.GENERAL_PUNCTUATION, Character.UnicodeBlock.forName("GENERAL_PUNCTUATION"));
- assertEquals(Character.UnicodeBlock.GENERAL_PUNCTUATION, Character.UnicodeBlock.forName("General Punctuation"));
- assertEquals(Character.UnicodeBlock.GENERAL_PUNCTUATION, Character.UnicodeBlock.forName("GeneralPunctuation"));
- assertEquals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, Character.UnicodeBlock.forName("SUPERSCRIPTS_AND_SUBSCRIPTS"));
- assertEquals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, Character.UnicodeBlock.forName("Superscripts and Subscripts"));
- assertEquals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, Character.UnicodeBlock.forName("SuperscriptsandSubscripts"));
- assertEquals(Character.UnicodeBlock.CURRENCY_SYMBOLS, Character.UnicodeBlock.forName("CURRENCY_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.CURRENCY_SYMBOLS, Character.UnicodeBlock.forName("Currency Symbols"));
- assertEquals(Character.UnicodeBlock.CURRENCY_SYMBOLS, Character.UnicodeBlock.forName("CurrencySymbols"));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.forName("COMBINING_MARKS_FOR_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.forName("Combining Diacritical Marks for Symbols"));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.forName("CombiningDiacriticalMarksforSymbols"));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.forName("Combining Marks for Symbols"));
- assertEquals(Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, Character.UnicodeBlock.forName("CombiningMarksforSymbols"));
- assertEquals(Character.UnicodeBlock.LETTERLIKE_SYMBOLS, Character.UnicodeBlock.forName("LETTERLIKE_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.LETTERLIKE_SYMBOLS, Character.UnicodeBlock.forName("Letterlike Symbols"));
- assertEquals(Character.UnicodeBlock.LETTERLIKE_SYMBOLS, Character.UnicodeBlock.forName("LetterlikeSymbols"));
- assertEquals(Character.UnicodeBlock.NUMBER_FORMS, Character.UnicodeBlock.forName("NUMBER_FORMS"));
- assertEquals(Character.UnicodeBlock.NUMBER_FORMS, Character.UnicodeBlock.forName("Number Forms"));
- assertEquals(Character.UnicodeBlock.NUMBER_FORMS, Character.UnicodeBlock.forName("NumberForms"));
- assertEquals(Character.UnicodeBlock.ARROWS, Character.UnicodeBlock.forName("ARROWS"));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_OPERATORS, Character.UnicodeBlock.forName("MATHEMATICAL_OPERATORS"));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_OPERATORS, Character.UnicodeBlock.forName("Mathematical Operators"));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_OPERATORS, Character.UnicodeBlock.forName("MathematicalOperators"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_TECHNICAL, Character.UnicodeBlock.forName("MISCELLANEOUS_TECHNICAL"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_TECHNICAL, Character.UnicodeBlock.forName("Miscellaneous Technical"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_TECHNICAL, Character.UnicodeBlock.forName("MiscellaneousTechnical"));
- assertEquals(Character.UnicodeBlock.CONTROL_PICTURES, Character.UnicodeBlock.forName("CONTROL_PICTURES"));
- assertEquals(Character.UnicodeBlock.CONTROL_PICTURES, Character.UnicodeBlock.forName("Control Pictures"));
- assertEquals(Character.UnicodeBlock.CONTROL_PICTURES, Character.UnicodeBlock.forName("ControlPictures"));
- assertEquals(Character.UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, Character.UnicodeBlock.forName("OPTICAL_CHARACTER_RECOGNITION"));
- assertEquals(Character.UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, Character.UnicodeBlock.forName("Optical Character Recognition"));
- assertEquals(Character.UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, Character.UnicodeBlock.forName("OpticalCharacterRecognition"));
- assertEquals(Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS, Character.UnicodeBlock.forName("ENCLOSED_ALPHANUMERICS"));
- assertEquals(Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS, Character.UnicodeBlock.forName("Enclosed Alphanumerics"));
- assertEquals(Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS, Character.UnicodeBlock.forName("EnclosedAlphanumerics"));
- assertEquals(Character.UnicodeBlock.BOX_DRAWING, Character.UnicodeBlock.forName("BOX_DRAWING"));
- assertEquals(Character.UnicodeBlock.BOX_DRAWING, Character.UnicodeBlock.forName("Box Drawing"));
- assertEquals(Character.UnicodeBlock.BOX_DRAWING, Character.UnicodeBlock.forName("BoxDrawing"));
- assertEquals(Character.UnicodeBlock.BLOCK_ELEMENTS, Character.UnicodeBlock.forName("BLOCK_ELEMENTS"));
- assertEquals(Character.UnicodeBlock.BLOCK_ELEMENTS, Character.UnicodeBlock.forName("Block Elements"));
- assertEquals(Character.UnicodeBlock.BLOCK_ELEMENTS, Character.UnicodeBlock.forName("BlockElements"));
- assertEquals(Character.UnicodeBlock.GEOMETRIC_SHAPES, Character.UnicodeBlock.forName("GEOMETRIC_SHAPES"));
- assertEquals(Character.UnicodeBlock.GEOMETRIC_SHAPES, Character.UnicodeBlock.forName("Geometric Shapes"));
- assertEquals(Character.UnicodeBlock.GEOMETRIC_SHAPES, Character.UnicodeBlock.forName("GeometricShapes"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS, Character.UnicodeBlock.forName("MISCELLANEOUS_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS, Character.UnicodeBlock.forName("Miscellaneous Symbols"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS, Character.UnicodeBlock.forName("MiscellaneousSymbols"));
- assertEquals(Character.UnicodeBlock.DINGBATS, Character.UnicodeBlock.forName("DINGBATS"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, Character.UnicodeBlock.forName("MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, Character.UnicodeBlock.forName("Miscellaneous Mathematical Symbols-A"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A, Character.UnicodeBlock.forName("MiscellaneousMathematicalSymbols-A"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_A, Character.UnicodeBlock.forName("SUPPLEMENTAL_ARROWS_A"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_A, Character.UnicodeBlock.forName("Supplemental Arrows-A"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_A, Character.UnicodeBlock.forName("SupplementalArrows-A"));
- assertEquals(Character.UnicodeBlock.BRAILLE_PATTERNS, Character.UnicodeBlock.forName("BRAILLE_PATTERNS"));
- assertEquals(Character.UnicodeBlock.BRAILLE_PATTERNS, Character.UnicodeBlock.forName("Braille Patterns"));
- assertEquals(Character.UnicodeBlock.BRAILLE_PATTERNS, Character.UnicodeBlock.forName("BraillePatterns"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_B, Character.UnicodeBlock.forName("SUPPLEMENTAL_ARROWS_B"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_B, Character.UnicodeBlock.forName("Supplemental Arrows-B"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_ARROWS_B, Character.UnicodeBlock.forName("SupplementalArrows-B"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, Character.UnicodeBlock.forName("MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, Character.UnicodeBlock.forName("Miscellaneous Mathematical Symbols-B"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B, Character.UnicodeBlock.forName("MiscellaneousMathematicalSymbols-B"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_MATHEMATICAL_OPERATORS, Character.UnicodeBlock.forName("SUPPLEMENTAL_MATHEMATICAL_OPERATORS"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_MATHEMATICAL_OPERATORS, Character.UnicodeBlock.forName("Supplemental Mathematical Operators"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTAL_MATHEMATICAL_OPERATORS, Character.UnicodeBlock.forName("SupplementalMathematicalOperators"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_ARROWS, Character.UnicodeBlock.forName("MISCELLANEOUS_SYMBOLS_AND_ARROWS"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_ARROWS, Character.UnicodeBlock.forName("Miscellaneous Symbols and Arrows"));
- assertEquals(Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_ARROWS, Character.UnicodeBlock.forName("MiscellaneousSymbolsandArrows"));
- assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT, Character.UnicodeBlock.forName("CJK_RADICALS_SUPPLEMENT"));
- assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT, Character.UnicodeBlock.forName("CJK Radicals Supplement"));
- assertEquals(Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT, Character.UnicodeBlock.forName("CJKRadicalsSupplement"));
- assertEquals(Character.UnicodeBlock.KANGXI_RADICALS, Character.UnicodeBlock.forName("KANGXI_RADICALS"));
- assertEquals(Character.UnicodeBlock.KANGXI_RADICALS, Character.UnicodeBlock.forName("Kangxi Radicals"));
- assertEquals(Character.UnicodeBlock.KANGXI_RADICALS, Character.UnicodeBlock.forName("KangxiRadicals"));
- assertEquals(Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, Character.UnicodeBlock.forName("IDEOGRAPHIC_DESCRIPTION_CHARACTERS"));
- assertEquals(Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, Character.UnicodeBlock.forName("Ideographic Description Characters"));
- assertEquals(Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, Character.UnicodeBlock.forName("IdeographicDescriptionCharacters"));
- assertEquals(Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, Character.UnicodeBlock.forName("CJK_SYMBOLS_AND_PUNCTUATION"));
- assertEquals(Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, Character.UnicodeBlock.forName("CJK Symbols and Punctuation"));
- assertEquals(Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, Character.UnicodeBlock.forName("CJKSymbolsandPunctuation"));
- assertEquals(Character.UnicodeBlock.HIRAGANA, Character.UnicodeBlock.forName("HIRAGANA"));
- assertEquals(Character.UnicodeBlock.KATAKANA, Character.UnicodeBlock.forName("KATAKANA"));
- assertEquals(Character.UnicodeBlock.BOPOMOFO, Character.UnicodeBlock.forName("BOPOMOFO"));
- assertEquals(Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, Character.UnicodeBlock.forName("HANGUL_COMPATIBILITY_JAMO"));
- assertEquals(Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, Character.UnicodeBlock.forName("Hangul Compatibility Jamo"));
- assertEquals(Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, Character.UnicodeBlock.forName("HangulCompatibilityJamo"));
- assertEquals(Character.UnicodeBlock.KANBUN, Character.UnicodeBlock.forName("KANBUN"));
- assertEquals(Character.UnicodeBlock.BOPOMOFO_EXTENDED, Character.UnicodeBlock.forName("BOPOMOFO_EXTENDED"));
- assertEquals(Character.UnicodeBlock.BOPOMOFO_EXTENDED, Character.UnicodeBlock.forName("Bopomofo Extended"));
- assertEquals(Character.UnicodeBlock.BOPOMOFO_EXTENDED, Character.UnicodeBlock.forName("BopomofoExtended"));
- assertEquals(Character.UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, Character.UnicodeBlock.forName("KATAKANA_PHONETIC_EXTENSIONS"));
- assertEquals(Character.UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, Character.UnicodeBlock.forName("Katakana Phonetic Extensions"));
- assertEquals(Character.UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, Character.UnicodeBlock.forName("KatakanaPhoneticExtensions"));
- assertEquals(Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, Character.UnicodeBlock.forName("ENCLOSED_CJK_LETTERS_AND_MONTHS"));
- assertEquals(Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, Character.UnicodeBlock.forName("Enclosed CJK Letters and Months"));
- assertEquals(Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, Character.UnicodeBlock.forName("EnclosedCJKLettersandMonths"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY, Character.UnicodeBlock.forName("CJK_COMPATIBILITY"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY, Character.UnicodeBlock.forName("CJK Compatibility"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY, Character.UnicodeBlock.forName("CJKCompatibility"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, Character.UnicodeBlock.forName("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, Character.UnicodeBlock.forName("CJK Unified Ideographs Extension A"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, Character.UnicodeBlock.forName("CJKUnifiedIdeographsExtensionA"));
- assertEquals(Character.UnicodeBlock.YIJING_HEXAGRAM_SYMBOLS, Character.UnicodeBlock.forName("YIJING_HEXAGRAM_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.YIJING_HEXAGRAM_SYMBOLS, Character.UnicodeBlock.forName("Yijing Hexagram Symbols"));
- assertEquals(Character.UnicodeBlock.YIJING_HEXAGRAM_SYMBOLS, Character.UnicodeBlock.forName("YijingHexagramSymbols"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, Character.UnicodeBlock.forName("CJK_UNIFIED_IDEOGRAPHS"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, Character.UnicodeBlock.forName("CJK Unified Ideographs"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, Character.UnicodeBlock.forName("CJKUnifiedIdeographs"));
- assertEquals(Character.UnicodeBlock.YI_SYLLABLES, Character.UnicodeBlock.forName("YI_SYLLABLES"));
- assertEquals(Character.UnicodeBlock.YI_SYLLABLES, Character.UnicodeBlock.forName("Yi Syllables"));
- assertEquals(Character.UnicodeBlock.YI_SYLLABLES, Character.UnicodeBlock.forName("YiSyllables"));
- assertEquals(Character.UnicodeBlock.YI_RADICALS, Character.UnicodeBlock.forName("YI_RADICALS"));
- assertEquals(Character.UnicodeBlock.YI_RADICALS, Character.UnicodeBlock.forName("Yi Radicals"));
- assertEquals(Character.UnicodeBlock.YI_RADICALS, Character.UnicodeBlock.forName("YiRadicals"));
- assertEquals(Character.UnicodeBlock.HANGUL_SYLLABLES, Character.UnicodeBlock.forName("HANGUL_SYLLABLES"));
- assertEquals(Character.UnicodeBlock.HANGUL_SYLLABLES, Character.UnicodeBlock.forName("Hangul Syllables"));
- assertEquals(Character.UnicodeBlock.HANGUL_SYLLABLES, Character.UnicodeBlock.forName("HangulSyllables"));
- assertEquals(Character.UnicodeBlock.HIGH_SURROGATES, Character.UnicodeBlock.forName("HIGH_SURROGATES"));
- assertEquals(Character.UnicodeBlock.HIGH_SURROGATES, Character.UnicodeBlock.forName("High Surrogates"));
- assertEquals(Character.UnicodeBlock.HIGH_SURROGATES, Character.UnicodeBlock.forName("HighSurrogates"));
- assertEquals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, Character.UnicodeBlock.forName("HIGH_PRIVATE_USE_SURROGATES"));
- assertEquals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, Character.UnicodeBlock.forName("High Private Use Surrogates"));
- assertEquals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, Character.UnicodeBlock.forName("HighPrivateUseSurrogates"));
- assertEquals(Character.UnicodeBlock.LOW_SURROGATES, Character.UnicodeBlock.forName("LOW_SURROGATES"));
- assertEquals(Character.UnicodeBlock.LOW_SURROGATES, Character.UnicodeBlock.forName("Low Surrogates"));
- assertEquals(Character.UnicodeBlock.LOW_SURROGATES, Character.UnicodeBlock.forName("LowSurrogates"));
- assertEquals(Character.UnicodeBlock.PRIVATE_USE_AREA, Character.UnicodeBlock.forName("PRIVATE_USE_AREA"));
- assertEquals(Character.UnicodeBlock.PRIVATE_USE_AREA, Character.UnicodeBlock.forName("Private Use Area"));
- assertEquals(Character.UnicodeBlock.PRIVATE_USE_AREA, Character.UnicodeBlock.forName("PrivateUseArea"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, Character.UnicodeBlock.forName("CJK_COMPATIBILITY_IDEOGRAPHS"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, Character.UnicodeBlock.forName("CJK Compatibility Ideographs"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, Character.UnicodeBlock.forName("CJKCompatibilityIdeographs"));
- assertEquals(Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, Character.UnicodeBlock.forName("ALPHABETIC_PRESENTATION_FORMS"));
- assertEquals(Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, Character.UnicodeBlock.forName("Alphabetic Presentation Forms"));
- assertEquals(Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, Character.UnicodeBlock.forName("AlphabeticPresentationForms"));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, Character.UnicodeBlock.forName("ARABIC_PRESENTATION_FORMS_A"));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, Character.UnicodeBlock.forName("Arabic Presentation Forms-A"));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, Character.UnicodeBlock.forName("ArabicPresentationForms-A"));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS, Character.UnicodeBlock.forName("VARIATION_SELECTORS"));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS, Character.UnicodeBlock.forName("Variation Selectors"));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS, Character.UnicodeBlock.forName("VariationSelectors"));
- assertEquals(Character.UnicodeBlock.COMBINING_HALF_MARKS, Character.UnicodeBlock.forName("COMBINING_HALF_MARKS"));
- assertEquals(Character.UnicodeBlock.COMBINING_HALF_MARKS, Character.UnicodeBlock.forName("Combining Half Marks"));
- assertEquals(Character.UnicodeBlock.COMBINING_HALF_MARKS, Character.UnicodeBlock.forName("CombiningHalfMarks"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS, Character.UnicodeBlock.forName("CJK_COMPATIBILITY_FORMS"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS, Character.UnicodeBlock.forName("CJK Compatibility Forms"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS, Character.UnicodeBlock.forName("CJKCompatibilityForms"));
- assertEquals(Character.UnicodeBlock.SMALL_FORM_VARIANTS, Character.UnicodeBlock.forName("SMALL_FORM_VARIANTS"));
- assertEquals(Character.UnicodeBlock.SMALL_FORM_VARIANTS, Character.UnicodeBlock.forName("Small Form Variants"));
- assertEquals(Character.UnicodeBlock.SMALL_FORM_VARIANTS, Character.UnicodeBlock.forName("SmallFormVariants"));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, Character.UnicodeBlock.forName("ARABIC_PRESENTATION_FORMS_B"));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, Character.UnicodeBlock.forName("Arabic Presentation Forms-B"));
- assertEquals(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, Character.UnicodeBlock.forName("ArabicPresentationForms-B"));
- assertEquals(Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, Character.UnicodeBlock.forName("HALFWIDTH_AND_FULLWIDTH_FORMS"));
- assertEquals(Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, Character.UnicodeBlock.forName("Halfwidth and Fullwidth Forms"));
- assertEquals(Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, Character.UnicodeBlock.forName("HalfwidthandFullwidthForms"));
- assertEquals(Character.UnicodeBlock.SPECIALS, Character.UnicodeBlock.forName("SPECIALS"));
- assertEquals(Character.UnicodeBlock.LINEAR_B_SYLLABARY, Character.UnicodeBlock.forName("LINEAR_B_SYLLABARY"));
- assertEquals(Character.UnicodeBlock.LINEAR_B_SYLLABARY, Character.UnicodeBlock.forName("Linear B Syllabary"));
- assertEquals(Character.UnicodeBlock.LINEAR_B_SYLLABARY, Character.UnicodeBlock.forName("LinearBSyllabary"));
- assertEquals(Character.UnicodeBlock.LINEAR_B_IDEOGRAMS, Character.UnicodeBlock.forName("LINEAR_B_IDEOGRAMS"));
- assertEquals(Character.UnicodeBlock.LINEAR_B_IDEOGRAMS, Character.UnicodeBlock.forName("Linear B Ideograms"));
- assertEquals(Character.UnicodeBlock.LINEAR_B_IDEOGRAMS, Character.UnicodeBlock.forName("LinearBIdeograms"));
- assertEquals(Character.UnicodeBlock.AEGEAN_NUMBERS, Character.UnicodeBlock.forName("AEGEAN_NUMBERS"));
- assertEquals(Character.UnicodeBlock.AEGEAN_NUMBERS, Character.UnicodeBlock.forName("Aegean Numbers"));
- assertEquals(Character.UnicodeBlock.AEGEAN_NUMBERS, Character.UnicodeBlock.forName("AegeanNumbers"));
- assertEquals(Character.UnicodeBlock.OLD_ITALIC, Character.UnicodeBlock.forName("OLD_ITALIC"));
- assertEquals(Character.UnicodeBlock.OLD_ITALIC, Character.UnicodeBlock.forName("Old Italic"));
- assertEquals(Character.UnicodeBlock.OLD_ITALIC, Character.UnicodeBlock.forName("OldItalic"));
- assertEquals(Character.UnicodeBlock.GOTHIC, Character.UnicodeBlock.forName("GOTHIC"));
- assertEquals(Character.UnicodeBlock.UGARITIC, Character.UnicodeBlock.forName("UGARITIC"));
- assertEquals(Character.UnicodeBlock.DESERET, Character.UnicodeBlock.forName("DESERET"));
- assertEquals(Character.UnicodeBlock.SHAVIAN, Character.UnicodeBlock.forName("SHAVIAN"));
- assertEquals(Character.UnicodeBlock.OSMANYA, Character.UnicodeBlock.forName("OSMANYA"));
- assertEquals(Character.UnicodeBlock.CYPRIOT_SYLLABARY, Character.UnicodeBlock.forName("CYPRIOT_SYLLABARY"));
- assertEquals(Character.UnicodeBlock.CYPRIOT_SYLLABARY, Character.UnicodeBlock.forName("Cypriot Syllabary"));
- assertEquals(Character.UnicodeBlock.CYPRIOT_SYLLABARY, Character.UnicodeBlock.forName("CypriotSyllabary"));
- assertEquals(Character.UnicodeBlock.BYZANTINE_MUSICAL_SYMBOLS, Character.UnicodeBlock.forName("BYZANTINE_MUSICAL_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.BYZANTINE_MUSICAL_SYMBOLS, Character.UnicodeBlock.forName("Byzantine Musical Symbols"));
- assertEquals(Character.UnicodeBlock.BYZANTINE_MUSICAL_SYMBOLS, Character.UnicodeBlock.forName("ByzantineMusicalSymbols"));
- assertEquals(Character.UnicodeBlock.MUSICAL_SYMBOLS, Character.UnicodeBlock.forName("MUSICAL_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.MUSICAL_SYMBOLS, Character.UnicodeBlock.forName("Musical Symbols"));
- assertEquals(Character.UnicodeBlock.MUSICAL_SYMBOLS, Character.UnicodeBlock.forName("MusicalSymbols"));
- assertEquals(Character.UnicodeBlock.TAI_XUAN_JING_SYMBOLS, Character.UnicodeBlock.forName("TAI_XUAN_JING_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.TAI_XUAN_JING_SYMBOLS, Character.UnicodeBlock.forName("Tai Xuan Jing Symbols"));
- assertEquals(Character.UnicodeBlock.TAI_XUAN_JING_SYMBOLS, Character.UnicodeBlock.forName("TaiXuanJingSymbols"));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_ALPHANUMERIC_SYMBOLS, Character.UnicodeBlock.forName("MATHEMATICAL_ALPHANUMERIC_SYMBOLS"));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_ALPHANUMERIC_SYMBOLS, Character.UnicodeBlock.forName("Mathematical Alphanumeric Symbols"));
- assertEquals(Character.UnicodeBlock.MATHEMATICAL_ALPHANUMERIC_SYMBOLS, Character.UnicodeBlock.forName("MathematicalAlphanumericSymbols"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, Character.UnicodeBlock.forName("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, Character.UnicodeBlock.forName("CJK Unified Ideographs Extension B"));
- assertEquals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, Character.UnicodeBlock.forName("CJKUnifiedIdeographsExtensionB"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, Character.UnicodeBlock.forName("CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, Character.UnicodeBlock.forName("CJK Compatibility Ideographs Supplement"));
- assertEquals(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, Character.UnicodeBlock.forName("CJKCompatibilityIdeographsSupplement"));
- assertEquals(Character.UnicodeBlock.TAGS, Character.UnicodeBlock.forName("TAGS"));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS_SUPPLEMENT, Character.UnicodeBlock.forName("VARIATION_SELECTORS_SUPPLEMENT"));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS_SUPPLEMENT, Character.UnicodeBlock.forName("Variation Selectors Supplement"));
- assertEquals(Character.UnicodeBlock.VARIATION_SELECTORS_SUPPLEMENT, Character.UnicodeBlock.forName("VariationSelectorsSupplement"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A, Character.UnicodeBlock.forName("SUPPLEMENTARY_PRIVATE_USE_AREA_A"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A, Character.UnicodeBlock.forName("Supplementary Private Use Area-A"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A, Character.UnicodeBlock.forName("SupplementaryPrivateUseArea-A"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B, Character.UnicodeBlock.forName("SUPPLEMENTARY_PRIVATE_USE_AREA_B"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B, Character.UnicodeBlock.forName("Supplementary Private Use Area-B"));
- assertEquals(Character.UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B, Character.UnicodeBlock.forName("SupplementaryPrivateUseArea-B"));
- }
-
- public void test_forNameLjava_lang_StringExceptions() {
- try {
- Character.UnicodeBlock.forName(null);
- fail("No NPE");
- } catch(NullPointerException e) {
- }
-
- try {
- Character.UnicodeBlock.forName("INVALID_NAME");
- fail("No illegal argument exception");
- } catch(IllegalArgumentException e) {
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassCastExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassCastExceptionTest.java
deleted file mode 100644
index bc56cef..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassCastExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class ClassCastExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.ClassCastException#ClassCastException()
- */
- public void test_Constructor() {
- ClassCastException e = new ClassCastException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.ClassCastException#ClassCastException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- ClassCastException e = new ClassCastException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassCircularityErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassCircularityErrorTest.java
deleted file mode 100644
index 029e16c..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassCircularityErrorTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase; // android-changed
-
-public class ClassCircularityErrorTest extends TestCase { // android-changed
- // Thrown when a circularity has been detected while initializing a class.
- /**
- * @tests java.lang.ClassCircularityError#ClassCircularityError()
- */
- public void test_ClassCircularityError() {
- new ClassCircularityError();
- }
-
- /**
- * @tests java.lang.ClassCircularityError#ClassCircularityError(java.lang.String)
- */
- public void test_ClassCircularityError_LString() {
- ClassCircularityError e = new ClassCircularityError(
- "Some Error message");
- assertEquals("Wrong message", "Some Error message", e.getMessage());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassFormatErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassFormatErrorTest.java
deleted file mode 100644
index 2bf8678..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassFormatErrorTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase; // android-changed
-
-public class ClassFormatErrorTest extends TestCase { // android-changed
- /**
- * Thrown when the Java Virtual Machine attempts to read a class file and
- * determines that the file is malformed or otherwise cannot be interpreted
- * as a class file.
- */
-
- /**
- * @tests java.lang.ClassFormatError#ClassFormatError()
- */
- public void test_ClassFormatError() {
- new ClassFormatError();
- }
-
- /**
- * @tests java.lang.ClassFormatError#ClassFormatError(java.lang.String)
- */
- public void test_ClassFormatError_LString() {
- ClassFormatError e = new ClassFormatError("Some Error Message");
- assertEquals("Wrong message", "Some Error Message", e.getMessage());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java
deleted file mode 100644
index ca4ae28..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.InputStream;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Policy;
-import java.security.ProtectionDomain;
-import java.security.SecurityPermission;
-
-import junit.framework.TestCase;
-
-public class ClassLoaderTest extends TestCase {
-
- public static volatile int flag;
-
- /**
- * Tests that Classloader.defineClass() assigns appropriate
- * default domains to the defined classes.
- */
- public void test_defineClass_defaultDomain() throws Exception {
- // Regression for HARMONY-765
- DynamicPolicy plc = new DynamicPolicy();
- Policy back = Policy.getPolicy();
- try {
- Policy.setPolicy(plc);
-
- Class<?> a = new Ldr().define();
-
- Permission p = new SecurityPermission("abc");
- assertFalse("impossible! misconfiguration?", a.getProtectionDomain().implies(p));
-
- plc.pc = p.newPermissionCollection();
- plc.pc.add(p);
- assertTrue("default domain is not dynamic", a.getProtectionDomain().implies(p));
- } finally {
- Policy.setPolicy(back);
- }
- }
-
- static class SyncTestClassLoader extends ClassLoader {
- Object lock;
- volatile int numFindClassCalled;
-
- SyncTestClassLoader(Object o) {
- this.lock = o;
- numFindClassCalled = 0;
- }
-
- /*
- * Byte array of bytecode equivalent to the following source code:
- * public class TestClass {
- * }
- */
- private byte[] classData = new byte[] {
- -54, -2, -70, -66, 0, 0, 0, 49, 0, 13,
- 10, 0, 3, 0, 10, 7, 0, 11, 7, 0,
- 12, 1, 0, 6, 60, 105, 110, 105, 116, 62,
- 1, 0, 3, 40, 41, 86, 1, 0, 4, 67,
- 111, 100, 101, 1, 0, 15, 76, 105, 110, 101,
- 78, 117, 109, 98, 101, 114, 84, 97, 98, 108,
- 101, 1, 0, 10, 83, 111, 117, 114, 99, 101,
- 70, 105, 108, 101, 1, 0, 14, 84, 101, 115,
- 116, 67, 108, 97, 115, 115, 46, 106, 97, 118,
- 97, 12, 0, 4, 0, 5, 1, 0, 9, 84,
- 101, 115, 116, 67, 108, 97, 115, 115, 1, 0,
- 16, 106, 97, 118, 97, 47, 108, 97, 110, 103,
- 47, 79, 98, 106, 101, 99, 116, 0, 33, 0,
- 2, 0, 3, 0, 0, 0, 0, 0, 1, 0,
- 1, 0, 4, 0, 5, 0, 1, 0, 6, 0,
- 0, 0, 29, 0, 1, 0, 1, 0, 0, 0,
- 5, 42, -73, 0, 1, -79, 0, 0, 0, 1,
- 0, 7, 0, 0, 0, 6, 0, 1, 0, 0,
- 0, 1, 0, 1, 0, 8, 0, 0, 0, 2,
- 0, 9 };
-
- @Override
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- try {
- while (flag != 2) {
- synchronized (lock) {
- lock.wait();
- }
- }
- } catch (InterruptedException ie) {}
-
- if (name.equals("TestClass")) {
- numFindClassCalled++;
- return defineClass(null, classData, 0, classData.length);
- }
- throw new ClassNotFoundException("Class " + name + " not found.");
- }
- }
-
- static class SyncLoadTestThread extends Thread {
- volatile boolean started;
- ClassLoader cl;
- Class<?> cls;
-
- SyncLoadTestThread(ClassLoader cl) {
- this.cl = cl;
- }
-
- @Override
- public void run() {
- try {
- started = true;
- cls = Class.forName("TestClass", false, cl);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
-
- /**
- * Regression test for HARMONY-1939:
- * 2 threads simultaneously run Class.forName() method for the same classname
- * and the same classloader. It is expected that both threads succeed but
- * class must be defined just once.
- */
- public void test_loadClass_concurrentLoad() throws Exception
- {
- Object lock = new Object();
- SyncTestClassLoader cl = new SyncTestClassLoader(lock);
- SyncLoadTestThread tt1 = new SyncLoadTestThread(cl);
- SyncLoadTestThread tt2 = new SyncLoadTestThread(cl);
- flag = 1;
- tt1.start();
- tt2.start();
-
- while (!tt1.started && !tt2.started) {
- Thread.sleep(100);
- }
-
- flag = 2;
- synchronized (lock) {
- lock.notifyAll();
- }
- tt1.join();
- tt2.join();
-
- assertSame("Bad or redefined class", tt1.cls, tt2.cls);
- assertEquals("Both threads tried to define class", 1, cl.numFindClassCalled);
- }
-
- /**
- * @tests java.lang.ClassLoader#getResource(java.lang.String)
- */
- public void test_getResourceLjava_lang_String() {
- // Test for method java.net.URL
- // java.lang.ClassLoader.getResource(java.lang.String)
- java.net.URL u = ClassLoader.getSystemClassLoader().getResource("hyts_Foo.c");
- assertNotNull("Unable to find resource", u);
- java.io.InputStream is = null;
- try {
- is = u.openStream();
- assertNotNull("Resource returned is invalid", is);
- is.close();
- } catch (java.io.IOException e) {
- fail("IOException getting stream for resource : " + e.getMessage());
- }
- }
-
- /**
- * @tests java.lang.ClassLoader#getResourceAsStream(java.lang.String)
- */
- public void test_getResourceAsStreamLjava_lang_String() {
- // Test for method java.io.InputStream
- // java.lang.ClassLoader.getResourceAsStream(java.lang.String)
- // Need better test...
-
- java.io.InputStream is = null;
- assertNotNull("Failed to find resource: hyts_Foo.c", (is = ClassLoader
- .getSystemClassLoader().getResourceAsStream("hyts_Foo.c")));
- try {
- is.close();
- } catch (java.io.IOException e) {
- fail("Exception during getResourceAsStream: " + e.toString());
- }
- }
-
- /**
- * @tests java.lang.ClassLoader#getSystemClassLoader()
- */
- public void test_getSystemClassLoader() {
- // Test for method java.lang.ClassLoader
- // java.lang.ClassLoader.getSystemClassLoader()
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- java.io.InputStream is = cl.getResourceAsStream("hyts_Foo.c");
- assertNotNull("Failed to find resource from system classpath", is);
- try {
- is.close();
- } catch (java.io.IOException e) {
- }
-
- }
-
- /**
- * @tests java.lang.ClassLoader#getSystemResource(java.lang.String)
- */
- public void test_getSystemResourceLjava_lang_String() {
- // Test for method java.net.URL
- // java.lang.ClassLoader.getSystemResource(java.lang.String)
- // Need better test...
- assertNotNull("Failed to find resource: hyts_Foo.c", ClassLoader
- .getSystemResource("hyts_Foo.c"));
- }
-
-
- //Regression Test for JIRA-2047
- public void test_getResourceAsStream_withSharpChar() throws Exception {
- InputStream in = this.getClass().getClassLoader().getResourceAsStream(
- ClassTest.FILENAME);
- assertNotNull(in);
- in.close();
- }
-}
-
-class DynamicPolicy extends Policy {
-
- public PermissionCollection pc;
-
- @Override
- public PermissionCollection getPermissions(ProtectionDomain pd) {
- return pc;
- }
-
- @Override
- public PermissionCollection getPermissions(CodeSource codesource) {
- return pc;
- }
-
- @Override
- public void refresh() {
- }
-}
-
-class A {
-}
-
-class Ldr extends ClassLoader {
- @SuppressWarnings("deprecation")
- public Class<?> define() throws Exception {
- Package p = getClass().getPackage();
- // Class loader paths use '/' character as separator
- String path = p == null ? "" : p.getName().replace('.', '/') + '/';
- InputStream is = getResourceAsStream(path + "A.class");
- byte[] buf = new byte[512];
- int len = is.read(buf);
- return defineClass(buf, 0, len);
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassNotFoundExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassNotFoundExceptionTest.java
deleted file mode 100644
index 3a26a79..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassNotFoundExceptionTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-public class ClassNotFoundExceptionTest extends TestCase {
- /**
- * Thrown when an application tries to load in a class through its string
- * name using the forName method in class Class.
- */
-
- /**
- * @tests java.lang.ClassNotFoundException#ClassNotFoundException()
- */
- public void test_Constructor() {
- ClassNotFoundException e = new ClassNotFoundException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.ClassNotFoundException#ClassNotFoundException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- ClassNotFoundException e = new ClassNotFoundException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.ClassNotFoundException#ClassNotFoundException(java.lang.String, java.lang.Throwable)
- */
- public void test_ClassNotFoundException_LString_LThrowable() {
- IOException in = new IOException();
- ClassNotFoundException e = new ClassNotFoundException("SomeMessage", in);
- assertEquals("Wrong Exception", in, e.getException());
- assertEquals("Wrong message", "SomeMessage", e.getMessage());
- assertEquals("Wrong cause", in, e.getCause());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
deleted file mode 100644
index 4f373de..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
+++ /dev/null
@@ -1,1806 +0,0 @@
-/*
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.BasicPermission;
-import java.security.DomainCombiner;
-import java.security.Permission;
-import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
-import java.security.Security;
-import java.util.AbstractList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Vector;
-
-import tests.support.Support_ClassLoader;
-import tests.support.resource.Support_Resources;
-import dalvik.annotation.AndroidOnly;
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargetNew;
-
-@SuppressWarnings("deprecation")
-@TestTargetClass(Class.class)
-public class ClassTest extends junit.framework.TestCase {
-
- public static final String FILENAME =
- ClassTest.class.getPackage().getName().replace('.', '/') +
- "/test#.properties";
-
- final String packageName = getClass().getPackage().getName();
- final String classNameInitError1 = packageName + ".TestClass1";
- final String classNameInitError2 = packageName + ".TestClass1B";
- final String classNameLinkageError = packageName + ".TestClass";
- final String sourceJARfile = "illegalClasses.jar";
- final String illegalClassName = "illegalClass";
-
- static class StaticMember$Class {
- class Member2$A {
- }
- }
-
- class Member$Class {
- class Member3$B {
- }
- }
-
- public static class TestClass {
- @SuppressWarnings("unused")
- private int privField = 1;
-
- public int pubField = 2;
-
- private Object cValue = null;
-
- public Object ack = new Object();
-
- @SuppressWarnings("unused")
- private int privMethod() {
- return 1;
- }
-
- public int pubMethod() {
- return 2;
- }
-
- public Object cValue() {
- return cValue;
- }
-
- public TestClass() {
- }
-
- @SuppressWarnings("unused")
- private TestClass(Object o) {
- }
- }
-
- public static class SubTestClass extends TestClass {
- }
-
- interface Intf1 {
- public int field1 = 1;
- public int field2 = 1;
- void test();
- }
-
- interface Intf2 {
- public int field1 = 1;
- void test();
- }
-
- interface Intf3 extends Intf1 {
- public int field1 = 1;
- }
-
- interface Intf4 extends Intf1, Intf2 {
- public int field1 = 1;
- void test2(int a, Object b);
- }
-
- interface Intf5 extends Intf1 {
- }
-
- class Cls1 implements Intf2 {
- public int field1 = 2;
- public int field2 = 2;
- public void test() {
- }
- }
-
- class Cls2 extends Cls1 implements Intf1 {
- public int field1 = 2;
- @Override
- public void test() {
- }
- }
-
- class Cls3 implements Intf3, Intf4 {
- public void test() {
- }
- public void test2(int a, Object b) {
- }
- }
-
- static class Cls4 {
-
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getAnnotations",
- args = {}
- )
- public void test_getAnnotations() {
- Annotation [] annotations = PublicTestClass.class.getAnnotations();
- assertEquals(1, annotations.length);
- assertEquals(TestAnnotation.class, annotations[0].annotationType());
-
- annotations = ExtendTestClass.class.getAnnotations();
- assertEquals(2, annotations.length);
-
- for(int i = 0; i < annotations.length; i++) {
- Class<? extends Annotation> type = annotations[i].annotationType();
- assertTrue("Annotation's type " + i + ": " + type,
- type.equals(Deprecated.class) ||
- type.equals(TestAnnotation.class));
- }
- }
-
- /**
- * @tests java.lang.Class#forName(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.SUFFICIENT,
- notes = "java.lang.LinkageError can't be checked.",
- method = "forName",
- args = {java.lang.String.class}
- )
- @AndroidOnly("harmony specific: test with " +
- "'org.apache.harmony.luni.tests.java.lang.TestClass1'")
- public void test_forNameLjava_lang_String() throws Exception {
-
- assertSame("Class for name failed for java.lang.Object",
- Object.class, Class.forName("java.lang.Object"));
- assertSame("Class for name failed for [[Ljava.lang.Object;",
- Object[][].class, Class.forName("[[Ljava.lang.Object;"));
-
- assertSame("Class for name failed for [I",
- int[].class, Class.forName("[I"));
-
- try {
- Class.forName("int");
- fail();
- } catch (ClassNotFoundException e) {
- }
-
- try {
- Class.forName("byte");
- fail();
- } catch (ClassNotFoundException e) {
- }
- try {
- Class.forName("char");
- fail();
- } catch (ClassNotFoundException e) {
- }
-
- try {
- Class.forName("void");
- fail();
- } catch (ClassNotFoundException e) {
- }
-
- try {
- Class.forName("short");
- fail();
- } catch (ClassNotFoundException e) {
- }
- try {
- Class.forName("long");
- fail();
- } catch (ClassNotFoundException e) {
- }
-
- try {
- Class.forName("boolean");
- fail();
- } catch (ClassNotFoundException e) {
- }
- try {
- Class.forName("float");
- fail();
- } catch (ClassNotFoundException e) {
- }
- try {
- Class.forName("double");
- fail();
- } catch (ClassNotFoundException e) {
- }
-
- //regression test for JIRA 2162
- try {
- Class.forName("%");
- fail("should throw ClassNotFoundException.");
- } catch (ClassNotFoundException e) {
- }
-
- //Regression Test for HARMONY-3332
- String securityProviderClassName;
- int count = 1;
- while ((securityProviderClassName = Security
- .getProperty("security.provider." + count++)) != null) {
- Class.forName(securityProviderClassName);
- }
-
- try {
- Class.forName(classNameInitError1);
- fail("ExceptionInInitializerError or ClassNotFoundException " +
- "expected.");
- } catch (java.lang.ExceptionInInitializerError ie) {
- // Expected for the RI.
- } catch (java.lang.ClassNotFoundException ce) {
- // Expected for Android.
- }
- }
-
- @TestTargetNew(
- level = TestLevel.SUFFICIENT,
- notes = "",
- method = "forName",
- args = {java.lang.String.class, boolean.class, java.lang.ClassLoader.class}
- )
- public void test_forNameLjava_lang_StringLbooleanLClassLoader() throws Exception {
-
- ClassLoader pcl = getClass().getClassLoader();
-
- Class<?> [] classes = {PublicTestClass.class, ExtendTestClass.class,
- ExtendTestClass1.class, TestInterface.class, String.class};
-
- for(int i = 0; i < classes.length; i++) {
- Class<?> clazz = Class.forName(classes[i].getName(), true, pcl);
- assertEquals(classes[i], clazz);
-
- clazz = Class.forName(classes[i].getName(), false, pcl);
- assertEquals(classes[i], clazz);
- }
-
- Class<?> [] systemClasses = {String.class, Integer.class, Object.class,
- Object[].class};
-
- for(int i = 0; i < systemClasses.length; i++) {
- Class<?> clazz = Class.forName(systemClasses[i].getName(), true,
- ClassLoader.getSystemClassLoader());
- assertEquals(systemClasses[i], clazz);
-
- clazz = Class.forName(systemClasses[i].getName(), false,
- ClassLoader.getSystemClassLoader());
- assertEquals(systemClasses[i], clazz);
- }
-
- try {
- Class.forName(null, true, pcl);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
-
- try {
- Class.forName("NotExistClass", true, pcl);
- fail("ClassNotFoundException is not thrown for non existent class.");
- } catch(ClassNotFoundException cnfe) {
- //expected
- }
-
- try {
- Class.forName("String", false, pcl);
- fail("ClassNotFoundException is not thrown for non existent class.");
- } catch(ClassNotFoundException cnfe) {
- //expected
- }
-
- try {
- Class.forName("org.apache.harmony.luni.tests.java.PublicTestClass",
- false, pcl);
- fail("ClassNotFoundException is not thrown for non existent class.");
- } catch(ClassNotFoundException cnfe) {
- //expected
- }
- }
-
- @TestTargetNew(
- level = TestLevel.SUFFICIENT,
- notes = "",
- method = "forName",
- args = {java.lang.String.class, boolean.class, java.lang.ClassLoader.class}
- )
- @AndroidOnly("Class.forName method throws ClassNotFoundException on " +
- "Android.")
- public void test_forNameLjava_lang_StringLbooleanLClassLoader_AndroidOnly() throws Exception {
-
- // Android doesn't support loading class files from a jar.
- try {
-
- URL url = getClass().getClassLoader().getResource(
- packageName.replace(".", "/") + "/" + sourceJARfile);
-
- ClassLoader loader = new URLClassLoader(new URL[] { url },
- getClass().getClassLoader());
- try {
- Class.forName(classNameLinkageError, true, loader);
- fail("LinkageError or ClassNotFoundException expected.");
- } catch (java.lang.LinkageError le) {
- // Expected for the RI.
- } catch (java.lang.ClassNotFoundException ce) {
- // Expected for Android.
- }
- } catch(Exception e) {
- fail("Unexpected exception was thrown: " + e.toString());
- }
-
- try {
- Class.forName(classNameInitError2,
- true, getClass().getClassLoader());
- fail("ExceptionInInitializerError or ClassNotFoundException " +
- "should be thrown.");
- } catch (java.lang.ExceptionInInitializerError ie) {
- // Expected for the RI.
- // Remove this comment to let the test pass on Android.
- } catch (java.lang.ClassNotFoundException ce) {
- // Expected for Android.
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getAnnotation",
- args = {java.lang.Class.class}
- )
- public void test_getAnnotation() {
- TestAnnotation target = PublicTestClass.class.getAnnotation(TestAnnotation.class);
- assertEquals(target.value(), PublicTestClass.class.getName());
-
- assertNull(PublicTestClass.class.getAnnotation(Deprecated.class));
-
- Deprecated target2 = ExtendTestClass.class.getAnnotation(Deprecated.class);
- assertNotNull(target2);
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaredAnnotations",
- args = {}
- )
- public void test_getDeclaredAnnotations() {
- Annotation [] annotations = PublicTestClass.class.getDeclaredAnnotations();
- assertEquals(1, annotations.length);
-
- annotations = ExtendTestClass.class.getDeclaredAnnotations();
- assertEquals(2, annotations.length);
-
- annotations = TestInterface.class.getDeclaredAnnotations();
- assertEquals(0, annotations.length);
-
- annotations = String.class.getDeclaredAnnotations();
- assertEquals(0, annotations.length);
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getEnclosingClass",
- args = {}
- )
- public void test_getEnclosingClass() {
- Class clazz = ExtendTestClass.class.getEnclosingClass();
- assertNull(clazz);
-
- assertEquals(getClass(), Cls1.class.getEnclosingClass());
- assertEquals(getClass(), Intf1.class.getEnclosingClass());
- assertEquals(getClass(), Cls4.class.getEnclosingClass());
- }
-
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getEnclosingMethod",
- args = {}
- )
- public void test_getEnclosingMethod() {
- Method clazz = ExtendTestClass.class.getEnclosingMethod();
- assertNull(clazz);
-
- PublicTestClass ptc = new PublicTestClass();
- try {
- assertEquals("getEnclosingMethod returns incorrect method.",
- PublicTestClass.class.getMethod("getLocalClass",
- (Class []) null),
- ptc.getLocalClass().getClass().getEnclosingMethod());
- } catch(NoSuchMethodException nsme) {
- fail("NoSuchMethodException was thrown.");
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getEnclosingConstructor",
- args = {}
- )
- public void test_getEnclosingConstructor() {
-
- PublicTestClass ptc = new PublicTestClass();
-
- assertEquals("getEnclosingConstructor method returns incorrect class.",
- PublicTestClass.class.getConstructors()[0],
- ptc.clazz.getClass().getEnclosingConstructor());
-
- assertNull("getEnclosingConstructor should return null for local " +
- "class declared in method.",
- ptc.getLocalClass().getClass().getEnclosingConstructor());
-
- assertNull("getEnclosingConstructor should return null for local " +
- "class declared in method.",
- ExtendTestClass.class.getEnclosingConstructor());
- }
-
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getEnumConstants",
- args = {}
- )
- public void test_getEnumConstants() {
- Object [] clazz = ExtendTestClass.class.getEnumConstants();
- assertNull(clazz);
- Object [] constants = TestEnum.class.getEnumConstants();
- assertEquals(TestEnum.values().length, constants.length);
- for(int i = 0; i < constants.length; i++) {
- assertEquals(TestEnum.values()[i], constants[i]);
- }
- assertEquals(0, TestEmptyEnum.class.getEnumConstants().length);
- }
- public enum TestEnum {
- ONE, TWO, THREE
- }
- public enum TestEmptyEnum {
- }
- @TestTargetNew(
- level = TestLevel.SUFFICIENT,
- notes = "GenericSignatureFormatError, TypeNotPresentException, " +
- "MalformedParameterizedTypeException are not verified.",
- method = "getGenericInterfaces",
- args = {}
- )
- public void test_getGenericInterfaces() {
- Type [] types = ExtendTestClass1.class.getGenericInterfaces();
- assertEquals(0, types.length);
-
- Class [] interfaces = {TestInterface.class, Serializable.class,
- Cloneable.class};
- types = PublicTestClass.class.getGenericInterfaces();
- assertEquals(interfaces.length, types.length);
- for(int i = 0; i < types.length; i++) {
- assertEquals(interfaces[i], types[i]);
- }
-
- types = TestInterface.class.getGenericInterfaces();
- assertEquals(0, types.length);
-
- types = List.class.getGenericInterfaces();
- assertEquals(1, types.length);
- assertEquals(Collection.class, ((ParameterizedType)types[0]).getRawType());
-
- assertEquals(0, int.class.getGenericInterfaces().length);
- assertEquals(0, void.class.getGenericInterfaces().length);
- }
-
- @TestTargetNew(
- level = TestLevel.SUFFICIENT,
- notes = "GenericSignatureFormatError, TypeNotPresentException, MalformedParameterizedTypeException are not verified.",
- method = "getGenericSuperclass",
- args = {}
- )
- public void test_getGenericSuperclass () {
- assertEquals(PublicTestClass.class,
- ExtendTestClass.class.getGenericSuperclass());
- assertEquals(ExtendTestClass.class,
- ExtendTestClass1.class.getGenericSuperclass());
- assertEquals(Object.class, PublicTestClass.class.getGenericSuperclass());
- assertEquals(Object.class, String.class.getGenericSuperclass());
- assertEquals(null, TestInterface.class.getGenericSuperclass());
-
- ParameterizedType type = (ParameterizedType) Vector.class.getGenericSuperclass();
- assertEquals(AbstractList.class, type.getRawType());
- }
-
- @TestTargetNew(
- level = TestLevel.SUFFICIENT,
- method = "getPackage",
- args = {}
- )
- @AndroidOnly("Uses dalvik.system.PathClassLoader.")
- @BrokenTest("Different behavior between cts host and run-core-test")
- public void test_getPackage() {
-
- Package thisPackage = getClass().getPackage();
- assertEquals("org.apache.harmony.luni.tests.java.lang",
- thisPackage.getName());
-
- Package stringPackage = String.class.getPackage();
- assertNotNull("java.lang", stringPackage.getName());
-
- String hyts_package_name = "hyts_package_dex.jar";
- File resources = Support_Resources.createTempFolder();
- Support_Resources.copyFile(resources, "Package", hyts_package_name);
-
- String resPath = resources.toString();
- if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\')
- resPath = resPath.substring(1);
-
- try {
-
- URL resourceURL = new URL("file:/" + resPath + "/Package/"
- + hyts_package_name);
-
- ClassLoader cl = Support_ClassLoader.getInstance(resourceURL,
- getClass().getClassLoader());
-
- Class clazz = cl.loadClass("C");
- assertNull("getPackage for C.class should return null",
- clazz.getPackage());
-
- clazz = cl.loadClass("a.b.C");
- Package cPackage = clazz.getPackage();
- assertNotNull("getPackage for a.b.C.class should not return null",
- cPackage);
-
- /*
- * URLClassLoader doesn't work on Android for jar files
- *
- * URL url = getClass().getClassLoader().getResource(
- * packageName.replace(".", "/") + "/" + sourceJARfile);
- *
- * ClassLoader loader = new URLClassLoader(new URL[] { url }, null);
- *
- * try {
- * Class<?> clazz = loader.loadClass(illegalClassName);
- * Package pack = clazz.getPackage();
- * assertNull(pack);
- * } catch(ClassNotFoundException cne) {
- * fail("ClassNotFoundException was thrown for " + illegalClassName);
- * }
- */
- } catch(Exception e) {
- fail("Unexpected exception was thrown: " + e.toString());
- }
- }
-
- @TestTargetNew(
- level = TestLevel.SUFFICIENT,
- notes = "",
- method = "getSigners",
- args = {}
- )
- public void test_getSigners() {
- assertNull(void.class.getSigners());
- assertNull(PublicTestClass.class.getSigners());
-
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getSimpleName",
- args = {}
- )
- public void test_getSimpleName() {
- assertEquals("PublicTestClass", PublicTestClass.class.getSimpleName());
- assertEquals("void", void.class.getSimpleName());
- assertEquals("int[]", int[].class.getSimpleName());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getTypeParameters",
- args = {}
- )
- public void test_getTypeParameters() {
- assertEquals(0, PublicTestClass.class.getTypeParameters().length);
- TypeVariable [] tv = TempTestClass1.class.getTypeParameters();
- assertEquals(1, tv.length);
- assertEquals(Object.class, tv[0].getBounds()[0]);
-
- TempTestClass2<String> tc = new TempTestClass2<String>();
- tv = tc.getClass().getTypeParameters();
- assertEquals(1, tv.length);
- assertEquals(String.class, tv[0].getBounds()[0]);
- }
-
- class TempTestClass1<T> {
- }
-
- class TempTestClass2<S extends String> extends TempTestClass1<S> {
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isAnnotation",
- args = {}
- )
- public void test_isAnnotation() {
- assertTrue(Deprecated.class.isAnnotation());
- assertTrue(TestAnnotation.class.isAnnotation());
- assertFalse(PublicTestClass.class.isAnnotation());
- assertFalse(String.class.isAnnotation());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isAnnotationPresent",
- args = {java.lang.Class.class}
- )
- public void test_isAnnotationPresent() {
- assertTrue(PublicTestClass.class.isAnnotationPresent(TestAnnotation.class));
- assertFalse(ExtendTestClass1.class.isAnnotationPresent(TestAnnotation.class));
- assertFalse(String.class.isAnnotationPresent(Deprecated.class));
- assertTrue(ExtendTestClass.class.isAnnotationPresent(TestAnnotation.class));
- assertTrue(ExtendTestClass.class.isAnnotationPresent(Deprecated.class));
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isAnonymousClass",
- args = {}
- )
- public void test_isAnonymousClass() {
- assertFalse(PublicTestClass.class.isAnonymousClass());
- assertTrue((new Thread() {}).getClass().isAnonymousClass());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isEnum",
- args = {}
- )
- public void test_isEnum() {
- assertFalse(PublicTestClass.class.isEnum());
- assertFalse(ExtendTestClass.class.isEnum());
- assertTrue(TestEnum.ONE.getClass().isEnum());
- assertTrue(TestEnum.class.isEnum());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isLocalClass",
- args = {}
- )
- public void test_isLocalClass() {
- assertFalse(ExtendTestClass.class.isLocalClass());
- assertFalse(TestInterface.class.isLocalClass());
- assertFalse(TestEnum.class.isLocalClass());
- class InternalClass {}
- assertTrue(InternalClass.class.isLocalClass());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isMemberClass",
- args = {}
- )
- public void test_isMemberClass() {
- assertFalse(ExtendTestClass.class.isMemberClass());
- assertFalse(TestInterface.class.isMemberClass());
- assertFalse(String.class.isMemberClass());
- assertTrue(TestEnum.class.isMemberClass());
- assertTrue(StaticMember$Class.class.isMemberClass());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isSynthetic",
- args = {}
- )
- public void test_isSynthetic() {
- assertFalse("Returned true for non synthetic class.",
- ExtendTestClass.class.isSynthetic());
- assertFalse("Returned true for non synthetic class.",
- TestInterface.class.isSynthetic());
- assertFalse("Returned true for non synthetic class.",
- String.class.isSynthetic());
-
- String className = "org.apache.harmony.luni.tests.java.lang.ClassLoaderTest$1";
-
- /*
- *try {
- * assertTrue("Returned false for synthetic class.",
- * getClass().getClassLoader().loadClass(className).
- * isSynthetic());
- *} catch(ClassNotFoundException cnfe) {
- * fail("Class " + className + " can't be found.");
- *}
- */
-
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isInstance",
- args = {java.lang.Object.class}
- )
- public void test_isInstance() {
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getCanonicalName",
- args = {}
- )
- public void test_getCanonicalName() {
- String name = int[].class.getCanonicalName();
- Class [] classArray = { int.class, int[].class, String.class,
- PublicTestClass.class, TestInterface.class,
- ExtendTestClass.class };
- String [] classNames = {"int", "int[]", "java.lang.String",
- "org.apache.harmony.luni.tests.java.lang.PublicTestClass",
- "org.apache.harmony.luni.tests.java.lang.TestInterface",
- "org.apache.harmony.luni.tests.java.lang.ExtendTestClass"};
-
- for(int i = 0; i < classArray.length; i++) {
- assertEquals(classNames[i], classArray[i].getCanonicalName());
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getClassLoader",
- args = {}
- )
- public void test_getClassLoader() {
- assertEquals(ExtendTestClass.class.getClassLoader(),
- PublicTestClass.class.getClassLoader());
-
- assertNull(int.class.getClassLoader());
- assertNull(void.class.getClassLoader());
- }
-
- /**
- * @tests java.lang.Class#getClasses()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getClasses",
- args = {}
- )
- public void test_getClasses() {
- assertEquals("Incorrect class array returned",
- 4, ClassTest.class.getClasses().length);
- }
-
- /**
- * @tests java.lang.Class#getComponentType()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getComponentType",
- args = {}
- )
- public void test_getComponentType() {
- assertSame("int array does not have int component type", int.class, int[].class
- .getComponentType());
- assertSame("Object array does not have Object component type", Object.class,
- Object[].class.getComponentType());
- assertNull("Object has non-null component type", Object.class.getComponentType());
- }
-
- /**
- * @tests java.lang.Class#getConstructor(java.lang.Class[])
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getConstructor",
- args = {java.lang.Class[].class}
- )
- public void test_getConstructor$Ljava_lang_Class()
- throws NoSuchMethodException {
- Constructor constr = TestClass.class.getConstructor(new Class[0]);
- assertNotNull(constr);
- assertEquals("org.apache.harmony.luni.tests.java.lang.ClassTest$TestClass",
- constr.getName());
- try {
- TestClass.class.getConstructor(Object.class);
- fail("Found private constructor");
- } catch (NoSuchMethodException e) {
- // Correct - constructor with obj is private
- }
- }
-
- /**
- * @tests java.lang.Class#getConstructors()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getConstructors",
- args = {}
- )
- public void test_getConstructors() throws Exception {
- Constructor[] c = TestClass.class.getConstructors();
- assertEquals("Incorrect number of constructors returned", 1, c.length);
- }
-
- /**
- * @tests java.lang.Class#getDeclaredClasses()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaredClasses",
- args = {}
- )
- public void test_getDeclaredClasses() {
-
- Class [] declClasses = Object.class.getDeclaredClasses();
- assertEquals("Incorrect length of declared classes array is returned " +
- "for Object.", 0, declClasses.length);
-
- declClasses = PublicTestClass.class.getDeclaredClasses();
- assertEquals(2, declClasses.length);
-
- assertEquals(0, int.class.getDeclaredClasses().length);
- assertEquals(0, void.class.getDeclaredClasses().length);
-
- for(int i = 0; i < declClasses.length; i++) {
- Constructor<?> constr = declClasses[i].getDeclaredConstructors()[0];
- constr.setAccessible(true);
- PublicTestClass publicClazz = new PublicTestClass();
- try {
- Object o = constr.newInstance(publicClazz);
- assertTrue("Returned incorrect class: " + o.toString(),
- o.toString().startsWith("PrivateClass"));
- } catch(Exception e) {
- fail("Unexpected exception was thrown: " + e.toString());
- }
- }
-
-
- declClasses = TestInterface.class.getDeclaredClasses();
- assertEquals(0, declClasses.length);
- }
-
-
- /**
- * @tests java.lang.Class#getDeclaredConstructor(java.lang.Class[])
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaredConstructor",
- args = {java.lang.Class[].class}
- )
- public void test_getDeclaredConstructor$Ljava_lang_Class() throws Exception {
- Constructor<TestClass> c = TestClass.class.getDeclaredConstructor(new Class[0]);
- assertNull("Incorrect constructor returned", c.newInstance().cValue());
- c = TestClass.class.getDeclaredConstructor(Object.class);
-
- try {
- TestClass.class.getDeclaredConstructor(String.class);
- fail("NoSuchMethodException should be thrown.");
- } catch(NoSuchMethodException nsme) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Class#getDeclaredConstructors()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaredConstructors",
- args = {}
- )
- public void test_getDeclaredConstructors() throws Exception {
- Constructor[] c = TestClass.class.getDeclaredConstructors();
- assertEquals("Incorrect number of constructors returned", 2, c.length);
- }
-
- /**
- * @tests java.lang.Class#getDeclaredField(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaredField",
- args = {java.lang.String.class}
- )
- public void test_getDeclaredFieldLjava_lang_String() throws Exception {
- Field f = TestClass.class.getDeclaredField("pubField");
- assertEquals("Returned incorrect field", 2, f.getInt(new TestClass()));
-
- try {
- TestClass.class.getDeclaredField(null);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
-
- try {
- TestClass.class.getDeclaredField("NonExistentField");
- fail("NoSuchFieldException is not thrown.");
- } catch(NoSuchFieldException nsfe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Class#getDeclaredFields()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaredFields",
- args = {}
- )
- public void test_getDeclaredFields() throws Exception {
- Field[] f = TestClass.class.getDeclaredFields();
- assertEquals("Returned incorrect number of fields", 4, f.length);
- f = SubTestClass.class.getDeclaredFields();
- // Declared fields do not include inherited
- assertEquals("Returned incorrect number of fields", 0, f.length);
- }
-
- /**
- * @tests java.lang.Class#getDeclaredMethod(java.lang.String,
- * java.lang.Class[])
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaredMethod",
- args = {java.lang.String.class, java.lang.Class[].class}
- )
- public void test_getDeclaredMethodLjava_lang_String$Ljava_lang_Class() throws Exception {
- Method m = TestClass.class.getDeclaredMethod("pubMethod", new Class[0]);
- assertEquals("Returned incorrect method", 2, ((Integer) (m.invoke(new TestClass())))
- .intValue());
- m = TestClass.class.getDeclaredMethod("privMethod", new Class[0]);
-
- try {
- TestClass.class.getDeclaredMethod(null, new Class[0]);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
-
- try {
- TestClass.class.getDeclaredMethod("NonExistentMethod", new Class[0]);
- fail("NoSuchMethodException is not thrown.");
- } catch(NoSuchMethodException nsme) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Class#getDeclaredMethods()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaredMethods",
- args = {}
- )
- public void test_getDeclaredMethods() throws Exception {
- Method[] m = TestClass.class.getDeclaredMethods();
- assertEquals("Returned incorrect number of methods", 3, m.length);
- m = SubTestClass.class.getDeclaredMethods();
- assertEquals("Returned incorrect number of methods", 0, m.length);
- }
-
- /**
- * @tests java.lang.Class#getDeclaringClass()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDeclaringClass",
- args = {}
- )
- public void test_getDeclaringClass() {
- assertEquals(ClassTest.class, TestClass.class.getDeclaringClass());
- assertNull(PublicTestClass.class.getDeclaringClass());
- }
-
- /**
- * @tests java.lang.Class#getField(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getField",
- args = {java.lang.String.class}
- )
- public void test_getFieldLjava_lang_String() throws Exception {
- Field f = TestClass.class.getField("pubField");
- assertEquals("Returned incorrect field", 2, f.getInt(new TestClass()));
-
- f = PublicTestClass.class.getField("TEST_FIELD");
- assertEquals("Returned incorrect field", "test field",
- f.get(new PublicTestClass()));
-
- f = PublicTestClass.class.getField("TEST_INTERFACE_FIELD");
- assertEquals("Returned incorrect field", 0,
- f.getInt(new PublicTestClass()));
-
- try {
- f = TestClass.class.getField("privField");
- fail("Private field access failed to throw exception");
- } catch (NoSuchFieldException e) {
- // Correct
- }
-
- try {
- TestClass.class.getField(null);
- fail("NullPointerException is thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Class#getFields()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "getFields",
- args = {}
- )
- public void test_getFields2() throws Exception {
- Field[] f;
- Field expected = null;
-
- f = PublicTestClass.class.getFields();
- assertEquals("Test 1: Incorrect number of fields;", 2, f.length);
-
- f = Cls2.class.getFields();
- assertEquals("Test 2: Incorrect number of fields;", 6, f.length);
-
- f = Cls3.class.getFields();
- assertEquals("Test 2: Incorrect number of fields;", 5, f.length);
-
- for (Field field : f) {
- if (field.toString().equals("public static final int org.apache" +
- ".harmony.luni.tests.java.lang.ClassTest$Intf3.field1")) {
- expected = field;
- break;
- }
- }
- if (expected == null) {
- fail("Test 3: getFields() did not return all fields.");
- }
- assertEquals("Test 4: Incorrect field;", expected,
- Cls3.class.getField("field1"));
-
- expected = null;
- for (Field field : f) {
- if(field.toString().equals("public static final int org.apache" +
- ".harmony.luni.tests.java.lang.ClassTest$Intf1.field2")) {
- expected = field;
- break;
- }
- }
- if (expected == null) {
- fail("Test 5: getFields() did not return all fields.");
- }
- assertEquals("Test 6: Incorrect field;", expected,
- Cls3.class.getField("field2"));
- }
-
- /**
- * @tests java.lang.Class#getFields()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "getFields",
- args = {}
- )
- public void test_getFields() throws Exception {
- Field[] f = TestClass.class.getFields();
- assertEquals("Test 1: Incorrect number of fields;", 2, f.length);
- f = SubTestClass.class.getFields();
- // Check inheritance of pub fields
- assertEquals("Test 2: Incorrect number of fields;", 2, f.length);
-
- Field expected = null;
- Field[] fields = Cls2.class.getFields();
- for (Field field : fields) {
- if(field.toString().equals("public int org.apache.harmony.luni" +
- ".tests.java.lang.ClassTest$Cls2.field1")) {
- expected = field;
- break;
- }
- }
- if (expected == null) {
- fail("getFields() did not return all fields");
- }
- assertEquals(expected, Cls2.class.getField("field1"));
- }
-
- /**
- * @tests java.lang.Class#getInterfaces()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getInterfaces",
- args = {}
- )
- public void test_getInterfaces() {
- Class[] interfaces;
- List<?> interfaceList;
- interfaces = Object.class.getInterfaces();
- assertEquals("Incorrect interface list for Object", 0, interfaces.length);
- interfaceList = Arrays.asList(Vector.class.getInterfaces());
- assertTrue("Incorrect interface list for Vector", interfaceList
- .contains(Cloneable.class)
- && interfaceList.contains(Serializable.class)
- && interfaceList.contains(List.class));
-
- Class [] interfaces1 = Cls1.class.getInterfaces();
- assertEquals(1, interfaces1.length);
- assertEquals(Intf2.class, interfaces1[0]);
-
- Class [] interfaces2 = Cls2.class.getInterfaces();
- assertEquals(1, interfaces2.length);
- assertEquals(Intf1.class, interfaces2[0]);
-
- Class [] interfaces3 = Cls3.class.getInterfaces();
- assertEquals(2, interfaces3.length);
- assertEquals(Intf3.class, interfaces3[0]);
- assertEquals(Intf4.class, interfaces3[1]);
-
- Class [] interfaces4 = Cls4.class.getInterfaces();
- assertEquals(0, interfaces4.length);
- }
-
- /**
- * @tests java.lang.Class#getMethod(java.lang.String, java.lang.Class[])
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getMethod",
- args = {java.lang.String.class, java.lang.Class[].class}
- )
- public void test_getMethodLjava_lang_String$Ljava_lang_Class() throws Exception {
- Method m = TestClass.class.getMethod("pubMethod", new Class[0]);
- assertEquals("Returned incorrect method", 2, ((Integer) (m.invoke(new TestClass())))
- .intValue());
-
- m = ExtendTestClass1.class.getMethod("getCount", new Class[0]);
- assertEquals("Returned incorrect method", 0, ((Integer) (m.invoke(new ExtendTestClass1())))
- .intValue());
-
- try {
- m = TestClass.class.getMethod("privMethod", new Class[0]);
- fail("Failed to throw exception accessing private method");
- } catch (NoSuchMethodException e) {
- // Correct
- return;
- }
-
- try {
- m = TestClass.class.getMethod("init", new Class[0]);
- fail("Failed to throw exception accessing to init method");
- } catch (NoSuchMethodException e) {
- // Correct
- return;
- }
-
- try {
- TestClass.class.getMethod("pubMethod", new Class[0]);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Class#getMethods()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getMethods",
- args = {}
- )
- public void test_getMethods() throws Exception {
- Method[] m = TestClass.class.getMethods();
- assertEquals("Returned incorrect number of methods",
- 2 + Object.class.getMethods().length, m.length);
- m = SubTestClass.class.getMethods();
- assertEquals("Returned incorrect number of sub-class methods",
- 2 + Object.class.getMethods().length, m.length);
- // Number of inherited methods
-
- assertEquals("Incorrect number of methods", 10,
- Cls2.class.getMethods().length);
- assertEquals("Incorrect number of methods", 11,
- Cls3.class.getMethods().length);
-
- Method expected = null;
- Method[] methods = Cls2.class.getMethods();
- for (Method method : methods) {
- if(method.toString().equals("public void org.apache.harmony.luni" +
- ".tests.java.lang.ClassTest$Cls2.test()")) {
- expected = method;
- break;
- }
- }
- if (expected == null) {
- fail("getMethods() did not return all methods");
- }
- assertEquals(expected, Cls2.class.getMethod("test"));
-
- expected = null;
- methods = Cls3.class.getMethods();
- for (Method method : methods) {
- if(method.toString().equals("public void org.apache.harmony.luni" +
- ".tests.java.lang.ClassTest$Cls3.test()")) {
- expected = method;
- break;
- }
- }
- if (expected == null) {
- fail("getMethods() did not return all methods");
- }
- assertEquals(expected, Cls3.class.getMethod("test"));
-
- expected = null;
- methods = Cls3.class.getMethods();
- for (Method method : methods) {
- if(method.toString().equals("public void org.apache.harmony.luni" +
- ".tests.java.lang.ClassTest$Cls3.test2(int," +
- "java.lang.Object)")) {
- expected = method;
- break;
- }
- }
- if (expected == null) {
- fail("getMethods() did not return all methods");
- }
-
- assertEquals(expected, Cls3.class.getMethod("test2", int.class,
- Object.class));
-
- assertEquals("Incorrect number of methods", 1,
- Intf5.class.getMethods().length);
- }
-
- private static final class PrivateClass {
- }
- /**
- * @tests java.lang.Class#getModifiers()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getModifiers",
- args = {}
- )
- public void test_getModifiers() {
- int dcm = PrivateClass.class.getModifiers();
- assertFalse("default class is public", Modifier.isPublic(dcm));
- assertFalse("default class is protected", Modifier.isProtected(dcm));
- assertTrue("default class is not private", Modifier.isPrivate(dcm));
-
- int ocm = Object.class.getModifiers();
- assertTrue("public class is not public", Modifier.isPublic(ocm));
- assertFalse("public class is protected", Modifier.isProtected(ocm));
- assertFalse("public class is private", Modifier.isPrivate(ocm));
- }
-
- /**
- * @tests java.lang.Class#getName()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getName",
- args = {}
- )
- public void test_getName() throws Exception {
- String className = Class.forName("java.lang.Object").getName();
- assertNotNull(className);
-
- assertEquals("Class getName printed wrong value", "java.lang.Object", className);
- assertEquals("Class getName printed wrong value", "int", int.class.getName());
- className = Class.forName("[I").getName();
- assertNotNull(className);
- assertEquals("Class getName printed wrong value", "[I", className);
-
- className = Class.forName("[Ljava.lang.Object;").getName();
- assertNotNull(className);
-
- assertEquals("Class getName printed wrong value", "[Ljava.lang.Object;", className);
- }
-
- /**
- * @tests java.lang.Class#getResource(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getResource",
- args = {java.lang.String.class}
- )
- public void test_getResourceLjava_lang_String() {
- final String name = "/";
- URL res = getClass().getResource(name + "HelloWorld.txt");
- assertNotNull(res);
- assertNull(getClass().getResource(
- "org/apache/harmony/luni/tests/java/lang/NonExistentResource"));
- assertNull(getClass().getResource(name + "NonExistentResource"));
- }
-
- /**
- * @tests java.lang.Class#getResourceAsStream(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "getResourceAsStream",
- args = {java.lang.String.class}
- )
- public void test_getResourceAsStreamLjava_lang_String() throws Exception {
- String name = "/HelloWorld.txt";
- assertNotNull("the file " + name + " can not be found in this " +
- "directory", getClass().getResourceAsStream(name));
-
- final String nameBadURI = "org/apache/harmony/luni/tests/" +
- "test_resource.txt";
- assertNull("the file " + nameBadURI + " should not be found in this " +
- "directory",
- getClass().getResourceAsStream(nameBadURI));
-
- ClassLoader pcl = getClass().getClassLoader();
- Class<?> clazz = pcl.loadClass("org.apache.harmony.luni.tests.java.lang.ClassTest");
- assertNotNull(clazz.getResourceAsStream("HelloWorld1.txt"));
-
- try {
- getClass().getResourceAsStream(null);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Class#getSuperclass()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getSuperclass",
- args = {}
- )
- public void test_getSuperclass() {
- assertNull("Object has a superclass???", Object.class.getSuperclass());
- assertSame("Normal class has bogus superclass", InputStream.class,
- FileInputStream.class.getSuperclass());
- assertSame("Array class has bogus superclass", Object.class, FileInputStream[].class
- .getSuperclass());
- assertNull("Base class has a superclass", int.class.getSuperclass());
- assertNull("Interface class has a superclass", Cloneable.class.getSuperclass());
- }
-
- /**
- * @tests java.lang.Class#isArray()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isArray",
- args = {}
- )
- public void test_isArray() throws ClassNotFoundException {
- assertTrue("Non-array type claims to be.", !int.class.isArray());
- Class<?> clazz = null;
- clazz = Class.forName("[I");
- assertTrue("int Array type claims not to be.", clazz.isArray());
-
- clazz = Class.forName("[Ljava.lang.Object;");
- assertTrue("Object Array type claims not to be.", clazz.isArray());
-
- clazz = Class.forName("java.lang.Object");
- assertTrue("Non-array Object type claims to be.", !clazz.isArray());
- }
-
- /**
- * @tests java.lang.Class#isAssignableFrom(java.lang.Class)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isAssignableFrom",
- args = {java.lang.Class.class}
- )
- public void test_isAssignableFromLjava_lang_Class() {
- Class<?> clazz1 = null;
- Class<?> clazz2 = null;
-
- clazz1 = Object.class;
- clazz2 = Class.class;
- assertTrue("returned false for superclass",
- clazz1.isAssignableFrom(clazz2));
-
- clazz1 = TestClass.class;
- assertTrue("returned false for same class",
- clazz1.isAssignableFrom(clazz1));
-
- clazz1 = Runnable.class;
- clazz2 = Thread.class;
- assertTrue("returned false for implemented interface",
- clazz1.isAssignableFrom(clazz2));
-
- assertFalse("returned true not assignable classes",
- Integer.class.isAssignableFrom(String.class));
-
- try {
- clazz1.isAssignableFrom(null);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Class#isInterface()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isInterface",
- args = {}
- )
- public void test_isInterface() throws ClassNotFoundException {
- assertTrue("Prim type claims to be interface.", !int.class.isInterface());
- Class<?> clazz = null;
- clazz = Class.forName("[I");
- assertTrue("Prim Array type claims to be interface.", !clazz.isInterface());
-
- clazz = Class.forName("java.lang.Runnable");
- assertTrue("Interface type claims not to be interface.", clazz.isInterface());
- clazz = Class.forName("java.lang.Object");
- assertTrue("Object type claims to be interface.", !clazz.isInterface());
-
- clazz = Class.forName("[Ljava.lang.Object;");
- assertTrue("Array type claims to be interface.", !clazz.isInterface());
- }
-
- /**
- * @tests java.lang.Class#isPrimitive()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isPrimitive",
- args = {}
- )
- public void test_isPrimitive() {
- assertFalse("Interface type claims to be primitive.",
- Runnable.class.isPrimitive());
- assertFalse("Object type claims to be primitive.",
- Object.class.isPrimitive());
- assertFalse("Prim Array type claims to be primitive.",
- int[].class.isPrimitive());
- assertFalse("Array type claims to be primitive.",
- Object[].class.isPrimitive());
- assertTrue("Prim type claims not to be primitive.",
- int.class.isPrimitive());
- assertFalse("Object type claims to be primitive.",
- Object.class.isPrimitive());
- }
-
- /**
- * @tests java.lang.Class#newInstance()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "newInstance",
- args = {}
- )
- public void test_newInstance() throws Exception {
- Class<?> clazz = null;
- clazz = Class.forName("java.lang.Object");
- assertNotNull("new object instance was null", clazz.newInstance());
-
- clazz = Class.forName("java.lang.Throwable");
- assertSame("new Throwable instance was not a throwable",
- clazz, clazz.newInstance().getClass());
-
- clazz = Class.forName("java.lang.Integer");
- try {
- clazz.newInstance();
- fail("Exception for instantiating a newInstance with no default " +
- " constructor is not thrown");
- } catch (InstantiationException e) {
- // expected
- }
-
- try {
- TestClass3.class.newInstance();
- fail("IllegalAccessException is not thrown.");
- } catch(IllegalAccessException iae) {
- //expected
- }
-
- try {
- TestClass1C.class.newInstance();
- fail("ExceptionInInitializerError should be thrown.");
- } catch (java.lang.ExceptionInInitializerError ie) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Class#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() throws ClassNotFoundException {
- assertEquals("Class toString printed wrong value",
- "int", int.class.toString());
- Class<?> clazz = null;
- clazz = Class.forName("[I");
- assertEquals("Class toString printed wrong value",
- "class [I", clazz.toString());
-
- clazz = Class.forName("java.lang.Object");
- assertEquals("Class toString printed wrong value",
- "class java.lang.Object", clazz.toString());
-
- clazz = Class.forName("[Ljava.lang.Object;");
- assertEquals("Class toString printed wrong value",
- "class [Ljava.lang.Object;", clazz.toString());
- }
-
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "getResourceAsStream",
- args = {java.lang.String.class}
- )
- // Regression Test for JIRA-2047
- public void test_getResourceAsStream_withSharpChar() throws Exception{
- InputStream in = getClass().getResourceAsStream("/" + FILENAME);
- assertNotNull(in);
- in.close();
-
- in = getClass().getResourceAsStream(FILENAME);
- assertNull(in);
-
- in = this.getClass().getClassLoader().getResourceAsStream(
- FILENAME);
- assertNotNull(in);
- in.close();
- }
-
- /*
- * Regression test for HARMONY-2644:
- * Load system and non-system array classes via Class.forName()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies ClassNotFoundException.",
- method = "forName",
- args = {java.lang.String.class}
- )
- public void test_forName_arrays() throws Exception {
- Class<?> c1 = getClass();
- String s = c1.getName();
- Class<?> a1 = Class.forName("[L" + s + ";");
- Class<?> a2 = Class.forName("[[L" + s + ";");
- assertSame(c1, a1.getComponentType());
- assertSame(a1, a2.getComponentType());
- Class<?> l4 = Class.forName("[[[[[J");
- assertSame(long[][][][][].class, l4);
-
- try{
- Class<?> clazz = Class.forName("[;");
- fail("1: " + clazz);
- } catch (ClassNotFoundException ok) {}
- try{
- Class<?> clazz = Class.forName("[[");
- fail("2:" + clazz);
- } catch (ClassNotFoundException ok) {}
- try{
- Class<?> clazz = Class.forName("[L");
- fail("3:" + clazz);
- } catch (ClassNotFoundException ok) {}
- try{
- Class<?> clazz = Class.forName("[L;");
- fail("4:" + clazz);
- } catch (ClassNotFoundException ok) {}
- try{
- Class<?> clazz = Class.forName(";");
- fail("5:" + clazz);
- } catch (ClassNotFoundException ok) {}
- try{
- Class<?> clazz = Class.forName("");
- fail("6:" + clazz);
- } catch (ClassNotFoundException ok) {}
- }
-
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "asSubclass",
- args = {java.lang.Class.class}
- )
- public void test_asSubclass1() {
- assertEquals(ExtendTestClass.class,
- ExtendTestClass.class.asSubclass(PublicTestClass.class));
-
- assertEquals(PublicTestClass.class,
- PublicTestClass.class.asSubclass(TestInterface.class));
-
- assertEquals(ExtendTestClass1.class,
- ExtendTestClass1.class.asSubclass(PublicTestClass.class));
-
- assertEquals(PublicTestClass.class,
- PublicTestClass.class.asSubclass(PublicTestClass.class));
- }
-
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "asSubclass",
- args = {java.lang.Class.class}
- )
- public void test_asSubclass2() {
- try {
- PublicTestClass.class.asSubclass(ExtendTestClass.class);
- fail("Test 1: ClassCastException expected.");
- } catch(ClassCastException cce) {
- // Expected.
- }
-
- try {
- PublicTestClass.class.asSubclass(String.class);
- fail("Test 2: ClassCastException expected.");
- } catch(ClassCastException cce) {
- // Expected.
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "cast",
- args = {java.lang.Object.class}
- )
- public void test_cast() {
- Object o = PublicTestClass.class.cast(new ExtendTestClass());
- assertTrue(o instanceof ExtendTestClass);
-
- try {
- ExtendTestClass.class.cast(new PublicTestClass());
- fail("Test 1: ClassCastException expected.");
- } catch(ClassCastException cce) {
- //expected
- }
-
- try {
- ExtendTestClass.class.cast(new String());
- fail("ClassCastException is not thrown.");
- } catch(ClassCastException cce) {
- //expected
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "desiredAssertionStatus",
- args = {}
- )
- public void test_desiredAssertionStatus() {
- Class [] classArray = { Object.class, Integer.class,
- String.class, PublicTestClass.class,
- ExtendTestClass.class, ExtendTestClass1.class};
-
- for(int i = 0; i < classArray.length; i++) {
- assertFalse("assertion status for " + classArray[i],
- classArray[i].desiredAssertionStatus());
- }
- }
-
-
-
- SecurityManager sm = new SecurityManager() {
-
- final String forbidenPermissionName = "user.dir";
-
- public void checkPermission(Permission perm) {
- if (perm.getName().equals(forbidenPermissionName)) {
- throw new SecurityException();
- }
- }
-
- public void checkMemberAccess(Class<?> clazz,
- int which) {
- if(clazz.equals(TestClass.class)) {
- throw new SecurityException();
- }
- }
-
- public void checkPackageAccess(String pkg) {
- if(pkg.equals(TestClass.class.getPackage())) {
- throw new SecurityException();
- }
- }
-
- };
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest2.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest2.java
deleted file mode 100644
index ea69bb2..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest2.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-@TestTargetClass(Class.class)
-public class ClassTest2 extends junit.framework.TestCase {
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
-
- /**
- * Tests loading a resource with a relative name.
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "getResourceAsStream",
- args = {java.lang.String.class}
- )
- public void testGetResourceAsStream1() throws IOException {
- Class clazz = getClass();
-
- InputStream stream = clazz.getResourceAsStream("HelloWorld.txt");
- assert(stream != null);
-
- byte[] buffer = new byte[20];
- int length = stream.read(buffer);
- String s = new String(buffer, 0, length);
- assert("Hello, World.".equals(s));
-
- stream.close();
- }
-
- /**
- * Tests loading a resource with a global name.
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "getResourceAsStream",
- args = {java.lang.String.class}
- )
- public void testGetResourceAsStream2() throws IOException {
- Class clazz = getClass();
-
- InputStream stream = clazz.getResourceAsStream("/org/apache/harmony/luni/tests/java/lang/HelloWorld.txt");
- assert(stream != null);
-
- byte[] buffer = new byte[20];
- int length = stream.read(buffer);
- String s = new String(buffer, 0, length);
- assert("Hello, World.".equals(s));
-
- stream.close();
-
- try {
- clazz.getResourceAsStream(null);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- assertNull(clazz.getResourceAsStream("/NonExistentResource"));
- assertNull(clazz.getResourceAsStream("org/apache/harmony/luni/tests/java/lang/HelloWorld.txt"));
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CloneNotSupportedExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CloneNotSupportedExceptionTest.java
deleted file mode 100644
index da66da9..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CloneNotSupportedExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class CloneNotSupportedExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.CloneNotSupportedException#CloneNotSupportedException()
- */
- public void test_Constructor() {
- CloneNotSupportedException e = new CloneNotSupportedException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.CloneNotSupportedException#CloneNotSupportedException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- CloneNotSupportedException e = new CloneNotSupportedException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CompilerTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CompilerTest.java
deleted file mode 100644
index 4793a42..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/CompilerTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class CompilerTest extends TestCase {
-
- /**
- * @tests java.lang.Compiler#command(java.lang.Object)
- */
- public void test_commandLjava_lang_Object() {
- assertNull("Incorrect behavior.", Compiler.command(new Object()));
- }
-
- /**
- * @tests java.lang.Compiler#compileClass(java.lang.Class)
- */
- public void test_compileClassLjava_lang_Class() {
- // Do not test return value, may return true or false depending on
- // if the jit is enabled. Make the call to ensure it doesn't crash.
- Compiler.compileClass(Compiler.class);
- }
-
- /**
- * @tests java.lang.Compiler#compileClasses(java.lang.String)
- */
- public void test_compileClassesLjava_lang_String() {
- // Do not test return value, may return true or false depending on
- // if the jit is enabled. Make the call to ensure it doesn't crash.
- Compiler.compileClasses("Compiler");
- }
-
- /**
- * @tests java.lang.Compiler#disable()
- */
- public void test_disable() {
- Compiler.disable();
- Compiler.compileClass(Compiler.class);
- }
-
- /**
- * @tests java.lang.Compiler#enable()
- */
- public void test_enable() {
- Compiler.disable();
- Compiler.enable();
- Compiler.compileClass(Compiler.class);
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/DoubleTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/DoubleTest.java
deleted file mode 100644
index 501e981..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/DoubleTest.java
+++ /dev/null
@@ -1,1661 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-import java.util.Locale;
-
-@TestTargetClass(Double.class)
-public class DoubleTest extends TestCase {
- private static final long rawBitsFor3_4en324ToN1[] = { 0x1L, 0x7L, 0x45L, 0x2b0L, 0x1ae2L,
- 0x10cd1L, 0xa8028L, 0x69018dL, 0x41a0f7eL, 0x29049aedL, 0x19a2e0d44L,
- 0x1005cc84acL, 0xa039fd2ebdL, 0x64243e3d361L, 0x3e96a6e641c6L, 0x271e284fe91b8L,
- 0x1872d931f1b131L, 0x4e8f8f7e6e1d7dL, 0x8319b9af04d26eL, 0xb7e0281ac6070aL,
- 0xedd832217788ccL, 0x122a71f54eab580L, 0x15750e72a2562e0L, 0x18d2520f4aebb98L,
- 0x1c2373498ed353fL, 0x1f6c501bf28828eL, 0x22c76422ef2a332L, 0x261c9e95d57a5ffL,
- 0x2963c63b4ad8f7fL, 0x2cbcb7ca1d8f35fL, 0x3015f2de527981bL, 0x335b6f95e717e22L,
- 0x36b24b7b60dddabL, 0x3a0f6f2d1c8aa8bL, 0x3d534af863ad52dL, 0x40a81db67c98a79L,
- 0x440912920ddf68bL, 0x474b5736915742eL, 0x4a9e2d0435ad13aL, 0x4e02dc22a18c2c4L,
- 0x5143932b49ef375L, 0x549477f61c6b052L, 0x57f995f3a385c67L, 0x5b3bfdb846339c0L,
- 0x5e8afd2657c0830L, 0x61edbc6fedb0a3dL, 0x653495c5f48e666L, 0x6881bb3771b1fffL,
- 0x6be22a054e1e7ffL, 0x6f2d5a4350d30ffL, 0x7278b0d42507d3fL, 0x75d6dd092e49c8fL,
- 0x79264a25bcee1daL, 0x7c6fdcaf2c29a50L, 0x7fcbd3daf7340e4L, 0x831f6468da8088eL,
- 0x86673d831120ab2L, 0x89c10ce3d568d5fL, 0x8d18a80e656185bL, 0x905ed211feb9e72L,
- 0x93b686967e6860eL, 0x9712141e0f013c9L, 0x9a56992592c18bbL, 0x9dac3f6ef771eeaL,
- 0xa10ba7a55aa7352L, 0xa44e918eb151027L, 0xa7a235f25da5430L, 0xab0561b77a8749eL,
- 0xae46ba2559291c6L, 0xb19868aeaf73637L, 0xb4fe82da5b503c5L, 0xb83f11c8791225bL,
- 0xbb8ed63a9756af2L, 0xbef28bc93d2c5afL, 0xc237975dc63bb8dL, 0xc5857d3537caa70L,
- 0xc8e6dc8285bd50cL, 0xcc3049d19396528L, 0xcf7c5c45f87be72L, 0xd2db7357769ae0eL,
- 0xd6292816aa20cc9L, 0xd973721c54a8ffbL, 0xdcd04ea369d33faL, 0xe0223126222407cL,
- 0xe36abd6faaad09bL, 0xe6c56ccb95584c2L, 0xea1b63ff3d572f9L, 0xed623cff0cacfb8L,
- 0xf0bacc3ecfd83a5L, 0xf414bfa741e7247L, 0xf759ef911260ed9L, 0xfab06b7556f9290L,
- 0xfe0e4329565bb9aL, 0x10151d3f3abf2a80L, 0x104a648f096ef520L, 0x10807ed965e55934L,
- 0x10b49e8fbf5eaf81L, 0x10e9c633af365b61L, 0x11201be04d81f91dL, 0x115422d860e27764L,
- 0x11892b8e791b153dL, 0x11bf76721761da8cL, 0x11f3aa074e9d2898L, 0x12289489224472beL,
- 0x125eb9ab6ad58f6dL, 0x1293340b22c579a4L, 0x12c8010deb76d80dL, 0x12fe015166548e11L,
- 0x1332c0d2dff4d8caL, 0x1367710797f20efdL, 0x139d4d497dee92bcL, 0x13d2504deeb51bb6L,
- 0x1406e4616a6262a3L, 0x143c9d79c4fafb4cL, 0x1471e26c1b1cdd0fL, 0x14a65b0721e41453L,
- 0x14dbf1c8ea5d1968L, 0x1511771d927a2fe1L, 0x1545d4e4f718bbd9L, 0x157b4a1e34deead0L,
- 0x15b10e52e10b52c2L, 0x15e551e7994e2772L, 0x161aa6617fa1b14fL, 0x1650a7fcefc50ed1L,
- 0x1684d1fc2bb65286L, 0x16ba067b36a3e727L, 0x16f0440d02267078L, 0x1724551042b00c96L,
- 0x17596a54535c0fbcL, 0x178fc4e9683313abL, 0x17c3db11e11fec4bL, 0x17f8d1d65967e75eL,
- 0x182f064befc1e135L, 0x186363ef75d92cc1L, 0x18983ceb534f77f1L, 0x18ce4c26282355eeL,
- 0x1902ef97d91615b5L, 0x1937ab7dcf5b9b22L, 0x196d965d433281eaL, 0x19a27dfa49ff9132L,
- 0x19d71d78dc7f757fL, 0x1a0ce4d7139f52dfL, 0x1a420f066c4393cbL, 0x1a7692c8075478beL,
- 0x1aac377a092996edL, 0x1ae1a2ac45b9fe54L, 0x1b160b5757287de9L, 0x1b4b8e2d2cf29d64L,
- 0x1b8138dc3c17a25eL, 0x1bb587134b1d8af6L, 0x1beae8d81de4edb4L, 0x1c20d18712af1490L,
- 0x1c5505e8d75ad9b4L, 0x1c8a47630d319021L, 0x1cc06c9de83efa15L, 0x1cf487c5624eb89aL,
- 0x1d29a9b6bae266c1L, 0x1d600a1234cd8038L, 0x1d940c96c200e046L, 0x1dc90fbc72811858L,
- 0x1dff53ab8f215e6eL, 0x1e33944b3974db05L, 0x1e68795e07d211c6L, 0x1e9e97b589c69637L,
- 0x1ed31ed1761c1de3L, 0x1f07e685d3a3255bL, 0x1f3de027488beeb2L, 0x1f72ac188d57752fL,
- 0x1fa7571eb0ad527bL, 0x1fdd2ce65cd8a71aL, 0x20123c0ffa076870L, 0x2046cb13f889428cL,
- 0x207c7dd8f6ab932fL, 0x20b1cea79a2b3bfeL, 0x20e6425180b60afdL, 0x211bd2e5e0e38dbcL,
- 0x215163cfac8e3896L, 0x2185bcc397b1c6bbL, 0x21bb2bf47d9e386aL, 0x21f0fb78ce82e342L,
- 0x22253a5702239c13L, 0x225a88ecc2ac8317L, 0x22909593f9abd1efL, 0x22c4baf8f816c66aL,
- 0x22f9e9b7361c7805L, 0x2330321281d1cb03L, 0x23643e9722463dc4L, 0x23994e3cead7cd35L,
- 0x23cfa1cc258dc082L, 0x2403c51f97789851L, 0x2438b6677d56be65L, 0x246ee4015cac6dffL,
- 0x24a34e80d9ebc4bfL, 0x24d822211066b5efL, 0x250e2aa95480636bL, 0x2542daa9d4d03e23L,
- 0x257791544a044dabL, 0x25ad75a95c856116L, 0x25e26989d9d35caeL, 0x261703ec504833d9L,
- 0x264cc4e7645a40d0L, 0x2681fb109eb86882L, 0x26b679d4c66682a2L, 0x26ec1849f800234bL,
- 0x27218f2e3b00160fL, 0x2755f2f9c9c01b93L, 0x278b6fb83c302277L, 0x27c125d3259e158bL,
- 0x27f56f47ef059aedL, 0x282acb19eac701a8L, 0x2860bef032bc6109L, 0x2894eeac3f6b794cL,
- 0x28ca2a574f46579eL, 0x29005a76918bf6c3L, 0x2934711435eef474L, 0x29698d59436ab191L,
- 0x299ff0af94455df5L, 0x29d3f66dbcab5ab9L, 0x2a08f4092bd63167L, 0x2a3f310b76cbbdc1L,
- 0x2a737ea72a3f5699L, 0x2aa85e50f4cf2c3fL, 0x2ade75e53202f74fL, 0x2b1309af3f41da91L,
- 0x2b47cc1b0f125135L, 0x2b7dbf21d2d6e583L, 0x2bb2977523c64f72L, 0x2be73d526cb7e34eL,
- 0x2c1d0ca707e5dc22L, 0x2c5227e864efa995L, 0x2c86b1e27e2b93faL, 0x2cbc5e5b1db678f9L,
- 0x2cf1baf8f2920b9cL, 0x2d2629b72f368e83L, 0x2d5bb424fb043223L, 0x2d9150971ce29f56L,
- 0x2dc5a4bce41b472bL, 0x2dfb0dec1d2218f6L, 0x2e30e8b392354f9aL, 0x2e6522e076c2a380L,
- 0x2e9a6b9894734c61L, 0x2ed0833f5cc80fbcL, 0x2f04a40f33fa13abL, 0x2f39cd1300f89896L,
- 0x2f70202be09b5f5eL, 0x2fa42836d8c23735L, 0x2fd932448ef2c503L, 0x300f7ed5b2af7643L,
- 0x3043af458fada9eaL, 0x30789b16f3991465L, 0x30aec1dcb07f597eL, 0x30e33929ee4f97efL,
- 0x3118077469e37deaL, 0x314e0951845c5d65L, 0x3182c5d2f2b9ba5fL, 0x31b77747af6828f7L,
- 0x31ed55199b423335L, 0x3222553001096001L, 0x3256ea7c014bb801L, 0x328ca51b019ea601L,
- 0x32c1e730e10327c1L, 0x32f660fd1943f1b1L, 0x332bf93c5f94ee1dL, 0x33617bc5bbbd14d2L,
- 0x3395dab72aac5a07L, 0x33cb5164f5577089L, 0x340112df1956a655L, 0x34355796dfac4febL,
- 0x346aad7c979763e5L, 0x34a0ac6ddebe9e6fL, 0x34d4d789566e460bL, 0x350a0d6bac09d78eL,
- 0x354048634b8626b9L, 0x35745a7c1e67b067L, 0x35a9711b26019c81L, 0x35dfcd61ef8203a1L,
- 0x3613e05d35b14245L, 0x3648d874831d92d6L, 0x367f0e91a3e4f78bL, 0x36b3691b066f1ab7L,
- 0x36e84361c80ae165L, 0x371e543a3a0d99beL, 0x3752f4a464488017L, 0x3787b1cd7d5aa01cL,
- 0x37bd9e40dcb14823L, 0x37f282e889eecd16L, 0x382723a2ac6a805cL, 0x385cec8b57852073L,
- 0x389213d716b33448L, 0x38c698ccdc60015aL, 0x38fc3f00137801b0L, 0x3931a7600c2b010eL,
- 0x396611380f35c151L, 0x399b9586130331a6L, 0x39d13d73cbe1ff08L, 0x3a058cd0beda7ec9L,
- 0x3a3af004ee911e7cL, 0x3a70d603151ab30dL, 0x3aa50b83da615fd1L, 0x3ada4e64d0f9b7c5L,
- 0x3b1070ff029c12dbL, 0x3b448d3ec3431792L, 0x3b79b08e7413dd76L, 0x3bb00e59088c6a6aL,
- 0x3be411ef4aaf8504L, 0x3c19166b1d5b6646L, 0x3c4f5c05e4b23fd7L, 0x3c839983aeef67e6L,
- 0x3cb87fe49aab41e0L, 0x3cee9fddc1561258L, 0x3d2323ea98d5cb77L, 0x3d57ece53f0b3e55L,
- 0x3d8de81e8ece0deaL, 0x3dc2b1131940c8b2L, 0x3df75d57df90fadfL, 0x3e2d34add7753996L,
- 0x3e6240eca6a943feL, 0x3e96d127d05394fdL, 0x3ecc8571c4687a3dL, 0x3f01d3671ac14c66L,
- 0x3f364840e1719f80L, 0x3f6bda5119ce075fL, 0x3fa16872b020c49cL, 0x3fd5c28f5c28f5c3L,
- 0x400B333333333333L };
-
- private static final long rawBitsFor1_2e0To309[] = { 0x3ff3333333333333L, 0x4028000000000000L,
- 0x405e000000000000L, 0x4092c00000000000L, 0x40c7700000000000L, 0x40fd4c0000000000L,
- 0x41324f8000000000L, 0x4166e36000000000L, 0x419c9c3800000000L, 0x41d1e1a300000000L,
- 0x42065a0bc0000000L, 0x423bf08eb0000000L, 0x427176592e000000L, 0x42a5d3ef79800000L,
- 0x42db48eb57e00000L, 0x43110d9316ec0000L, 0x434550f7dca70000L, 0x437aa535d3d0c000L,
- 0x43b0a741a4627800L, 0x43e4d1120d7b1600L, 0x441a055690d9db80L, 0x445043561a882930L,
- 0x4484542ba12a337cL, 0x44b969368974c05bL, 0x44efc3842bd1f072L, 0x4523da329b633647L,
- 0x4558d0bf423c03d9L, 0x458f04ef12cb04cfL, 0x45c363156bbee301L, 0x45f83bdac6ae9bc2L,
- 0x462e4ad1785a42b2L, 0x4662eec2eb3869afL, 0x4697aa73a606841bL, 0x46cd95108f882522L,
- 0x47027d2a59b51735L, 0x47371c74f0225d03L, 0x476ce3922c2af443L, 0x47a20e3b5b9ad8aaL,
- 0x47d691ca32818ed5L, 0x480c363cbf21f28aL, 0x4841a1e5f7753796L, 0x48760a5f7552857cL,
- 0x48ab8cf752a726daL, 0x48e1381a93a87849L, 0x491586213892965bL, 0x494ae7a986b73bf1L,
- 0x4980d0c9f4328577L, 0x49b504fc713f26d5L, 0x49ea463b8d8ef08aL, 0x4a206be538795656L,
- 0x4a5486de8697abecL, 0x4a89a896283d96e6L, 0x4ac0095dd9267e50L, 0x4af40bb54f701de4L,
- 0x4b290ea2a34c255dL, 0x4b5f524b4c1f2eb4L, 0x4b93936f0f937d31L, 0x4bc8784ad3785c7dL,
- 0x4bfe965d8856739cL, 0x4c331dfa75360842L, 0x4c67e57912838a52L, 0x4c9dded757246ce6L,
- 0x4cd2ab469676c410L, 0x4d0756183c147514L, 0x4d3d2b9e4b199259L, 0x4d723b42eeeffb78L,
- 0x4da6ca13aaabfa56L, 0x4ddc7c989556f8ebL, 0x4e11cddf5d565b93L, 0x4e46415734abf278L,
- 0x4e7bd1ad01d6ef15L, 0x4eb1630c2126556dL, 0x4ee5bbcf296feac9L, 0x4f1b2ac2f3cbe57bL,
- 0x4f50fab9d85f6f6dL, 0x4f8539684e774b48L, 0x4fba87c262151e1aL, 0x4ff094d97d4d32d0L,
- 0x5024ba0fdca07f84L, 0x5059e893d3c89f65L, 0x5090315c645d639fL, 0x50c43db37d74bc87L,
- 0x50f94d205cd1eba9L, 0x512fa06874066693L, 0x5163c4414884001cL, 0x5198b5519aa50023L,
- 0x51cee2a6014e402cL, 0x52034da7c0d0e81bL, 0x52382111b1052222L, 0x526e29561d466aabL,
- 0x52a2d9d5d24c02abL, 0x52d7904b46df0355L, 0x530d745e1896c42bL, 0x534268bacf5e3a9bL,
- 0x537702e98335c941L, 0x53acc3a3e4033b92L, 0x53e1fa466e82053bL, 0x541678d80a22868aL,
- 0x544c170e0cab282cL, 0x54818e68c7eaf91cL, 0x54b5f202f9e5b763L, 0x54eb6e83b85f253bL,
- 0x55212512533b7745L, 0x55556e56e80a5516L, 0x558ac9eca20cea5cL, 0x55c0be33e5481279L,
- 0x55f4edc0de9a1718L, 0x562a293116409cdeL, 0x566059beade8620bL, 0x5694702e59627a8dL,
- 0x56c98c39efbb1931L, 0x56ffef486ba9df7dL, 0x5733f58d434a2baeL, 0x5768f2f0941cb699L,
- 0x579f2facb923e440L, 0x57d37dcbf3b66ea8L, 0x58085d3ef0a40a52L, 0x583e748eaccd0ce6L,
- 0x587308d92c002810L, 0x58a7cb0f77003214L, 0x58ddbdd354c03e99L, 0x591296a414f82720L,
- 0x59473c4d1a3630e8L, 0x597d0b6060c3bd21L, 0x59b2271c3c7a5635L, 0x59e6b0e34b98ebc2L,
- 0x5a1c5d1c1e7f26b3L, 0x5a51ba31930f7830L, 0x5a8628bdf7d3563cL, 0x5abbb2ed75c82bcaL,
- 0x5af14fd4699d1b5fL, 0x5b25a3c984046236L, 0x5b5b0cbbe5057ac4L, 0x5b90e7f56f236cbaL,
- 0x5bc521f2caec47e9L, 0x5bfa6a6f7da759e3L, 0x5c308285ae88982eL, 0x5c64a3271a2abe39L,
- 0x5c99cbf0e0b56dc8L, 0x5cd01f768c71649dL, 0x5d0427542f8dbdc4L, 0x5d3931293b712d35L,
- 0x5d6f7d738a4d7882L, 0x5da3ae6836706b51L, 0x5dd89a02440c8626L, 0x5e0ec082d50fa7afL,
- 0x5e433851c529c8ceL, 0x5e78066636743b01L, 0x5eae07ffc41149c1L, 0x5ee2c4ffda8ace19L,
- 0x5f17763fd12d819fL, 0x5f4d53cfc578e207L, 0x5f825461db6b8d44L, 0x5fb6e97a52467095L,
- 0x5feca3d8e6d80cbbL, 0x6021e667904707f5L, 0x605660017458c9f2L, 0x608bf801d16efc6eL,
- 0x60c17b0122e55dc5L, 0x60f5d9c16b9eb536L, 0x612b5031c6866284L, 0x6161121f1c13fd92L,
- 0x619556a6e318fcf7L, 0x61caac509bdf3c34L, 0x6200abb2616b85a1L, 0x6234d69ef9c66709L,
- 0x626a0c46b83800cbL, 0x62a047ac3323007fL, 0x62d459973febc09fL, 0x63096ffd0fe6b0c6L,
- 0x633fcbfc53e05cf8L, 0x6373df7db46c3a1bL, 0x63a8d75d218748a2L, 0x63df0d3469e91acaL,
- 0x64136840c231b0beL, 0x64484250f2be1ceeL, 0x647e52e52f6da42aL, 0x64b2f3cf3da4869aL,
- 0x64e7b0c30d0da840L, 0x651d9cf3d0511251L, 0x655282186232ab72L, 0x6587229e7abf564fL,
- 0x65bceb46196f2be3L, 0x65f2130bcfe57b6eL, 0x662697cec3deda49L, 0x665c3dc274d690dbL,
- 0x6691a69989061a89L, 0x66c6103feb47a12bL, 0x66fb944fe6198976L, 0x67313cb1efcff5eaL,
- 0x67658bde6bc3f364L, 0x679aeed606b4f03dL, 0x67d0d545c4311626L, 0x68050a97353d5bb0L,
- 0x683a4d3d028cb29cL, 0x687070462197efa2L, 0x68a48c57a9fdeb8aL, 0x68d9af6d947d666cL,
- 0x69100da47cce6004L, 0x6944110d9c01f805L, 0x6979155103027606L, 0x69af5aa543c31387L,
- 0x69e398a74a59ec35L, 0x6a187ed11cf06742L, 0x6a4e9e85642c8112L, 0x6a8323135e9bd0abL,
- 0x6ab7ebd83642c4d6L, 0x6aede6ce43d3760cL, 0x6b22b040ea6429c7L, 0x6b575c5124fd3439L,
- 0x6b8d33656e3c8147L, 0x6bc2401f64e5d0cdL, 0x6bf6d0273e1f4500L, 0x6c2c84310da71640L,
- 0x6c61d29ea8886de8L, 0x6c96474652aa8962L, 0x6ccbd917e7552bbaL, 0x6d0167aef0953b54L,
- 0x6d35c19aacba8a29L, 0x6d6b320157e92cb4L, 0x6da0ff40d6f1bbf0L, 0x6dd53f110cae2aedL,
- 0x6e0a8ed54fd9b5a8L, 0x6e40994551e81189L, 0x6e74bf96a66215ebL, 0x6ea9ef7c4ffa9b66L,
- 0x6ee035adb1fca120L, 0x6f1443191e7bc967L, 0x6f4953df661abbc1L, 0x6f7fa8d73fa16ab2L,
- 0x6fb3c98687c4e2afL, 0x6fe8bbe829b61b5bL, 0x701eeae23423a232L, 0x705352cd6096455fL,
- 0x70882780b8bbd6b7L, 0x70be3160e6eacc64L, 0x70f2dedc9052bfbfL, 0x71279693b4676faeL,
- 0x715d7c38a1814b9aL, 0x71926da364f0cf40L, 0x71c7090c3e2d0310L, 0x71fccb4f4db843d4L,
- 0x7231ff1190932a65L, 0x72667ed5f4b7f4feL, 0x729c1e8b71e5f23dL, 0x72d19317272fb766L,
- 0x7305f7dcf0fba540L, 0x733b75d42d3a8e90L, 0x737129a49c44991aL, 0x73a5740dc355bf60L,
- 0x73dad111342b2f39L, 0x7410c2aac09afd83L, 0x7444f35570c1bce4L, 0x747a302accf22c1dL,
- 0x74b05e1ac0175b92L, 0x74e475a1701d3277L, 0x75199309cc247f15L, 0x754ff7cc3f2d9edaL,
- 0x7583fadfa77c8348L, 0x75b8f997915ba41aL, 0x75ef37fd75b28d21L, 0x762382fe698f9834L,
- 0x765863be03f37e41L, 0x768e7cad84f05dd2L, 0x76c30dec73163aa3L, 0x76f7d1678fdbc94cL,
- 0x772dc5c173d2bb9fL, 0x77629b98e863b543L, 0x7797427f227ca294L, 0x77cd131eeb1bcb39L,
- 0x78022bf352f15f04L, 0x7836b6f027adb6c5L, 0x786c64ac31992476L, 0x78a1beeb9effb6caL,
- 0x78d62ea686bfa47cL, 0x790bba50286f8d9bL, 0x794154721945b881L, 0x7975a98e9f9726a1L,
- 0x79ab13f2477cf049L, 0x79e0ec776cae162eL, 0x7a15279547d99bb9L, 0x7a4a717a99d002a8L,
- 0x7a8086eca02201a9L, 0x7ab4a8a7c82a8213L, 0x7ae9d2d1ba352298L, 0x7b2023c31461359fL,
- 0x7b542cb3d9798307L, 0x7b8937e0cfd7e3c8L, 0x7bbf85d903cddcbaL, 0x7bf3b3a7a260a9f4L,
- 0x7c28a0918af8d472L, 0x7c5ec8b5edb7098eL, 0x7c933d71b49265f9L, 0x7cc80cce21b6ff77L,
- 0x7cfe1001aa24bf55L, 0x7d32ca010a56f795L, 0x7d677c814cecb57aL, 0x7d9d5ba1a027e2d9L,
- 0x7dd259450418edc7L, 0x7e06ef96451f2939L, 0x7e3cab7bd666f388L, 0x7e71eb2d66005835L,
- 0x7ea665f8bf806e42L, 0x7edbff76ef6089d2L, 0x7f117faa559c5623L, 0x7f45df94eb036bacL,
- 0x7f7b577a25c44697L, 0x7fb116ac579aac1fL, 0x7fe55c576d815726L, 0x7ff0000000000000L };
-
- private void doTestCompareRawBits(String originalDoubleString, long expectedRawBits,
- String expectedString) {
- double result;
- long rawBits;
- String convertedString;
- result = Double.parseDouble(originalDoubleString);
- rawBits = Double.doubleToLongBits(result);
- convertedString = new Double(result).toString();
- assertEquals(expectedRawBits, rawBits);
- assertEquals(expectedString.toLowerCase(Locale.US), convertedString
- .toLowerCase(Locale.US));
- }
-
- private void test_toString(double dd, String answer) {
- assertEquals(answer, Double.toString(dd));
- Double d = new Double(dd);
- assertEquals(answer, Double.toString(d.doubleValue()));
- assertEquals(answer, d.toString());
- }
-
- /**
- * @tests java.lang.Double#Double(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Double",
- args = {double.class}
- )
- public void test_ConstructorD() {
- Double d = new Double(39089.88888888888888888888888888888888);
- assertEquals("Created incorrect double", 39089.88888888888888888888888888888888, d
- .doubleValue(), 0D);
- }
-
- /**
- * @tests java.lang.Double#Double(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Double",
- args = {java.lang.String.class}
- )
- public void test_ConstructorLjava_lang_String() {
- Double d = new Double("39089.88888888888888888888888888888888");
- assertEquals("Created incorrect double", 39089.88888888888888888888888888888888, d
- .doubleValue(), 0D);
-
- // REGRESSION for HARMONY-489
- try {
- d = new Double("1E+-20");
- fail("new Double(\"1E+-20\") should throw exception");
- } catch (NumberFormatException e) {
- // expected
- }
- }
-
- /**
- * @tests java.lang.Double#byteValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "byteValue",
- args = {}
- )
- public void test_byteValue() {
- Double d = new Double(1923311.47712);
- assertEquals("Returned incorrect byte value", (byte) -17, d.byteValue());
- d= new Double(Byte.MAX_VALUE);
- assertEquals("Returned incorrect byte value", Byte.MAX_VALUE, d.byteValue());
- d= new Double(Byte.MIN_VALUE);
- assertEquals("Returned incorrect byte value", Byte.MIN_VALUE, d.byteValue());
- d= new Double(Double.MAX_VALUE);
- assertEquals("Returned incorrect byte value", -1, d.byteValue());
- }
-
- /**
- * @tests java.lang.Double#compareTo(java.lang.Double)
- * @tests java.lang.Double#compare(double, double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "compare",
- args = {double.class, double.class}
- )
- public void test_compare() {
- double[] values = new double[] { Double.NEGATIVE_INFINITY, -Double.MAX_VALUE, -2d,
- -Double.MIN_VALUE, -0d, 0d, Double.MIN_VALUE, 2d, Double.MAX_VALUE,
- Double.POSITIVE_INFINITY, Double.NaN };
- for (int i = 0; i < values.length; i++) {
- double d1 = values[i];
- assertTrue("compare() should be equal: " + d1, Double.compare(d1, d1) == 0);
- Double D1 = new Double(d1);
- assertTrue("compareTo() should be equal: " + d1, D1.compareTo(D1) == 0);
- for (int j = i + 1; j < values.length; j++) {
- double d2 = values[j];
- assertTrue("compare() " + d1 + " should be less " + d2,
- Double.compare(d1, d2) == -1);
- assertTrue("compare() " + d2 + " should be greater " + d1, Double.compare(d2,
- d1) == 1);
- Double D2 = new Double(d2);
- assertTrue("compareTo() " + d1 + " should be less " + d2,
- D1.compareTo(D2) == -1);
- assertTrue("compareTo() " + d2 + " should be greater " + d1,
- D2.compareTo(D1) == 1);
- }
- }
-
- try {
- new Double(0.0D).compareTo(null);
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Double#doubleToLongBits(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "doubleToLongBits",
- args = {double.class}
- )
- public void test_doubleToLongBitsD() {
- // Test for method long java.lang.Double.doubleToLongBits(double)
- Double d = new Double(Double.MAX_VALUE);
- long lbits = Double.doubleToLongBits(d.doubleValue());
- double r = Double.longBitsToDouble(lbits);
-
- assertTrue("Bit conversion failed", d.doubleValue() == r);
-
- assertEquals(0x7ff8000000000000L, Double.doubleToLongBits(Double.NaN));
- assertEquals(0x7ff0000000000000L, Double.doubleToLongBits(Double.POSITIVE_INFINITY));
- assertEquals(0xfff0000000000000L, Double.doubleToLongBits(Double.NEGATIVE_INFINITY));
- }
-
- /**
- * @tests java.lang.Double#doubleToRawLongBits(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "doubleToRawLongBits",
- args = {double.class}
- )
- public void test_doubleToRawLongBitsD() {
- long l = 0x7ff80000000004d2L;
- double d = Double.longBitsToDouble(l);
- assertTrue("Wrong raw bits", Double.doubleToRawLongBits(d) == l);
-
- assertEquals(0x7ff8000000000000L, Double.doubleToLongBits(Double.NaN));
- assertEquals(0x7ff0000000000000L, Double.doubleToLongBits(Double.POSITIVE_INFINITY));
- assertEquals(0xfff0000000000000L, Double.doubleToLongBits(Double.NEGATIVE_INFINITY));
- }
-
- /**
- * @tests java.lang.Double#doubleValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "doubleValue",
- args = {}
- )
- public void test_doubleValue() {
- assertEquals("Incorrect double value returned", 999999999999999.9999999999999,
- new Double(999999999999999.9999999999999).doubleValue(), 0D);
- assertEquals(Double.POSITIVE_INFINITY, new Double("1.7976931348623159E308").doubleValue());
- assertEquals(Double.NEGATIVE_INFINITY, new Double("-1.7976931348623159E308").doubleValue());
- assertEquals(Double.MAX_VALUE, new Double("1.7976931348623157E308").doubleValue());
- assertEquals(Double.MIN_VALUE, new Double("4.9E-324").doubleValue());
- }
-
- /**
- * @tests java.lang.Double#floatValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "floatValue",
- args = {}
- )
- public void test_floatValue() {
- // Test for method float java.lang.Double.floatValue()
- assertTrue(
- "Incorrect float value returned ",
- Math.abs(new Double(999999999999999.9999999999999d).
- floatValue() - 999999999999999.9999999999999f) < 1);
- assertEquals(Float.POSITIVE_INFINITY, new Double("3.4028236E38").floatValue());
- assertEquals(Float.NEGATIVE_INFINITY, new Double("-3.4028236E38").floatValue());
- assertEquals(Float.MAX_VALUE, new Double("3.4028235E38").floatValue());
- assertEquals(Float.MIN_VALUE, new Double("1.4E-45").floatValue());
- }
-
- /**
- * @tests java.lang.Double#hashCode()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "hashCode",
- args = {}
- )
- public void test_hashCode() {
- // Test for method int java.lang.Double.hashCode()
- for (int i = -1000; i < 1000; i++) {
- Double d = new Double(i);
- Double dd = new Double(i);
- assertTrue("Should not be identical ", d != dd);
- assertTrue("Should be equals 1 ", d.equals(dd));
- assertTrue("Should be equals 2 ", dd.equals(d));
- assertTrue("Should have identical values ", dd.doubleValue() == d.doubleValue());
- assertTrue("Invalid hash for equal but not identical doubles ", d.hashCode() == dd
- .hashCode());
- }
- assertEquals("Magic assumption hasCode (0.0) = 0 failed", 0, new Double(0.0).hashCode());
- }
-
- /**
- * @tests java.lang.Double#intValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "intValue",
- args = {}
- )
- public void test_intValue() {
- // Test for method int java.lang.Double.intValue()
- Double d = new Double(1923311.47712);
- assertEquals("Returned incorrect int value", 1923311, d.intValue());
- assertEquals("Returned incorrect int value", Integer.MAX_VALUE,
- new Double(2147483648d).intValue());
- assertEquals("Returned incorrect int value", Integer.MIN_VALUE,
- new Double(-2147483649d).intValue());
- }
-
- /**
- * @tests java.lang.Double#isInfinite()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isInfinite",
- args = {}
- )
- public void test_isInfinite() {
- // Test for method boolean java.lang.Double.isInfinite()
- assertTrue("NEGATIVE_INFINITY returned false", new Double(Double.NEGATIVE_INFINITY)
- .isInfinite());
- assertTrue("POSITIVE_INFINITY returned false", new Double(Double.POSITIVE_INFINITY)
- .isInfinite());
- assertTrue("Non infinite number returned true", !(new Double(1000).isInfinite()));
- }
-
- /**
- * @tests java.lang.Double#isInfinite(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isInfinite",
- args = {double.class}
- )
- public void test_isInfiniteD() {
- // Test for method boolean java.lang.Double.isInfinite(double)
- assertTrue("Infinity check failed", Double.isInfinite(Double.NEGATIVE_INFINITY)
- && (Double.isInfinite(Double.POSITIVE_INFINITY))
- && !(Double.isInfinite(Double.MAX_VALUE)));
- }
-
- /**
- * @tests java.lang.Double#isNaN()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isNaN",
- args = {}
- )
- public void test_isNaN() {
- // Test for method boolean java.lang.Double.isNaN()
- Double d = new Double(0.0 / 0.0);
- assertTrue("NAN returned false", d.isNaN());
- d = new Double(0);
- assertTrue("Non NAN returned true", !d.isNaN());
- }
-
- /**
- * @tests java.lang.Double#isNaN(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isNaN",
- args = {double.class}
- )
- public void test_isNaND() {
- // Test for method boolean java.lang.Double.isNaN(double)
-
- Double d = new Double(0.0 / 0.0);
- assertTrue("NAN check failed", Double.isNaN(d.doubleValue()));
-
- assertFalse("Doesn't return false value", Double.isNaN(new Double(Double.MAX_VALUE)));
- }
-
- /**
- * @tests java.lang.Double#longBitsToDouble(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "longBitsToDouble",
- args = {long.class}
- )
- public void test_longBitsToDoubleJ() {
- // Test for method double java.lang.Double.longBitsToDouble(long)
-
- Double d = new Double(Double.MAX_VALUE);
- long lbits = Double.doubleToLongBits(d.doubleValue());
- double r = Double.longBitsToDouble(lbits);
-
- assertTrue("Bit conversion failed", d.doubleValue() == r);
- }
-
- /**
- * @tests java.lang.Double#longValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "longValue",
- args = {}
- )
- public void test_longValue() {
- // Test for method long java.lang.Double.longValue()
- Double d = new Double(1923311.47712);
- assertEquals("Returned incorrect long value", 1923311, d.longValue());
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies boundary values and the loop due to the difference in the expected output string.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDoubleLjava_lang_String() {
- assertEquals("Incorrect double returned, expected zero.", 0.0, Double
- .parseDouble("2.4703282292062327208828439643411e-324"), 0.0);
- assertTrue("Incorrect double returned, expected minimum double.", Double
- .parseDouble("2.4703282292062327208828439643412e-324") == Double.MIN_VALUE);
-
- for (int i = 324; i > 0; i--) {
- Double.parseDouble("3.4e-" + i);
- }
- for (int i = 0; i <= 309; i++) {
- Double.parseDouble("1.2e" + i);
- }
-
- /*
- * The first two cases and the last four cases have to placed outside
- * the loop due to the difference in the expected output string.
- */
- doTestCompareRawBits("3.4e-324", rawBitsFor3_4en324ToN1[0], "4.9e-324");
- doTestCompareRawBits("3.4e-323", rawBitsFor3_4en324ToN1[1], "3.5e-323");
- for (int i = 322; i > 3; i--) {
- String testString, expectedString;
- testString = expectedString = "3.4e-" + i;
- doTestCompareRawBits(testString, rawBitsFor3_4en324ToN1[324 - i], expectedString);
- }
- doTestCompareRawBits("3.4e-3", rawBitsFor3_4en324ToN1[321], "0.0034");
- doTestCompareRawBits("3.4e-2", rawBitsFor3_4en324ToN1[322], "0.034");
- doTestCompareRawBits("3.4e-1", rawBitsFor3_4en324ToN1[323], "0.34");
- doTestCompareRawBits("3.4e-0", rawBitsFor3_4en324ToN1[324], "3.4");
-
- doTestCompareRawBits("1.2e0", rawBitsFor1_2e0To309[0], "1.2");
- doTestCompareRawBits("1.2e1", rawBitsFor1_2e0To309[1], "12.0");
- doTestCompareRawBits("1.2e2", rawBitsFor1_2e0To309[2], "120.0");
- doTestCompareRawBits("1.2e3", rawBitsFor1_2e0To309[3], "1200.0");
- doTestCompareRawBits("1.2e4", rawBitsFor1_2e0To309[4], "12000.0");
- doTestCompareRawBits("1.2e5", rawBitsFor1_2e0To309[5], "120000.0");
- doTestCompareRawBits("1.2e6", rawBitsFor1_2e0To309[6], "1200000.0");
- for (int i = 7; i <= 308; i++) {
- String testString, expectedString;
- testString = expectedString = "1.2e" + i;
- doTestCompareRawBits(testString, rawBitsFor1_2e0To309[i], expectedString);
- }
- doTestCompareRawBits("1.2e309", rawBitsFor1_2e0To309[309], "Infinity");
-
- doTestCompareRawBits(
- "111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000.92233720368547758079223372036854775807",
- 0x7e054218c295e43fL, "1.1122233344455567E299");
- doTestCompareRawBits(
- "-111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000111222333444555666777888999000.92233720368547758079223372036854775807",
- 0xfe054218c295e43fL, "-1.1122233344455567E299");
-
- doTestCompareRawBits("1.234123412431233E107", 0x562ae7a25fe706ebL,
- "1.234123412431233E107");
- doTestCompareRawBits("1.2341234124312331E107", 0x562ae7a25fe706ecL,
- "1.2341234124312331E107");
- doTestCompareRawBits("1.2341234124312332E107", 0x562ae7a25fe706ecL,
- "1.2341234124312331E107");
- doTestCompareRawBits("-1.234123412431233E107", 0xd62ae7a25fe706ebL,
- "-1.234123412431233E107");
- doTestCompareRawBits("-1.2341234124312331E107", 0xd62ae7a25fe706ecL,
- "-1.2341234124312331E107");
- doTestCompareRawBits("-1.2341234124312332E107", 0xd62ae7a25fe706ecL,
- "-1.2341234124312331E107");
-
- doTestCompareRawBits("9.999999999999999e22", 0x44b52d02c7e14af6L,
- "9.999999999999999e22");
-
- /*
- * These particular tests verify that the extreme boundary conditions
- * are converted correctly.
- */
- doTestCompareRawBits("0.0e-309", 0L, "0.0");
- doTestCompareRawBits("-0.0e-309", 0x8000000000000000L, "-0.0");
- doTestCompareRawBits("0.0e309", 0L, "0.0");
- doTestCompareRawBits("-0.0e309", 0x8000000000000000L, "-0.0");
- doTestCompareRawBits("0.1e309", 0x7fe1ccf385ebc8a0L, "1.0e308");
- doTestCompareRawBits("0.2e309", 0x7ff0000000000000L, "Infinity");
- doTestCompareRawBits("65e-325", 1L, "4.9e-324");
- doTestCompareRawBits("1000e-326", 2L, "1.0e-323");
-
- doTestCompareRawBits("4.0e-306", 0x86789e3750f791L, "4.0e-306");
- doTestCompareRawBits("2.22507e-308", 0xffffe2e8159d0L, "2.22507e-308");
- doTestCompareRawBits(
- "111222333444555666777888999000111228999000.92233720368547758079223372036854775807",
- 0x48746da623f1dd8bL, "1.1122233344455567E41");
- doTestCompareRawBits(
- "-111222333444555666777888999000111228999000.92233720368547758079223372036854775807",
- 0xc8746da623f1dd8bL, "-1.1122233344455567E41");
- doTestCompareRawBits(
- "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210",
- 0x54820fe0ba17f469L, "1.2345678901234567E99");
- doTestCompareRawBits(
- "-1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210",
- 0xd4820fe0ba17f469L, "-1.2345678901234567E99");
-
- doTestCompareRawBits(
- "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.01",
- 0x7fefffffffffffffL, "1.7976931348623157E308");
- doTestCompareRawBits(
- "-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.01",
- 0xffefffffffffffffL, "-1.7976931348623157E308");
- doTestCompareRawBits(
- "1112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001234567890",
- 0x7ff0000000000000L, "Infinity");
- doTestCompareRawBits(
- "-1112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001112223334445556667778889990001234567890",
- 0xfff0000000000000L, "-Infinity");
- doTestCompareRawBits(
- "179769313486231590000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.01",
- 0x7ff0000000000000L, "Infinity");
- doTestCompareRawBits(
- "-179769313486231590000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.01",
- 0xfff0000000000000L, "-Infinity");
- doTestCompareRawBits(
- "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017976931348623157",
- 0x2b392a32afcc661eL, "1.7976931348623157E-100");
- doTestCompareRawBits(
- "-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017976931348623157",
- 0xab392a32afcc661eL, "-1.7976931348623157E-100");
- doTestCompareRawBits(
- "0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017976931348623157",
- 0x1b3432f0cb68e61L, "1.7976931348623157E-300");
- doTestCompareRawBits(
- "-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017976931348623157",
- 0x81b3432f0cb68e61L, "-1.7976931348623157E-300");
- doTestCompareRawBits(
- "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017976931348623157",
- 0x2117b590b942L, "1.79769313486234E-310");
- doTestCompareRawBits(
- "-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017976931348623157",
- 0x80002117b590b942L, "-1.79769313486234E-310");
- doTestCompareRawBits(
- "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017976931348623157",
- 0xe37L, "1.798E-320");
- doTestCompareRawBits(
- "-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017976931348623157",
- 0x8000000000000e37L, "-1.798E-320");
- doTestCompareRawBits(
- "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
- 0x2L, "1.0E-323");
- doTestCompareRawBits(
- "-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
- 0x8000000000000002L, "-1.0E-323");
- doTestCompareRawBits(
- "0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055595409854908458349204328908234982349050934129878452378432452458968024357823490509341298784523784324524589680243578234905093412987845237843245245896802435782349050934129878452378432452458968024357868024357823490509341298784523784324524589680243578234905093412987845237843245245896802435786802435782349050934129878452378432452458968024357823490509341298784523784324524589680243578",
- 0x1L, "4.9E-324");
- doTestCompareRawBits(
- "-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055595409854908458349204328908234982349050934129878452378432452458968024357823490509341298784523784324524589680243578234905093412987845237843245245896802435782349050934129878452378432452458968024357868024357823490509341298784523784324524589680243578234905093412987845237843245245896802435786802435782349050934129878452378432452458968024357823490509341298784523784324524589680243578",
- 0x8000000000000001L, "-4.9E-324");
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies NumberFormatException.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_Illegal() {
- try {
- Double.parseDouble("0.0p0D");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
-
- try {
- Double.parseDouble("+0x.p1d");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
-
- try {
- Double.parseDouble("0Xg.gp1D");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
-
- try {
- Double.parseDouble("-0x1.1p");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
-
- try {
- Double.parseDouble("+0x 1.1 p2d");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
-
- try {
- Double.parseDouble("x1.1p2d");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
-
- try {
- Double.parseDouble(" 0x-2.1p2");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
-
- try {
- Double.parseDouble(" 0x2.1pad");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
-
- try {
- Double.parseDouble(" 0x111.222p 22d");
- fail("Should throw NumberFormatException.");
- } catch (NumberFormatException e) {
- // expected
- }
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Doesn't check exception.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_FromHexString() {
- double actual;
- double expected;
-
- actual = Double.parseDouble("0x0.0p0D");
- assertEquals("Returned incorrect value", 0.0d, actual, 0.0D);
-
- actual = Double.parseDouble("0xa.ap+9d");
- assertEquals("Returned incorrect value", 5440.0d, actual, 0.0D);
-
- actual = Double.parseDouble("+0Xb.10ap8");
- assertEquals("Returned incorrect value", 2832.625d, actual, 0.0D);
-
- actual = Double.parseDouble("-0X.a0P2D");
- assertEquals("Returned incorrect value", -2.5d, actual, 0.0D);
-
- actual = Double.parseDouble("\r 0x22.1p2d \t");
- assertEquals("Returned incorrect value", 136.25d, actual, 0.0D);
-
- actual = Double.parseDouble("0x1.0p-1");
- assertEquals("Returned incorrect value", 0.5, actual, 0.0D);
-
- actual = Double
- .parseDouble("0x00000000000000000000000000000000001.0p-1");
- assertEquals("Returned incorrect value", 0.5, actual, 0.0D);
-
- actual = Double.parseDouble("0x1.0p-00000000000000000000000000001");
- assertEquals("Returned incorrect value", 0.5, actual, 0.0D);
-
- actual = Double.parseDouble("0x.100000000000000000000000000000000p1");
- assertEquals("Returned incorrect value", 0.125, actual, 0.0D);
-
- actual = Double.parseDouble("0x0.0p999999999999999999999999999999999999999999999999999999999999999");
- assertEquals("Returned incorrect value", 0.0, actual, 0.0D);
-
- actual = Double.parseDouble("0xf1.0p9999999999999999999999999999999999999999999999999999999999999999");
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, actual, 0.0D);
-
- actual = Double.parseDouble("0xffffffffffffffffffffffffffffffffffff.ffffffffffffffffffffffffffffffffffffffffffffffp1");
- expected = Double.longBitsToDouble(0x4900000000000000L);
- assertEquals("Returned incorrect value", expected, actual, 0.0D);
-
- actual = Double.parseDouble("0x0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001p1600");
- expected = Double.longBitsToDouble(0x7f30000000000000L);
- assertEquals("Returned incorrect value", expected, actual, 0.0D);
-
- actual = Double.parseDouble("0x0.0p-999999999999999999999999999999999999999999999999999999");
- assertEquals("Returned incorrect value", 0.0, actual, 0.0D);
-
- actual = Double.parseDouble("0xf1.0p-9999999999999999999999999999999999999999999999999999999999999999");
- assertEquals("Returned incorrect value", 0.0, actual, 0.0D);
-
- actual = Double.parseDouble("0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000p-1600");
- expected = Double.longBitsToDouble(0xf0000000000000L);
- assertEquals("Returned incorrect value", expected, actual, 0.0D);
-
- actual = Double.parseDouble("0x1.p9223372036854775807");
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, actual, 0.0D);
-
- actual = Double.parseDouble("0x1.p9223372036854775808");
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, actual, 0.0D);
-
- actual = Double.parseDouble("0x10.p9223372036854775808");
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, actual, 0.0D);
-
- actual = Double.parseDouble("0xabcd.ffffffffp+2000");
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, actual, 0.0D);
-
- actual = Double.parseDouble("0x1.p-9223372036854775808");
- assertEquals("Returned incorrect value", 0.0, actual, 0.0D);
-
- actual = Double.parseDouble("0x1.p-9223372036854775809");
- assertEquals("Returned incorrect value", 0.0, actual, 0.0D);
-
- actual = Double.parseDouble("0x.1p-9223372036854775809");
- assertEquals("Returned incorrect value", 0.0, actual, 0.0D);
-
- actual = Double.parseDouble("0xabcd.ffffffffffffffp-2000");
- assertEquals("Returned incorrect value", 0.0, actual, 0.0D);
- }
-
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Regression test for hotfix in native code of double parser.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_AndroidRegression() {
- // Android regression test
- long startTime = System.currentTimeMillis();
- double actual = Double.parseDouble("9e551027");
- assertTrue("parsing double 9e551027 took too long.",
- (System.currentTimeMillis() - startTime) < 1000);
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY,
- actual, 0.0D);
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies positive functionality.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_NormalPositiveExponent() {
- long[] expecteds = {
- 0x3f323456789abcdfL, 0x40e111012345678aL, 0x41a1110091a2b3c5L,
- 0x4259998091a2b3c5L, 0x4311110048d159e2L, 0x43c5554048d159e2L,
- 0x4479998048d159e2L, 0x452dddc048d159e2L, 0x45e111002468acf1L,
- 0x469333202468acf1L, 0x4751011001234568L, 0x4802112101234568L,
- 0x48b3213201234568L, 0x4964314301234568L, 0x4a15415401234568L,
- 0x4ac6516501234568L, 0x4b77617601234568L, 0x4c28718701234568L,
- 0x4cd9819801234568L, 0x4d9049048091a2b4L, 0x4e4101100091a2b4L,
- 0x4ef189188091a2b4L, 0x4fa211210091a2b4L, 0x505299298091a2b4L,
- 0x510321320091a2b4L, 0x51b3a93a8091a2b4L, 0x526431430091a2b4L,
- 0x5314b94b8091a2b4L, 0x53c841840091a2b4L, 0x5478c98c8091a2b4L,
- 0x552981980091a2b4L, 0x55da09a08091a2b4L, 0x568a91a90091a2b4L,
- 0x573b19b18091a2b4L, 0x57eba1ba0091a2b4L, 0x589c29c28091a2b4L,
- 0x594cb1cb0091a2b4L, 0x5a001d01c048d15aL, 0x5ab061060048d15aL,
- 0x5b60a50a4048d15aL, 0x5c1101100048d15aL, 0x5cc145144048d15aL,
- 0x5d7189188048d15aL, 0x5e21cd1cc048d15aL, 0x5ed211210048d15aL,
- 0x5f8255254048d15aL, 0x603419418048d15aL, 0x60e45d45c048d15aL,
- 0x6194a14a0048d15aL, 0x6244e54e4048d15aL, 0x62f541540048d15aL,
- 0x63a585584048d15aL, 0x6455c95c8048d15aL, 0x65060d60c048d15aL,
- 0x65b651650048d15aL, 0x666815814048d15aL, 0x671859858048d15aL,
- 0x67c89d89c048d15aL, 0x6878e18e0048d15aL, 0x692925924048d15aL,
- 0x69d981980048d15aL, 0x6a89c59c4048d15aL, 0x6b3a09a08048d15aL,
- 0x6bea4da4c048d15aL, 0x6c9c11c10048d15aL, 0x6d4c55c54048d15aL,
- 0x6dfc99c98048d15aL, 0x6eacddcdc048d15aL, 0x6f5d21d20048d15aL,
- 0x700d65d64048d15aL, 0x70bdc1dc0048d15aL, 0x716e05e04048d15aL,
- 0x721e49e48048d15aL, 0x72d00700602468adL, 0x73802902802468adL,
- 0x74304b04a02468adL, 0x74e06d06c02468adL, 0x75908f08e02468adL,
- 0x7640b10b002468adL, 0x76f0d30d202468adL, 0x77a10110002468adL,
- 0x78512312202468adL, 0x79020520402468adL, 0x79b22722602468adL,
- 0x7a624924802468adL, 0x7b126b26a02468adL, 0x7bc28d28c02468adL,
- 0x7c72af2ae02468adL, 0x7d22d12d002468adL, 0x7dd2f32f202468adL,
- 0x7e832132002468adL, 0x7f40011001012345L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L };
-
- for (int i = 0; i < expecteds.length; i++) {
- int part = i*11;
- String inputString = "0x" + part + "." + part + "0123456789abcdefp" + part;
-
- double actual = Double.parseDouble(inputString);
- double expected = Double.longBitsToDouble(expecteds[i]);
-
- String expectedString = "0x" + Long.toHexString(Double.doubleToLongBits(expected));
- String actualString = "0x" + Long.toHexString(Double.doubleToLongBits(actual));
- String errorMsg = i + "th input string is:<" + inputString
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0D);
- }
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies positive functionality.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_NormalNegativeExponent() {
- long[] expecteds = {
- 0x3f323456789abcdfL, 0x3f8111012345678aL, 0x3ee1110091a2b3c5L,
- 0x3e39998091a2b3c5L, 0x3d91110048d159e2L, 0x3ce5554048d159e2L,
- 0x3c39998048d159e2L, 0x3b8dddc048d159e2L, 0x3ae111002468acf1L,
- 0x3a3333202468acf1L, 0x3991011001234568L, 0x38e2112101234568L,
- 0x3833213201234568L, 0x3784314301234568L, 0x36d5415401234568L,
- 0x3626516501234568L, 0x3577617601234568L, 0x34c8718701234568L,
- 0x3419819801234568L, 0x337049048091a2b4L, 0x32c101100091a2b4L,
- 0x321189188091a2b4L, 0x316211210091a2b4L, 0x30b299298091a2b4L,
- 0x300321320091a2b4L, 0x2f53a93a8091a2b4L, 0x2ea431430091a2b4L,
- 0x2df4b94b8091a2b4L, 0x2d4841840091a2b4L, 0x2c98c98c8091a2b4L,
- 0x2be981980091a2b4L, 0x2b3a09a08091a2b4L, 0x2a8a91a90091a2b4L,
- 0x29db19b18091a2b4L, 0x292ba1ba0091a2b4L, 0x287c29c28091a2b4L,
- 0x27ccb1cb0091a2b4L, 0x27201d01c048d15aL, 0x267061060048d15aL,
- 0x25c0a50a4048d15aL, 0x251101100048d15aL, 0x246145144048d15aL,
- 0x23b189188048d15aL, 0x2301cd1cc048d15aL, 0x225211210048d15aL,
- 0x21a255254048d15aL, 0x20f419418048d15aL, 0x20445d45c048d15aL,
- 0x1f94a14a0048d15aL, 0x1ee4e54e4048d15aL, 0x1e3541540048d15aL,
- 0x1d8585584048d15aL, 0x1cd5c95c8048d15aL, 0x1c260d60c048d15aL,
- 0x1b7651650048d15aL, 0x1ac815814048d15aL, 0x1a1859858048d15aL,
- 0x19689d89c048d15aL, 0x18b8e18e0048d15aL, 0x180925924048d15aL,
- 0x175981980048d15aL, 0x16a9c59c4048d15aL, 0x15fa09a08048d15aL,
- 0x154a4da4c048d15aL, 0x149c11c10048d15aL, 0x13ec55c54048d15aL,
- 0x133c99c98048d15aL, 0x128cddcdc048d15aL, 0x11dd21d20048d15aL,
- 0x112d65d64048d15aL, 0x107dc1dc0048d15aL, 0xfce05e04048d15aL,
- 0xf1e49e48048d15aL, 0xe700700602468adL, 0xdc02902802468adL,
- 0xd104b04a02468adL, 0xc606d06c02468adL, 0xbb08f08e02468adL,
- 0xb00b10b002468adL, 0xa50d30d202468adL, 0x9a10110002468adL,
- 0x8f12312202468adL, 0x8420520402468adL, 0x7922722602468adL,
- 0x6e24924802468adL, 0x6326b26a02468adL, 0x5828d28c02468adL,
- 0x4d2af2ae02468adL, 0x422d12d002468adL, 0x372f32f202468adL,
- 0x2c32132002468adL, 0x220011001012345L, 0x170121012012345L,
- 0xc0231023012345L, 0x10341034012345L, 0x208a208a024L,
- 0x41584158L, 0x83388L, 0x108L,
- 0x0L, 0x0L, 0x0L,
- 0x0L, 0x0L, 0x0L,
- 0x0L, 0x0L, 0x0L,
- 0x0L, 0x0L, 0x0L,
- 0x0L, 0x0L };
-
- for (int i = 0; i < expecteds.length; i++) {
- int part = i*11;
- String inputString = "0x" + part + "." + part + "0123456789abcdefp-" + part;
-
- double actual = Double.parseDouble(inputString);
- double expected = Double.longBitsToDouble(expecteds[i]);
-
- String expectedString = "0x" + Long.toHexString(Double.doubleToLongBits(expected));
- String actualString = "0x" + Long.toHexString(Double.doubleToLongBits(actual));
- String errorMsg = i + "th input string is:<" + inputString
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0D);
- }
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies max boundary.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_MaxNormalBoundary() {
- long[] expecteds = {
- 0x7fefffffffffffffL, 0x7fefffffffffffffL, 0x7fefffffffffffffL,
- 0x7fefffffffffffffL, 0x7fefffffffffffffL, 0x7fefffffffffffffL,
- 0x7fefffffffffffffL, 0x7ff0000000000000L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L, 0x7ff0000000000000L,
- 0x7ff0000000000000L, 0x7ff0000000000000L, 0x7ff0000000000000L,
-
- 0xffefffffffffffffL, 0xffefffffffffffffL, 0xffefffffffffffffL,
- 0xffefffffffffffffL, 0xffefffffffffffffL, 0xffefffffffffffffL,
- 0xffefffffffffffffL, 0xfff0000000000000L, 0xfff0000000000000L,
- 0xfff0000000000000L, 0xfff0000000000000L, 0xfff0000000000000L,
- 0xfff0000000000000L, 0xfff0000000000000L, 0xfff0000000000000L };
-
- String[] inputs = {
- "0x1.fffffffffffffp1023",
- "0x1.fffffffffffff000000000000000000000000001p1023",
- "0x1.fffffffffffff1p1023",
- "0x1.fffffffffffff100000000000000000000000001p1023",
- "0x1.fffffffffffff1fffffffffffffffffffffffffffffffffffffffffffffp1023",
- "0x1.fffffffffffff7p1023",
- "0x1.fffffffffffff700000000000000000000000001p1023",
- "0x1.fffffffffffff8p1023",
- "0x1.fffffffffffff800000000000000000000000001p1023",
- "0x1.fffffffffffff8fffffffffffffffffffffffffffffffffffffffffffffp1023",
- "0x1.fffffffffffff9p1023",
- "0x1.fffffffffffff900000000000000000000000001p1023",
- "0x1.ffffffffffffffp1023",
- "0x1.ffffffffffffff00000000000000000000000001p1023",
- "0x1.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp1023",
-
- "-0x1.fffffffffffffp1023",
- "-0x1.fffffffffffff000000000000000000000000001p1023",
- "-0x1.fffffffffffff1p1023",
- "-0x1.fffffffffffff100000000000000000000000001p1023",
- "-0x1.fffffffffffff1fffffffffffffffffffffffffffffffffffffffffffffp1023",
- "-0x1.fffffffffffff7p1023",
- "-0x1.fffffffffffff700000000000000000000000001p1023",
- "-0x1.fffffffffffff8p1023",
- "-0x1.fffffffffffff800000000000000000000000001p1023",
- "-0x1.fffffffffffff8fffffffffffffffffffffffffffffffffffffffffffffp1023",
- "-0x1.fffffffffffff9p1023",
- "-0x1.fffffffffffff900000000000000000000000001p1023",
- "-0x1.ffffffffffffffp1023",
- "-0x1.ffffffffffffff00000000000000000000000001p1023",
- "-0x1.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp1023" };
-
- for (int i = 0; i < inputs.length; i++) {
- double actual = Double.parseDouble(inputs[i]);
- double expected = Double.longBitsToDouble(expecteds[i]);
-
- String expectedString = "0x" + Long.toHexString(Double.doubleToLongBits(expected));
- String actualString = "0x" + Long.toHexString(Double.doubleToLongBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0D);
- }
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies Min boundary.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_MinNormalBoundary() {
- long[] expecteds = {
- 0x10000000000000L, 0x10000000000000L, 0x10000000000000L,
- 0x10000000000000L, 0x10000000000000L, 0x10000000000000L,
- 0x10000000000000L, 0x10000000000000L, 0x10000000000001L,
- 0x10000000000001L, 0x10000000000001L, 0x10000000000001L,
- 0x10000000000001L, 0x10000000000001L, 0x10000000000001L,
-
- 0x8010000000000000L, 0x8010000000000000L, 0x8010000000000000L,
- 0x8010000000000000L, 0x8010000000000000L, 0x8010000000000000L,
- 0x8010000000000000L, 0x8010000000000000L, 0x8010000000000001L,
- 0x8010000000000001L, 0x8010000000000001L, 0x8010000000000001L,
- 0x8010000000000001L, 0x8010000000000001L, 0x8010000000000001L };
-
- String[] inputs = {
- "0x1.0p-1022",
- "0x1.00000000000001p-1022",
- "0x1.000000000000010000000000000000001p-1022",
- "0x1.00000000000001fffffffffffffffffffffffffffffffffp-1022",
- "0x1.00000000000007p-1022",
- "0x1.000000000000070000000000000000001p-1022",
- "0x1.00000000000007fffffffffffffffffffffffffffffffffp-1022",
- "0x1.00000000000008p-1022",
- "0x1.000000000000080000000000000000001p-1022",
- "0x1.00000000000008fffffffffffffffffffffffffffffffffp-1022",
- "0x1.00000000000009p-1022",
- "0x1.000000000000090000000000000000001p-1022",
- "0x1.00000000000009fffffffffffffffffffffffffffffffffp-1022",
- "0x1.0000000000000fp-1022",
- "0x1.0000000000000ffffffffffffffffffffffffffffffffffp-1022",
-
- "-0x1.0p-1022",
- "-0x1.00000000000001p-1022",
- "-0x1.000000000000010000000000000000001p-1022",
- "-0x1.00000000000001fffffffffffffffffffffffffffffffffp-1022",
- "-0x1.00000000000007p-1022",
- "-0x1.000000000000070000000000000000001p-1022",
- "-0x1.00000000000007fffffffffffffffffffffffffffffffffp-1022",
- "-0x1.00000000000008p-1022",
- "-0x1.000000000000080000000000000000001p-1022",
- "-0x1.00000000000008fffffffffffffffffffffffffffffffffp-1022",
- "-0x1.00000000000009p-1022",
- "-0x1.000000000000090000000000000000001p-1022",
- "-0x1.00000000000009fffffffffffffffffffffffffffffffffp-1022",
- "-0x1.0000000000000fp-1022",
- "-0x1.0000000000000ffffffffffffffffffffffffffffffffffp-1022" };
-
- for (int i = 0; i < inputs.length; i++) {
- double actual = Double.parseDouble(inputs[i]);
- double expected = Double.longBitsToDouble(expecteds[i]);
-
- String expectedString = "0x" + Long.toHexString(Double.doubleToLongBits(expected));
- String actualString = "0x" + Long.toHexString(Double.doubleToLongBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0D);
- }
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies Max boundary.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_MaxSubNormalBoundary() {
- long[] expecteds = {
- 0xfffffffffffffL, 0xfffffffffffffL, 0xfffffffffffffL,
- 0xfffffffffffffL, 0xfffffffffffffL, 0xfffffffffffffL,
- 0xfffffffffffffL, 0x10000000000000L, 0x10000000000000L,
- 0x10000000000000L, 0x10000000000000L, 0x10000000000000L,
- 0x10000000000000L, 0x10000000000000L, 0x10000000000000L,
-
- 0x800fffffffffffffL, 0x800fffffffffffffL, 0x800fffffffffffffL,
- 0x800fffffffffffffL, 0x800fffffffffffffL, 0x800fffffffffffffL,
- 0x800fffffffffffffL, 0x8010000000000000L, 0x8010000000000000L,
- 0x8010000000000000L, 0x8010000000000000L, 0x8010000000000000L,
- 0x8010000000000000L, 0x8010000000000000L, 0x8010000000000000L };
-
- String[] inputs = {
- "0x0.fffffffffffffp-1022",
- "0x0.fffffffffffff00000000000000000000000000000000001p-1022",
- "0x0.fffffffffffff1p-1022",
- "0x0.fffffffffffff10000000000000000000000000000000001p-1022",
- "0x0.fffffffffffff1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
- "0x0.fffffffffffff7p-1022",
- "0x0.fffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
- "0x0.fffffffffffff8p-1022",
- "0x0.fffffffffffff80000000000000000000000000000000001p-1022",
- "0x0.fffffffffffff8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
- "0x0.fffffffffffff9p-1022",
- "0x0.fffffffffffff9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
- "0x0.ffffffffffffffp-1022",
- "0x0.ffffffffffffff0000000000000000000000000000000001p-1022",
- "0x0.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
-
- "-0x0.fffffffffffffp-1022",
- "-0x0.fffffffffffff00000000000000000000000000000000001p-1022",
- "-0x0.fffffffffffff1p-1022",
- "-0x0.fffffffffffff10000000000000000000000000000000001p-1022",
- "-0x0.fffffffffffff1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
- "-0x0.fffffffffffff7p-1022",
- "-0x0.fffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
- "-0x0.fffffffffffff8p-1022",
- "-0x0.fffffffffffff80000000000000000000000000000000001p-1022",
- "-0x0.fffffffffffff8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
- "-0x0.fffffffffffff9p-1022",
- "-0x0.fffffffffffff9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022",
- "-0x0.ffffffffffffffp-1022",
- "-0x0.ffffffffffffff0000000000000000000000000000000001p-1022",
- "-0x0.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-1022" };
-
- for (int i = 0; i < inputs.length; i++) {
- double actual = Double.parseDouble(inputs[i]);
- double expected = Double.longBitsToDouble(expecteds[i]);
-
- String expectedString = "0x" + Long.toHexString(Double.doubleToLongBits(expected));
- String actualString = "0x" + Long.toHexString(Double.doubleToLongBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0D);
- }
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies Min boundary.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_MinSubNormalBoundary() {
- long[] expecteds = {
- 0x1L, 0x1L, 0x2L,
- 0x1L, 0x1L, 0x1L,
- 0x2L, 0x2L, 0x2L,
- 0x2L, 0x2L, 0x2L,
- 0x2L, 0x2L, 0x2L,
-
- 0x8000000000000001L, 0x8000000000000001L, 0x8000000000000002L,
- 0x8000000000000001L, 0x8000000000000001L, 0x8000000000000001L,
- 0x8000000000000002L, 0x8000000000000002L, 0x8000000000000002L,
- 0x8000000000000002L, 0x8000000000000002L, 0x8000000000000002L,
- 0x8000000000000002L, 0x8000000000000002L, 0x8000000000000002L };
-
- String[] inputs = {
- "0x0.0000000000001p-1022",
- "0x0.00000000000010000000000000000001p-1022",
- "0x0.0000000000001fffffffffffffffffffffffffffffffffp-1022",
- "0x0.00000000000017p-1022",
- "0x0.000000000000170000000000000000001p-1022",
- "0x0.00000000000017fffffffffffffffffffffffffffffffffp-1022",
- "0x0.00000000000018p-1022",
- "0x0.000000000000180000000000000000001p-1022",
- "0x0.00000000000018fffffffffffffffffffffffffffffffffp-1022",
- "0x0.00000000000019p-1022",
- "0x0.000000000000190000000000000000001p-1022",
- "0x0.00000000000019fffffffffffffffffffffffffffffffffp-1022",
- "0x0.0000000000001fp-1022",
- "0x0.0000000000001f0000000000000000001p-1022",
- "0x0.0000000000001ffffffffffffffffffffffffffffffffffp-1022",
-
- "-0x0.0000000000001p-1022",
- "-0x0.00000000000010000000000000000001p-1022",
- "-0x0.0000000000001fffffffffffffffffffffffffffffffffp-1022",
- "-0x0.00000000000017p-1022",
- "-0x0.000000000000170000000000000000001p-1022",
- "-0x0.00000000000017fffffffffffffffffffffffffffffffffp-1022",
- "-0x0.00000000000018p-1022",
- "-0x0.000000000000180000000000000000001p-1022",
- "-0x0.00000000000018fffffffffffffffffffffffffffffffffp-1022",
- "-0x0.00000000000019p-1022",
- "-0x0.000000000000190000000000000000001p-1022",
- "-0x0.00000000000019fffffffffffffffffffffffffffffffffp-1022",
- "-0x0.0000000000001fp-1022",
- "-0x0.0000000000001f0000000000000000001p-1022",
- "-0x0.0000000000001ffffffffffffffffffffffffffffffffffp-1022" };
-
- for (int i = 0; i < inputs.length; i++) {
- double actual = Double.parseDouble(inputs[i]);
- double expected = Double.longBitsToDouble(expecteds[i]);
-
- String expectedString = "0x" + Long.toHexString(Double.doubleToLongBits(expected));
- String actualString = "0x" + Long.toHexString(Double.doubleToLongBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0D);
- }
- }
-
- /**
- * @tests java.lang.Double#parseDouble(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies zero boundary.",
- method = "parseDouble",
- args = {java.lang.String.class}
- )
- public void test_parseDouble_LString_ZeroBoundary() {
- long[] expecteds = {
- 0x0L, 0x0L, 0x0L,
- 0x1L, 0x1L, 0x1L,
- 0x1L, 0x1L, 0x1L,
- 0x8000000000000000L, 0x8000000000000000L, 0x8000000000000000L,
- 0x8000000000000001L, 0x8000000000000001L, 0x8000000000000001L,
- 0x8000000000000001L, 0x8000000000000001L, 0x8000000000000001L };
-
- String[] inputs = {
- "0x0.00000000000004p-1022",
- "0x0.00000000000007ffffffffffffffffffffffp-1022",
- "0x0.00000000000008p-1022",
- "0x0.000000000000080000000000000000001p-1022",
- "0x0.00000000000008fffffffffffffffffffffffffffffffp-1022",
- "0x0.00000000000009p-1022",
- "0x0.000000000000090000000000000000001p-1022",
- "0x0.00000000000009fffffffffffffffffffffffffffffffffp-1022",
- "0x0.0000000000000fffffffffffffffffffffffffffffffffffp-1022",
-
- "-0x0.00000000000004p-1022",
- "-0x0.00000000000007ffffffffffffffffffffffp-1022",
- "-0x0.00000000000008p-1022",
- "-0x0.000000000000080000000000000000001p-1022",
- "-0x0.00000000000008fffffffffffffffffffffffffffffffp-1022",
- "-0x0.00000000000009p-1022",
- "-0x0.000000000000090000000000000000001p-1022",
- "-0x0.00000000000009fffffffffffffffffffffffffffffffffp-1022",
- "-0x0.0000000000000fffffffffffffffffffffffffffffffffffp-1022" };
-
- for (int i = 0; i < inputs.length; i++) {
- double actual = Double.parseDouble(inputs[i]);
- double expected = Double.longBitsToDouble(expecteds[i]);
-
- String expectedString = "0x" + Long.toHexString(Double.doubleToLongBits(expected));
- String actualString = "0x" + Long.toHexString(Double.doubleToLongBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0D);
- }
- }
-
- /**
- * @tests java.lang.Double#shortValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "shortValue",
- args = {}
- )
- public void test_shortValue() {
- // Test for method short java.lang.Double.shortValue()
- Double d = new Double(1923311.47712);
- assertEquals("Returned incorrect short value", 22767, d.shortValue());
- }
-
- /**
- * @tests java.lang.Double#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() {
- // Test for method java.lang.String java.lang.Double.toString()
- test_toString(1.7976931348623157E308, "1.7976931348623157E308");
- test_toString(5.0E-4, "5.0E-4");
- }
-
- /**
- * @tests java.lang.Double#toString(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {double.class}
- )
- public void test_toStringD() {
- // Test for method java.lang.String java.lang.Double.toString(double)
- test_toString(1.7976931348623157E308, "1.7976931348623157E308");
- test_toString(1.0 / 0.0, "Infinity");
- test_toString(0.0 / 0.0, "NaN");
- test_toString(-1.0 / 0.0, "-Infinity");
-
- double d;
- d = Double.longBitsToDouble(0x470fffffffffffffL);
- test_toString(d, "2.0769187434139308E34");
- d = Double.longBitsToDouble(0x4710000000000000L);
- test_toString(d, "2.076918743413931E34");
-
- d = Double.longBitsToDouble(0x470000000000000aL);
- test_toString(d, "1.0384593717069678E34");
- d = Double.longBitsToDouble(0x470000000000000bL);
- test_toString(d, "1.038459371706968E34");
-
- d = Double.longBitsToDouble(0x4700000000000017L);
- test_toString(d, "1.0384593717069708E34");
- d = Double.longBitsToDouble(0x4700000000000018L);
- test_toString(d, "1.038459371706971E34");
-
- d = Double.longBitsToDouble(0x4700000000000024L);
- test_toString(d, "1.0384593717069738E34");
- d = Double.longBitsToDouble(0x4700000000000025L);
- test_toString(d, "1.038459371706974E34");
-
- d = Double.longBitsToDouble(0x4700000000000031L);
- test_toString(d, "1.0384593717069768E34");
- d = Double.longBitsToDouble(0x4700000000000032L);
- test_toString(d, "1.038459371706977E34");
-
- d = Double.longBitsToDouble(0x470000000000003eL);
- test_toString(d, "1.0384593717069798E34");
- d = Double.longBitsToDouble(0x470000000000003fL);
- test_toString(d, "1.03845937170698E34");
-
- d = Double.longBitsToDouble(0x7e00000000000003L);
- test_toString(d, "8.371160993642719E298");
- d = Double.longBitsToDouble(0x7e00000000000004L);
- test_toString(d, "8.37116099364272E298");
-
- d = Double.longBitsToDouble(0x7e00000000000008L);
- test_toString(d, "8.371160993642728E298");
- d = Double.longBitsToDouble(0x7e00000000000009L);
- test_toString(d, "8.37116099364273E298");
-
- d = Double.longBitsToDouble(0x7e00000000000013L);
- test_toString(d, "8.371160993642749E298");
- d = Double.longBitsToDouble(0x7e00000000000014L);
- test_toString(d, "8.37116099364275E298");
-
- d = Double.longBitsToDouble(0x7e00000000000023L);
- test_toString(d, "8.371160993642779E298");
- d = Double.longBitsToDouble(0x7e00000000000024L);
- test_toString(d, "8.37116099364278E298");
-
- d = Double.longBitsToDouble(0x7e0000000000002eL);
- test_toString(d, "8.371160993642799E298");
- d = Double.longBitsToDouble(0x7e0000000000002fL);
- test_toString(d, "8.3711609936428E298");
-
- d = Double.longBitsToDouble(0xda00000000000001L);
- test_toString(d, "-3.3846065602060736E125");
- d = Double.longBitsToDouble(0xda00000000000002L);
- test_toString(d, "-3.384606560206074E125");
-
- d = Double.longBitsToDouble(0xda00000000000005L);
- test_toString(d, "-3.3846065602060766E125");
- d = Double.longBitsToDouble(0xda00000000000006L);
- test_toString(d, "-3.384606560206077E125");
-
- d = Double.longBitsToDouble(0xda00000000000009L);
- test_toString(d, "-3.3846065602060796E125");
- d = Double.longBitsToDouble(0xda0000000000000aL);
- test_toString(d, "-3.38460656020608E125");
-
- d = Double.longBitsToDouble(0xda0000000000000dL);
- test_toString(d, "-3.3846065602060826E125");
- d = Double.longBitsToDouble(0xda0000000000000eL);
- test_toString(d, "-3.384606560206083E125");
- }
-
- /**
- * @tests java.lang.Double#valueOf(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {java.lang.String.class}
- )
- public void test_valueOfLjava_lang_String() {
- // Test for method java.lang.Double
- // java.lang.Double.valueOf(java.lang.String)
- assertTrue("Incorrect double returned", Math.abs(Double.valueOf("999999999999.999")
- .doubleValue() - 999999999999.999d) < 1);
-
- try {
- Double.valueOf(null);
- fail("Expected Double.valueOf(null) to throw NPE.");
- } catch (NullPointerException ex) {
- // expected
- } catch (Throwable ex) {
- fail("Expected Double.valueOf(null) to throw NPE not " + ex.getClass().getName());
- }
-
- try {
- Double.valueOf("");
- fail("Expected Double.valueOf(\"\") to throw NFE");
- } catch (NumberFormatException e) {
- // expected
- }
-
- Double pi = Double.valueOf("3.141592654");
- assertEquals(3.141592654, pi.doubleValue(), 0D);
-
- Double posZero = Double.valueOf("+0.0");
- Double negZero = Double.valueOf("-0.0");
- assertFalse("Doubletest0", posZero.equals(negZero));
-
- // Tests for double values by name.
- Double expectedNaN = new Double(Double.NaN);
-
- Double posNaN = Double.valueOf("NaN");
- assertTrue("Doubletest1", posNaN.equals(expectedNaN));
-
- Double posNaNSigned = Double.valueOf("+NaN");
- assertTrue("Doubletest2", posNaNSigned.equals(expectedNaN));
-
- Double negNaNSigned = Double.valueOf("-NaN");
- assertTrue("Doubletest3", negNaNSigned.equals(expectedNaN));
-
- Double posInfinite = Double.valueOf("Infinity");
- assertTrue("Doubletest4", posInfinite.equals(new Double(Double.POSITIVE_INFINITY)));
-
- Double posInfiniteSigned = Double.valueOf("+Infinity");
- assertTrue("Doubletest5", posInfiniteSigned
- .equals(new Double(Double.POSITIVE_INFINITY)));
-
- Double negInfiniteSigned = Double.valueOf("-Infinity");
- assertTrue("Doubletest6", negInfiniteSigned
- .equals(new Double(Double.NEGATIVE_INFINITY)));
- }
-
- /**
- * @tests java.lang.Double#compareTo(java.lang.Double)
- * @tests java.lang.Double#compare(double, double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "compareTo",
- args = {java.lang.Double.class}
- )
- public void test_compareToLjava_lang_Double() {
- // A selection of double values in ascending order.
- double[] values = new double[] { Double.NEGATIVE_INFINITY, -Double.MAX_VALUE, -2d,
- -Double.MIN_VALUE, -0d, 0d, Double.MIN_VALUE, 2d, Double.MAX_VALUE,
- Double.POSITIVE_INFINITY, Double.NaN };
- for (int i = 0; i < values.length; i++) {
- double d1 = values[i];
-
- // Test that each value compares equal to itself; and each object is
- // equal to another object like itself.
- assertTrue("Assert 0: compare() should be equal: " + d1,
- Double.compare(d1, d1) == 0);
- Double objDouble = new Double(d1);
- assertTrue("Assert 1: compareTo() should be equal: " + d1, objDouble
- .compareTo(objDouble) == 0);
-
- // Test that the Double-defined order is respected
- for (int j = i + 1; j < values.length; j++) {
- double d2 = values[j];
- assertTrue("Assert 2: compare() " + d1 + " should be less " + d2, Double
- .compare(d1, d2) == -1);
- assertTrue("Assert 3: compare() " + d2 + " should be greater " + d1, Double
- .compare(d2, d1) == 1);
- Double D2 = new Double(d2);
- assertTrue("Assert 4: compareTo() " + d1 + " should be less " + d2, objDouble
- .compareTo(D2) == -1);
- assertTrue("Assert 5: compareTo() " + d2 + " should be greater " + d1, D2
- .compareTo(objDouble) == 1);
- }
- }
-
- try {
- new Double(0.0D).compareTo(null);
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Double#equals(java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "equals",
- args = {java.lang.Object.class}
- )
- public void test_equalsLjava_lang_Object() {
- Double d1 = new Double(87654321.12345d);
- Double d2 = new Double(87654321.12345d);
- Double d3 = new Double(0.0002f);
- assertTrue("Assert 0: Equality test failed", d1.equals(d2) && !(d1.equals(d3)));
-
- assertTrue("Assert 2: NaN should not be == Nan", Double.NaN != Double.NaN);
- assertTrue("Assert 3: NaN should not be == Nan", new Double(Double.NaN)
- .equals(new Double(Double.NaN)));
- assertTrue("Assert 4: -0d should be == 0d", 0d == -0d);
- assertTrue("Assert 5: -0d should not be equals() 0d", !new Double(0d)
- .equals(new Double(-0d)));
-
- Double dmax = new Double(Double.MAX_VALUE);
- Double dmax1 = new Double(Double.MAX_VALUE);
-
- assertTrue("Equality test failed", dmax.equals(dmax1) && !(dmax.equals(new Object())));
- }
-
- /**
- * @tests java.lang.Double#toHexString(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toHexString",
- args = {double.class}
- )
- public void test_toHexStringF() {
- // the follow values come from the Double Javadoc/Spec
- assertEquals("0x0.0p0", Double.toHexString(0.0D));
- assertEquals("-0x0.0p0", Double.toHexString(-0.0D));
- assertEquals("0x1.0p0", Double.toHexString(1.0D));
- assertEquals("-0x1.0p0", Double.toHexString(-1.0D));
- assertEquals("0x1.0p1", Double.toHexString(2.0D));
- assertEquals("0x1.8p1", Double.toHexString(3.0D));
- assertEquals("0x1.0p-1", Double.toHexString(0.5D));
- assertEquals("0x1.0p-2", Double.toHexString(0.25D));
- assertEquals("0x1.fffffffffffffp1023", Double.toHexString(Double.MAX_VALUE));
- assertEquals("0x0.0000000000001p-1022", Double.toHexString(Double.MIN_VALUE));
-
- // test edge cases
- assertEquals("NaN", Double.toHexString(Double.NaN));
- assertEquals("-Infinity", Double.toHexString(Double.NEGATIVE_INFINITY));
- assertEquals("Infinity", Double.toHexString(Double.POSITIVE_INFINITY));
-
- // test various numbers
- assertEquals("-0x1.da8p6", Double.toHexString(-118.625D));
- assertEquals("0x1.2957874cccccdp23", Double.toHexString(9743299.65D));
- assertEquals("0x1.2957874cccccdp23", Double.toHexString(9743299.65000D));
- assertEquals("0x1.2957874cccf63p23", Double.toHexString(9743299.650001234D));
- assertEquals("0x1.700d1061d3333p33", Double.toHexString(12349743299.65000D));
-
- // test HARMONY-2132
- assertEquals("0x1.01p10", Double.toHexString(0x1.01p10));
- }
-
- /**
- * @tests java.lang.Double#valueOf(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {double.class}
- )
- public void test_valueOfD() {
- assertEquals(new Double(Double.MIN_VALUE), Double.valueOf(Double.MIN_VALUE));
- assertEquals(new Double(Double.MAX_VALUE), Double.valueOf(Double.MAX_VALUE));
- assertEquals(new Double(0), Double.valueOf(0));
-
- int s = -128;
- while (s < 128) {
- assertEquals(new Double(s), Double.valueOf(s));
- assertEquals(new Double(s + 0.1D), Double.valueOf(s + 0.1D));
- s++;
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/EnumConstantNotPresentExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/EnumConstantNotPresentExceptionTest.java
deleted file mode 100644
index 053c694..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/EnumConstantNotPresentExceptionTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class EnumConstantNotPresentExceptionTest extends TestCase {
-
- public enum Fixture {
- ONE,TWO,THREE
- }
-
- /**
- * @test java.lang.EnumConstantNotPresentException#EnumConstantNotPresentException(Class<?
- * extends Enum>, String)
- */
- public void test_ConstructorLjava_lang_ClassLjava_lang_String() {
- try {
- new EnumConstantNotPresentException(null, "");
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @test java.lang.EnumConstantNotPresentException#enumType()
- */
- public void test_enumType() {
- EnumConstantNotPresentException e = new EnumConstantNotPresentException(Fixture.class, "FOUR");
- assertEquals(Fixture.class, e.enumType());
- }
-
- /**
- * @test java.lang.EnumConstantNotPresentException#constantName()
- */
- public void test_constantName() {
- EnumConstantNotPresentException e = new EnumConstantNotPresentException(Fixture.class, "FOUR");
- assertEquals("FOUR", e.constantName());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ErrorTest.java
deleted file mode 100644
index 32db9b3..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class ErrorTest extends TestCase {
-
- /**
- * @tests java.lang.Error#Error()
- */
- public void test_Constructor() {
- Error e = new Error();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.Error#Error(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- Error e = new Error("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExceptionInInitializerErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExceptionInInitializerErrorTest.java
deleted file mode 100644
index 83c6cd8..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExceptionInInitializerErrorTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class ExceptionInInitializerErrorTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.ExceptionInInitializerError#ExceptionInInitializerError()
- */
- public void test_Constructor() {
- ExceptionInInitializerError e = new ExceptionInInitializerError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.ExceptionInInitializerError#ExceptionInInitializerError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- ExceptionInInitializerError e = new ExceptionInInitializerError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.ExceptionInInitializerExceptionInInitializerError#ExceptionInInitializerError(java.lang.Throwable)
- */
- public void test_ConstructorLjava_lang_Throwable() {
- NullPointerException npe = new NullPointerException("fixture");
- ExceptionInInitializerError e = new ExceptionInInitializerError(npe);
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertSame(npe, e.getException());
- assertSame(npe, e.getCause());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExceptionTest.java
deleted file mode 100644
index 88cc2e4..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class ExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.Exception#Exception()
- */
- public void test_Constructor() {
- Exception e = new Exception();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.Exception#Exception(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- Exception e = new Exception("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExtendTestClass.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExtendTestClass.java
deleted file mode 100644
index f4944b2..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExtendTestClass.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.harmony.luni.tests.java.lang;
-
-@Deprecated
-@TestAnnotation("org.apache.harmony.luni.tests.java.lang.ExtendTestClass")
-public class ExtendTestClass extends PublicTestClass {
-
- private static final long serialVersionUID = 1L;
-
- public enum enumExm {ONE, TWO, THREE};
- @Override
- public void setCount(int value) {
-
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExtendTestClass1.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExtendTestClass1.java
deleted file mode 100644
index 8af91f1..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ExtendTestClass1.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class ExtendTestClass1 extends ExtendTestClass {
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/FloatTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/FloatTest.java
deleted file mode 100644
index a81b96e..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/FloatTest.java
+++ /dev/null
@@ -1,1293 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-@TestTargetClass(Float.class)
-public class FloatTest extends TestCase {
-
- private static final int rawBitsFor3_4eN38To38[] = { 0x1394470, 0x2e7958c, 0x490bd77, 0x634ecd5,
- 0x7e2280b, 0x98d5907, 0xb30af48, 0xcdcdb1a, 0xe8a08f0, 0x102c8b2d, 0x11d7adf8,
- 0x1386ccbb, 0x15287fe9, 0x16d29fe4, 0x1883a3ee, 0x1a248cea, 0x1bcdb025, 0x1d808e17,
- 0x1f20b19d, 0x20c8de04, 0x227b1585, 0x241ced73, 0x25c428d0, 0x27753303, 0x29193fe2,
- 0x2abf8fdb, 0x2c6f73d1, 0x2e15a863, 0x2fbb127c, 0x3169d71a, 0x33122671, 0x34b6b00d,
- 0x36645c10, 0x380eb98a, 0x39b267ec, 0x3b5f01e8, 0x3d0b6131, 0x3eae397d, 0x4059c7dc,
- 0x42081cea, 0x43aa2424, 0x4554ad2d, 0x4704ec3c, 0x48a6274b, 0x4a4fb11e, 0x4c01ceb3,
- 0x4da2425f, 0x4f4ad2f7, 0x50fd87b5, 0x529e74d1, 0x54461205, 0x55f79687, 0x579abe14,
- 0x59416d99, 0x5af1c900, 0x5c971da0, 0x5e3ce508, 0x5fec1e4a, 0x619392ee, 0x633877a9,
- 0x64e69594, 0x66901d7c, 0x683424dc, 0x69e12e12, 0x6b8cbccb, 0x6d2febfe, 0x6edbe6fe,
- 0x7089705f, 0x722bcc76, 0x73d6bf94, 0x758637bc, 0x7727c5ac, 0x78d1b717, 0x7a83126e,
- 0x7c23d70a, 0x7dcccccc, 0x7f7fffff };
-
- private static final String expectedStringFor3_4eN38To38[] = { "3.4028235E-38", "3.4028235E-37",
- "3.4028233E-36", "3.4028234E-35", "3.4028236E-34", "3.4028236E-33",
- "3.4028234E-32", "3.4028234E-31", "3.4028233E-30", "3.4028236E-29",
- "3.4028235E-28", "3.4028235E-27", "3.4028233E-26", "3.4028235E-25",
- "3.4028233E-24", "3.4028235E-23", "3.4028236E-22", "3.4028235E-21",
- "3.4028236E-20", "3.4028236E-19", "3.4028236E-18", "3.4028235E-17",
- "3.4028236E-16", "3.4028234E-15", "3.4028234E-14", "3.4028235E-13",
- "3.4028234E-12", "3.4028235E-11", "3.4028236E-10", "3.4028234E-9", "3.4028236E-8",
- "3.4028236E-7", "3.4028235E-6", "3.4028235E-5", "3.4028233E-4", "0.0034028236",
- "0.034028236", "0.34028235", "3.4028234", "34.028236", "340.28235", "3402.8235",
- "34028.234", "340282.34", "3402823.5", "3.4028236E7", "3.40282336E8",
- "3.40282342E9", "3.40282348E10", "3.40282343E11", "3.40282337E12", "3.40282353E13",
- "3.4028234E14", "3.4028234E15", "3.40282356E16", "3.40282356E17", "3.40282356E18",
- "3.4028236E19", "3.4028235E20", "3.4028233E21", "3.4028235E22", "3.4028233E23",
- "3.4028236E24", "3.4028234E25", "3.4028233E26", "3.4028234E27", "3.4028235E28",
- "3.4028236E29", "3.4028233E30", "3.4028235E31", "3.4028233E32", "3.4028236E33",
- "3.4028236E34", "3.4028234E35", "3.4028236E36", "3.4028235E37", "3.4028235E38" };
-
- private static final int rawBitsFor1_17eN38To38[] = { 0x80800000, 0x82200000, 0x83c80000,
- 0x857a0000, 0x871c4000, 0x88c35000, 0x8a742400, 0x8c189680, 0x8dbebc20, 0x8f6e6b28,
- 0x911502f9, 0x92ba43b7, 0x9468d4a5, 0x961184e7, 0x97b5e621, 0x99635fa9, 0x9b0e1bca,
- 0x9cb1a2bc, 0x9e5e0b6b, 0xa00ac723, 0xa1ad78ec, 0xa358d727, 0xa5078678, 0xa6a96816,
- 0xa853c21c, 0xaa045951, 0xaba56fa6, 0xad4ecb8f, 0xaf013f39, 0xb0a18f08, 0xb249f2ca,
- 0xb3fc6f7c, 0xb59dc5ae, 0xb7453719, 0xb8f684df, 0xba9a130c, 0xbc4097ce, 0xbdf0bdc2,
- 0xbf967699, 0xc13c1440, 0xc2eb1950, 0xc492efd2, 0xc637abc6, 0xc7e596b8, 0xc98f7e33,
- 0xcb335dc0, 0xcce0352f, 0xce8c213e, 0xd02f298d, 0xd1daf3f0, 0xd388d876, 0xd52b0e94,
- 0xd6d5d239, 0xd885a363, 0xda270c3c, 0xdbd0cf4b, 0xdd82818f, 0xdf2321f3, 0xe0cbea70,
- 0xe27ee50b, 0xe41f4f27, 0xe5c722f1, 0xe778ebad, 0xe91b934c, 0xeac2781f, 0xec731627,
- 0xee17edd8, 0xefbde94f, 0xf16d63a2, 0xf3145e45, 0xf4b975d7, 0xf667d34c, 0xf810e410,
- 0xf9b51d14, 0xfb626459, 0xfd0d7eb7, 0xfeb0de65 };
-
- private static final String expectedStringFor1_17eN38To38[] = { "-1.17549435E-38",
- "-1.1754944E-37", "-1.17549435E-36", "-1.17549435E-35", "-1.1754944E-34",
- "-1.17549435E-33", "-1.17549435E-32", "-1.1754944E-31", "-1.17549435E-30",
- "-1.17549435E-29", "-1.1754944E-28", "-1.1754943E-27", "-1.17549435E-26",
- "-1.1754943E-25", "-1.1754944E-24", "-1.1754943E-23", "-1.1754944E-22",
- "-1.1754943E-21", "-1.1754943E-20", "-1.1754943E-19", "-1.1754944E-18",
- "-1.1754944E-17", "-1.1754943E-16", "-1.1754943E-15", "-1.1754944E-14",
- "-1.1754943E-13", "-1.1754944E-12", "-1.1754943E-11", "-1.1754943E-10",
- "-1.1754944E-9", "-1.1754944E-8", "-1.1754943E-7", "-1.1754944E-6",
- "-1.1754943E-5", "-1.1754943E-4", "-0.0011754944", "-0.011754943", "-0.117549434",
- "-1.1754943", "-11.754944", "-117.54944", "-1175.4944", "-11754.943", "-117549.44",
- "-1175494.4", "-1.1754944E7", "-1.17549432E8", "-1.1754944E9", "-1.17549435E10",
- "-1.17549433E11", "-1.17549433E12", "-1.17549438E13", "-1.17549438E14",
- "-1.1754943E15", "-1.17549432E16", "-1.17549432E17", "-1.17549434E18",
- "-1.1754944E19", "-1.1754944E20", "-1.1754943E21", "-1.1754943E22",
- "-1.1754944E23", "-1.17549434E24", "-1.1754943E25", "-1.1754943E26",
- "-1.17549434E27", "-1.1754943E28", "-1.1754944E29", "-1.1754943E30",
- "-1.1754943E31", "-1.1754944E32", "-1.1754943E33", "-1.1754944E34",
- "-1.1754944E35", "-1.1754944E36", "-1.1754943E37", "-1.1754943E38" };
-
- private void doTestCompareRawBits(String originalFloatString, int expectedRawBits,
- String expectedString) {
- int rawBits;
- float result = Float.parseFloat(originalFloatString);
- rawBits = Float.floatToIntBits(result);
- assertEquals("Original float(" + originalFloatString + ") Converted float(" + result
- + ") Expecting:" + Integer.toHexString(expectedRawBits) + " Got: "
- + Integer.toHexString(rawBits), expectedRawBits, rawBits);
- }
-
- /**
- * @tests java.lang.Float#Float(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Float",
- args = {float.class}
- )
- public void test_ConstructorF() {
- // Test for method java.lang.Float(float)
-
- Float f = new Float(900.89f);
- assertTrue("Created incorrect float", f.floatValue() == 900.89f);
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Float",
- args = {double.class}
- )
- public void test_ConstructorD() {
-
- Float f = new Float(Double.MAX_VALUE);
- assertTrue("Created incorrect float", f.floatValue() == Float.POSITIVE_INFINITY);
- }
-
- /**
- * @tests java.lang.Float#Float(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Float",
- args = {java.lang.String.class}
- )
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.lang.Float(java.lang.String)
-
- Float f = new Float("900.89");
- assertTrue("Created incorrect Float", f.floatValue() == 900.89f);
- try {
- new Float("900.89ff");
- fail("NumberFormatException is not thrown.");
- } catch(NumberFormatException nfe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Float#byteValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "byteValue",
- args = {}
- )
- public void test_byteValue() {
- // Test for method byte java.lang.Float.byteValue()
- Float f = new Float(0.46874f);
- Float f2 = new Float(90.8f);
- assertTrue("Returned incorrect byte value", f.byteValue() == 0 && f2.byteValue() == 90);
- }
-
- /**
- * @tests java.lang.Float#compareTo(java.lang.Float)
- * @tests java.lang.Float#compare(float, float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "compare",
- args = {float.class, float.class}
- )
- public void test_compare() {
- float[] values = new float[] { Float.NEGATIVE_INFINITY, -Float.MAX_VALUE, -2f,
- -Float.MIN_VALUE, -0f, 0f, Float.MIN_VALUE, 2f, Float.MAX_VALUE,
- Float.POSITIVE_INFINITY, Float.NaN };
- for (int i = 0; i < values.length; i++) {
- float f1 = values[i];
- assertTrue("compare() should be equal: " + f1, Float.compare(f1, f1) == 0);
- Float F1 = new Float(f1);
- assertTrue("compareTo() should be equal: " + f1, F1.compareTo(F1) == 0);
- for (int j = i + 1; j < values.length; j++) {
- float f2 = values[j];
- assertTrue("compare() " + f1 + " should be less " + f2,
- Float.compare(f1, f2) == -1);
- assertTrue("compare() " + f2 + " should be greater " + f1, Float
- .compare(f2, f1) == 1);
- Float F2 = new Float(f2);
- assertTrue("compareTo() " + f1 + " should be less " + f2,
- F1.compareTo(F2) == -1);
- assertTrue("compareTo() " + f2 + " should be greater " + f1,
- F2.compareTo(F1) == 1);
- }
- }
-
- try {
- new Float(0.0F).compareTo(null);
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Float#doubleValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "doubleValue",
- args = {}
- )
- public void test_doubleValue() {
- // Test for method double java.lang.Float.doubleValue()
- assertTrue("Incorrect double value returned", Math.abs(new Float(999999.999f)
- .doubleValue() - 999999.999d) < 1);
- }
-
- /**
- * @tests java.lang.Float#floatToIntBits(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "floatToIntBits",
- args = {float.class}
- )
- public void test_floatToIntBitsF() {
- float f = 9876.2345f;
- int bits = Float.floatToIntBits(f);
- float r = Float.intBitsToFloat(bits);
- assertTrue("Incorrect intBits returned", f == r);
-
- assertEquals(0x7f800000, Float.floatToIntBits(Float.POSITIVE_INFINITY));
- assertEquals(0xff800000, Float.floatToIntBits(Float.NEGATIVE_INFINITY));
- assertEquals(0x7fc00000, Float.floatToIntBits(Float.NaN));
- }
-
- /**
- * @tests java.lang.Float#floatToRawIntBits(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "floatToRawIntBits",
- args = {float.class}
- )
- public void test_floatToRawIntBitsF() {
- int i = 0x7fc004d2;
- float f = Float.intBitsToFloat(i);
- assertTrue("Wrong raw bits", Float.floatToRawIntBits(f) == i);
-
- assertEquals(0x7f800000, Float.floatToRawIntBits(Float.POSITIVE_INFINITY));
- assertEquals(0xff800000, Float.floatToRawIntBits(Float.NEGATIVE_INFINITY));
- assertEquals(0x7fc00000, Float.floatToRawIntBits(Float.NaN));
- }
-
- /**
- * @tests java.lang.Float#floatValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "floatValue",
- args = {}
- )
- public void test_floatValue() {
- // Test for method float java.lang.Float.floatValue()
- Float f = new Float(87.657f);
- Float f2 = new Float(-0.876f);
- assertTrue("Returned incorrect floatValue", f.floatValue() == 87.657f
- && (f2.floatValue() == -0.876f));
-
- }
-
- /**
- * @tests java.lang.Float#hashCode()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "hashCode",
- args = {}
- )
- public void test_hashCode() {
- // Test for method int java.lang.Float.hashCode()
- Float f = new Float(1908.8786f);
- assertTrue("Returned invalid hash code for 1908.8786f", f.hashCode() == Float
- .floatToIntBits(1908.8786f));
-
- f = new Float(-1.112f);
- assertTrue("Returned invalid hash code for -1.112", f.hashCode() == Float
- .floatToIntBits(-1.112f));
-
- f = new Float(0f);
- assertTrue("Returned invalid hash code for 0", f.hashCode() == Float.floatToIntBits(0f));
-
- assertTrue(new Float(Float.MAX_VALUE).hashCode() != new Float(Float.MIN_VALUE).hashCode());
- }
-
- /**
- * @tests java.lang.Float#intBitsToFloat(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "intBitsToFloat",
- args = {int.class}
- )
- public void test_intBitsToFloatI() {
- float f = 9876.2345f;
- int bits = Float.floatToIntBits(f);
- float r = Float.intBitsToFloat(bits);
- assertEquals("Incorrect intBits returned", f, r, 0F);
-
- assertEquals(Float.POSITIVE_INFINITY, Float.intBitsToFloat(0x7f800000));
- assertEquals(Float.NEGATIVE_INFINITY, Float.intBitsToFloat(0xff800000));
-
- assertEquals(Float.NaN, Float.intBitsToFloat(0x7f800001));
- assertEquals(Float.NaN, Float.intBitsToFloat(0x7fffffff));
- assertEquals(Float.NaN, Float.intBitsToFloat(0xff800001));
- assertEquals(Float.NaN, Float.intBitsToFloat(0xffffffff));
- }
-
- /**
- * @tests java.lang.Float#intValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "intValue",
- args = {}
- )
- public void test_intValue() {
- // Test for method int java.lang.Float.intValue()
- Float f = new Float(0.46874f);
- Float f2 = new Float(90.8f);
- assertTrue("Returned incorrect int value", f.intValue() == 0 && f2.intValue() == 90);
- assertEquals(Integer.MAX_VALUE, new Float(Float.MAX_VALUE).intValue());
- assertEquals(0, new Float(Float.MIN_VALUE).intValue());
- }
-
- /**
- * @tests java.lang.Float#isInfinite()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isInfinite",
- args = {}
- )
- public void test_isInfinite() {
- // Test for method boolean java.lang.Float.isInfinite()
- assertTrue("Infinity check failed",
- (new Float(Float.POSITIVE_INFINITY).isInfinite() && new Float(
- Float.NEGATIVE_INFINITY).isInfinite())
- && !(new Float(0.13131414f).isInfinite()));
- }
-
- /**
- * @tests java.lang.Float#isInfinite(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isInfinite",
- args = {float.class}
- )
- public void test_isInfiniteF() {
- // Test for method boolean java.lang.Float.isInfinite(float)
-
- assertTrue("Infinity check failed", Float.isInfinite(Float.POSITIVE_INFINITY)
- && (Float.isInfinite(Float.NEGATIVE_INFINITY)) && !(Float.isInfinite(1.0f)));
- }
-
- /**
- * @tests java.lang.Float#isNaN()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isNaN",
- args = {}
- )
- public void test_isNaN() {
- // Test for method boolean java.lang.Float.isNaN()
- assertTrue("NAN check failed", new Float(Float.NaN).isNaN()
- && !(new Float(1.0f).isNaN()));
- }
-
- /**
- * @tests java.lang.Float#isNaN(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isNaN",
- args = {float.class}
- )
- public void test_isNaNF() {
- // Test for method boolean java.lang.Float.isNaN(float)
- assertTrue("NaN check failed", Float.isNaN(Float.NaN) && !(Float.isNaN(12.09f))
- && !Float.isNaN(Float.MAX_VALUE) && !Float.isNaN(Float.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.Float#longValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "longValue",
- args = {}
- )
- public void test_longValue() {
- // Test for method long java.lang.Float.longValue()
- Float f = new Float(0.46874f);
- Float f2 = new Float(90.8f);
- assertTrue("Returned incorrect long value", f.longValue() == 0 && f2.longValue() == 90);
- assertEquals(Long.MAX_VALUE, new Float(Float.MAX_VALUE).longValue());
- assertEquals(0, new Float(Float.MIN_VALUE).longValue());
- }
-
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies NumberFormatException.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloatLExceptions() {
- String [] incorrectStrings = {"", ";", "99999999EE999999", "99999l",
- "0x1.f.ffffep127"};
- for(int i = 0; i < incorrectStrings.length; i++) {
- try {
- Float.parseFloat(incorrectStrings[i]);
- fail("NumberFormatException is not thrown for string: "
- + incorrectStrings[i]);
- } catch(NumberFormatException nfe) {
- //expected
- }
- }
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies boundary cases.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloatLjava_lang_String() {
- assertEquals("Incorrect float returned, expected zero.", 0.0, Float
- .parseFloat("7.0064923216240853546186479164495e-46"), 0.0);
- assertEquals("Incorrect float returned, expected minimum float.", Float.MIN_VALUE,
- Float.parseFloat("7.0064923216240853546186479164496e-46"), 0.0);
-
- doTestCompareRawBits(
- "0.000000000000000000000000000000000000011754942807573642917278829910357665133228589927589904276829631184250030649651730385585324256680905818939208984375",
- 0x800000, "1.17549435E-38");
- doTestCompareRawBits(
- "0.00000000000000000000000000000000000001175494280757364291727882991035766513322858992758990427682963118425003064965173038558532425668090581893920898437499999f",
- 0x7fffff, "1.1754942E-38");
-
- /* Test a set of regular floats with exponents from -38 to +38 */
- for (int i = 38; i > 3; i--) {
- String testString;
- testString = "3.4028234663852886e-" + i;
- doTestCompareRawBits(testString, rawBitsFor3_4eN38To38[38 - i],
- expectedStringFor3_4eN38To38[38 - i]);
- }
- doTestCompareRawBits("3.4028234663852886e-3", rawBitsFor3_4eN38To38[38 - 3],
- expectedStringFor3_4eN38To38[38 - 3]);
- doTestCompareRawBits("3.4028234663852886e-2", rawBitsFor3_4eN38To38[38 - 2],
- expectedStringFor3_4eN38To38[38 - 2]);
- doTestCompareRawBits("3.4028234663852886e-1", rawBitsFor3_4eN38To38[38 - 1],
- expectedStringFor3_4eN38To38[38 - 1]);
- doTestCompareRawBits("3.4028234663852886e-0", rawBitsFor3_4eN38To38[38 - 0],
- expectedStringFor3_4eN38To38[38 - 0]);
- doTestCompareRawBits("3.4028234663852886e+1", rawBitsFor3_4eN38To38[38 + 1],
- expectedStringFor3_4eN38To38[38 + 1]);
- doTestCompareRawBits("3.4028234663852886e+2", rawBitsFor3_4eN38To38[38 + 2],
- expectedStringFor3_4eN38To38[38 + 2]);
- doTestCompareRawBits("3.4028234663852886e+3", rawBitsFor3_4eN38To38[38 + 3],
- expectedStringFor3_4eN38To38[38 + 3]);
- doTestCompareRawBits("3.4028234663852886e+4", rawBitsFor3_4eN38To38[38 + 4],
- expectedStringFor3_4eN38To38[38 + 4]);
- doTestCompareRawBits("3.4028234663852886e+5", rawBitsFor3_4eN38To38[38 + 5],
- expectedStringFor3_4eN38To38[38 + 5]);
- doTestCompareRawBits("3.4028234663852886e+6", rawBitsFor3_4eN38To38[38 + 6],
- expectedStringFor3_4eN38To38[38 + 6]);
-
- for (int i = 7; i < 39; i++) {
- String testString;
- testString = "3.4028234663852886e+" + i;
- doTestCompareRawBits(testString, rawBitsFor3_4eN38To38[38 + i],
- expectedStringFor3_4eN38To38[38 + i]);
- }
-
- /* Test another set of regular floats with exponents from -38 to +38 */
- for (int i = 38; i > 3; i--) {
- String testString;
- testString = "-1.1754943508222875e-" + i;
- doTestCompareRawBits(testString, rawBitsFor1_17eN38To38[38 - i],
- expectedStringFor1_17eN38To38[38 - i]);
- }
- doTestCompareRawBits("-1.1754943508222875e-3", rawBitsFor1_17eN38To38[38 - 3],
- expectedStringFor1_17eN38To38[38 - 3]);
- doTestCompareRawBits("-1.1754943508222875e-2", rawBitsFor1_17eN38To38[38 - 2],
- expectedStringFor1_17eN38To38[38 - 2]);
- doTestCompareRawBits("-1.1754943508222875e-1", rawBitsFor1_17eN38To38[38 - 1],
- expectedStringFor1_17eN38To38[38 - 1]);
- doTestCompareRawBits("-1.1754943508222875e-0", rawBitsFor1_17eN38To38[38 - 0],
- expectedStringFor1_17eN38To38[38 - 0]);
- doTestCompareRawBits("-1.1754943508222875e+1", rawBitsFor1_17eN38To38[38 + 1],
- expectedStringFor1_17eN38To38[38 + 1]);
- doTestCompareRawBits("-1.1754943508222875e+2", rawBitsFor1_17eN38To38[38 + 2],
- expectedStringFor1_17eN38To38[38 + 2]);
- doTestCompareRawBits("-1.1754943508222875e+3", rawBitsFor1_17eN38To38[38 + 3],
- expectedStringFor1_17eN38To38[38 + 3]);
- doTestCompareRawBits("-1.1754943508222875e+4", rawBitsFor1_17eN38To38[38 + 4],
- expectedStringFor1_17eN38To38[38 + 4]);
- doTestCompareRawBits("-1.1754943508222875e+5", rawBitsFor1_17eN38To38[38 + 5],
- expectedStringFor1_17eN38To38[38 + 5]);
- doTestCompareRawBits("-1.1754943508222875e+6", rawBitsFor1_17eN38To38[38 + 6],
- expectedStringFor1_17eN38To38[38 + 6]);
-
- for (int i = 7; i < 39; i++) {
- String testString;
- testString = "-1.1754943508222875e+" + i;
- doTestCompareRawBits(testString, rawBitsFor1_17eN38To38[38 + i],
- expectedStringFor1_17eN38To38[38 + i]);
- }
-
- /* Test denormalized floats (floats with exponents <= -38 */
- doTestCompareRawBits("1.1012984643248170E-45", 1, "1.4E-45");
- doTestCompareRawBits("-1.1012984643248170E-45", 0x80000001, "-1.4E-45");
- doTestCompareRawBits("1.0E-45", 1, "1.4E-45");
- doTestCompareRawBits("-1.0E-45", 0x80000001, "-1.4E-45");
- doTestCompareRawBits("0.9E-45", 1, "1.4E-45");
- doTestCompareRawBits("-0.9E-45", 0x80000001, "-1.4E-45");
- doTestCompareRawBits("4.203895392974451e-45", 3, "4.2E-45");
- doTestCompareRawBits("-4.203895392974451e-45", 0x80000003, "-4.2E-45");
- doTestCompareRawBits("0.004E-45", 0, "0.0");
- doTestCompareRawBits("-0.004E-45", 0x80000000, "-0.0");
-
- /*
- * Test for large floats close to and greater than 3.4028235E38 and
- * -3.4028235E38
- */
- doTestCompareRawBits("1.2E+38", 0x7eb48e52, "1.2E38");
- doTestCompareRawBits("-1.2E+38", 0xfeb48e52, "-1.2E38");
- doTestCompareRawBits("3.2E+38", 0x7f70bdc2, "3.2E38");
- doTestCompareRawBits("-3.2E+38", 0xff70bdc2, "-3.2E38");
- doTestCompareRawBits("3.4E+38", 0x7f7fc99e, "3.4E38");
- doTestCompareRawBits("-3.4E+38", 0xff7fc99e, "-3.4E38");
- doTestCompareRawBits("3.4028234663852886E+38", 0x7f7fffff, "3.4028235E38");
- doTestCompareRawBits("-3.4028234663852886E+38", 0xff7fffff, "-3.4028235E38");
- doTestCompareRawBits("3.405E+38", 0x7f800000, "Infinity");
- doTestCompareRawBits("-3.405E+38", 0xff800000, "-Infinity");
- doTestCompareRawBits("3.41E+38", 0x7f800000, "Infinity");
- doTestCompareRawBits("-3.41E+38", 0xff800000, "-Infinity");
- doTestCompareRawBits("3.42E+38", 0x7f800000, "Infinity");
- doTestCompareRawBits("-3.42E+38", 0xff800000, "-Infinity");
- doTestCompareRawBits("1.0E+39", 0x7f800000, "Infinity");
- doTestCompareRawBits("-1.0E+39", 0xff800000, "-Infinity");
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies boundary values.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloat_LString_Unusual() {
- float actual;
-
- actual = Float.parseFloat("0x00000000000000000000000000000000000000000.0000000000000000000000000000000000000p0000000000000000000000000000000000");
- assertEquals("Returned incorrect value", 0.0f, actual, 0.0F);
-
- actual = Float.parseFloat("+0Xfffff.fffffffffffffffffffffffffffffffp+99F");
- assertEquals("Returned incorrect value", 6.64614E35f, actual, 0.0F);
-
- actual = Float.parseFloat("-0X.123456789abcdefp+99f");
- assertEquals("Returned incorrect value", -4.5072022E28f, actual, 0.0F);
-
- actual = Float.parseFloat("-0X123456789abcdef.p+1f");
- assertEquals("Returned incorrect value", -1.63971062E17f, actual, 0.0F);
-
- actual = Float.parseFloat("-0X000000000000000000000000000001abcdef.0000000000000000000000000001abefp00000000000000000000000000000000000000000004f");
- assertEquals("Returned incorrect value", -4.48585472E8f, actual, 0.0F);
-
- actual = Float.parseFloat("0X0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001234p600f");
- assertEquals("Returned incorrect value", 5.907252E33f, actual, 0.0F);
-
- actual = Float.parseFloat("0x1.p9223372036854775807");
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY, actual, 0.0F);
-
- actual = Float.parseFloat("0x1.p9223372036854775808");
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY, actual, 0.0F);
-
- actual = Float.parseFloat("0x10.p9223372036854775808");
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY, actual, 0.0F);
-
- actual = Float.parseFloat("0xabcd.ffffffffp+2000");
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY, actual, 0.0F);
-
- actual = Float.parseFloat("0x1.p-9223372036854775808");
- assertEquals("Returned incorrect value", 0.0f, actual, 0.0F);
-
- actual = Float.parseFloat("0x1.p-9223372036854775809");
- assertEquals("Returned incorrect value", 0.0f, actual, 0.0F);
-
- actual = Float.parseFloat("0x.1p-9223372036854775809");
- assertEquals("Returned incorrect value", 0.0f, actual, 0.0F);
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies positive exponent.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloat_LString_NormalPositiveExponent() {
- int[] expecteds = {
- 0x3991a2b4, 0x43cc0247, 0x47909009,
- 0x4ac0c009, 0x4e109005, 0x5140c005,
- 0x5458d805, 0x57848402, 0x5a909002,
- 0x5da8a802, 0x60c0c002, 0x63cccc02,
- 0x66e4e402, 0x69f0f002, 0x6d048401,
- 0x70109001, 0x73169601, 0x76810810,
- 0x79840840, 0x7c8a08a0, 0x7f800000,
- 0x7f800000, 0x7f800000, 0x7f800000,
- 0x7f800000,
- };
-
- for (int i = 0; i < expecteds.length; i++) {
- int part = i * 6;
- String inputString = "0x" + part + "." + part + "0123456789abcdefp" + part;
-
- float actual = Float.parseFloat(inputString);
- float expected = Float.intBitsToFloat(expecteds[i]);
-
- String expectedString = Integer.toHexString(Float.floatToIntBits(expected));
- String actualString = Integer.toHexString(Float.floatToIntBits(actual));
- String errorMsg = i + "th input string is:<" + inputString
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0F);
- }
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies negative exponent.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloat_LString_NormalNegativeExponent() {
- int[] expecteds = {
- 0x3991a2b4,
- 0x3d6e0247,
- 0x3aa0a009,
- 0x37848405,
- 0x3420a005,
- 0x30d4d405,
- 0x2d848402,
- 0x2a129202,
- 0x26acac02,
- 0x2346c602,
- 0x1fe0e002,
- 0x1c6eee02,
- 0x19048401,
- 0x15919101,
- 0x12189801,
- 0xf028828,
- 0xb890890,
- 0x80c88c8,
- 0x4930930,
- 0x1198998,
- 0x28028,
- 0x51c,
- 0xb,
- 0x0,
- 0x0,
- };
-
- for (int i = 0; i < expecteds.length; i++) {
- int part = i * 7;
- String inputString = "0x" + part + "." + part + "0123456789abcdefp-" + part;
-
- float actual = Float.parseFloat(inputString);
- float expected = Float.intBitsToFloat(expecteds[i]);
-
- String expectedString = Integer.toHexString(Float.floatToIntBits(expected));
- String actualString = Integer.toHexString(Float.floatToIntBits(actual));
- String errorMsg = i + "th input string is:<" + inputString
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0F);
- }
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies max boundary value. Doesn't verify NumberFormatException.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloat_LString_MaxNormalBoundary() {
- int[] expecteds ={
- 0x7f7fffff,
- 0x7f7fffff,
- 0x7f7fffff,
- 0x7f800000,
- 0x7f800000,
- 0x7f800000,
-
- 0xff7fffff,
- 0xff7fffff,
- 0xff7fffff,
- 0xff800000,
- 0xff800000,
- 0xff800000,
- };
-
- String[] inputs = {
- "0x1.fffffep127",
- "0x1.fffffe000000000000000000000000000000000000000000000001p127",
- "0x1.fffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp127",
- "0x1.ffffffp127",
- "0x1.ffffff000000000000000000000000000000000000000000000001p127",
- "0x1.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp127",
-
- "-0x1.fffffep127",
- "-0x1.fffffe000000000000000000000000000000000000000000000001p127",
- "-0x1.fffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp127",
- "-0x1.ffffffp127",
- "-0x1.ffffff000000000000000000000000000000000000000000000001p127",
- "-0x1.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp127",
- };
-
- for (int i = 0; i < inputs.length; i++) {
- float actual = Float.parseFloat(inputs[i]);
- float expected = Float.intBitsToFloat(expecteds[i]);
-
- String expectedString = Integer.toHexString(Float.floatToIntBits(expected));
- String actualString = Integer.toHexString(Float.floatToIntBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0F);
- }
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies min boundary value.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloat_LString_MinNormalBoundary() {
- int expecteds[] = {
- 0x800000,
- 0x800000,
- 0x800000,
- 0x800000,
- 0x800001,
- 0x800001,
-
- 0x80800000,
- 0x80800000,
- 0x80800000,
- 0x80800000,
- 0x80800001,
- 0x80800001,
- };
-
- String inputs[] = {
- "0x1.0p-126",
- "0x1.00000000000000000000000000000000000000000000001p-126",
- "0x1.000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- "0x1.000001p-126",
- "0x1.000001000000000000000000000000000000000000000001p-126",
- "0x1.000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
-
- "-0x1.0p-126",
- "-0x1.00000000000000000000000000000000000000000000001p-126",
- "-0x1.000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- "-0x1.000001p-126",
- "-0x1.000001000000000000000000000000000000000000000001p-126",
- "-0x1.000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- };
-
- for (int i = 0; i < inputs.length; i++) {
- float actual = Float.parseFloat(inputs[i]);
- float expected = Float.intBitsToFloat(expecteds[i]);
-
- String expectedString = Integer.toHexString(Float.floatToIntBits(expected));
- String actualString = Integer.toHexString(Float.floatToIntBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0F);
- }
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies max boundary value.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloat_LString_MaxSubNormalBoundary() {
- int expecteds[] = {
- 0x7fffff,
- 0x7fffff,
- 0x7fffff,
- 0x800000,
- 0x800000,
- 0x800000,
-
- 0x807fffff,
- 0x807fffff,
- 0x807fffff,
- 0x80800000,
- 0x80800000,
- 0x80800000,
- };
-
- String inputs[] = {
- "0x0.fffffep-126",
- "0x0.fffffe000000000000000000000000000000000000000000000000000001p-126",
- "0x0.fffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- "0x0.ffffffp-126",
- "0x0.ffffff0000000000000000000000000000000000000000000000000000001p-126",
- "0x0.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
-
- "-0x0.fffffep-126",
- "-0x0.fffffe000000000000000000000000000000000000000000000000000001p-126",
- "-0x0.fffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- "-0x0.ffffffp-126",
- "-0x0.ffffff0000000000000000000000000000000000000000000000000000001p-126",
- "-0x0.ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- };
-
- for (int i = 0; i < inputs.length; i++) {
- float actual = Float.parseFloat(inputs[i]);
- float expected = Float.intBitsToFloat(expecteds[i]);
-
- String expectedString = Integer.toHexString(Float.floatToIntBits(expected));
- String actualString = Integer.toHexString(Float.floatToIntBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0F);
- }
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies min boundary value.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloat_LString_MinSubNormalBoundary() {
- int expecteds[] = {
- 0x1,
- 0x1,
- 0x1,
- 0x2,
- 0x2,
- 0x2,
-
- 0x80000001,
- 0x80000001,
- 0x80000001,
- 0x80000002,
- 0x80000002,
- 0x80000002,
- };
-
- String inputs[] = {
- "0x0.000002p-126",
- "0x0.00000200000000000000000000000000000000000001p-126",
- "0x0.000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- "0x0.000003p-126",
- "0x0.000003000000000000000000000000000000000000001p-126",
- "0x0.000003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
-
- "-0x0.000002p-126",
- "-0x0.00000200000000000000000000000000000000000001p-126",
- "-0x0.000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- "-0x0.000003p-126",
- "-0x0.000003000000000000000000000000000000000000001p-126",
- "-0x0.000003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- };
-
- for (int i = 0; i < inputs.length; i++) {
- float actual = Float.parseFloat(inputs[i]);
- float expected = Float.intBitsToFloat(expecteds[i]);
-
- String expectedString = Integer.toHexString(Float.floatToIntBits(expected));
- String actualString = Integer.toHexString(Float.floatToIntBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0F);
- }
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies zero boundary value.",
- method = "parseFloat",
- args = {java.lang.String.class}
- )
- public void test_parseFloat_LString_ZeroBoundary() {
- int expecteds[] = {
- 0x0,
- 0x0,
- 0x0,
- 0x0,
- 0x1,
- 0x1,
-
- 0x80000000,
- 0x80000000,
- 0x80000000,
- 0x80000000,
- 0x80000001,
- 0x80000001,
- };
-
- String inputs[] = {
- "0x0.000000000000000p-126",
- "0x0.000000000000000000000000000000000000000000000001p-126",
- "0x0.000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- "0x0.000001p-126",
- "0x0.000001000000000000000000000000000000000000000001p-126",
- "0x0.000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
-
- "-0x0.000000000000000p-126",
- "-0x0.000000000000000000000000000000000000000000000001p-126",
- "-0x0.000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- "-0x0.000001p-126",
- "-0x0.000001000000000000000000000000000000000000000001p-126",
- "-0x0.000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffp-126",
- };
-
- for (int i = 0; i < inputs.length; i++) {
- float actual = Float.parseFloat(inputs[i]);
- float expected = Float.intBitsToFloat(expecteds[i]);
-
- String expectedString = Integer.toHexString(Float.floatToIntBits(expected));
- String actualString = Integer.toHexString(Float.floatToIntBits(actual));
- String errorMsg = i + "th input string is:<" + inputs[i]
- + ">.The expected result should be:<" + expectedString
- + ">, but was: <" + actualString + ">. ";
-
- assertEquals(errorMsg, expected, actual, 0.0F);
- }
- }
-
- /**
- * @tests java.lang.Float#parseFloat(java.lang.String)
- */
- public void test_parseFloat_LString_Harmony6261() {
- // Regression test for HARMONY-6261
- float f = new Float("2147483648");
- assertEquals("2.1474836E9", Float.toString(f));
-
- doTestCompareRawBits("123456790528.000000000000000f", 0x51e5f4c9, "1.2345679E11");
- doTestCompareRawBits("8589934592", 0x50000000, "8.5899346E9");
- doTestCompareRawBits("8606711808", 0x50004000, "8.606712E9");
- }
-
- /**
- * @tests java.lang.Float#shortValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "shortValue",
- args = {}
- )
- public void test_shortValue() {
- // Test for method short java.lang.Float.shortValue()
- Float f = new Float(0.46874f);
- Float f2 = new Float(90.8f);
- assertTrue("Returned incorrect short value", f.shortValue() == 0
- && f2.shortValue() == 90);
- }
-
- /**
- * @tests java.lang.Float#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() {
- // Test for method java.lang.String java.lang.Float.toString()
-
- test_toString(12.90898f, "12.90898");
-
- test_toString(1.7014118346046924e+38F, "1.7014118E38");
- }
-
- /**
- * @tests java.lang.Float#toString(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {float.class}
- )
- public void test_toStringF() {
- // Test for method java.lang.String java.lang.Float.toString(float)
-
- float ff;
- String answer;
-
- ff = 12.90898f;
- answer = "12.90898";
- assertTrue("Incorrect String representation want " + answer + ", got "
- + Float.toString(ff), Float.toString(ff).equals(answer));
-
- ff = Float.MAX_VALUE;
- answer = "3.4028235E38";
- assertTrue("Incorrect String representation want " + answer + ", got "
- + Float.toString(ff), Float.toString(ff).equals(answer));
- }
-
- /**
- * @tests java.lang.Float#valueOf(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {java.lang.String.class}
- )
- public void test_valueOfLjava_lang_String() {
- // Test for method java.lang.Float
- // java.lang.Float.valueOf(java.lang.String)
-
- Float wanted = new Float(432.1235f);
- Float got = Float.valueOf("432.1235");
- assertTrue("Incorrect float returned--wanted: " + wanted + " but got: " + got, got
- .equals(wanted));
-
- wanted = new Float(0f);
- got = Float.valueOf("0");
- assertTrue("Incorrect float returned--wanted: " + wanted + " but got: " + got, got
- .equals(wanted));
-
- wanted = new Float(-1212.3232f);
- got = Float.valueOf("-1212.3232");
- assertTrue("Incorrect float returned--wanted: " + wanted + " but got: " + got, got
- .equals(wanted));
-
- try {
- Float.valueOf(null);
- fail("Expected Float.valueOf(null) to throw NPE.");
- } catch (NullPointerException ex) {
- // expected
- }
-
- try {
- Float.valueOf("");
- fail("Expected Float.valueOf(\"\") to throw NFE");
- } catch (NumberFormatException e) {
- // expected
- }
-
- Float posZero = Float.valueOf("+0.0");
- Float negZero = Float.valueOf("-0.0");
- assertFalse("Floattest0", posZero.equals(negZero));
- assertTrue("Floattest1", 0.0f == -0.0f);
-
- // Tests for float values by name.
- Float expectedNaN = new Float(Float.NaN);
-
- Float posNaN = Float.valueOf("NaN");
- assertTrue("Floattest2", posNaN.equals(expectedNaN));
-
- Float posNaNSigned = Float.valueOf("+NaN");
- assertTrue("Floattest3", posNaNSigned.equals(expectedNaN));
-
- Float negNaNSigned = Float.valueOf("-NaN");
- assertTrue("Floattest4", negNaNSigned.equals(expectedNaN));
-
- Float posInfinite = Float.valueOf("Infinity");
- assertTrue("Floattest5", posInfinite.equals(new Float(Float.POSITIVE_INFINITY)));
-
- Float posInfiniteSigned = Float.valueOf("+Infinity");
- assertTrue("Floattest6", posInfiniteSigned.equals(new Float(Float.POSITIVE_INFINITY)));
-
- Float negInfiniteSigned = Float.valueOf("-Infinity");
- assertTrue("Floattest7", negInfiniteSigned.equals(new Float(Float.NEGATIVE_INFINITY)));
- }
-
- private void test_toString(float ff, String answer) {
- // Test for method java.lang.String java.lang.Double.toString(double)
- assertTrue("Incorrect String representation want " + answer + ", got ("
- + Float.toString(ff) + ")", Float.toString(ff).equals(answer));
- Float f = new Float(ff);
- assertTrue("Incorrect String representation want " + answer + ", got ("
- + Float.toString(f.floatValue()) + ")", Float.toString(f.floatValue()).equals(
- answer));
- assertTrue("Incorrect String representation want " + answer + ", got (" + f.toString()
- + ")", f.toString().equals(answer));
- }
-
- /**
- * @tests java.lang.Float#compareTo(java.lang.Float)
- * @tests java.lang.Float#compare(float, float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "compareTo",
- args = {java.lang.Float.class}
- )
- public void test_compareToLjava_lang_Float() {
- // A selection of float values in ascending order.
- float[] values = new float[] { Float.NEGATIVE_INFINITY, -Float.MAX_VALUE, -2f,
- -Float.MIN_VALUE, -0f, 0f, Float.MIN_VALUE, 2f, Float.MAX_VALUE,
- Float.POSITIVE_INFINITY, Float.NaN };
-
- for (int i = 0; i < values.length; i++) {
- float f1 = values[i];
-
- // Test that each value compares equal to itself; and each object is
- // equal to another object
- // like itself
- assertTrue("Assert 0: compare() should be equal: " + f1, Float.compare(f1, f1) == 0);
- Float objFloat = new Float(f1);
- assertTrue("Assert 1: compareTo() should be equal: " + objFloat, objFloat
- .compareTo(objFloat) == 0);
-
- // Test that the Float-defined order is respected
- for (int j = i + 1; j < values.length; j++) {
- float f2 = values[j];
- assertTrue("Assert 2: compare() " + f1 + " should be less " + f2, Float
- .compare(f1, f2) == -1);
- assertTrue("Assert 3: compare() " + f2 + " should be greater " + f1, Float
- .compare(f2, f1) == 1);
-
- Float F2 = new Float(f2);
- assertTrue("Assert 4: compareTo() " + f1 + " should be less " + f2, objFloat
- .compareTo(F2) == -1);
- assertTrue("Assert 5: compareTo() " + f2 + " should be greater " + f1, F2
- .compareTo(objFloat) == 1);
- }
- }
- }
-
- /**
- * @tests java.lang.Float#equals(java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "equals",
- args = {java.lang.Object.class}
- )
- public void test_equalsLjava_lang_Object() {
- Float f1 = new Float(8765.4321f);
- Float f2 = new Float(8765.4321f);
- Float f3 = new Float(-1.0f);
- assertTrue("Assert 0: Equality test failed", f1.equals(f2) && !(f1.equals(f3)));
-
- assertTrue("Assert 1: NaN should not be == Nan", Float.NaN != Float.NaN);
- assertTrue("Assert 2: NaN should not be == Nan", new Float(Float.NaN).equals(new Float(
- Float.NaN)));
- assertTrue("Assert 3: -0f should be == 0f", 0f == -0f);
- assertTrue("Assert 4: -0f should not be equals() 0f", !new Float(0f).equals(new Float(
- -0f)));
-
- f1 = new Float(1098.576f);
- f2 = new Float(1098.576f);
- f3 = new Float(1.0f);
- assertTrue("Equality test failed", f1.equals(f2) && !(f1.equals(f3)));
-
- assertTrue("NaN should not be == Nan", Float.NaN != Float.NaN);
- assertTrue("NaN should not be == Nan", new Float(Float.NaN)
- .equals(new Float(Float.NaN)));
- assertTrue("-0f should be == 0f", 0f == -0f);
- assertTrue("-0f should not be equals() 0f", !new Float(0f).equals(new Float(-0f)));
- }
-
- /**
- * @tests java.lang.Float#toHexString(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toHexString",
- args = {float.class}
- )
- public void test_toHexStringF() {
- // the follow values comes from the Float Javadoc/Spec
- assertEquals("0x0.0p0", Float.toHexString(0.0F));
- assertEquals("-0x0.0p0", Float.toHexString(-0.0F));
- assertEquals("0x1.0p0", Float.toHexString(1.0F));
- assertEquals("-0x1.0p0", Float.toHexString(-1.0F));
- assertEquals("0x1.0p1", Float.toHexString(2.0F));
- assertEquals("0x1.8p1", Float.toHexString(3.0F));
- assertEquals("0x1.0p-1", Float.toHexString(0.5F));
- assertEquals("0x1.0p-2", Float.toHexString(0.25F));
- assertEquals("0x1.fffffep127", Float.toHexString(Float.MAX_VALUE));
- assertEquals("0x0.000002p-126", Float.toHexString(Float.MIN_VALUE));
-
- // test edge cases
- assertEquals("NaN", Float.toHexString(Float.NaN));
- assertEquals("-Infinity", Float.toHexString(Float.NEGATIVE_INFINITY));
- assertEquals("Infinity", Float.toHexString(Float.POSITIVE_INFINITY));
-
- // test various numbers
- assertEquals("-0x1.da8p6", Float.toHexString(-118.625F));
- assertEquals("0x1.295788p23", Float.toHexString(9743299.65F));
- assertEquals("0x1.295788p23", Float.toHexString(9743299.65000F));
- assertEquals("0x1.295788p23", Float.toHexString(9743299.650001234F));
- assertEquals("0x1.700d1p33", Float.toHexString(12349743299.65000F));
-
- // test HARMONY-2132
- assertEquals("0x1.01p10", Float.toHexString(0x1.01p10f));
- }
-
- /**
- * @tests java.lang.Float#valueOf(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {float.class}
- )
- public void test_valueOfF() {
- assertEquals(new Float(Float.MIN_VALUE), Float.valueOf(Float.MIN_VALUE));
- assertEquals(new Float(Float.MAX_VALUE), Float.valueOf(Float.MAX_VALUE));
- assertEquals(new Float(0), Float.valueOf(0));
-
- int s = -128;
- while (s < 128) {
- assertEquals(new Float(s), Float.valueOf(s));
- assertEquals(new Float(s + 0.1F), Float.valueOf(s + 0.1F));
- assertEquals(Float.valueOf(s + 0.1F), Float.valueOf(s + 0.1F));
- s++;
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalAccessErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalAccessErrorTest.java
deleted file mode 100644
index 5b032e1..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalAccessErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class IllegalAccessErrorTest extends TestCase {
-
- /**
- * @tests java.lang.IllegalAccessError#IllegalAccessError()
- */
- public void test_Constructor() {
- IllegalAccessError e = new IllegalAccessError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.IllegalAccessError#IllegalAccessError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- IllegalAccessError e = new IllegalAccessError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalAccessExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalAccessExceptionTest.java
deleted file mode 100644
index 2a984cb..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalAccessExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class IllegalAccessExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.IllegalAccessException#IllegalAccessException()
- */
- public void test_Constructor() {
- IllegalAccessException e = new IllegalAccessException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.IllegalAccessException#IllegalAccessException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- IllegalAccessException e = new IllegalAccessException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java
deleted file mode 100644
index c9faa09..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalArgumentExceptionTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-public class IllegalArgumentExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.IllegalArgumentException#IllegalArgumentException()
- */
- public void test_Constructor() {
- IllegalArgumentException e = new IllegalArgumentException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.IllegalArgumentException#IllegalArgumentException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- IllegalArgumentException e = new IllegalArgumentException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests {@link java.lang.IllegalArgumentException#IllegalArgumentException(Throwable)}
- */
- public void test_ConstructorLjava_lang_Throwable() {
- Throwable emptyThrowable = new Exception();
- IllegalArgumentException emptyException = new IllegalArgumentException(emptyThrowable);
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getMessage());
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getLocalizedMessage());
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getCause().toString());
-
- Throwable exception = new Exception("msg");
- IllegalArgumentException e = new IllegalArgumentException(exception);
- assertEquals(exception.getClass().getName() + ": " + "msg", e.getMessage());
- assertEquals(exception.getClass().getName(), emptyException.getLocalizedMessage());
- assertEquals(exception.getClass().getName(), emptyException.getCause().toString());
- }
-
- /**
- * @tests java.lang.IllegalArgumentException#IllegalArgumentException(String,Throwable)
- */
- @SuppressWarnings("nls")
- public void test_ConstructorLjava_lang_StringLjava_lang_Throwable() {
- NullPointerException npe = new NullPointerException();
- IllegalArgumentException e = new IllegalArgumentException("fixture",
- npe);
- assertSame("fixture", e.getMessage());
- assertSame(npe, e.getCause());
- }
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
- SerializationTest.verifySelf(new IllegalArgumentException());
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
- SerializationTest.verifyGolden(this, new IllegalArgumentException());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalMonitorStateExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalMonitorStateExceptionTest.java
deleted file mode 100644
index 37ce9c3..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalMonitorStateExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class IllegalMonitorStateExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.IllegalMonitorStateException#IllegalMonitorStateException()
- */
- public void test_Constructor() {
- IllegalMonitorStateException e = new IllegalMonitorStateException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.IllegalMonitorStateException#IllegalMonitorStateException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- IllegalMonitorStateException e = new IllegalMonitorStateException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalStateExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalStateExceptionTest.java
deleted file mode 100644
index a926535..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalStateExceptionTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-public class IllegalStateExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.IllegalStateException#IllegalStateException()
- */
- public void test_Constructor() {
- IllegalStateException e = new IllegalStateException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.IllegalStateException#IllegalStateException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- IllegalStateException e = new IllegalStateException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests {@link java.land.IllegalStateException#IllIllegalStateException(java.lang.Throwable)}
- */
- public void test_ConstructorLjava_lang_Throwable() {
- Throwable emptyThrowable = new Exception();
- IllegalStateException emptyException = new IllegalStateException(emptyThrowable);
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getMessage());
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getLocalizedMessage());
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getCause().toString());
-
- Throwable throwable = new Exception("msg");
- IllegalStateException exception = new IllegalStateException(throwable);
- assertEquals(throwable.getClass().getName() + ": " + "msg", exception.getMessage());
- assertEquals(throwable.getClass().getName(), emptyException.getLocalizedMessage());
- assertEquals(throwable.getClass().getName(), emptyException.getCause().toString());
- }
-
- /**
- * @tests {@link java.land.IllegalStateException#IllIllegalStateException(java.lang.String, java.lang.Throwable)}
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_Throwable() {
- Throwable emptyThrowable = new Exception();
- IllegalStateException emptyException = new IllegalStateException("msg", emptyThrowable);
- assertEquals("msg", emptyException.getMessage());
- assertEquals("msg", emptyException.getLocalizedMessage());
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getCause().toString());
-
- Throwable throwable = new Exception("msg_exception");
- IllegalStateException exception = new IllegalStateException("msg", throwable);
- assertEquals("msg", exception.getMessage());
- assertEquals("msg", exception.getLocalizedMessage());
- assertEquals(throwable.getClass().getName() + ": " + throwable.getMessage(), exception
- .getCause().toString());
- }
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- SerializationTest.verifySelf(new IllegalStateException());
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this, new IllegalStateException());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalThreadStateExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalThreadStateExceptionTest.java
deleted file mode 100644
index 475f6bb..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IllegalThreadStateExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class IllegalThreadStateExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.IllegalThreadStateException#IllegalThreadStateException()
- */
- public void test_Constructor() {
- IllegalThreadStateException e = new IllegalThreadStateException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.IllegalThreadStateException#IllegalThreadStateException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- IllegalThreadStateException e = new IllegalThreadStateException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IncompatibleClassChangeErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IncompatibleClassChangeErrorTest.java
deleted file mode 100644
index b6a8d6a..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IncompatibleClassChangeErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class IncompatibleClassChangeErrorTest extends TestCase {
-
- /**
- * @tests java.lang.IncompatibleClassChangeError#IncompatibleClassChangeError()
- */
- public void test_Constructor() {
- IncompatibleClassChangeError e = new IncompatibleClassChangeError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.IncompatibleClassChangeError#IncompatibleClassChangeError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- IncompatibleClassChangeError e = new IncompatibleClassChangeError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IndexOutOfBoundsExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IndexOutOfBoundsExceptionTest.java
deleted file mode 100644
index 617c71c..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IndexOutOfBoundsExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class IndexOutOfBoundsExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.IndexOutOfBoundsException#IndexOutOfBoundsException()
- */
- public void test_Constructor() {
- IndexOutOfBoundsException e = new IndexOutOfBoundsException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.IndexOutOfBoundsException#IndexOutOfBoundsException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- IndexOutOfBoundsException e = new IndexOutOfBoundsException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InheritableThreadLocalTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InheritableThreadLocalTest.java
deleted file mode 100644
index 752aaec..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InheritableThreadLocalTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-@TestTargetClass(InheritableThreadLocal.class)
-public class InheritableThreadLocalTest extends TestCase {
-
- /**
- * @tests java.lang.InheritableThreadLocal#InheritableThreadLocal()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "InheritableThreadLocal",
- args = {}
- )
- public void test_Constructor() {
- InheritableThreadLocal<String> itl = new InheritableThreadLocal<String>();
- assertNull(itl.get());
- }
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "initialValue",
- args = {}
- )
- public void test_initialValue() {
- InheritableThreadLocal<String> itl = new InheritableThreadLocal<String>() {
- @Override
- protected String initialValue() {
- return "initial";
- }
- };
- assertEquals("initial", itl.get());
- }
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "childValue",
- args = {java.lang.Object.class}
- )
- public void test_childValue() {
- InheritableThreadLocal<String> itl = new InheritableThreadLocal<String>() {
- @Override
- protected String initialValue() {
- return "initial";
- }
- @Override
- protected String childValue(String parentValue) {
- return "childValue";
- }
- };
- assertEquals("initial", itl.get());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InstantiationErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InstantiationErrorTest.java
deleted file mode 100644
index 1d9722c..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InstantiationErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class InstantiationErrorTest extends TestCase {
-
- /**
- * @tests java.lang.InstantiationError#InstantiationError()
- */
- public void test_Constructor() {
- InstantiationError e = new InstantiationError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.InstantiationError#InstantiationError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- InstantiationError e = new InstantiationError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InstantiationExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InstantiationExceptionTest.java
deleted file mode 100644
index 5f636d5..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InstantiationExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class InstantiationExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.InstantiationException#InstantiationException()
- */
- public void test_Constructor() {
- InstantiationException e = new InstantiationException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.InstantiationException#InstantiationException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- InstantiationException e = new InstantiationException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IntegerTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IntegerTest.java
deleted file mode 100644
index 12fb758..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/IntegerTest.java
+++ /dev/null
@@ -1,1531 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-import java.util.Properties;
-
-@TestTargetClass(Integer.class)
-public class IntegerTest extends TestCase {
- private Properties orgProps;
-
- @Override
- protected void setUp() {
- orgProps = System.getProperties();
- }
-
- @Override
- protected void tearDown() {
- System.setProperties(orgProps);
- }
-
- /**
- * @tests java.lang.Integer#byteValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "byteValue",
- args = {}
- )
- public void test_byteValue() {
- // Test for method byte java.lang.Integer.byteValue()
- assertEquals("Returned incorrect byte value", -1, new Integer(65535)
- .byteValue());
- assertEquals("Returned incorrect byte value", 127, new Integer(127)
- .byteValue());
- }
-
- /**
- * @tests java.lang.Integer#compareTo(java.lang.Integer)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "compareTo",
- args = {java.lang.Integer.class}
- )
- public void test_compareToLjava_lang_Integer() {
- // Test for method int java.lang.Integer.compareTo(java.lang.Integer)
- assertTrue("-2 compared to 1 gave non-negative answer", new Integer(-2)
- .compareTo(new Integer(1)) < 0);
- assertEquals("-2 compared to -2 gave non-zero answer", 0, new Integer(-2)
- .compareTo(new Integer(-2)));
- assertTrue("3 compared to 2 gave non-positive answer", new Integer(3)
- .compareTo(new Integer(2)) > 0);
-
- try {
- new Integer(0).compareTo(null);
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Integer#decode(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "decode",
- args = {java.lang.String.class}
- )
- public void test_decodeLjava_lang_String2() {
- // Test for method java.lang.Integer
- // java.lang.Integer.decode(java.lang.String)
- assertEquals("Failed for 132233",
- 132233, Integer.decode("132233").intValue());
- assertEquals("Failed for 07654321",
- 07654321, Integer.decode("07654321").intValue());
- assertTrue("Failed for #1234567",
- Integer.decode("#1234567").intValue() == 0x1234567);
- assertTrue("Failed for 0xdAd",
- Integer.decode("0xdAd").intValue() == 0xdad);
- assertEquals("Failed for -23", -23, Integer.decode("-23").intValue());
- assertEquals("Returned incorrect value for 0 decimal", 0, Integer
- .decode("0").intValue());
- assertEquals("Returned incorrect value for 0 hex", 0, Integer.decode("0x0")
- .intValue());
- assertTrue("Returned incorrect value for most negative value decimal",
- Integer.decode("-2147483648").intValue() == 0x80000000);
- assertTrue("Returned incorrect value for most negative value hex",
- Integer.decode("-0x80000000").intValue() == 0x80000000);
- assertTrue("Returned incorrect value for most positive value decimal",
- Integer.decode("2147483647").intValue() == 0x7fffffff);
- assertTrue("Returned incorrect value for most positive value hex",
- Integer.decode("0x7fffffff").intValue() == 0x7fffffff);
-
- boolean exception = false;
- try {
- Integer.decode("0a");
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Failed to throw NumberFormatException for \"Oa\"",
- exception);
-
- exception = false;
- try {
- Integer.decode("2147483648");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Integer.decode("-2147483649");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Integer.decode("0x80000000");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Integer.decode("-0x80000001");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Integer.decode("9999999999");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for 9999999999", exception);
-
- try {
- Integer.decode("-");
- fail("Expected exception for -");
- } catch (NumberFormatException e) {
- // Expected
- }
-
- try {
- Integer.decode("0x");
- fail("Expected exception for 0x");
- } catch (NumberFormatException e) {
- // Expected
- }
-
- try {
- Integer.decode("#");
- fail("Expected exception for #");
- } catch (NumberFormatException e) {
- // Expected
- }
-
- try {
- Integer.decode("x123");
- fail("Expected exception for x123");
- } catch (NumberFormatException e) {
- // Expected
- }
-
- try {
- Integer.decode(null);
- fail("Expected exception for null");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- Integer.decode("");
- fail("Expected exception for empty string");
- } catch (NumberFormatException ex) {
- // Expected
- }
-
- try {
- Integer.decode(" ");
- fail("Expected exception for single space");
- } catch (NumberFormatException ex) {
- // Expected
- }
-
- }
-
- /**
- * @tests java.lang.Integer#doubleValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Checks integer's boundary values.",
- method = "doubleValue",
- args = {}
- )
- public void test_doubleValue2() {
- // Test for method double java.lang.Integer.doubleValue()
- assertEquals("Returned incorrect double value", 2147483647.0, new Integer(2147483647)
- .doubleValue(), 0.0D);
- assertEquals("Returned incorrect double value", -2147483647.0, new Integer(-2147483647)
- .doubleValue(), 0.0D);
- }
-
- /**
- * @tests java.lang.Integer#equals(java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "equals",
- args = {java.lang.Object.class}
- )
- public void test_equalsLjava_lang_Object2() {
- // Test for method boolean java.lang.Integer.equals(java.lang.Object)
- Integer i1 = new Integer(1000);
- Integer i2 = new Integer(1000);
- Integer i3 = new Integer(-1000);
- assertTrue("Equality test failed", i1.equals(i2) && !(i1.equals(i3)));
- }
-
- /**
- * @tests java.lang.Integer#floatValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "floatValue",
- args = {}
- )
- public void test_floatValue2() {
- // Test for method float java.lang.Integer.floatValue()
- assertTrue("Returned incorrect float value", new Integer(65535)
- .floatValue() == 65535.0f);
- assertTrue("Returned incorrect float value", new Integer(-65535)
- .floatValue() == -65535.0f);
- }
-
- /**
- * @tests java.lang.Integer#getInteger(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getInteger",
- args = {java.lang.String.class}
- )
- public void test_getIntegerLjava_lang_String() {
- // Test for method java.lang.Integer
- // java.lang.Integer.getInteger(java.lang.String)
- Properties tProps = new Properties();
- tProps.put("testInt", "99");
- System.setProperties(tProps);
- assertTrue("returned incorrect Integer", Integer.getInteger("testInt")
- .equals(new Integer(99)));
- assertNull("returned incorrect default Integer", Integer
- .getInteger("ff"));
- }
-
- /**
- * @tests java.lang.Integer#getInteger(java.lang.String, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getInteger",
- args = {java.lang.String.class, int.class}
- )
- public void test_getIntegerLjava_lang_StringI() {
- // Test for method java.lang.Integer
- // java.lang.Integer.getInteger(java.lang.String, int)
- Properties tProps = new Properties();
- tProps.put("testInt", "99");
- tProps.put("testIncInt", "notInt");
- System.setProperties(tProps);
- assertTrue("returned incorrect Integer", Integer.getInteger("testInt",
- 4).equals(new Integer(99)));
- assertTrue("returned incorrect default Integer", Integer.getInteger(
- "ff", 4).equals(new Integer(4)));
- assertTrue("returned incorrect default Integer", Integer.getInteger(
- "testIncInt", 4).equals(new Integer(4)));
- }
-
- /**
- * @tests java.lang.Integer#getInteger(java.lang.String, java.lang.Integer)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getInteger",
- args = {java.lang.String.class, java.lang.Integer.class}
- )
- public void test_getIntegerLjava_lang_StringLjava_lang_Integer() {
- // Test for method java.lang.Integer
- // java.lang.Integer.getInteger(java.lang.String, java.lang.Integer)
- Properties tProps = new Properties();
- tProps.put("testInt", "99");
- tProps.put("testIncInt", "notInt");
- System.setProperties(tProps);
- assertTrue("returned incorrect Integer", Integer.getInteger("testInt",
- new Integer(4)).equals(new Integer(99)));
- assertTrue("returned incorrect default Integer", Integer.getInteger(
- "ff", new Integer(4)).equals(new Integer(4)));
- assertTrue("returned incorrect default Integer", Integer.getInteger(
- "testIncInt", new Integer(4)).equals(new Integer(4)));
- }
-
- /**
- * @tests java.lang.Integer#hashCode()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "hashCode",
- args = {}
- )
- public void test_hashCode2() {
- // Test for method int java.lang.Integer.hashCode()
-
- Integer i1 = new Integer(1000);
- Integer i2 = new Integer(-1000);
- assertTrue("Returned incorrect hashcode", i1.hashCode() == 1000
- && (i2.hashCode() == -1000));
- }
-
- /**
- * @tests java.lang.Integer#intValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL,
- notes = "Checks one value.",
- method = "intValue",
- args = {}
- )
- public void test_intValue2() {
- // Test for method int java.lang.Integer.intValue()
-
- Integer i = new Integer(8900);
- assertEquals("Returned incorrect int value", 8900, i.intValue());
- }
-
- /**
- * @tests java.lang.Integer#longValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL,
- notes = "Checks one value.",
- method = "longValue",
- args = {}
- )
- public void test_longValue2() {
- // Test for method long java.lang.Integer.longValue()
- Integer i = new Integer(8900);
- assertEquals("Returned incorrect long value", 8900L, i.longValue());
- }
-
- /**
- * @tests java.lang.Integer#parseInt(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "parseInt",
- args = {java.lang.String.class}
- )
- public void test_parseIntLjava_lang_String2() {
- // Test for method int java.lang.Integer.parseInt(java.lang.String)
-
- int i = Integer.parseInt("-8900");
- assertEquals("Returned incorrect int", -8900, i);
- assertEquals("Returned incorrect value for 0", 0, Integer.parseInt("0"));
- assertTrue("Returned incorrect value for most negative value", Integer
- .parseInt("-2147483648") == 0x80000000);
- assertTrue("Returned incorrect value for most positive value", Integer
- .parseInt("2147483647") == 0x7fffffff);
-
- boolean exception = false;
- try {
- Integer.parseInt("999999999999");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for value > int", exception);
-
- exception = false;
- try {
- Integer.parseInt("2147483648");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Integer.parseInt("-2147483649");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
- }
-
- /**
- * @tests java.lang.Integer#parseInt(java.lang.String, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "parseInt",
- args = {java.lang.String.class, int.class}
- )
- public void test_parseIntLjava_lang_StringI2() {
- // Test for method int java.lang.Integer.parseInt(java.lang.String, int)
- assertEquals("Parsed dec val incorrectly",
- -8000, Integer.parseInt("-8000", 10));
- assertEquals("Parsed hex val incorrectly",
- 255, Integer.parseInt("FF", 16));
- assertEquals("Parsed oct val incorrectly",
- 16, Integer.parseInt("20", 8));
- assertEquals("Returned incorrect value for 0 hex", 0, Integer.parseInt("0",
- 16));
- assertTrue("Returned incorrect value for most negative value hex",
- Integer.parseInt("-80000000", 16) == 0x80000000);
- assertTrue("Returned incorrect value for most positive value hex",
- Integer.parseInt("7fffffff", 16) == 0x7fffffff);
- assertEquals("Returned incorrect value for 0 decimal", 0, Integer.parseInt(
- "0", 10));
- assertTrue("Returned incorrect value for most negative value decimal",
- Integer.parseInt("-2147483648", 10) == 0x80000000);
- assertTrue("Returned incorrect value for most positive value decimal",
- Integer.parseInt("2147483647", 10) == 0x7fffffff);
-
- boolean exception = false;
- try {
- Integer.parseInt("FFFF", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue(
- "Failed to throw exception when passes hex string and dec parm",
- exception);
-
- exception = false;
- try {
- Integer.parseInt("2147483648", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Integer.parseInt("-2147483649", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Integer.parseInt("80000000", 16);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Integer.parseInt("-80000001", 16);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MIN_VALUE + 1", exception);
-
- exception = false;
- try {
- Integer.parseInt("9999999999", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for 9999999999", exception);
- }
-
- /**
- * @tests java.lang.Integer#shortValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL,
- notes = "Checks one value.",
- method = "shortValue",
- args = {}
- )
- public void test_shortValue2() {
- // Test for method short java.lang.Integer.shortValue()
- Integer i = new Integer(2147450880);
- assertEquals("Returned incorrect long value", -32768, i.shortValue());
- }
-
- /**
- * @tests java.lang.Integer#toBinaryString(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toBinaryString",
- args = {int.class}
- )
- public void test_toBinaryStringI() {
- // Test for method java.lang.String
- // java.lang.Integer.toBinaryString(int)
- assertEquals("Incorrect string returned", "1111111111111111111111111111111", Integer.toBinaryString(
- Integer.MAX_VALUE));
- assertEquals("Incorrect string returned", "10000000000000000000000000000000", Integer.toBinaryString(
- Integer.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.Integer#toHexString(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toHexString",
- args = {int.class}
- )
- public void test_toHexStringI() {
- // Test for method java.lang.String java.lang.Integer.toHexString(int)
-
- String[] hexvals = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
- "a", "b", "c", "d", "e", "f" };
-
- for (int i = 0; i < 16; i++) {
- assertTrue("Incorrect string returned " + hexvals[i], Integer
- .toHexString(i).equals(hexvals[i]));
- }
-
- assertTrue("Returned incorrect hex string: "
- + Integer.toHexString(Integer.MAX_VALUE), Integer.toHexString(
- Integer.MAX_VALUE).equals("7fffffff"));
- assertTrue("Returned incorrect hex string: "
- + Integer.toHexString(Integer.MIN_VALUE), Integer.toHexString(
- Integer.MIN_VALUE).equals("80000000"));
- }
-
- /**
- * @tests java.lang.Integer#toOctalString(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toOctalString",
- args = {int.class}
- )
- public void test_toOctalStringI() {
- // Test for method java.lang.String java.lang.Integer.toOctalString(int)
- // Spec states that the int arg is treated as unsigned
- assertEquals("Returned incorrect octal string", "17777777777", Integer.toOctalString(
- Integer.MAX_VALUE));
- assertEquals("Returned incorrect octal string", "20000000000", Integer.toOctalString(
- Integer.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.Integer#toString()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL,
- notes = "Checks one value.",
- method = "toString",
- args = {}
- )
- public void test_toString2() {
- // Test for method java.lang.String java.lang.Integer.toString()
-
- Integer i = new Integer(-80001);
-
- assertEquals("Returned incorrect String", "-80001", i.toString());
- }
-
- /**
- * @tests java.lang.Integer#toString(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {int.class}
- )
- public void test_toStringI2() {
- // Test for method java.lang.String java.lang.Integer.toString(int)
-
- assertEquals("Returned incorrect String", "-80765", Integer.toString(-80765)
- );
- assertEquals("Returned incorrect octal string", "2147483647", Integer.toString(
- Integer.MAX_VALUE));
- assertEquals("Returned incorrect octal string", "-2147483647", Integer.toString(
- -Integer.MAX_VALUE));
- assertEquals("Returned incorrect octal string", "-2147483648", Integer.toString(
- Integer.MIN_VALUE));
-
- // Test for HARMONY-6068
- assertEquals("Returned incorrect octal String", "-1000", Integer.toString(-1000));
- assertEquals("Returned incorrect octal String", "1000", Integer.toString(1000));
- assertEquals("Returned incorrect octal String", "0", Integer.toString(0));
- assertEquals("Returned incorrect octal String", "708", Integer.toString(708));
- assertEquals("Returned incorrect octal String", "-100", Integer.toString(-100));
- assertEquals("Returned incorrect octal String", "-1000000008", Integer.toString(-1000000008));
- assertEquals("Returned incorrect octal String", "2000000008", Integer.toString(2000000008));
- }
-
- /**
- * @tests java.lang.Integer#toString(int, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {int.class, int.class}
- )
- public void test_toStringII() {
- // Test for method java.lang.String java.lang.Integer.toString(int, int)
- assertEquals("Returned incorrect octal string", "17777777777", Integer.toString(
- 2147483647, 8));
- assertTrue("Returned incorrect hex string--wanted 7fffffff but got: "
- + Integer.toString(2147483647, 16), Integer.toString(
- 2147483647, 16).equals("7fffffff"));
- assertEquals("Incorrect string returned", "1111111111111111111111111111111", Integer.toString(2147483647, 2)
- );
- assertEquals("Incorrect string returned", "2147483647", Integer
- .toString(2147483647, 10));
-
- assertEquals("Returned incorrect octal string", "-17777777777", Integer.toString(
- -2147483647, 8));
- assertTrue("Returned incorrect hex string--wanted -7fffffff but got: "
- + Integer.toString(-2147483647, 16), Integer.toString(
- -2147483647, 16).equals("-7fffffff"));
- assertEquals("Incorrect string returned",
- "-1111111111111111111111111111111", Integer
- .toString(-2147483647, 2));
- assertEquals("Incorrect string returned", "-2147483647", Integer.toString(-2147483647,
- 10));
-
- assertEquals("Returned incorrect octal string", "-20000000000", Integer.toString(
- -2147483648, 8));
- assertTrue("Returned incorrect hex string--wanted -80000000 but got: "
- + Integer.toString(-2147483648, 16), Integer.toString(
- -2147483648, 16).equals("-80000000"));
- assertEquals("Incorrect string returned",
- "-10000000000000000000000000000000", Integer
- .toString(-2147483648, 2));
- assertEquals("Incorrect string returned", "-2147483648", Integer.toString(-2147483648,
- 10));
- }
-
- /**
- * @tests java.lang.Integer#valueOf(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Verifies boundary values.",
- method = "valueOf",
- args = {java.lang.String.class}
- )
- public void test_valueOfLjava_lang_String2() {
- // Test for method java.lang.Integer
- // java.lang.Integer.valueOf(java.lang.String)
- assertEquals("Returned incorrect int", 8888888, Integer.valueOf("8888888")
- .intValue());
- assertTrue("Returned incorrect int", Integer.valueOf("2147483647")
- .intValue() == Integer.MAX_VALUE);
- assertTrue("Returned incorrect int", Integer.valueOf("-2147483648")
- .intValue() == Integer.MIN_VALUE);
-
- boolean exception = false;
- try {
- Integer.valueOf("2147483648");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception with MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Integer.valueOf("-2147483649");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception with MIN_VALUE - 1", exception);
- }
-
- /**
- * @tests java.lang.Integer#valueOf(java.lang.String, int)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Checks boundary values.",
- method = "valueOf",
- args = {java.lang.String.class, int.class}
- )
- public void test_valueOfLjava_lang_StringI2() {
- // Test for method java.lang.Integer
- // java.lang.Integer.valueOf(java.lang.String, int)
- assertEquals("Returned incorrect int for hex string", 255, Integer.valueOf(
- "FF", 16).intValue());
- assertEquals("Returned incorrect int for oct string", 16, Integer.valueOf(
- "20", 8).intValue());
- assertEquals("Returned incorrect int for bin string", 4, Integer.valueOf(
- "100", 2).intValue());
-
- assertEquals("Returned incorrect int for - hex string", -255, Integer.valueOf(
- "-FF", 16).intValue());
- assertEquals("Returned incorrect int for - oct string", -16, Integer.valueOf(
- "-20", 8).intValue());
- assertEquals("Returned incorrect int for - bin string", -4, Integer.valueOf(
- "-100", 2).intValue());
- assertTrue("Returned incorrect int", Integer.valueOf("2147483647", 10)
- .intValue() == Integer.MAX_VALUE);
- assertTrue("Returned incorrect int", Integer.valueOf("-2147483648", 10)
- .intValue() == Integer.MIN_VALUE);
- assertTrue("Returned incorrect int", Integer.valueOf("7fffffff", 16)
- .intValue() == Integer.MAX_VALUE);
- assertTrue("Returned incorrect int", Integer.valueOf("-80000000", 16)
- .intValue() == Integer.MIN_VALUE);
-
- boolean exception = false;
- try {
- Integer.valueOf("FF", 2);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue(
- "Failed to throw exception with hex string and base 2 radix",
- exception);
-
- exception = false;
- try {
- Integer.valueOf("2147483648", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception with MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Integer.valueOf("-2147483649", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception with MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Integer.valueOf("80000000", 16);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception with hex MAX_VALUE + 1",
- exception);
-
- exception = false;
- try {
- Integer.valueOf("-80000001", 16);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception with hex MIN_VALUE - 1",
- exception);
- }
-
- /**
- * @tests java.lang.Integer#valueOf(byte)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {int.class}
- )
- public void test_valueOfI() {
- assertEquals(new Integer(Integer.MIN_VALUE), Integer.valueOf(Integer.MIN_VALUE));
- assertEquals(new Integer(Integer.MAX_VALUE), Integer.valueOf(Integer.MAX_VALUE));
- assertEquals(new Integer(0), Integer.valueOf(0));
-
- short s = -128;
- while (s < 128) {
- assertEquals(new Integer(s), Integer.valueOf(s));
- assertSame(Integer.valueOf(s), Integer.valueOf(s));
- s++;
- }
- }
-
- /**
- * @tests java.lang.Integer#hashCode()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "hashCode",
- args = {}
- )
- public void test_hashCode() {
- assertEquals(1, new Integer(1).hashCode());
- assertEquals(2, new Integer(2).hashCode());
- assertEquals(0, new Integer(0).hashCode());
- assertEquals(-1, new Integer(-1).hashCode());
- }
-
- /**
- * @tests java.lang.Integer#Integer(String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Integer",
- args = {java.lang.String.class}
- )
- public void test_ConstructorLjava_lang_String() {
- assertEquals(new Integer(0), new Integer("0"));
- assertEquals(new Integer(1), new Integer("1"));
- assertEquals(new Integer(-1), new Integer("-1"));
-
- try {
- new Integer("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Integer("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Integer("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Integer(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Integer#Integer
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Integer",
- args = {int.class}
- )
- public void test_ConstructorI() {
- assertEquals(1, new Integer(1).intValue());
- assertEquals(2, new Integer(2).intValue());
- assertEquals(0, new Integer(0).intValue());
- assertEquals(-1, new Integer(-1).intValue());
-
- Integer i = new Integer(-89000);
- assertEquals("Incorrect Integer created", -89000, i.intValue());
- }
-
- /**
- * @tests java.lang.Integer#byteValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "byteValue",
- args = {}
- )
- public void test_booleanValue() {
- assertEquals(1, new Integer(1).byteValue());
- assertEquals(2, new Integer(2).byteValue());
- assertEquals(0, new Integer(0).byteValue());
- assertEquals(-1, new Integer(-1).byteValue());
- }
-
- /**
- * @tests java.lang.Integer#equals(Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "equals",
- args = {java.lang.Object.class}
- )
- public void test_equalsLjava_lang_Object() {
- assertEquals(new Integer(0), Integer.valueOf(0));
- assertEquals(new Integer(1), Integer.valueOf(1));
- assertEquals(new Integer(-1), Integer.valueOf(-1));
-
- Integer fixture = new Integer(25);
- assertEquals(fixture, fixture);
- assertFalse(fixture.equals(null));
- assertFalse(fixture.equals("Not a Integer"));
- }
-
- /**
- * @tests java.lang.Integer#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() {
- assertEquals("-1", new Integer(-1).toString());
- assertEquals("0", new Integer(0).toString());
- assertEquals("1", new Integer(1).toString());
- assertEquals("-1", new Integer(0xFFFFFFFF).toString());
- }
-
- /**
- * @tests java.lang.Integer#toString
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {int.class}
- )
- public void test_toStringI() {
- assertEquals("-1", Integer.toString(-1));
- assertEquals("0", Integer.toString(0));
- assertEquals("1", Integer.toString(1));
- assertEquals("-1", Integer.toString(0xFFFFFFFF));
- }
-
- /**
- * @tests java.lang.Integer#valueOf(String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Doesn't check boundary values.",
- method = "valueOf",
- args = {java.lang.String.class}
- )
- public void test_valueOfLjava_lang_String() {
- assertEquals(new Integer(0), Integer.valueOf("0"));
- assertEquals(new Integer(1), Integer.valueOf("1"));
- assertEquals(new Integer(-1), Integer.valueOf("-1"));
-
- try {
- Integer.valueOf("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.valueOf("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.valueOf("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.valueOf(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Integer#valueOf(String,int)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Doesn't check boundary values.",
- method = "valueOf",
- args = {java.lang.String.class, int.class}
- )
- public void test_valueOfLjava_lang_StringI() {
- assertEquals(new Integer(0), Integer.valueOf("0", 10));
- assertEquals(new Integer(1), Integer.valueOf("1", 10));
- assertEquals(new Integer(-1), Integer.valueOf("-1", 10));
-
- //must be consistent with Character.digit()
- assertEquals(Character.digit('1', 2), Integer.valueOf("1", 2).byteValue());
- assertEquals(Character.digit('F', 16), Integer.valueOf("F", 16).byteValue());
-
- try {
- Integer.valueOf("0x1", 10);
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.valueOf("9.2", 10);
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.valueOf("", 10);
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.valueOf(null, 10);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Integer#parseInt(String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Doesn't check boundary values.",
- method = "parseInt",
- args = {java.lang.String.class}
- )
- public void test_parseIntLjava_lang_String() {
- assertEquals(0, Integer.parseInt("0"));
- assertEquals(1, Integer.parseInt("1"));
- assertEquals(-1, Integer.parseInt("-1"));
-
- try {
- Integer.parseInt("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.parseInt("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.parseInt("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.parseInt(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Integer#parseInt(String,int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "parseInt",
- args = {java.lang.String.class, int.class}
- )
- public void test_parseIntLjava_lang_StringI() {
- assertEquals(0, Integer.parseInt("0", 10));
- assertEquals(1, Integer.parseInt("1", 10));
- assertEquals(-1, Integer.parseInt("-1", 10));
-
- //must be consistent with Character.digit()
- assertEquals(Character.digit('1', 2), Integer.parseInt("1", 2));
- assertEquals(Character.digit('F', 16), Integer.parseInt("F", 16));
-
- try {
- Integer.parseInt("0x1", 10);
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.parseInt("9.2", 10);
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.parseInt("", 10);
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.parseInt(null, 10);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Integer#decode(String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "decode",
- args = {java.lang.String.class}
- )
- public void test_decodeLjava_lang_String() {
- assertEquals(new Integer(0), Integer.decode("0"));
- assertEquals(new Integer(1), Integer.decode("1"));
- assertEquals(new Integer(-1), Integer.decode("-1"));
- assertEquals(new Integer(0xF), Integer.decode("0xF"));
- assertEquals(new Integer(0xF), Integer.decode("#F"));
- assertEquals(new Integer(0xF), Integer.decode("0XF"));
- assertEquals(new Integer(07), Integer.decode("07"));
-
- try {
- Integer.decode("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.decode("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Integer.decode(null);
- //undocumented NPE, but seems consistent across JREs
- fail("Expected NullPointerException with null string.");
- } catch (NullPointerException e) {}
- }
-
- /**
- * @tests java.lang.Integer#doubleValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Doesn't check boundaries.",
- method = "doubleValue",
- args = {}
- )
- public void test_doubleValue() {
- assertEquals(-1D, new Integer(-1).doubleValue(), 0D);
- assertEquals(0D, new Integer(0).doubleValue(), 0D);
- assertEquals(1D, new Integer(1).doubleValue(), 0D);
- }
-
- /**
- * @tests java.lang.Integer#floatValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "floatValue",
- args = {}
- )
- public void test_floatValue() {
- assertEquals(-1F, new Integer(-1).floatValue(), 0F);
- assertEquals(0F, new Integer(0).floatValue(), 0F);
- assertEquals(1F, new Integer(1).floatValue(), 0F);
- }
-
- /**
- * @tests java.lang.Integer#intValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "intValue",
- args = {}
- )
- public void test_intValue() {
- assertEquals(-1, new Integer(-1).intValue());
- assertEquals(0, new Integer(0).intValue());
- assertEquals(1, new Integer(1).intValue());
- assertEquals(Integer.MAX_VALUE, new Integer(Integer.MAX_VALUE).intValue());
- assertEquals(Integer.MIN_VALUE, new Integer(Integer.MIN_VALUE).intValue());
- }
-
- /**
- * @tests java.lang.Integer#longValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "longValue",
- args = {}
- )
- public void test_longValue() {
- assertEquals(-1L, new Integer(-1).longValue());
- assertEquals(0L, new Integer(0).longValue());
- assertEquals(1L, new Integer(1).longValue());
- assertEquals(Integer.MAX_VALUE, new Integer(Integer.MAX_VALUE).longValue());
- assertEquals(Integer.MIN_VALUE, new Integer(Integer.MIN_VALUE).longValue());
- }
-
- /**
- * @tests java.lang.Integer#shortValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "shortValue",
- args = {}
- )
- public void test_shortValue() {
- assertEquals(-1, new Integer(-1).shortValue());
- assertEquals(0, new Integer(0).shortValue());
- assertEquals(1, new Integer(1).shortValue());
- assertEquals(-1, new Integer(Integer.MAX_VALUE).shortValue());
- assertEquals(0, new Integer(Integer.MIN_VALUE).shortValue());
- }
- /**
- * @tests java.lang.Integer#highestOneBit(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "highestOneBit",
- args = {int.class}
- )
- public void test_highestOneBitI() {
- assertEquals(0x08, Integer.highestOneBit(0x0A));
- assertEquals(0x08, Integer.highestOneBit(0x0B));
- assertEquals(0x08, Integer.highestOneBit(0x0C));
- assertEquals(0x08, Integer.highestOneBit(0x0F));
- assertEquals(0x80, Integer.highestOneBit(0xFF));
-
- assertEquals(0x080000, Integer.highestOneBit(0x0F1234));
- assertEquals(0x800000, Integer.highestOneBit(0xFF9977));
-
- assertEquals(0x80000000, Integer.highestOneBit(0xFFFFFFFF));
-
- assertEquals(0, Integer.highestOneBit(0));
- assertEquals(1, Integer.highestOneBit(1));
- assertEquals(0x80000000, Integer.highestOneBit(-1));
- }
-
- /**
- * @tests java.lang.Integer#lowestOneBit(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "lowestOneBit",
- args = {int.class}
- )
- public void test_lowestOneBitI() {
- assertEquals(0x10, Integer.lowestOneBit(0xF0));
-
- assertEquals(0x10, Integer.lowestOneBit(0x90));
- assertEquals(0x10, Integer.lowestOneBit(0xD0));
-
- assertEquals(0x10, Integer.lowestOneBit(0x123490));
- assertEquals(0x10, Integer.lowestOneBit(0x1234D0));
-
- assertEquals(0x100000, Integer.lowestOneBit(0x900000));
- assertEquals(0x100000, Integer.lowestOneBit(0xD00000));
-
- assertEquals(0x40, Integer.lowestOneBit(0x40));
- assertEquals(0x40, Integer.lowestOneBit(0xC0));
-
- assertEquals(0x4000, Integer.lowestOneBit(0x4000));
- assertEquals(0x4000, Integer.lowestOneBit(0xC000));
-
- assertEquals(0x4000, Integer.lowestOneBit(0x99994000));
- assertEquals(0x4000, Integer.lowestOneBit(0x9999C000));
-
- assertEquals(0, Integer.lowestOneBit(0));
- assertEquals(1, Integer.lowestOneBit(1));
- assertEquals(1, Integer.lowestOneBit(-1));
- }
- /**
- * @tests java.lang.Integer#numberOfLeadingZeros(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "numberOfLeadingZeros",
- args = {int.class}
- )
- public void test_numberOfLeadingZerosI() {
- assertEquals(32, Integer.numberOfLeadingZeros(0x0));
- assertEquals(31, Integer.numberOfLeadingZeros(0x1));
- assertEquals(30, Integer.numberOfLeadingZeros(0x2));
- assertEquals(30, Integer.numberOfLeadingZeros(0x3));
- assertEquals(29, Integer.numberOfLeadingZeros(0x4));
- assertEquals(29, Integer.numberOfLeadingZeros(0x5));
- assertEquals(29, Integer.numberOfLeadingZeros(0x6));
- assertEquals(29, Integer.numberOfLeadingZeros(0x7));
- assertEquals(28, Integer.numberOfLeadingZeros(0x8));
- assertEquals(28, Integer.numberOfLeadingZeros(0x9));
- assertEquals(28, Integer.numberOfLeadingZeros(0xA));
- assertEquals(28, Integer.numberOfLeadingZeros(0xB));
- assertEquals(28, Integer.numberOfLeadingZeros(0xC));
- assertEquals(28, Integer.numberOfLeadingZeros(0xD));
- assertEquals(28, Integer.numberOfLeadingZeros(0xE));
- assertEquals(28, Integer.numberOfLeadingZeros(0xF));
- assertEquals(27, Integer.numberOfLeadingZeros(0x10));
- assertEquals(24, Integer.numberOfLeadingZeros(0x80));
- assertEquals(24, Integer.numberOfLeadingZeros(0xF0));
- assertEquals(23, Integer.numberOfLeadingZeros(0x100));
- assertEquals(20, Integer.numberOfLeadingZeros(0x800));
- assertEquals(20, Integer.numberOfLeadingZeros(0xF00));
- assertEquals(19, Integer.numberOfLeadingZeros(0x1000));
- assertEquals(16, Integer.numberOfLeadingZeros(0x8000));
- assertEquals(16, Integer.numberOfLeadingZeros(0xF000));
- assertEquals(15, Integer.numberOfLeadingZeros(0x10000));
- assertEquals(12, Integer.numberOfLeadingZeros(0x80000));
- assertEquals(12, Integer.numberOfLeadingZeros(0xF0000));
- assertEquals(11, Integer.numberOfLeadingZeros(0x100000));
- assertEquals(8, Integer.numberOfLeadingZeros(0x800000));
- assertEquals(8, Integer.numberOfLeadingZeros(0xF00000));
- assertEquals(7, Integer.numberOfLeadingZeros(0x1000000));
- assertEquals(4, Integer.numberOfLeadingZeros(0x8000000));
- assertEquals(4, Integer.numberOfLeadingZeros(0xF000000));
- assertEquals(3, Integer.numberOfLeadingZeros(0x10000000));
- assertEquals(0, Integer.numberOfLeadingZeros(0x80000000));
- assertEquals(0, Integer.numberOfLeadingZeros(0xF0000000));
-
- assertEquals(1, Integer.numberOfLeadingZeros(Integer.MAX_VALUE));
- assertEquals(0, Integer.numberOfLeadingZeros(Integer.MIN_VALUE));
- }
-
- /**
- * @tests
- * java.lang.Integer#numberOfTrailingZeros(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "numberOfTrailingZeros",
- args = {int.class}
- )
- public void test_numberOfTrailingZerosI() {
- assertEquals(32, Integer.numberOfTrailingZeros(0x0));
- assertEquals(31, Integer.numberOfTrailingZeros(Integer.MIN_VALUE));
- assertEquals(0, Integer.numberOfTrailingZeros(Integer.MAX_VALUE));
-
- assertEquals(0, Integer.numberOfTrailingZeros(0x1));
- assertEquals(3, Integer.numberOfTrailingZeros(0x8));
- assertEquals(0, Integer.numberOfTrailingZeros(0xF));
-
- assertEquals(4, Integer.numberOfTrailingZeros(0x10));
- assertEquals(7, Integer.numberOfTrailingZeros(0x80));
- assertEquals(4, Integer.numberOfTrailingZeros(0xF0));
-
- assertEquals(8, Integer.numberOfTrailingZeros(0x100));
- assertEquals(11, Integer.numberOfTrailingZeros(0x800));
- assertEquals(8, Integer.numberOfTrailingZeros(0xF00));
-
- assertEquals(12, Integer.numberOfTrailingZeros(0x1000));
- assertEquals(15, Integer.numberOfTrailingZeros(0x8000));
- assertEquals(12, Integer.numberOfTrailingZeros(0xF000));
-
- assertEquals(16, Integer.numberOfTrailingZeros(0x10000));
- assertEquals(19, Integer.numberOfTrailingZeros(0x80000));
- assertEquals(16, Integer.numberOfTrailingZeros(0xF0000));
-
- assertEquals(20, Integer.numberOfTrailingZeros(0x100000));
- assertEquals(23, Integer.numberOfTrailingZeros(0x800000));
- assertEquals(20, Integer.numberOfTrailingZeros(0xF00000));
-
- assertEquals(24, Integer.numberOfTrailingZeros(0x1000000));
- assertEquals(27, Integer.numberOfTrailingZeros(0x8000000));
- assertEquals(24, Integer.numberOfTrailingZeros(0xF000000));
-
- assertEquals(28, Integer.numberOfTrailingZeros(0x10000000));
- assertEquals(31, Integer.numberOfTrailingZeros(0x80000000));
- assertEquals(28, Integer.numberOfTrailingZeros(0xF0000000));
- }
-
- /**
- * @tests java.lang.Integer#bitCount(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "bitCount",
- args = {int.class}
- )
- public void test_bitCountI() {
- assertEquals(0, Integer.bitCount(0x0));
- assertEquals(1, Integer.bitCount(0x1));
- assertEquals(1, Integer.bitCount(0x2));
- assertEquals(2, Integer.bitCount(0x3));
- assertEquals(1, Integer.bitCount(0x4));
- assertEquals(2, Integer.bitCount(0x5));
- assertEquals(2, Integer.bitCount(0x6));
- assertEquals(3, Integer.bitCount(0x7));
- assertEquals(1, Integer.bitCount(0x8));
- assertEquals(2, Integer.bitCount(0x9));
- assertEquals(2, Integer.bitCount(0xA));
- assertEquals(3, Integer.bitCount(0xB));
- assertEquals(2, Integer.bitCount(0xC));
- assertEquals(3, Integer.bitCount(0xD));
- assertEquals(3, Integer.bitCount(0xE));
- assertEquals(4, Integer.bitCount(0xF));
-
- assertEquals(8, Integer.bitCount(0xFF));
- assertEquals(12, Integer.bitCount(0xFFF));
- assertEquals(16, Integer.bitCount(0xFFFF));
- assertEquals(20, Integer.bitCount(0xFFFFF));
- assertEquals(24, Integer.bitCount(0xFFFFFF));
- assertEquals(28, Integer.bitCount(0xFFFFFFF));
- assertEquals(32, Integer.bitCount(0xFFFFFFFF));
- }
-
- /**
- * @tests java.lang.Integer#rotateLeft(int,int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "rotateLeft",
- args = {int.class, int.class}
- )
- public void test_rotateLeftII() {
- assertEquals(0xF, Integer.rotateLeft(0xF, 0));
- assertEquals(0xF0, Integer.rotateLeft(0xF, 4));
- assertEquals(0xF00, Integer.rotateLeft(0xF, 8));
- assertEquals(0xF000, Integer.rotateLeft(0xF, 12));
- assertEquals(0xF0000, Integer.rotateLeft(0xF, 16));
- assertEquals(0xF00000, Integer.rotateLeft(0xF, 20));
- assertEquals(0xF000000, Integer.rotateLeft(0xF, 24));
- assertEquals(0xF0000000, Integer.rotateLeft(0xF, 28));
- assertEquals(0xF0000000, Integer.rotateLeft(0xF0000000, 32));
- }
-
- /**
- * @tests java.lang.Integer#rotateRight(int,int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "rotateRight",
- args = {int.class, int.class}
- )
- public void test_rotateRightII() {
- assertEquals(0xF, Integer.rotateRight(0xF0, 4));
- assertEquals(0xF, Integer.rotateRight(0xF00, 8));
- assertEquals(0xF, Integer.rotateRight(0xF000, 12));
- assertEquals(0xF, Integer.rotateRight(0xF0000, 16));
- assertEquals(0xF, Integer.rotateRight(0xF00000, 20));
- assertEquals(0xF, Integer.rotateRight(0xF000000, 24));
- assertEquals(0xF, Integer.rotateRight(0xF0000000, 28));
- assertEquals(0xF0000000, Integer.rotateRight(0xF0000000, 32));
- assertEquals(0xF0000000, Integer.rotateRight(0xF0000000, 0));
-
- }
-
- /**
- * @tests java.lang.Integer#reverseBytes(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "reverseBytes",
- args = {int.class}
- )
- public void test_reverseBytesI() {
- assertEquals(0xAABBCCDD, Integer.reverseBytes(0xDDCCBBAA));
- assertEquals(0x11223344, Integer.reverseBytes(0x44332211));
- assertEquals(0x00112233, Integer.reverseBytes(0x33221100));
- assertEquals(0x20000002, Integer.reverseBytes(0x02000020));
- }
-
- /**
- * @tests java.lang.Integer#reverse(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "reverse",
- args = {int.class}
- )
- public void test_reverseI() {
- assertEquals(-1, Integer.reverse(-1));
- assertEquals(0x80000000,Integer.reverse(1));
- }
-
- /**
- * @tests java.lang.Integer#signum(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "signum",
- args = {int.class}
- )
- public void test_signumI() {
- for (int i = -128; i<0; i++) {
- assertEquals(-1, Integer.signum(i));
- }
- assertEquals(0, Integer.signum(0));
- for (int i = 1; i<=127; i++) {
- assertEquals(1, Integer.signum(i));
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InternalErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InternalErrorTest.java
deleted file mode 100644
index 3ff4711..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InternalErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class InternalErrorTest extends TestCase {
-
- /**
- * @tests java.lang.InternalError#InternalError()
- */
- public void test_Constructor() {
- InternalError e = new InternalError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.InternalError#InternalError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- InternalError e = new InternalError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InterruptedExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InterruptedExceptionTest.java
deleted file mode 100644
index 96c85e6..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/InterruptedExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class InterruptedExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.InterruptedException#InterruptedException()
- */
- public void test_Constructor() {
- InterruptedException e = new InterruptedException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.InterruptedException#InterruptedException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- InterruptedException e = new InterruptedException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/LinkageErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/LinkageErrorTest.java
deleted file mode 100644
index 9c1adcb..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/LinkageErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class LinkageErrorTest extends TestCase {
-
- /**
- * @tests java.lang.LinkageError#LinkageError()
- */
- public void test_Constructor() {
- LinkageError e = new LinkageError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.LinkageError#LinkageError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- LinkageError e = new LinkageError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/LongTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/LongTest.java
deleted file mode 100644
index 432f802..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/LongTest.java
+++ /dev/null
@@ -1,1332 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-import java.util.Properties;
-
-@TestTargetClass(Long.class)
-public class LongTest extends TestCase {
- private Properties orgProps;
-
- @Override
- protected void setUp() {
- orgProps = System.getProperties();
- }
-
- @Override
- protected void tearDown() {
- System.setProperties(orgProps);
- }
-
- /**
- * @tests java.lang.Long#byteValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Checks bounary values.",
- method = "byteValue",
- args = {}
- )
- public void test_byteValue() {
- // Test for method byte java.lang.Long.byteValue()
- Long l = new Long(127);
- assertEquals("Returned incorrect byte value", 127, l.byteValue());
- assertEquals("Returned incorrect byte value", -1, new Long(Long.MAX_VALUE)
- .byteValue());
- }
-
- /**
- * @tests java.lang.Long#compareTo(java.lang.Long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "compareTo",
- args = {java.lang.Long.class}
- )
- public void test_compareToLjava_lang_Long() {
- // Test for method int java.lang.Long.compareTo(java.lang.Long)
- assertTrue("-2 compared to 1 gave non-negative answer", new Long(-2L)
- .compareTo(new Long(1L)) < 0);
- assertEquals("-2 compared to -2 gave non-zero answer", 0, new Long(-2L)
- .compareTo(new Long(-2L)));
- assertTrue("3 compared to 2 gave non-positive answer", new Long(3L)
- .compareTo(new Long(2L)) > 0);
-
- try {
- new Long(0).compareTo(null);
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Long#decode(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "decode",
- args = {java.lang.String.class}
- )
- public void test_decodeLjava_lang_String2() {
- // Test for method java.lang.Long
- // java.lang.Long.decode(java.lang.String)
- assertEquals("Returned incorrect value for hex string", 255L, Long.decode(
- "0xFF").longValue());
- assertEquals("Returned incorrect value for dec string", -89000L, Long.decode(
- "-89000").longValue());
- assertEquals("Returned incorrect value for 0 decimal", 0, Long.decode("0")
- .longValue());
- assertEquals("Returned incorrect value for 0 hex", 0, Long.decode("0x0")
- .longValue());
- assertTrue(
- "Returned incorrect value for most negative value decimal",
- Long.decode("-9223372036854775808").longValue() == 0x8000000000000000L);
- assertTrue(
- "Returned incorrect value for most negative value hex",
- Long.decode("-0x8000000000000000").longValue() == 0x8000000000000000L);
- assertTrue(
- "Returned incorrect value for most positive value decimal",
- Long.decode("9223372036854775807").longValue() == 0x7fffffffffffffffL);
- assertTrue(
- "Returned incorrect value for most positive value hex",
- Long.decode("0x7fffffffffffffff").longValue() == 0x7fffffffffffffffL);
- assertTrue("Failed for 07654321765432", Long.decode("07654321765432")
- .longValue() == 07654321765432l);
-
- boolean exception = false;
- try {
- Long
- .decode("999999999999999999999999999999999999999999999999999999");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for value > ilong", exception);
-
- exception = false;
- try {
- Long.decode("9223372036854775808");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Long.decode("-9223372036854775809");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Long.decode("0x8000000000000000");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Long.decode("-0x8000000000000001");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Long.decode("42325917317067571199");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for 42325917317067571199",
- exception);
- }
-
- /**
- * @tests java.lang.Long#getLong(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getLong",
- args = {java.lang.String.class}
- )
- public void test_getLongLjava_lang_String() {
- // Test for method java.lang.Long
- // java.lang.Long.getLong(java.lang.String)
- Properties tProps = new Properties();
- tProps.put("testLong", "99");
- tProps.put("testIncLong", "string");
- System.setProperties(tProps);
- assertTrue("returned incorrect Long", Long.getLong("testLong").equals(
- new Long(99)));
- assertNull("returned incorrect default Long",
- Long.getLong("ff"));
- assertNull("returned incorrect default Long",
- Long.getLong("testIncLong"));
- }
-
- /**
- * @tests java.lang.Long#getLong(java.lang.String, long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getLong",
- args = {java.lang.String.class, long.class}
- )
- public void test_getLongLjava_lang_StringJ() {
- // Test for method java.lang.Long
- // java.lang.Long.getLong(java.lang.String, long)
- Properties tProps = new Properties();
- tProps.put("testLong", "99");
- tProps.put("testIncLong", "string");
- System.setProperties(tProps);
- assertTrue("returned incorrect Long", Long.getLong("testLong", 4L)
- .equals(new Long(99)));
- assertTrue("returned incorrect default Long", Long.getLong("ff", 4L)
- .equals(new Long(4)));
- assertTrue("returned incorrect default Long", Long.getLong("testIncLong", 4L)
- .equals(new Long(4)));
- }
-
- /**
- * @tests java.lang.Long#getLong(java.lang.String, java.lang.Long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getLong",
- args = {java.lang.String.class, java.lang.Long.class}
- )
- public void test_getLongLjava_lang_StringLjava_lang_Long() {
- // Test for method java.lang.Long
- // java.lang.Long.getLong(java.lang.String, java.lang.Long)
- Properties tProps = new Properties();
- tProps.put("testLong", "99");
- tProps.put("testIncLong", "string");
- System.setProperties(tProps);
- assertTrue("returned incorrect Long", Long.getLong("testLong",
- new Long(4)).equals(new Long(99)));
- assertTrue("returned incorrect default Long", Long.getLong("ff",
- new Long(4)).equals(new Long(4)));
- assertTrue("returned incorrect default Long", Long.getLong("testIncLong",
- new Long(4)).equals(new Long(4)));
- }
-
- /**
- * @tests java.lang.Long#parseLong(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Checks boundary values and exceptions.",
- method = "parseLong",
- args = {java.lang.String.class}
- )
- public void test_parseLongLjava_lang_String2() {
- // Test for method long java.lang.Long.parseLong(java.lang.String)
-
- long l = Long.parseLong("89000000005");
- assertEquals("Parsed to incorrect long value", 89000000005L, l);
- assertEquals("Returned incorrect value for 0", 0, Long.parseLong("0"));
- assertTrue("Returned incorrect value for most negative value", Long
- .parseLong("-9223372036854775808") == 0x8000000000000000L);
- assertTrue("Returned incorrect value for most positive value", Long
- .parseLong("9223372036854775807") == 0x7fffffffffffffffL);
-
- boolean exception = false;
- try {
- Long.parseLong("9223372036854775808");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Long.parseLong("-9223372036854775809");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
- }
-
- /**
- * @tests java.lang.Long#parseLong(java.lang.String, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "parseLong",
- args = {java.lang.String.class, int.class}
- )
- public void test_parseLongLjava_lang_StringI() {
- // Test for method long java.lang.Long.parseLong(java.lang.String, int)
- assertEquals("Returned incorrect value",
- 100000000L, Long.parseLong("100000000", 10));
- assertEquals("Returned incorrect value from hex string", 68719476735L, Long.parseLong(
- "FFFFFFFFF", 16));
- assertTrue("Returned incorrect value from octal string: "
- + Long.parseLong("77777777777"), Long.parseLong("77777777777",
- 8) == 8589934591L);
- assertEquals("Returned incorrect value for 0 hex", 0, Long
- .parseLong("0", 16));
- assertTrue("Returned incorrect value for most negative value hex", Long
- .parseLong("-8000000000000000", 16) == 0x8000000000000000L);
- assertTrue("Returned incorrect value for most positive value hex", Long
- .parseLong("7fffffffffffffff", 16) == 0x7fffffffffffffffL);
- assertEquals("Returned incorrect value for 0 decimal", 0, Long.parseLong(
- "0", 10));
- assertTrue(
- "Returned incorrect value for most negative value decimal",
- Long.parseLong("-9223372036854775808", 10) == 0x8000000000000000L);
- assertTrue(
- "Returned incorrect value for most positive value decimal",
- Long.parseLong("9223372036854775807", 10) == 0x7fffffffffffffffL);
-
- boolean exception = false;
- try {
- Long.parseLong("999999999999", 8);
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Failed to throw exception when passed invalid string",
- exception);
-
- exception = false;
- try {
- Long.parseLong("9223372036854775808", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Long.parseLong("-9223372036854775809", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Long.parseLong("8000000000000000", 16);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Long.parseLong("-8000000000000001", 16);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MIN_VALUE + 1", exception);
-
- exception = false;
- try {
- Long.parseLong("42325917317067571199", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for 42325917317067571199",
- exception);
- }
-
- /**
- * @tests java.lang.Long#toBinaryString(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toBinaryString",
- args = {long.class}
- )
- public void test_toBinaryStringJ() {
- // Test for method java.lang.String java.lang.Long.toBinaryString(long)
- assertEquals("Incorrect binary string returned", "11011001010010010000", Long.toBinaryString(
- 890000L));
- assertEquals("Incorrect binary string returned",
-
- "1000000000000000000000000000000000000000000000000000000000000000", Long
- .toBinaryString(Long.MIN_VALUE)
- );
- assertEquals("Incorrect binary string returned",
-
- "111111111111111111111111111111111111111111111111111111111111111", Long
- .toBinaryString(Long.MAX_VALUE)
- );
- }
-
- /**
- * @tests java.lang.Long#toHexString(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toHexString",
- args = {long.class}
- )
- public void test_toHexStringJ() {
- // Test for method java.lang.String java.lang.Long.toHexString(long)
- assertEquals("Incorrect hex string returned", "54e0845", Long.toHexString(89000005L)
- );
- assertEquals("Incorrect hex string returned", "8000000000000000", Long.toHexString(
- Long.MIN_VALUE));
- assertEquals("Incorrect hex string returned", "7fffffffffffffff", Long.toHexString(
- Long.MAX_VALUE));
- }
-
- /**
- * @tests java.lang.Long#toOctalString(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toOctalString",
- args = {long.class}
- )
- public void test_toOctalStringJ() {
- // Test for method java.lang.String java.lang.Long.toOctalString(long)
- assertEquals("Returned incorrect oct string", "77777777777", Long.toOctalString(
- 8589934591L));
- assertEquals("Returned incorrect oct string", "1000000000000000000000", Long.toOctalString(
- Long.MIN_VALUE));
- assertEquals("Returned incorrect oct string", "777777777777777777777", Long.toOctalString(
- Long.MAX_VALUE));
- }
-
- /**
- * @tests java.lang.Long#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString2() {
- // Test for method java.lang.String java.lang.Long.toString()
- Long l = new Long(89000000005L);
- assertEquals("Returned incorrect String",
- "89000000005", l.toString());
- assertEquals("Returned incorrect String", "-9223372036854775808", new Long(Long.MIN_VALUE)
- .toString());
- assertEquals("Returned incorrect String", "9223372036854775807", new Long(Long.MAX_VALUE)
- .toString());
- }
-
- /**
- * @tests java.lang.Long#toString(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {long.class}
- )
- public void test_toStringJ2() {
- // Test for method java.lang.String java.lang.Long.toString(long)
-
- assertEquals("Returned incorrect String", "89000000005", Long.toString(89000000005L)
- );
- assertEquals("Returned incorrect String", "-9223372036854775808", Long.toString(Long.MIN_VALUE)
- );
- assertEquals("Returned incorrect String", "9223372036854775807", Long.toString(Long.MAX_VALUE)
- );
- }
-
- /**
- * @tests java.lang.Long#toString(long, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {long.class, int.class}
- )
- public void test_toStringJI() {
- // Test for method java.lang.String java.lang.Long.toString(long, int)
- assertEquals("Returned incorrect dec string", "100000000", Long.toString(100000000L,
- 10));
- assertEquals("Returned incorrect hex string", "fffffffff", Long.toString(68719476735L,
- 16));
- assertEquals("Returned incorrect oct string", "77777777777", Long.toString(8589934591L,
- 8));
- assertEquals("Returned incorrect bin string",
- "1111111111111111111111111111111111111111111", Long.toString(
- 8796093022207L, 2));
- assertEquals("Returned incorrect min string", "-9223372036854775808", Long.toString(
- 0x8000000000000000L, 10));
- assertEquals("Returned incorrect max string", "9223372036854775807", Long.toString(
- 0x7fffffffffffffffL, 10));
- assertEquals("Returned incorrect min string", "-8000000000000000", Long.toString(
- 0x8000000000000000L, 16));
- assertEquals("Returned incorrect max string", "7fffffffffffffff", Long.toString(
- 0x7fffffffffffffffL, 16));
- }
-
- /**
- * @tests java.lang.Long#valueOf(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {java.lang.String.class}
- )
- public void test_valueOfLjava_lang_String2() {
- // Test for method java.lang.Long
- // java.lang.Long.valueOf(java.lang.String)
- assertEquals("Returned incorrect value", 100000000L, Long.valueOf("100000000")
- .longValue());
- assertTrue("Returned incorrect value", Long.valueOf(
- "9223372036854775807").longValue() == Long.MAX_VALUE);
- assertTrue("Returned incorrect value", Long.valueOf(
- "-9223372036854775808").longValue() == Long.MIN_VALUE);
-
- boolean exception = false;
- try {
- Long
- .valueOf("999999999999999999999999999999999999999999999999999999999999");
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Failed to throw exception when passed invalid string",
- exception);
-
- exception = false;
- try {
- Long.valueOf("9223372036854775808");
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Failed to throw exception when passed invalid string",
- exception);
-
- exception = false;
- try {
- Long.valueOf("-9223372036854775809");
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Failed to throw exception when passed invalid string",
- exception);
- }
-
- /**
- * @tests java.lang.Long#valueOf(java.lang.String, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {java.lang.String.class, int.class}
- )
- public void test_valueOfLjava_lang_StringI() {
- // Test for method java.lang.Long
- // java.lang.Long.valueOf(java.lang.String, int)
- assertEquals("Returned incorrect value", 100000000L, Long.valueOf("100000000", 10)
- .longValue());
- assertEquals("Returned incorrect value from hex string", 68719476735L, Long.valueOf(
- "FFFFFFFFF", 16).longValue());
- assertTrue("Returned incorrect value from octal string: "
- + Long.valueOf("77777777777", 8).toString(), Long.valueOf(
- "77777777777", 8).longValue() == 8589934591L);
- assertTrue("Returned incorrect value", Long.valueOf(
- "9223372036854775807", 10).longValue() == Long.MAX_VALUE);
- assertTrue("Returned incorrect value", Long.valueOf(
- "-9223372036854775808", 10).longValue() == Long.MIN_VALUE);
- assertTrue("Returned incorrect value", Long.valueOf("7fffffffffffffff",
- 16).longValue() == Long.MAX_VALUE);
- assertTrue("Returned incorrect value", Long.valueOf(
- "-8000000000000000", 16).longValue() == Long.MIN_VALUE);
-
- boolean exception = false;
- try {
- Long.valueOf("999999999999", 8);
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Failed to throw exception when passed invalid string",
- exception);
-
- exception = false;
- try {
- Long.valueOf("9223372036854775808", 10);
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Failed to throw exception when passed invalid string",
- exception);
-
- exception = false;
- try {
- Long.valueOf("-9223372036854775809", 10);
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Failed to throw exception when passed invalid string",
- exception);
- }
- /**
- * @tests java.lang.Long#valueOf(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {long.class}
- )
- public void test_valueOfJ() {
- assertEquals(new Long(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE));
- assertEquals(new Long(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE));
- assertEquals(new Long( 0), Long.valueOf( 0));
-
- long lng = -128;
- while (lng < 128) {
- assertEquals(new Long(lng), Long.valueOf(lng));
- assertSame(Long.valueOf(lng), Long.valueOf(lng));
- lng++;
- }
- }
-
- /**
- * @tests java.lang.Long#hashCode()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "hashCode",
- args = {}
- )
- public void test_hashCode() {
- assertEquals((int)(1L ^ (1L >>> 32)), new Long(1).hashCode());
- assertEquals((int)(2L ^ (2L >>> 32)), new Long(2).hashCode());
- assertEquals((int)(0L ^ (0L >>> 32)), new Long(0).hashCode());
- assertEquals((int)(-1L ^ (-1L >>> 32)), new Long(-1).hashCode());
- }
-
- /**
- * @tests java.lang.Long#Long(String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Long",
- args = {java.lang.String.class}
- )
- public void test_ConstructorLjava_lang_String() {
- assertEquals(new Long(0), new Long("0"));
- assertEquals(new Long(1), new Long("1"));
- assertEquals(new Long(-1), new Long("-1"));
-
- try {
- new Long("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Long("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Long("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Long(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Long#Long
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Long",
- args = {long.class}
- )
- public void test_ConstructorJ() {
- assertEquals(1, new Long(1).intValue());
- assertEquals(2, new Long(2).intValue());
- assertEquals(0, new Long(0).intValue());
- assertEquals(-1, new Long(-1).intValue());
- }
-
- /**
- * @tests java.lang.Long#byteValue()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Doesn't check boundary values.",
- method = "byteValue",
- args = {}
- )
- public void test_byteValue2() {
- assertEquals(1, new Long(1).byteValue());
- assertEquals(2, new Long(2).byteValue());
- assertEquals(0, new Long(0).byteValue());
- assertEquals(-1, new Long(-1).byteValue());
- }
-
- /**
- * @tests java.lang.Long#equals(Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "equals",
- args = {java.lang.Object.class}
- )
- public void test_equalsLjava_lang_Object() {
- assertEquals(new Long(0), Long.valueOf(0));
- assertEquals(new Long(1), Long.valueOf(1));
- assertEquals(new Long(-1), Long.valueOf(-1));
-
- Long fixture = new Long(25);
- assertEquals(fixture, fixture);
- assertFalse(fixture.equals(null));
- assertFalse(fixture.equals("Not a Long"));
- }
-
- /**
- * @tests java.lang.Long#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() {
- assertEquals("-1", new Long(-1).toString());
- assertEquals("0", new Long(0).toString());
- assertEquals("1", new Long(1).toString());
- assertEquals("-1", new Long(0xFFFFFFFF).toString());
- }
-
- /**
- * @tests java.lang.Long#toString
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {long.class}
- )
- public void test_toStringJ() {
- assertEquals("-1", Long.toString(-1));
- assertEquals("0", Long.toString(0));
- assertEquals("1", Long.toString(1));
- assertEquals("-1", Long.toString(0xFFFFFFFF));
- }
-
- /**
- * @tests java.lang.Long#valueOf(String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {java.lang.String.class}
- )
- public void test_valueOfLjava_lang_String() {
- assertEquals(new Long(0), Long.valueOf("0"));
- assertEquals(new Long(1), Long.valueOf("1"));
- assertEquals(new Long(-1), Long.valueOf("-1"));
-
- try {
- Long.valueOf("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.valueOf("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.valueOf("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.valueOf(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Long#valueOf(String,long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "valueOf",
- args = {java.lang.String.class, int.class}
- )
- public void test_valueOfLjava_lang_StringJ() {
- assertEquals(new Long(0), Long.valueOf("0", 10));
- assertEquals(new Long(1), Long.valueOf("1", 10));
- assertEquals(new Long(-1), Long.valueOf("-1", 10));
-
- //must be consistent with Character.digit()
- assertEquals(Character.digit('1', 2), Long.valueOf("1", 2).byteValue());
- assertEquals(Character.digit('F', 16), Long.valueOf("F", 16).byteValue());
-
- try {
- Long.valueOf("0x1", 10);
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.valueOf("9.2", 10);
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.valueOf("", 10);
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.valueOf(null, 10);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Long#parseLong(String)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Doesn't check boundary values.",
- method = "parseLong",
- args = {java.lang.String.class}
- )
- public void test_parseLongLjava_lang_String() {
- assertEquals(0, Long.parseLong("0"));
- assertEquals(1, Long.parseLong("1"));
- assertEquals(-1, Long.parseLong("-1"));
-
- try {
- Long.parseLong("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.parseLong("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.parseLong("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.parseLong(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Long#parseLong(String,long)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL,
- notes = "Doesn't check boundary values.",
- method = "parseLong",
- args = {java.lang.String.class, int.class}
- )
- public void test_parseLongLjava_lang_StringJ() {
- assertEquals(0, Long.parseLong("0", 10));
- assertEquals(1, Long.parseLong("1", 10));
- assertEquals(-1, Long.parseLong("-1", 10));
-
- //must be consistent with Character.digit()
- assertEquals(Character.digit('1', 2), Long.parseLong("1", 2));
- assertEquals(Character.digit('F', 16), Long.parseLong("F", 16));
-
- try {
- Long.parseLong("0x1", 10);
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.parseLong("9.2", 10);
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.parseLong("", 10);
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.parseLong(null, 10);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Long#decode(String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "decode",
- args = {java.lang.String.class}
- )
- public void test_decodeLjava_lang_String() {
- assertEquals(new Long(0), Long.decode("0"));
- assertEquals(new Long(1), Long.decode("1"));
- assertEquals(new Long(-1), Long.decode("-1"));
- assertEquals(new Long(0xF), Long.decode("0xF"));
- assertEquals(new Long(0xF), Long.decode("#F"));
- assertEquals(new Long(0xF), Long.decode("0XF"));
- assertEquals(new Long(07), Long.decode("07"));
-
- try {
- Long.decode("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.decode("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Long.decode(null);
- //undocumented NPE, but seems consistent across JREs
- fail("Expected NullPointerException with null string.");
- } catch (NullPointerException e) {}
- }
-
- /**
- * @tests java.lang.Long#doubleValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "doubleValue",
- args = {}
- )
- public void test_doubleValue() {
- assertEquals(-1D, new Long(-1).doubleValue(), 0D);
- assertEquals(0D, new Long(0).doubleValue(), 0D);
- assertEquals(1D, new Long(1).doubleValue(), 0D);
- }
-
- /**
- * @tests java.lang.Long#floatValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "floatValue",
- args = {}
- )
- public void test_floatValue() {
- assertEquals(-1F, new Long(-1).floatValue(), 0F);
- assertEquals(0F, new Long(0).floatValue(), 0F);
- assertEquals(1F, new Long(1).floatValue(), 0F);
-
- assertEquals(Long.MAX_VALUE, new Long(Long.MAX_VALUE).floatValue(), 0F);
- assertEquals(Long.MIN_VALUE, new Long(Long.MIN_VALUE).floatValue(), 0F);
- }
-
- /**
- * @tests java.lang.Long#intValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "intValue",
- args = {}
- )
- public void test_intValue() {
- assertEquals(-1, new Long(-1).intValue());
- assertEquals(0, new Long(0).intValue());
- assertEquals(1, new Long(1).intValue());
-
- assertEquals(-1, new Long(Long.MAX_VALUE).intValue());
- assertEquals(0, new Long(Long.MIN_VALUE).intValue());
- }
-
- /**
- * @tests java.lang.Long#longValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "longValue",
- args = {}
- )
- public void test_longValue() {
- assertEquals(-1L, new Long(-1).longValue());
- assertEquals(0L, new Long(0).longValue());
- assertEquals(1L, new Long(1).longValue());
-
- assertEquals(Long.MAX_VALUE, new Long(Long.MAX_VALUE).longValue());
- assertEquals(Long.MIN_VALUE, new Long(Long.MIN_VALUE).longValue());
- }
-
- /**
- * @tests java.lang.Long#shortValue()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "shortValue",
- args = {}
- )
- public void test_shortValue() {
- assertEquals(-1, new Long(-1).shortValue());
- assertEquals(0, new Long(0).shortValue());
- assertEquals(1, new Long(1).shortValue());
-
- assertEquals(-1, new Long(Long.MAX_VALUE).shortValue());
- assertEquals(0, new Long(Long.MIN_VALUE).shortValue());
- }
- /**
- * @tests java.lang.Long#highestOneBit(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "highestOneBit",
- args = {long.class}
- )
- public void test_highestOneBitJ() {
- assertEquals(0x08, Long.highestOneBit(0x0A));
- assertEquals(0x08, Long.highestOneBit(0x0B));
- assertEquals(0x08, Long.highestOneBit(0x0C));
- assertEquals(0x08, Long.highestOneBit(0x0F));
- assertEquals(0x80, Long.highestOneBit(0xFF));
-
- assertEquals(0x080000, Long.highestOneBit(0x0F1234));
- assertEquals(0x800000, Long.highestOneBit(0xFF9977));
-
- assertEquals(0x8000000000000000L, Long.highestOneBit(0xFFFFFFFFFFFFFFFFL));
-
- assertEquals(0, Long.highestOneBit(0));
- assertEquals(1, Long.highestOneBit(1));
- assertEquals(0x8000000000000000L, Long.highestOneBit(-1));
- }
-
- /**
- * @tests java.lang.Long#lowestOneBit(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "lowestOneBit",
- args = {long.class}
- )
- public void test_lowestOneBitJ() {
- assertEquals(0x10, Long.lowestOneBit(0xF0));
-
- assertEquals(0x10, Long.lowestOneBit(0x90));
- assertEquals(0x10, Long.lowestOneBit(0xD0));
-
- assertEquals(0x10, Long.lowestOneBit(0x123490));
- assertEquals(0x10, Long.lowestOneBit(0x1234D0));
-
- assertEquals(0x100000, Long.lowestOneBit(0x900000));
- assertEquals(0x100000, Long.lowestOneBit(0xD00000));
-
- assertEquals(0x40, Long.lowestOneBit(0x40));
- assertEquals(0x40, Long.lowestOneBit(0xC0));
-
- assertEquals(0x4000, Long.lowestOneBit(0x4000));
- assertEquals(0x4000, Long.lowestOneBit(0xC000));
-
- assertEquals(0x4000, Long.lowestOneBit(0x99994000));
- assertEquals(0x4000, Long.lowestOneBit(0x9999C000));
-
- assertEquals(0, Long.lowestOneBit(0));
- assertEquals(1, Long.lowestOneBit(1));
- assertEquals(1, Long.lowestOneBit(-1));
- }
- /**
- * @tests java.lang.Long#numberOfLeadingZeros(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "numberOfLeadingZeros",
- args = {long.class}
- )
- public void test_numberOfLeadingZerosJ() {
- assertEquals(64, Long.numberOfLeadingZeros(0x0L));
- assertEquals(63, Long.numberOfLeadingZeros(0x1));
- assertEquals(62, Long.numberOfLeadingZeros(0x2));
- assertEquals(62, Long.numberOfLeadingZeros(0x3));
- assertEquals(61, Long.numberOfLeadingZeros(0x4));
- assertEquals(61, Long.numberOfLeadingZeros(0x5));
- assertEquals(61, Long.numberOfLeadingZeros(0x6));
- assertEquals(61, Long.numberOfLeadingZeros(0x7));
- assertEquals(60, Long.numberOfLeadingZeros(0x8));
- assertEquals(60, Long.numberOfLeadingZeros(0x9));
- assertEquals(60, Long.numberOfLeadingZeros(0xA));
- assertEquals(60, Long.numberOfLeadingZeros(0xB));
- assertEquals(60, Long.numberOfLeadingZeros(0xC));
- assertEquals(60, Long.numberOfLeadingZeros(0xD));
- assertEquals(60, Long.numberOfLeadingZeros(0xE));
- assertEquals(60, Long.numberOfLeadingZeros(0xF));
- assertEquals(59, Long.numberOfLeadingZeros(0x10));
- assertEquals(56, Long.numberOfLeadingZeros(0x80));
- assertEquals(56, Long.numberOfLeadingZeros(0xF0));
- assertEquals(55, Long.numberOfLeadingZeros(0x100));
- assertEquals(52, Long.numberOfLeadingZeros(0x800));
- assertEquals(52, Long.numberOfLeadingZeros(0xF00));
- assertEquals(51, Long.numberOfLeadingZeros(0x1000));
- assertEquals(48, Long.numberOfLeadingZeros(0x8000));
- assertEquals(48, Long.numberOfLeadingZeros(0xF000));
- assertEquals(47, Long.numberOfLeadingZeros(0x10000));
- assertEquals(44, Long.numberOfLeadingZeros(0x80000));
- assertEquals(44, Long.numberOfLeadingZeros(0xF0000));
- assertEquals(43, Long.numberOfLeadingZeros(0x100000));
- assertEquals(40, Long.numberOfLeadingZeros(0x800000));
- assertEquals(40, Long.numberOfLeadingZeros(0xF00000));
- assertEquals(39, Long.numberOfLeadingZeros(0x1000000));
- assertEquals(36, Long.numberOfLeadingZeros(0x8000000));
- assertEquals(36, Long.numberOfLeadingZeros(0xF000000));
- assertEquals(35, Long.numberOfLeadingZeros(0x10000000));
- assertEquals(0, Long.numberOfLeadingZeros(0x80000000));
- assertEquals(0, Long.numberOfLeadingZeros(0xF0000000));
-
- assertEquals(1, Long.numberOfLeadingZeros(Long.MAX_VALUE));
- assertEquals(0, Long.numberOfLeadingZeros(Long.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.Long#numberOfTrailingZeros(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "numberOfTrailingZeros",
- args = {long.class}
- )
- public void test_numberOfTrailingZerosJ() {
- assertEquals(64, Long.numberOfTrailingZeros(0x0));
- assertEquals(63, Long.numberOfTrailingZeros(Long.MIN_VALUE));
- assertEquals(0, Long.numberOfTrailingZeros(Long.MAX_VALUE));
-
- assertEquals(0, Long.numberOfTrailingZeros(0x1));
- assertEquals(3, Long.numberOfTrailingZeros(0x8));
- assertEquals(0, Long.numberOfTrailingZeros(0xF));
-
- assertEquals(4, Long.numberOfTrailingZeros(0x10));
- assertEquals(7, Long.numberOfTrailingZeros(0x80));
- assertEquals(4, Long.numberOfTrailingZeros(0xF0));
-
- assertEquals(8, Long.numberOfTrailingZeros(0x100));
- assertEquals(11, Long.numberOfTrailingZeros(0x800));
- assertEquals(8, Long.numberOfTrailingZeros(0xF00));
-
- assertEquals(12, Long.numberOfTrailingZeros(0x1000));
- assertEquals(15, Long.numberOfTrailingZeros(0x8000));
- assertEquals(12, Long.numberOfTrailingZeros(0xF000));
-
- assertEquals(16, Long.numberOfTrailingZeros(0x10000));
- assertEquals(19, Long.numberOfTrailingZeros(0x80000));
- assertEquals(16, Long.numberOfTrailingZeros(0xF0000));
-
- assertEquals(20, Long.numberOfTrailingZeros(0x100000));
- assertEquals(23, Long.numberOfTrailingZeros(0x800000));
- assertEquals(20, Long.numberOfTrailingZeros(0xF00000));
-
- assertEquals(24, Long.numberOfTrailingZeros(0x1000000));
- assertEquals(27, Long.numberOfTrailingZeros(0x8000000));
- assertEquals(24, Long.numberOfTrailingZeros(0xF000000));
-
- assertEquals(28, Long.numberOfTrailingZeros(0x10000000));
- assertEquals(31, Long.numberOfTrailingZeros(0x80000000));
- assertEquals(28, Long.numberOfTrailingZeros(0xF0000000));
- }
-
- /**
- * @tests java.lang.Long#bitCount(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "bitCount",
- args = {long.class}
- )
- public void test_bitCountJ() {
- assertEquals(0, Long.bitCount(0x0));
- assertEquals(1, Long.bitCount(0x1));
- assertEquals(1, Long.bitCount(0x2));
- assertEquals(2, Long.bitCount(0x3));
- assertEquals(1, Long.bitCount(0x4));
- assertEquals(2, Long.bitCount(0x5));
- assertEquals(2, Long.bitCount(0x6));
- assertEquals(3, Long.bitCount(0x7));
- assertEquals(1, Long.bitCount(0x8));
- assertEquals(2, Long.bitCount(0x9));
- assertEquals(2, Long.bitCount(0xA));
- assertEquals(3, Long.bitCount(0xB));
- assertEquals(2, Long.bitCount(0xC));
- assertEquals(3, Long.bitCount(0xD));
- assertEquals(3, Long.bitCount(0xE));
- assertEquals(4, Long.bitCount(0xF));
-
- assertEquals(8, Long.bitCount(0xFF));
- assertEquals(12, Long.bitCount(0xFFF));
- assertEquals(16, Long.bitCount(0xFFFF));
- assertEquals(20, Long.bitCount(0xFFFFF));
- assertEquals(24, Long.bitCount(0xFFFFFF));
- assertEquals(28, Long.bitCount(0xFFFFFFF));
- assertEquals(64, Long.bitCount(0xFFFFFFFFFFFFFFFFL));
- }
-
- /**
- * @tests java.lang.Long#rotateLeft(long,long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "rotateLeft",
- args = {long.class, int.class}
- )
- public void test_rotateLeftJI() {
- assertEquals(0xF, Long.rotateLeft(0xF, 0));
- assertEquals(0xF0, Long.rotateLeft(0xF, 4));
- assertEquals(0xF00, Long.rotateLeft(0xF, 8));
- assertEquals(0xF000, Long.rotateLeft(0xF, 12));
- assertEquals(0xF0000, Long.rotateLeft(0xF, 16));
- assertEquals(0xF00000, Long.rotateLeft(0xF, 20));
- assertEquals(0xF000000, Long.rotateLeft(0xF, 24));
- assertEquals(0xF0000000L, Long.rotateLeft(0xF, 28));
- assertEquals(0xF000000000000000L, Long.rotateLeft(0xF000000000000000L, 64));
- }
-
- /**
- * @tests java.lang.Long#rotateRight(long,long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "rotateRight",
- args = {long.class, int.class}
- )
- public void test_rotateRightJI() {
- assertEquals(0xF, Long.rotateRight(0xF0, 4));
- assertEquals(0xF, Long.rotateRight(0xF00, 8));
- assertEquals(0xF, Long.rotateRight(0xF000, 12));
- assertEquals(0xF, Long.rotateRight(0xF0000, 16));
- assertEquals(0xF, Long.rotateRight(0xF00000, 20));
- assertEquals(0xF, Long.rotateRight(0xF000000, 24));
- assertEquals(0xF, Long.rotateRight(0xF0000000L, 28));
- assertEquals(0xF000000000000000L, Long.rotateRight(0xF000000000000000L, 64));
- assertEquals(0xF000000000000000L, Long.rotateRight(0xF000000000000000L, 0));
-
- }
-
- /**
- * @tests java.lang.Long#reverseBytes(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "reverseBytes",
- args = {long.class}
- )
- public void test_reverseBytesJ() {
- assertEquals(0xAABBCCDD00112233L, Long.reverseBytes(0x33221100DDCCBBAAL));
- assertEquals(0x1122334455667788L, Long.reverseBytes(0x8877665544332211L));
- assertEquals(0x0011223344556677L, Long.reverseBytes(0x7766554433221100L));
- assertEquals(0x2000000000000002L, Long.reverseBytes(0x0200000000000020L));
- }
-
- /**
- * @tests java.lang.Long#reverse(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "reverse",
- args = {long.class}
- )
- public void test_reverseJ() {
- assertEquals(0, Long.reverse(0));
- assertEquals(-1, Long.reverse(-1));
- assertEquals(0x8000000000000000L,Long.reverse(1));
- }
-
- /**
- * @tests java.lang.Long#signum(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "signum",
- args = {long.class}
- )
- public void test_signumJ() {
- for (int i = -128; i<0; i++) {
- assertEquals(-1, Long.signum(i));
- }
- assertEquals(0, Long.signum(0));
- for (int i = 1; i<=127; i++) {
- assertEquals(1, Long.signum(i));
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
deleted file mode 100644
index ceabd2c..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
+++ /dev/null
@@ -1,1987 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class MathTest extends junit.framework.TestCase {
-
- double HYP = Math.sqrt(2.0);
-
- double OPP = 1.0;
-
- double ADJ = 1.0;
-
- /* Required to make previous preprocessor flags work - do not remove */
- int unused = 0;
-
- /**
- * @tests java.lang.Math#abs(double)
- */
- public void test_absD() {
- // Test for method double java.lang.Math.abs(double)
-
- assertTrue("Incorrect double abs value",
- (Math.abs(-1908.8976) == 1908.8976));
- assertTrue("Incorrect double abs value",
- (Math.abs(1908.8976) == 1908.8976));
- }
-
- /**
- * @tests java.lang.Math#abs(float)
- */
- public void test_absF() {
- // Test for method float java.lang.Math.abs(float)
- assertTrue("Incorrect float abs value",
- (Math.abs(-1908.8976f) == 1908.8976f));
- assertTrue("Incorrect float abs value",
- (Math.abs(1908.8976f) == 1908.8976f));
- }
-
- /**
- * @tests java.lang.Math#abs(int)
- */
- public void test_absI() {
- // Test for method int java.lang.Math.abs(int)
- assertTrue("Incorrect int abs value", (Math.abs(-1908897) == 1908897));
- assertTrue("Incorrect int abs value", (Math.abs(1908897) == 1908897));
- }
-
- /**
- * @tests java.lang.Math#abs(long)
- */
- public void test_absJ() {
- // Test for method long java.lang.Math.abs(long)
- assertTrue("Incorrect long abs value",
- (Math.abs(-19088976000089L) == 19088976000089L));
- assertTrue("Incorrect long abs value",
- (Math.abs(19088976000089L) == 19088976000089L));
- }
-
- /**
- * @tests java.lang.Math#acos(double)
- */
- public void test_acosD() {
- // Test for method double java.lang.Math.acos(double)
- double r = Math.cos(Math.acos(ADJ / HYP));
- long lr = Double.doubleToLongBits(r);
- long t = Double.doubleToLongBits(ADJ / HYP);
- assertTrue("Returned incorrect arc cosine", lr == t || (lr + 1) == t
- || (lr - 1) == t);
- }
-
- /**
- * @tests java.lang.Math#asin(double)
- */
- public void test_asinD() {
- // Test for method double java.lang.Math.asin(double)
- double r = Math.sin(Math.asin(OPP / HYP));
- long lr = Double.doubleToLongBits(r);
- long t = Double.doubleToLongBits(OPP / HYP);
- assertTrue("Returned incorrect arc sine", lr == t || (lr + 1) == t
- || (lr - 1) == t);
- }
-
- /**
- * @tests java.lang.Math#atan(double)
- */
- public void test_atanD() {
- // Test for method double java.lang.Math.atan(double)
- double answer = Math.tan(Math.atan(1.0));
- assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
- && answer >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.Math#atan2(double, double)
- */
- public void test_atan2DD() {
- // Test for method double java.lang.Math.atan2(double, double)
- double answer = Math.atan(Math.tan(1.0));
- assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
- && answer >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.Math#cbrt(double)
- */
- public void test_cbrt_D() {
- //Test for special situations
- assertTrue("Should return Double.NaN", Double.isNaN(Math
- .cbrt(Double.NaN)));
- assertEquals("Should return Double.POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math
- .cbrt(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return Double.NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, Math
- .cbrt(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .cbrt(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double.doubleToLongBits(Math
- .cbrt(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double.doubleToLongBits(Math
- .cbrt(-0.0)));
-
- assertEquals("Should return 3.0", 3.0, Math.cbrt(27.0), 0D);
- assertEquals("Should return 23.111993172558684", 23.111993172558684,
- Math.cbrt(12345.6), 0D);
- assertEquals("Should return 5.643803094122362E102",
- 5.643803094122362E102, Math.cbrt(Double.MAX_VALUE), 0D);
- assertEquals("Should return 0.01", 0.01, Math.cbrt(0.000001), 0D);
-
- assertEquals("Should return -3.0", -3.0, Math.cbrt(-27.0), 0D);
- assertEquals("Should return -23.111993172558684", -23.111993172558684,
- Math.cbrt(-12345.6), 0D);
- assertEquals("Should return 1.7031839360032603E-108",
- 1.7031839360032603E-108, Math.cbrt(Double.MIN_VALUE), 0D);
- assertEquals("Should return -0.01", -0.01, Math.cbrt(-0.000001), 0D);
- }
-
- /**
- * @tests java.lang.Math#ceil(double)
- */
- public void test_ceilD() {
- // Test for method double java.lang.Math.ceil(double)
- assertEquals("Incorrect ceiling for double",
- 79, Math.ceil(78.89), 0);
- assertEquals("Incorrect ceiling for double",
- -78, Math.ceil(-78.89), 0);
- }
-
- /**
- * cases for test_copySign_DD in MathTest/StrictMathTest
- */
- static final double[] COPYSIGN_DD_CASES = new double[] {
- Double.POSITIVE_INFINITY, Double.MAX_VALUE, 3.4E302, 2.3,
- Double.MIN_NORMAL, Double.MIN_NORMAL / 2, Double.MIN_VALUE, +0.0,
- 0.0, -0.0, -Double.MIN_VALUE, -Double.MIN_NORMAL / 2,
- -Double.MIN_NORMAL, -4.5, -3.4E102, -Double.MAX_VALUE,
- Double.NEGATIVE_INFINITY };
-
- /**
- * @tests {@link java.lang.Math#copySign(double, double)}
- * @since 1.6
- *
- */
- @SuppressWarnings("boxing")
- public void test_copySign_DD() {
- for (int i = 0; i < COPYSIGN_DD_CASES.length; i++) {
- final double magnitude = COPYSIGN_DD_CASES[i];
- final long absMagnitudeBits = Double.doubleToLongBits(Math
- .abs(magnitude));
- final long negMagnitudeBits = Double.doubleToLongBits(-Math
- .abs(magnitude));
-
- // cases for NaN
- assertEquals("If the sign is NaN, the result should be positive.",
- absMagnitudeBits, Double.doubleToLongBits(Math.copySign(
- magnitude, Double.NaN)));
- assertTrue("The result should be NaN.", Double.isNaN(Math.copySign(
- Double.NaN, magnitude)));
-
- for (int j = 0; j < COPYSIGN_DD_CASES.length; j++) {
- final double sign = COPYSIGN_DD_CASES[j];
- final long resultBits = Double.doubleToLongBits(Math.copySign(
- magnitude, sign));
-
- if (sign > 0 || Double.valueOf(+0.0).equals(sign)
- || Double.valueOf(0.0).equals(sign)) {
- assertEquals(
- "If the sign is positive, the result should be positive.",
- absMagnitudeBits, resultBits);
- }
- if (sign < 0 || Double.valueOf(-0.0).equals(sign)) {
- assertEquals(
- "If the sign is negative, the result should be negative.",
- negMagnitudeBits, resultBits);
- }
- }
- }
-
- assertTrue("The result should be NaN.", Double.isNaN(Math.copySign(
- Double.NaN, Double.NaN)));
-
- try {
- Math.copySign((Double) null, 2.3);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.copySign(2.3, (Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.copySign((Double) null, (Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * cases for test_copySign_FF in MathTest/StrictMathTest
- */
- static final float[] COPYSIGN_FF_CASES = new float[] {
- Float.POSITIVE_INFINITY, Float.MAX_VALUE, 3.4E12f, 2.3f,
- Float.MIN_NORMAL, Float.MIN_NORMAL / 2, Float.MIN_VALUE, +0.0f,
- 0.0f, -0.0f, -Float.MIN_VALUE, -Float.MIN_NORMAL / 2,
- -Float.MIN_NORMAL, -4.5f, -5.6442E21f, -Float.MAX_VALUE,
- Float.NEGATIVE_INFINITY };
-
- /**
- * @tests {@link java.lang.Math#copySign(float, float)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_copySign_FF() {
- for (int i = 0; i < COPYSIGN_FF_CASES.length; i++) {
- final float magnitude = COPYSIGN_FF_CASES[i];
- final int absMagnitudeBits = Float.floatToIntBits(Math
- .abs(magnitude));
- final int negMagnitudeBits = Float.floatToIntBits(-Math
- .abs(magnitude));
-
- // cases for NaN
- assertEquals("If the sign is NaN, the result should be positive.",
- absMagnitudeBits, Float.floatToIntBits(Math.copySign(
- magnitude, Float.NaN)));
- assertTrue("The result should be NaN.", Float.isNaN(Math.copySign(
- Float.NaN, magnitude)));
-
- for (int j = 0; j < COPYSIGN_FF_CASES.length; j++) {
- final float sign = COPYSIGN_FF_CASES[j];
- final int resultBits = Float.floatToIntBits(Math.copySign(
- magnitude, sign));
- if (sign > 0 || Float.valueOf(+0.0f).equals(sign)
- || Float.valueOf(0.0f).equals(sign)) {
- assertEquals(
- "If the sign is positive, the result should be positive.",
- absMagnitudeBits, resultBits);
- }
- if (sign < 0 || Float.valueOf(-0.0f).equals(sign)) {
- assertEquals(
- "If the sign is negative, the result should be negative.",
- negMagnitudeBits, resultBits);
- }
- }
- }
-
- assertTrue("The result should be NaN.", Float.isNaN(Math.copySign(
- Float.NaN, Float.NaN)));
-
- try {
- Math.copySign((Float) null, 2.3f);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.copySign(2.3f, (Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.copySign((Float) null, (Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.Math#cos(double)
- */
- public void test_cosD() {
- // Test for method double java.lang.Math.cos(double)
- assertEquals("Incorrect answer", 1.0, Math.cos(0), 0D);
- assertEquals("Incorrect answer", 0.5403023058681398, Math.cos(1), 0D);
- }
-
- /**
- * @tests java.lang.Math#cosh(double)
- */
- public void test_cosh_D() {
- // Test for special situations
- assertTrue(Double.isNaN(Math.cosh(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Should return 1.0", 1.0, Math.cosh(+0.0), 0D);
- assertEquals("Should return 1.0", 1.0, Math.cosh(-0.0), 0D);
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(1234.56), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(-1234.56), 0D);
- assertEquals("Should return 1.0000000000005", 1.0000000000005, Math
- .cosh(0.000001), 0D);
- assertEquals("Should return 1.0000000000005", 1.0000000000005, Math
- .cosh(-0.000001), 0D);
- assertEquals("Should return 5.212214351945598", 5.212214351945598, Math
- .cosh(2.33482), 0D);
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 1.0", 1.0, Math.cosh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#exp(double)
- */
- public void test_expD() {
- // Test for method double java.lang.Math.exp(double)
- assertTrue("Incorrect answer returned for simple power", Math.abs(Math
- .exp(4D)
- - Math.E * Math.E * Math.E * Math.E) < 0.1D);
- assertTrue("Incorrect answer returned for larger power", Math.log(Math
- .abs(Math.exp(5.5D)) - 5.5D) < 10.0D);
- }
-
- /**
- * @tests java.lang.Math#expm1(double)
- */
- public void test_expm1_D() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(Math.expm1(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.expm1(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return -1.0", -1.0, Math
- .expm1(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .expm1(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.expm1(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.expm1(-0.0)));
-
- assertEquals("Should return -9.999950000166666E-6",
- -9.999950000166666E-6, Math.expm1(-0.00001), 0D);
- assertEquals("Should return 1.0145103074469635E60",
- 1.0145103074469635E60, Math.expm1(138.16951162), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math
- .expm1(123456789123456789123456789.4521584223), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.expm1(Double.MAX_VALUE), 0D);
- assertEquals("Should return MIN_VALUE", Double.MIN_VALUE, Math
- .expm1(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#floor(double)
- */
- public void test_floorD() {
- assertEquals("Incorrect floor for int", 42, Math.floor(42), 0);
- assertEquals("Incorrect floor for -int", -2, Math.floor(-2), 0);
- assertEquals("Incorrect floor for zero", 0d, Math.floor(0d), 0);
-
- assertEquals("Incorrect floor for +double", 78, Math.floor(78.89), 0);
- assertEquals("Incorrect floor for -double", -79, Math.floor(-78.89), 0);
- assertEquals("floor large +double", 3.7314645675925406E19, Math.floor(3.7314645675925406E19), 0);
- assertEquals("floor large -double", -8.173521839218E12, Math.floor(-8.173521839218E12), 0);
- assertEquals("floor small double", 0.0d, Math.floor(1.11895241315E-102), 0);
-
- // Compare toString representations here since -0.0 = +0.0, and
- // NaN != NaN and we need to distinguish
- assertEquals("Floor failed for NaN",
- Double.toString(Double.NaN), Double.toString(Math.floor(Double.NaN)));
- assertEquals("Floor failed for +0.0",
- Double.toString(+0.0d), Double.toString(Math.floor(+0.0d)));
- assertEquals("Floor failed for -0.0",
- Double.toString(-0.0d), Double.toString(Math.floor(-0.0d)));
- assertEquals("Floor failed for +infinity",
- Double.toString(Double.POSITIVE_INFINITY), Double.toString(Math.floor(Double.POSITIVE_INFINITY)));
- assertEquals("Floor failed for -infinity",
- Double.toString(Double.NEGATIVE_INFINITY), Double.toString(Math.floor(Double.NEGATIVE_INFINITY)));
- }
-
- /**
- * cases for test_getExponent_D in MathTest/StrictMathTest
- */
- static final double GETEXPONENT_D_CASES[] = new double[] {
- Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
- Double.MAX_VALUE, -Double.MAX_VALUE, 2.342E231, -2.342E231, 2800.0,
- -2800.0, 5.323, -5.323, 1.323, -1.323, 0.623, -0.623, 0.323,
- -0.323, Double.MIN_NORMAL * 24, -Double.MIN_NORMAL * 24,
- Double.MIN_NORMAL, -Double.MIN_NORMAL, Double.MIN_NORMAL / 2,
- -Double.MIN_NORMAL / 2, Double.MIN_VALUE, -Double.MIN_VALUE, +0.0,
- 0.0, -0.0, Double.NaN };
-
- /**
- * result for test_getExponent_D in MathTest/StrictMathTest
- */
- static final int GETEXPONENT_D_RESULTS[] = new int[] {
- Double.MAX_EXPONENT + 1, Double.MAX_EXPONENT + 1,
- Double.MAX_EXPONENT, Double.MAX_EXPONENT, 768, 768, 11, 11, 2, 2,
- 0, 0, -1, -1, -2, -2, -1018, -1018, Double.MIN_EXPONENT,
- Double.MIN_EXPONENT, Double.MIN_EXPONENT - 1,
- Double.MIN_EXPONENT - 1, Double.MIN_EXPONENT - 1,
- Double.MIN_EXPONENT - 1, Double.MIN_EXPONENT - 1,
- Double.MIN_EXPONENT - 1, Double.MIN_EXPONENT - 1,
- Double.MAX_EXPONENT + 1 };
-
- /**
- * @tests {@link java.lang.Math#getExponent(double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_getExponent_D() {
- for (int i = 0; i < GETEXPONENT_D_CASES.length; i++) {
- final double number = GETEXPONENT_D_CASES[i];
- final int result = GETEXPONENT_D_RESULTS[i];
- assertEquals("Wrong result of getExponent(double).", result, Math
- .getExponent(number));
- }
-
- try {
- Math.getExponent((Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * cases for test_getExponent_F in MathTest/StrictMathTest
- */
- static final float GETEXPONENT_F_CASES[] = new float[] {
- Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.MAX_VALUE,
- -Float.MAX_VALUE, 3.4256E23f, -3.4256E23f, 2800.0f, -2800.0f,
- 5.323f, -5.323f, 1.323f, -1.323f, 0.623f, -0.623f, 0.323f, -0.323f,
- Float.MIN_NORMAL * 24, -Float.MIN_NORMAL * 24, Float.MIN_NORMAL,
- -Float.MIN_NORMAL, Float.MIN_NORMAL / 2, -Float.MIN_NORMAL / 2,
- Float.MIN_VALUE, -Float.MIN_VALUE, +0.0f, 0.0f, -0.0f, Float.NaN,1,Float.MIN_NORMAL * 1.5f };
-
- /**
- * result for test_getExponent_F in MathTest/StrictMathTest
- */
- static final int GETEXPONENT_F_RESULTS[] = new int[] {
- Float.MAX_EXPONENT + 1, Float.MAX_EXPONENT + 1, Float.MAX_EXPONENT,
- Float.MAX_EXPONENT, 78, 78, 11, 11, 2, 2, 0, 0, -1, -1, -2, -2,
- -122, -122, Float.MIN_EXPONENT, Float.MIN_EXPONENT,
- Float.MIN_EXPONENT - 1, Float.MIN_EXPONENT - 1,
- Float.MIN_EXPONENT - 1, Float.MIN_EXPONENT - 1,
- Float.MIN_EXPONENT - 1, Float.MIN_EXPONENT - 1,
- Float.MIN_EXPONENT - 1, Float.MAX_EXPONENT + 1,0,Float.MIN_EXPONENT };
-
- /**
- * @tests {@link java.lang.Math#getExponent(float)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_getExponent_F() {
- for (int i = 0; i < GETEXPONENT_F_CASES.length; i++) {
- final float number = GETEXPONENT_F_CASES[i];
- final int result = GETEXPONENT_F_RESULTS[i];
- assertEquals("Wrong result of getExponent(float).", result, Math
- .getExponent(number));
- }
- try {
- Math.getExponent((Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.Math#hypot(double, double)
- */
- public void test_hypot_DD() {
- // Test for special cases
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(Double.POSITIVE_INFINITY,
- 1.0), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(Double.NEGATIVE_INFINITY,
- 123.324), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(-758.2587,
- Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(5687.21,
- Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(Double.POSITIVE_INFINITY,
- Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(Double.NEGATIVE_INFINITY,
- Double.POSITIVE_INFINITY), 0D);
- assertTrue("Should be NaN", Double.isNaN(Math.hypot(Double.NaN,
- 2342301.89843)));
- assertTrue("Should be NaN", Double.isNaN(Math.hypot(-345.2680,
- Double.NaN)));
-
- assertEquals("Should return 2396424.905416697", 2396424.905416697, Math
- .hypot(12322.12, -2396393.2258), 0D);
- assertEquals("Should return 138.16958070558556", 138.16958070558556,
- Math.hypot(-138.16951162, 0.13817035864), 0D);
- assertEquals("Should return 1.7976931348623157E308",
- 1.7976931348623157E308, Math.hypot(Double.MAX_VALUE, 211370.35), 0D);
- assertEquals("Should return 5413.7185", 5413.7185, Math.hypot(
- -5413.7185, Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#IEEEremainder(double, double)
- */
- public void test_IEEEremainderDD() {
- // Test for method double java.lang.Math.IEEEremainder(double, double)
- assertEquals("Incorrect remainder returned",
- 0.0, Math.IEEEremainder(1.0, 1.0), 0D);
- assertTrue("Incorrect remainder returned", Math.IEEEremainder(1.32,
- 89.765) >= 1.4705063220631647E-2
- || Math.IEEEremainder(1.32, 89.765) >= 1.4705063220631649E-2);
- }
-
- /**
- * @tests java.lang.Math#log(double)
- */
- public void test_logD() {
- // Test for method double java.lang.Math.log(double)
- for (double d = 10; d >= -10; d -= 0.5) {
- double answer = Math.log(Math.exp(d));
- assertTrue("Answer does not equal expected answer for d = " + d
- + " answer = " + answer, Math.abs(answer - d) <= Math
- .abs(d * 0.00000001));
- }
- }
-
- /**
- * @tests java.lang.Math#log10(double)
- */
- @SuppressWarnings("boxing")
- public void test_log10_D() {
- // Test for special cases
- assertTrue(Double.isNaN(Math.log10(Double.NaN)));
- assertTrue(Double.isNaN(Math.log10(-2541.05745687234187532)));
- assertTrue(Double.isNaN(Math.log10(-0.1)));
- assertEquals(Double.POSITIVE_INFINITY, Math.log10(Double.POSITIVE_INFINITY));
- assertEquals(Double.NEGATIVE_INFINITY, Math.log10(0.0));
- assertEquals(Double.NEGATIVE_INFINITY, Math.log10(+0.0));
- assertEquals(Double.NEGATIVE_INFINITY, Math.log10(-0.0));
-
- assertEquals(3.0, Math.log10(1000.0));
- assertEquals(14.0, Math.log10(Math.pow(10, 14)));
- assertEquals(3.7389561269540406, Math.log10(5482.2158));
- assertEquals(14.661551142893833, Math.log10(458723662312872.125782332587));
- assertEquals(-0.9083828622192334, Math.log10(0.12348583358871));
- assertEquals(308.25471555991675, Math.log10(Double.MAX_VALUE));
- assertEquals(-323.3062153431158, Math.log10(Double.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.Math#log1p(double)
- */
- public void test_log1p_D() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(Math.log1p(Double.NaN)));
- assertTrue("Should return NaN", Double.isNaN(Math.log1p(-32.0482175)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.log1p(Double.POSITIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .log1p(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.log1p(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.log1p(-0.0)));
-
- assertEquals("Should return -0.2941782295312541", -0.2941782295312541,
- Math.log1p(-0.254856327), 0D);
- assertEquals("Should return 7.368050685564151", 7.368050685564151, Math
- .log1p(1583.542), 0D);
- assertEquals("Should return 0.4633708685409921", 0.4633708685409921,
- Math.log1p(0.5894227), 0D);
- assertEquals("Should return 709.782712893384", 709.782712893384, Math
- .log1p(Double.MAX_VALUE), 0D);
- assertEquals("Should return Double.MIN_VALUE", Double.MIN_VALUE, Math
- .log1p(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#max(double, double)
- */
- public void test_maxDD() {
- // Test for method double java.lang.Math.max(double, double)
- assertEquals("Incorrect double max value", 1908897.6000089, Math.max(-1908897.6000089,
- 1908897.6000089), 0D);
- assertEquals("Incorrect double max value",
- 1908897.6000089, Math.max(2.0, 1908897.6000089), 0D);
- assertEquals("Incorrect double max value", -2.0, Math.max(-2.0,
- -1908897.6000089), 0D);
-
- // Compare toString representations here since -0.0 = +0.0, and
- // NaN != NaN and we need to distinguish
- assertEquals("Max failed for NaN",
- Double.toString(Double.NaN), Double.toString(Math.max(Double.NaN, 42.0d)));
- assertEquals("Max failed for NaN",
- Double.toString(Double.NaN), Double.toString(Math.max(42.0d, Double.NaN)));
- assertEquals("Max failed for 0.0",
- Double.toString(+0.0d), Double.toString(Math.max(+0.0d, -0.0d)));
- assertEquals("Max failed for 0.0",
- Double.toString(+0.0d), Double.toString(Math.max(-0.0d, +0.0d)));
- assertEquals("Max failed for -0.0d",
- Double.toString(-0.0d), Double.toString(Math.max(-0.0d, -0.0d)));
- assertEquals("Max failed for 0.0",
- Double.toString(+0.0d), Double.toString(Math.max(+0.0d, +0.0d)));
- }
-
- /**
- * @tests java.lang.Math#max(float, float)
- */
- public void test_maxFF() {
- // Test for method float java.lang.Math.max(float, float)
- assertTrue("Incorrect float max value", Math.max(-1908897.600f,
- 1908897.600f) == 1908897.600f);
- assertTrue("Incorrect float max value",
- Math.max(2.0f, 1908897.600f) == 1908897.600f);
- assertTrue("Incorrect float max value",
- Math.max(-2.0f, -1908897.600f) == -2.0f);
-
- // Compare toString representations here since -0.0 = +0.0, and
- // NaN != NaN and we need to distinguish
- assertEquals("Max failed for NaN",
- Float.toString(Float.NaN), Float.toString(Math.max(Float.NaN, 42.0f)));
- assertEquals("Max failed for NaN",
- Float.toString(Float.NaN), Float.toString(Math.max(42.0f, Float.NaN)));
- assertEquals("Max failed for 0.0",
- Float.toString(+0.0f), Float.toString(Math.max(+0.0f, -0.0f)));
- assertEquals("Max failed for 0.0",
- Float.toString(+0.0f), Float.toString(Math.max(-0.0f, +0.0f)));
- assertEquals("Max failed for -0.0f",
- Float.toString(-0.0f), Float.toString(Math.max(-0.0f, -0.0f)));
- assertEquals("Max failed for 0.0",
- Float.toString(+0.0f), Float.toString(Math.max(+0.0f, +0.0f)));
- }
-
- /**
- * @tests java.lang.Math#max(int, int)
- */
- public void test_maxII() {
- // Test for method int java.lang.Math.max(int, int)
- assertEquals("Incorrect int max value",
- 19088976, Math.max(-19088976, 19088976));
- assertEquals("Incorrect int max value",
- 19088976, Math.max(20, 19088976));
- assertEquals("Incorrect int max value", -20, Math.max(-20, -19088976));
- }
-
- /**
- * @tests java.lang.Math#max(long, long)
- */
- public void test_maxJJ() {
- // Test for method long java.lang.Math.max(long, long)
- assertEquals("Incorrect long max value", 19088976000089L, Math.max(-19088976000089L,
- 19088976000089L));
- assertEquals("Incorrect long max value",
- 19088976000089L, Math.max(20, 19088976000089L));
- assertEquals("Incorrect long max value",
- -20, Math.max(-20, -19088976000089L));
- }
-
- /**
- * @tests java.lang.Math#min(double, double)
- */
- public void test_minDD() {
- // Test for method double java.lang.Math.min(double, double)
- assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-1908897.6000089,
- 1908897.6000089), 0D);
- assertEquals("Incorrect double min value",
- 2.0, Math.min(2.0, 1908897.6000089), 0D);
- assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-2.0,
- -1908897.6000089), 0D);
- assertEquals("Incorrect double min value", 1.0d, Math.min(1.0d, 1.0d));
-
- // Compare toString representations here since -0.0 = +0.0, and
- // NaN != NaN and we need to distinguish
- assertEquals("Min failed for NaN",
- Double.toString(Double.NaN), Double.toString(Math.min(Double.NaN, 42.0d)));
- assertEquals("Min failed for NaN",
- Double.toString(Double.NaN), Double.toString(Math.min(42.0d, Double.NaN)));
- assertEquals("Min failed for -0.0",
- Double.toString(-0.0d), Double.toString(Math.min(+0.0d, -0.0d)));
- assertEquals("Min failed for -0.0",
- Double.toString(-0.0d), Double.toString(Math.min(-0.0d, +0.0d)));
- assertEquals("Min failed for -0.0d",
- Double.toString(-0.0d), Double.toString(Math.min(-0.0d, -0.0d)));
- assertEquals("Min failed for 0.0",
- Double.toString(+0.0d), Double.toString(Math.min(+0.0d, +0.0d)));
- }
-
- /**
- * @tests java.lang.Math#min(float, float)
- */
- public void test_minFF() {
- // Test for method float java.lang.Math.min(float, float)
- assertTrue("Incorrect float min value", Math.min(-1908897.600f,
- 1908897.600f) == -1908897.600f);
- assertTrue("Incorrect float min value",
- Math.min(2.0f, 1908897.600f) == 2.0f);
- assertTrue("Incorrect float min value",
- Math.min(-2.0f, -1908897.600f) == -1908897.600f);
- assertEquals("Incorrect float min value", 1.0f, Math.min(1.0f, 1.0f));
-
- // Compare toString representations here since -0.0 = +0.0, and
- // NaN != NaN and we need to distinguish
- assertEquals("Min failed for NaN",
- Float.toString(Float.NaN), Float.toString(Math.min(Float.NaN, 42.0f)));
- assertEquals("Min failed for NaN",
- Float.toString(Float.NaN), Float.toString(Math.min(42.0f, Float.NaN)));
- assertEquals("Min failed for -0.0",
- Float.toString(-0.0f), Float.toString(Math.min(+0.0f, -0.0f)));
- assertEquals("Min failed for -0.0",
- Float.toString(-0.0f), Float.toString(Math.min(-0.0f, +0.0f)));
- assertEquals("Min failed for -0.0f",
- Float.toString(-0.0f), Float.toString(Math.min(-0.0f, -0.0f)));
- assertEquals("Min failed for 0.0",
- Float.toString(+0.0f), Float.toString(Math.min(+0.0f, +0.0f)));
- }
-
- /**
- * @tests java.lang.Math#min(int, int)
- */
- public void test_minII() {
- // Test for method int java.lang.Math.min(int, int)
- assertEquals("Incorrect int min value",
- -19088976, Math.min(-19088976, 19088976));
- assertEquals("Incorrect int min value", 20, Math.min(20, 19088976));
- assertEquals("Incorrect int min value",
- -19088976, Math.min(-20, -19088976));
-
- }
-
- /**
- * @tests java.lang.Math#min(long, long)
- */
- public void test_minJJ() {
- // Test for method long java.lang.Math.min(long, long)
- assertEquals("Incorrect long min value", -19088976000089L, Math.min(-19088976000089L,
- 19088976000089L));
- assertEquals("Incorrect long min value",
- 20, Math.min(20, 19088976000089L));
- assertEquals("Incorrect long min value",
- -19088976000089L, Math.min(-20, -19088976000089L));
- }
-
- /**
- * start number cases for test_nextAfter_DD in MathTest/StrictMathTest
- * NEXTAFTER_DD_START_CASES[i][0] is the start number
- * NEXTAFTER_DD_START_CASES[i][1] is the nextUp of start number
- * NEXTAFTER_DD_START_CASES[i][2] is the nextDown of start number
- */
- static final double NEXTAFTER_DD_START_CASES[][] = new double[][] {
- { 3.4, 3.4000000000000004, 3.3999999999999995 },
- { -3.4, -3.3999999999999995, -3.4000000000000004 },
- { 3.4233E109, 3.4233000000000005E109, 3.4232999999999996E109 },
- { -3.4233E109, -3.4232999999999996E109, -3.4233000000000005E109 },
- { +0.0, Double.MIN_VALUE, -Double.MIN_VALUE },
- { 0.0, Double.MIN_VALUE, -Double.MIN_VALUE },
- { -0.0, Double.MIN_VALUE, -Double.MIN_VALUE },
- { Double.MIN_VALUE, 1.0E-323, +0.0 },
- { -Double.MIN_VALUE, -0.0, -1.0E-323 },
- { Double.MIN_NORMAL, 2.225073858507202E-308, 2.225073858507201E-308 },
- { -Double.MIN_NORMAL, -2.225073858507201E-308,
- -2.225073858507202E-308 },
- { Double.MAX_VALUE, Double.POSITIVE_INFINITY,
- 1.7976931348623155E308 },
- { -Double.MAX_VALUE, -1.7976931348623155E308,
- Double.NEGATIVE_INFINITY },
- { Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY,
- Double.MAX_VALUE },
- { Double.NEGATIVE_INFINITY, -Double.MAX_VALUE,
- Double.NEGATIVE_INFINITY } };
-
- /**
- * direction number cases for test_nextAfter_DD/test_nextAfter_FD in
- * MathTest/StrictMathTest
- */
- static final double NEXTAFTER_DD_FD_DIRECTION_CASES[] = new double[] {
- Double.POSITIVE_INFINITY, Double.MAX_VALUE, 8.8, 3.4, 1.4,
- Double.MIN_NORMAL, Double.MIN_NORMAL / 2, Double.MIN_VALUE, +0.0,
- 0.0, -0.0, -Double.MIN_VALUE, -Double.MIN_NORMAL / 2,
- -Double.MIN_NORMAL, -1.4, -3.4, -8.8, -Double.MAX_VALUE,
- Double.NEGATIVE_INFINITY };
-
- /**
- * @tests {@link java.lang.Math#nextAfter(double, double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_nextAfter_DD() {
- // test for most cases without exception
- for (int i = 0; i < NEXTAFTER_DD_START_CASES.length; i++) {
- final double start = NEXTAFTER_DD_START_CASES[i][0];
- final long nextUpBits = Double
- .doubleToLongBits(NEXTAFTER_DD_START_CASES[i][1]);
- final long nextDownBits = Double
- .doubleToLongBits(NEXTAFTER_DD_START_CASES[i][2]);
-
- for (int j = 0; j < NEXTAFTER_DD_FD_DIRECTION_CASES.length; j++) {
- final double direction = NEXTAFTER_DD_FD_DIRECTION_CASES[j];
- final long resultBits = Double.doubleToLongBits(Math.nextAfter(
- start, direction));
- final long directionBits = Double.doubleToLongBits(direction);
- if (direction > start) {
- assertEquals("Result should be next up-number.",
- nextUpBits, resultBits);
- } else if (direction < start) {
- assertEquals("Result should be next down-number.",
- nextDownBits, resultBits);
- } else {
- assertEquals("Result should be direction.", directionBits,
- resultBits);
- }
- }
- }
-
- // test for cases with NaN
- for (int i = 0; i < NEXTAFTER_DD_START_CASES.length; i++) {
- assertTrue("The result should be NaN.", Double.isNaN(Math
- .nextAfter(NEXTAFTER_DD_START_CASES[i][0], Double.NaN)));
- }
- for (int i = 0; i < NEXTAFTER_DD_FD_DIRECTION_CASES.length; i++) {
- assertTrue("The result should be NaN.", Double.isNaN(Math
- .nextAfter(Double.NaN, NEXTAFTER_DD_FD_DIRECTION_CASES[i])));
- }
- assertTrue("The result should be NaN.", Double.isNaN(Math.nextAfter(
- Double.NaN, Double.NaN)));
-
- // test for exception
- try {
- Math.nextAfter((Double) null, 2.3);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.nextAfter(2.3, (Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.nextAfter((Double) null, (Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * start number cases for test_nextAfter_FD in MathTest/StrictMathTest
- * NEXTAFTER_FD_START_CASES[i][0] is the start number
- * NEXTAFTER_FD_START_CASES[i][1] is the nextUp of start number
- * NEXTAFTER_FD_START_CASES[i][2] is the nextDown of start number
- */
- static final float NEXTAFTER_FD_START_CASES[][] = new float[][] {
- { 3.4f, 3.4000003f, 3.3999999f },
- { -3.4f, -3.3999999f, -3.4000003f },
- { 3.4233E19f, 3.4233002E19f, 3.4232998E19f },
- { -3.4233E19f, -3.4232998E19f, -3.4233002E19f },
- { +0.0f, Float.MIN_VALUE, -Float.MIN_VALUE },
- { 0.0f, Float.MIN_VALUE, -Float.MIN_VALUE },
- { -0.0f, Float.MIN_VALUE, -Float.MIN_VALUE },
- { Float.MIN_VALUE, 2.8E-45f, +0.0f },
- { -Float.MIN_VALUE, -0.0f, -2.8E-45f },
- { Float.MIN_NORMAL, 1.1754945E-38f, 1.1754942E-38f },
- { -Float.MIN_NORMAL, -1.1754942E-38f, -1.1754945E-38f },
- { Float.MAX_VALUE, Float.POSITIVE_INFINITY, 3.4028233E38f },
- { -Float.MAX_VALUE, -3.4028233E38f, Float.NEGATIVE_INFINITY },
- { Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.MAX_VALUE },
- { Float.NEGATIVE_INFINITY, -Float.MAX_VALUE,
- Float.NEGATIVE_INFINITY } };
-
- /**
- * @tests {@link java.lang.Math#nextAfter(float, double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_nextAfter_FD() {
- // test for most cases without exception
- for (int i = 0; i < NEXTAFTER_FD_START_CASES.length; i++) {
- final float start = NEXTAFTER_FD_START_CASES[i][0];
- final int nextUpBits = Float
- .floatToIntBits(NEXTAFTER_FD_START_CASES[i][1]);
- final int nextDownBits = Float
- .floatToIntBits(NEXTAFTER_FD_START_CASES[i][2]);
-
- for (int j = 0; j < NEXTAFTER_DD_FD_DIRECTION_CASES.length; j++) {
- final double direction = NEXTAFTER_DD_FD_DIRECTION_CASES[j];
- final int resultBits = Float.floatToIntBits(Math.nextAfter(
- start, direction));
- if (direction > start) {
- assertEquals("Result should be next up-number.",
- nextUpBits, resultBits);
- } else if (direction < start) {
- assertEquals("Result should be next down-number.",
- nextDownBits, resultBits);
- } else {
- final int equivalentBits = Float.floatToIntBits(new Float(
- direction));
- assertEquals(
- "Result should be a number equivalent to direction.",
- equivalentBits, resultBits);
- }
- }
- }
-
- // test for cases with NaN
- for (int i = 0; i < NEXTAFTER_FD_START_CASES.length; i++) {
- assertTrue("The result should be NaN.", Float.isNaN(Math.nextAfter(
- NEXTAFTER_FD_START_CASES[i][0], Float.NaN)));
- }
- for (int i = 0; i < NEXTAFTER_DD_FD_DIRECTION_CASES.length; i++) {
- assertTrue("The result should be NaN.", Float.isNaN(Math.nextAfter(
- Float.NaN, NEXTAFTER_DD_FD_DIRECTION_CASES[i])));
- }
- assertTrue("The result should be NaN.", Float.isNaN(Math.nextAfter(
- Float.NaN, Float.NaN)));
-
- // test for exception
- try {
- Math.nextAfter((Float) null, 2.3);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.nextAfter(2.3, (Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.nextAfter((Float) null, (Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests {@link java.lang.Math#nextUp(double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_nextUp_D() {
- // This method is semantically equivalent to nextAfter(d,
- // Double.POSITIVE_INFINITY),
- // so we use the data of test_nextAfter_DD
- for (int i = 0; i < NEXTAFTER_DD_START_CASES.length; i++) {
- final double start = NEXTAFTER_DD_START_CASES[i][0];
- final long nextUpBits = Double
- .doubleToLongBits(NEXTAFTER_DD_START_CASES[i][1]);
- final long resultBits = Double.doubleToLongBits(Math.nextUp(start));
- assertEquals("Result should be next up-number.", nextUpBits,
- resultBits);
- }
-
- // test for cases with NaN
- assertTrue("The result should be NaN.", Double.isNaN(Math
- .nextUp(Double.NaN)));
-
- // test for exception
- try {
- Math.nextUp((Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests {@link java.lang.Math#nextUp(float)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_nextUp_F() {
- // This method is semantically equivalent to nextAfter(f,
- // Float.POSITIVE_INFINITY),
- // so we use the data of test_nextAfter_FD
- for (int i = 0; i < NEXTAFTER_FD_START_CASES.length; i++) {
- final float start = NEXTAFTER_FD_START_CASES[i][0];
- final int nextUpBits = Float
- .floatToIntBits(NEXTAFTER_FD_START_CASES[i][1]);
- final int resultBits = Float.floatToIntBits(Math.nextUp(start));
- assertEquals("Result should be next up-number.", nextUpBits,
- resultBits);
- }
-
- // test for cases with NaN
- assertTrue("The result should be NaN.", Float.isNaN(Math
- .nextUp(Float.NaN)));
-
- // test for exception
- try {
- Math.nextUp((Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.Math#pow(double, double)
- */
- public void test_powDD() {
- // Test for method double java.lang.Math.pow(double, double)
- double NZERO = longTodouble(doubleTolong(0.0) ^ 0x8000000000000000L);
- double p1 = 1.0;
- double p2 = 2.0;
- double p3 = 3.0;
- double p4 = 4.0;
- double p5 = 5.0;
- double p6 = 6.0;
- double p7 = 7.0;
- double p8 = 8.0;
- double p9 = 9.0;
- double p10 = 10.0;
- double p11 = 11.0;
- double p12 = 12.0;
- double p13 = 13.0;
- double p14 = 14.0;
- double p15 = 15.0;
- double p16 = 16.0;
- double[] values = { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12,
- p13, p14, p15, p16 };
-
- for (int x = 0; x < values.length; x++) {
- double dval = values[x];
- double nagateDval = negateDouble(dval);
- if (nagateDval == Double.NaN) {
- continue;
- }
-
- // If the second argument is positive or negative zero, then the
- // result is 1.0.
- assertEquals("Result should be Math.pow(" + dval
- + ",-0.0)=+1.0", 1.0, Math.pow(dval, NZERO));
- assertEquals("Result should be Math.pow(" + nagateDval
- + ",-0.0)=+1.0", 1.0, Math.pow(nagateDval, NZERO));
- assertEquals("Result should be Math.pow(" + dval
- + ",+0.0)=+1.0", 1.0, Math.pow(dval, +0.0));
- assertEquals("Result should be Math.pow(" + nagateDval
- + ",+0.0)=+1.0", 1.0, Math.pow(nagateDval, +0.0));
-
- // If the second argument is 1.0, then the result is the same as the
- // first argument.
- assertEquals("Result should be Math.pow(" + dval + "," + 1.0 + ")="
- + dval, dval, Math.pow(dval, 1.0));
- assertEquals("Result should be Math.pow(" + nagateDval + "," + 1.0
- + ")=" + nagateDval, nagateDval, Math.pow(nagateDval, 1.0));
-
- // If the second argument is NaN, then the result is NaN.
- assertEquals("Result should be Math.pow(" + dval + "," + Double.NaN
- + ")=" + Double.NaN, Double.NaN, Math.pow(dval, Double.NaN));
- assertEquals("Result should be Math.pow(" + nagateDval + ","
- + Double.NaN + ")=" + Double.NaN, Double.NaN, Math.pow(nagateDval,
- Double.NaN));
-
- if (dval > 1) {
- // If the first argument is NaN and the second argument is
- // nonzero,
- // then the result is NaN.
- assertEquals("Result should be Math.pow(" + Double.NaN + ","
- + dval + ")=" + Double.NaN, Double.NaN, Math.pow(Double.NaN, dval));
- assertEquals("Result should be Math.pow(" + Double.NaN + ","
- + nagateDval + ")=" + Double.NaN, Double.NaN, Math.pow(Double.NaN,
- nagateDval));
-
- /*
- * If the first argument is positive zero and the second
- * argument is greater than zero, or the first argument is
- * positive infinity and the second argument is less than zero,
- * then the result is positive zero.
- */
- assertEquals("Result should be Math.pow(" + 0.0 + "," + dval
- + ")=" + 0.0, +0.0, Math.pow(0.0, dval));
- assertEquals("Result should be Math.pow("
- + Double.POSITIVE_INFINITY + "," + nagateDval + ")="
- + 0.0, +0.0, Math.pow(Double.POSITIVE_INFINITY, nagateDval));
-
- /*
- * If the first argument is positive zero and the second
- * argument is less than zero, or the first argument is positive
- * infinity and the second argument is greater than zero, then
- * the result is positive infinity.
- */
- assertEquals("Result should be Math.pow(" + 0.0 + ","
- + nagateDval + ")=" + Double.POSITIVE_INFINITY,Double.POSITIVE_INFINITY,
- Math.pow(0.0, nagateDval));
- assertEquals("Result should be Math.pow("
- + Double.POSITIVE_INFINITY + "," + dval + ")="
- + Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Math.pow(
- Double.POSITIVE_INFINITY, dval));
-
- // Not a finite odd integer
- if (dval % 2 == 0) {
- /*
- * If the first argument is negative zero and the second
- * argument is greater than zero but not a finite odd
- * integer, or the first argument is negative infinity and
- * the second argument is less than zero but not a finite
- * odd integer, then the result is positive zero.
- */
- assertEquals("Result should be Math.pow(" + NZERO + ","
- + dval + ")=" + 0.0, +0.0, Math.pow(NZERO, dval));
- assertEquals("Result should be Math.pow("
- + Double.NEGATIVE_INFINITY + "," + nagateDval
- + ")=" + 0.0, +0.0, Math.pow(Double.NEGATIVE_INFINITY,
- nagateDval));
-
- /*
- * If the first argument is negative zero and the second
- * argument is less than zero but not a finite odd integer,
- * or the first argument is negative infinity and the second
- * argument is greater than zero but not a finite odd
- * integer, then the result is positive infinity.
- */
- assertEquals("Result should be Math.pow(" + NZERO + ","
- + nagateDval + ")=" + Double.POSITIVE_INFINITY,Double.POSITIVE_INFINITY,
- Math.pow(NZERO, nagateDval));
- assertEquals("Result should be Math.pow("
- + Double.NEGATIVE_INFINITY + "," + dval + ")="
- + Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Math.pow(
- Double.NEGATIVE_INFINITY, dval));
- }
-
- // finite odd integer
- if (dval % 2 != 0) {
- /*
- * If the first argument is negative zero and the second
- * argument is a positive finite odd integer, or the first
- * argument is negative infinity and the second argument is
- * a negative finite odd integer, then the result is
- * negative zero.
- */
- assertEquals("Result should be Math.pow(" + NZERO + ","
- + dval + ")=" + NZERO, NZERO, Math.pow(NZERO, dval));
- assertEquals("Result should be Math.pow("
- + Double.NEGATIVE_INFINITY + "," + nagateDval
- + ")=" + NZERO, NZERO, Math.pow(Double.NEGATIVE_INFINITY,
- nagateDval));
- /*
- * If the first argument is negative zero and the second
- * argument is a negative finite odd integer, or the first
- * argument is negative infinity and the second argument is
- * a positive finite odd integer then the result is negative
- * infinity.
- */
- assertEquals("Result should be Math.pow(" + NZERO + ","
- + nagateDval + ")=" + Double.NEGATIVE_INFINITY,Double.NEGATIVE_INFINITY,
- Math.pow(NZERO, nagateDval));
- assertEquals("Result should be Math.pow("
- + Double.NEGATIVE_INFINITY + "," + dval + ")="
- + Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Math.pow(
- Double.NEGATIVE_INFINITY, dval));
- }
-
- /**
- * 1. If the first argument is finite and less than zero if the
- * second argument is a finite even integer, the result is equal
- * to the result of raising the absolute value of the first
- * argument to the power of the second argument
- *
- * 2. if the second argument is a finite odd integer, the result is equal to the
- * negative of the result of raising the absolute value of the
- * first argument to the power of the second argument
- *
- * 3. if the second argument is finite and not an integer, then the result
- * is NaN.
- */
- for (int j = 1; j < values.length; j++) {
- double jval = values[j];
- if (jval % 2.0 == 0.0) {
- assertEquals("" + nagateDval + " " + jval, Math.pow(
- dval, jval), Math.pow(nagateDval, jval));
- } else {
- assertEquals("" + nagateDval + " " + jval, -1.0
- * Math.pow(dval, jval), Math.pow(nagateDval,
- jval));
- }
- assertEquals(Double.NaN, Math
- .pow(nagateDval, jval / 0.5467));
- assertEquals(Double.NaN, Math.pow(nagateDval, -1.0 * jval
- / 0.5467));
- }
- }
-
- // If the absolute value of the first argument equals 1 and the
- // second argument is infinite, then the result is NaN.
- if (dval == 1) {
- assertEquals("Result should be Math.pow(" + dval + ","
- + Double.POSITIVE_INFINITY + ")=" + Double.NaN, Double.NaN, Math
- .pow(dval, Double.POSITIVE_INFINITY));
- assertEquals("Result should be Math.pow(" + dval + ","
- + Double.NEGATIVE_INFINITY + ")=" + Double.NaN, Double.NaN, Math
- .pow(dval, Double.NEGATIVE_INFINITY));
-
- assertEquals("Result should be Math.pow(" + nagateDval + ","
- + Double.POSITIVE_INFINITY + ")=" + Double.NaN, Double.NaN, Math
- .pow(nagateDval, Double.POSITIVE_INFINITY));
- assertEquals("Result should be Math.pow(" + nagateDval + ","
- + Double.NEGATIVE_INFINITY + ")=" + Double.NaN, Double.NaN, Math
- .pow(nagateDval, Double.NEGATIVE_INFINITY));
- }
-
- if (dval > 1) {
- /*
- * If the absolute value of the first argument is greater than 1
- * and the second argument is positive infinity, or the absolute
- * value of the first argument is less than 1 and the second
- * argument is negative infinity, then the result is positive
- * infinity.
- */
- assertEquals("Result should be Math.pow(" + dval + ","
- + Double.POSITIVE_INFINITY + ")="
- + Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Math.pow(dval,
- Double.POSITIVE_INFINITY));
-
- assertEquals("Result should be Math.pow(" + nagateDval + ","
- + Double.NEGATIVE_INFINITY + ")="
- + Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Math.pow(-0.13456,
- Double.NEGATIVE_INFINITY));
-
- /*
- * If the absolute value of the first argument is greater than 1
- * and the second argument is negative infinity, or the absolute
- * value of the first argument is less than 1 and the second
- * argument is positive infinity, then the result is positive
- * zero.
- */
- assertEquals("Result should be Math.pow(" + dval + ","
- + Double.NEGATIVE_INFINITY + ")= +0.0", +0.0, Math.pow(dval,
- Double.NEGATIVE_INFINITY));
- assertEquals("Result should be Math.pow(" + nagateDval + ","
- + Double.POSITIVE_INFINITY + ")= +0.0", +0.0, Math.pow(
- -0.13456, Double.POSITIVE_INFINITY));
- }
-
- assertEquals("Result should be Math.pow(" + 0.0 + "," + dval + ")="
- + 0.0, 0.0, Math.pow(0.0, dval));
- assertEquals("Result should be Math.pow(" + Double.NaN + "," + dval
- + ")=" + Double.NaN, Double.NaN, Math.pow(Double.NaN, dval));
- }
- assertTrue("pow returned incorrect value",
- (long) Math.pow(2, 8) == 256l);
- assertTrue("pow returned incorrect value",
- Math.pow(2, -8) == 0.00390625d);
- assertEquals("Incorrect root returned1",
- 2, Math.sqrt(Math.pow(Math.sqrt(2), 4)), 0);
-
- assertEquals(Double.NEGATIVE_INFINITY, Math.pow(-10.0, 3.093403029238847E15));
- assertEquals(Double.POSITIVE_INFINITY, Math.pow(10.0, 3.093403029238847E15));
- }
-
- private double longTodouble(long longvalue) {
- return Double.longBitsToDouble(longvalue);
- }
-
- private long doubleTolong(double doublevalue) {
- return Double.doubleToLongBits(doublevalue);
- }
-
- private double negateDouble(double doublevalue) {
- return doublevalue * -1.0;
- }
-
- /**
- * @tests java.lang.Math#rint(double)
- */
- public void test_rintD() {
- // Test for method double java.lang.Math.rint(double)
- assertEquals("Failed to round properly - up to odd",
- 3.0, Math.rint(2.9), 0D);
- assertTrue("Failed to round properly - NaN", Double.isNaN(Math
- .rint(Double.NaN)));
- assertEquals("Failed to round properly down to even",
- 2.0, Math.rint(2.1), 0D);
- assertTrue("Failed to round properly " + 2.5 + " to even", Math
- .rint(2.5) == 2.0);
- assertTrue("Failed to round properly " + (+0.0d),
- Math.rint(+0.0d) == +0.0d);
- assertTrue("Failed to round properly " + (-0.0d),
- Math.rint(-0.0d) == -0.0d);
- }
-
- /**
- * @tests java.lang.Math#round(double)
- */
- public void test_roundD() {
- // Test for method long java.lang.Math.round(double)
- assertEquals("Incorrect rounding of a float", -91, Math.round(-90.89d));
- }
-
- /**
- * @tests java.lang.Math#round(float)
- */
- public void test_roundF() {
- // Test for method int java.lang.Math.round(float)
- assertEquals("Incorrect rounding of a float", -91, Math.round(-90.89f));
- }
-
- /**
- * @tests {@link java.lang.Math#scalb(double, int)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_scalb_DI() {
- // result is normal
- assertEquals(4.1422946304E7, Math.scalb(1.2345, 25));
- assertEquals(3.679096698760986E-8, Math.scalb(1.2345, -25));
- assertEquals(1.2345, Math.scalb(1.2345, 0));
- assertEquals(7868514.304, Math.scalb(0.2345, 25));
-
- double normal = Math.scalb(0.2345, -25);
- assertEquals(6.98864459991455E-9, normal);
- // precision kept
- assertEquals(0.2345, Math.scalb(normal, 25));
-
- assertEquals(0.2345, Math.scalb(0.2345, 0));
- assertEquals(-4.1422946304E7, Math.scalb(-1.2345, 25));
- assertEquals(-6.98864459991455E-9, Math.scalb(-0.2345, -25));
- assertEquals(2.0, Math.scalb(Double.MIN_NORMAL / 2, 1024));
- assertEquals(64.0, Math.scalb(Double.MIN_VALUE, 1080));
- assertEquals(234, Math.getExponent(Math.scalb(1.0, 234)));
- assertEquals(3.9999999999999996, Math.scalb(Double.MAX_VALUE,
- Double.MIN_EXPONENT));
-
- // result is near infinity
- double halfMax = Math.scalb(1.0, Double.MAX_EXPONENT);
- assertEquals(8.98846567431158E307, halfMax);
- assertEquals(Double.MAX_VALUE, halfMax - Math.ulp(halfMax) + halfMax);
- assertEquals(Double.POSITIVE_INFINITY, halfMax + halfMax);
- assertEquals(1.7976931348623155E308, Math.scalb(1.0 - Math.ulp(1.0),
- Double.MAX_EXPONENT + 1));
- assertEquals(Double.POSITIVE_INFINITY, Math.scalb(1.0 - Math.ulp(1.0),
- Double.MAX_EXPONENT + 2));
-
- halfMax = Math.scalb(-1.0, Double.MAX_EXPONENT);
- assertEquals(-8.98846567431158E307, halfMax);
- assertEquals(-Double.MAX_VALUE, halfMax + Math.ulp(halfMax) + halfMax);
- assertEquals(Double.NEGATIVE_INFINITY, halfMax + halfMax);
-
- assertEquals(Double.POSITIVE_INFINITY, Math.scalb(0.345, 1234));
- assertEquals(Double.POSITIVE_INFINITY, Math.scalb(44.345E102, 934));
- assertEquals(Double.NEGATIVE_INFINITY, Math.scalb(-44.345E102, 934));
-
- assertEquals(Double.POSITIVE_INFINITY, Math.scalb(
- Double.MIN_NORMAL / 2, 4000));
- assertEquals(Double.POSITIVE_INFINITY, Math.scalb(Double.MIN_VALUE,
- 8000));
- assertEquals(Double.POSITIVE_INFINITY, Math.scalb(Double.MAX_VALUE, 1));
- assertEquals(Double.POSITIVE_INFINITY, Math.scalb(
- Double.POSITIVE_INFINITY, 0));
- assertEquals(Double.POSITIVE_INFINITY, Math.scalb(
- Double.POSITIVE_INFINITY, -1));
- assertEquals(Double.NEGATIVE_INFINITY, Math.scalb(
- Double.NEGATIVE_INFINITY, -1));
- assertEquals(Double.NEGATIVE_INFINITY, Math.scalb(
- Double.NEGATIVE_INFINITY, Double.MIN_EXPONENT));
-
- // result is subnormal/zero
- long posZeroBits = Double.doubleToLongBits(+0.0);
- long negZeroBits = Double.doubleToLongBits(-0.0);
- assertEquals(posZeroBits, Double.doubleToLongBits(Math.scalb(+0.0,
- Integer.MAX_VALUE)));
- assertEquals(posZeroBits, Double.doubleToLongBits(Math
- .scalb(+0.0, -123)));
- assertEquals(posZeroBits, Double.doubleToLongBits(Math.scalb(+0.0, 0)));
- assertEquals(negZeroBits, Double
- .doubleToLongBits(Math.scalb(-0.0, 123)));
- assertEquals(negZeroBits, Double.doubleToLongBits(Math.scalb(-0.0,
- Integer.MIN_VALUE)));
-
- assertEquals(Double.MIN_VALUE, Math.scalb(1.0, -1074));
- assertEquals(posZeroBits, Double.doubleToLongBits(Math
- .scalb(1.0, -1075)));
- assertEquals(negZeroBits, Double.doubleToLongBits(Math.scalb(-1.0,
- -1075)));
-
- // precision lost
- assertEquals(Math.scalb(21.405, -1078), Math.scalb(21.405, -1079));
- assertEquals(Double.MIN_VALUE, Math.scalb(21.405, -1079));
- assertEquals(-Double.MIN_VALUE, Math.scalb(-21.405, -1079));
- assertEquals(posZeroBits, Double.doubleToLongBits(Math.scalb(21.405,
- -1080)));
- assertEquals(negZeroBits, Double.doubleToLongBits(Math.scalb(-21.405,
- -1080)));
- assertEquals(posZeroBits, Double.doubleToLongBits(Math.scalb(
- Double.MIN_VALUE, -1)));
- assertEquals(negZeroBits, Double.doubleToLongBits(Math.scalb(
- -Double.MIN_VALUE, -1)));
- assertEquals(Double.MIN_VALUE, Math.scalb(Double.MIN_NORMAL, -52));
- assertEquals(posZeroBits, Double.doubleToLongBits(Math.scalb(
- Double.MIN_NORMAL, -53)));
- assertEquals(negZeroBits, Double.doubleToLongBits(Math.scalb(
- -Double.MIN_NORMAL, -53)));
- assertEquals(Double.MIN_VALUE, Math.scalb(Double.MAX_VALUE, -2098));
- assertEquals(posZeroBits, Double.doubleToLongBits(Math.scalb(
- Double.MAX_VALUE, -2099)));
- assertEquals(negZeroBits, Double.doubleToLongBits(Math.scalb(
- -Double.MAX_VALUE, -2099)));
- assertEquals(Double.MIN_VALUE, Math.scalb(Double.MIN_NORMAL / 3, -51));
- assertEquals(posZeroBits, Double.doubleToLongBits(Math.scalb(
- Double.MIN_NORMAL / 3, -52)));
- assertEquals(negZeroBits, Double.doubleToLongBits(Math.scalb(
- -Double.MIN_NORMAL / 3, -52)));
- double subnormal = Math.scalb(Double.MIN_NORMAL / 3, -25);
- assertEquals(2.2104123E-316, subnormal);
- // precision lost
- assertFalse(Double.MIN_NORMAL / 3 == Math.scalb(subnormal, 25));
-
- // NaN
- assertTrue(Double.isNaN(Math.scalb(Double.NaN, 1)));
- assertTrue(Double.isNaN(Math.scalb(Double.NaN, 0)));
- assertTrue(Double.isNaN(Math.scalb(Double.NaN, -120)));
-
- assertEquals(1283457024, Double.doubleToLongBits(Math.scalb(
- Double.MIN_VALUE * 153, 23)));
- assertEquals(-9223372035571318784L, Double.doubleToLongBits(Math.scalb(
- -Double.MIN_VALUE * 153, 23)));
- assertEquals(36908406321184768L, Double.doubleToLongBits(Math.scalb(
- Double.MIN_VALUE * 153, 52)));
- assertEquals(-9186463630533591040L, Double.doubleToLongBits(Math.scalb(
- -Double.MIN_VALUE * 153, 52)));
-
- // test for exception
- try {
- Math.scalb((Double) null, (Integer) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.scalb(1.0, (Integer) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.scalb((Double) null, 1);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
-
- long b1em1022 = 0x0010000000000000L; // bit representation of
- // Double.MIN_NORMAL
- long b1em1023 = 0x0008000000000000L; // bit representation of half of
- // Double.MIN_NORMAL
- // assert exact identity
- assertEquals(b1em1023, Double.doubleToLongBits(Math.scalb(Double
- .longBitsToDouble(b1em1022), -1)));
- }
-
- /**
- * @tests {@link java.lang.Math#scalb(float, int)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_scalb_FI() {
- // result is normal
- assertEquals(4.1422946304E7f, Math.scalb(1.2345f, 25));
- assertEquals(3.679096698760986E-8f, Math.scalb(1.2345f, -25));
- assertEquals(1.2345f, Math.scalb(1.2345f, 0));
- assertEquals(7868514.304f, Math.scalb(0.2345f, 25));
-
- float normal = Math.scalb(0.2345f, -25);
- assertEquals(6.98864459991455E-9f, normal);
- // precision kept
- assertEquals(0.2345f, Math.scalb(normal, 25));
-
- assertEquals(0.2345f, Math.scalb(0.2345f, 0));
- assertEquals(-4.1422946304E7f, Math.scalb(-1.2345f, 25));
- assertEquals(-6.98864459991455E-9f, Math.scalb(-0.2345f, -25));
- assertEquals(2.0f, Math.scalb(Float.MIN_NORMAL / 2, 128));
- assertEquals(64.0f, Math.scalb(Float.MIN_VALUE, 155));
- assertEquals(34, Math.getExponent(Math.scalb(1.0f, 34)));
- assertEquals(3.9999998f, Math
- .scalb(Float.MAX_VALUE, Float.MIN_EXPONENT));
-
- // result is near infinity
- float halfMax = Math.scalb(1.0f, Float.MAX_EXPONENT);
- assertEquals(1.7014118E38f, halfMax);
- assertEquals(Float.MAX_VALUE, halfMax - Math.ulp(halfMax) + halfMax);
- assertEquals(Float.POSITIVE_INFINITY, halfMax + halfMax);
- assertEquals(3.4028233E38f, Math.scalb(1.0f - Math.ulp(1.0f),
- Float.MAX_EXPONENT + 1));
- assertEquals(Float.POSITIVE_INFINITY, Math.scalb(1.0f - Math.ulp(1.0f),
- Float.MAX_EXPONENT + 2));
-
- halfMax = Math.scalb(-1.0f, Float.MAX_EXPONENT);
- assertEquals(-1.7014118E38f, halfMax);
- assertEquals(-Float.MAX_VALUE, halfMax + Math.ulp(halfMax) + halfMax);
- assertEquals(Float.NEGATIVE_INFINITY, halfMax + halfMax);
-
- assertEquals(Float.POSITIVE_INFINITY, Math.scalb(0.345f, 1234));
- assertEquals(Float.POSITIVE_INFINITY, Math.scalb(44.345E10f, 934));
- assertEquals(Float.NEGATIVE_INFINITY, Math.scalb(-44.345E10f, 934));
-
- assertEquals(Float.POSITIVE_INFINITY, Math.scalb(Float.MIN_NORMAL / 2,
- 400));
- assertEquals(Float.POSITIVE_INFINITY, Math.scalb(Float.MIN_VALUE, 800));
- assertEquals(Float.POSITIVE_INFINITY, Math.scalb(Float.MAX_VALUE, 1));
- assertEquals(Float.POSITIVE_INFINITY, Math.scalb(
- Float.POSITIVE_INFINITY, 0));
- assertEquals(Float.POSITIVE_INFINITY, Math.scalb(
- Float.POSITIVE_INFINITY, -1));
- assertEquals(Float.NEGATIVE_INFINITY, Math.scalb(
- Float.NEGATIVE_INFINITY, -1));
- assertEquals(Float.NEGATIVE_INFINITY, Math.scalb(
- Float.NEGATIVE_INFINITY, Float.MIN_EXPONENT));
-
- // result is subnormal/zero
- int posZeroBits = Float.floatToIntBits(+0.0f);
- int negZeroBits = Float.floatToIntBits(-0.0f);
- assertEquals(posZeroBits, Float.floatToIntBits(Math.scalb(+0.0f,
- Integer.MAX_VALUE)));
- assertEquals(posZeroBits, Float.floatToIntBits(Math.scalb(+0.0f, -123)));
- assertEquals(posZeroBits, Float.floatToIntBits(Math.scalb(+0.0f, 0)));
- assertEquals(negZeroBits, Float.floatToIntBits(Math.scalb(-0.0f, 123)));
- assertEquals(negZeroBits, Float.floatToIntBits(Math.scalb(-0.0f,
- Integer.MIN_VALUE)));
-
- assertEquals(Float.MIN_VALUE, Math.scalb(1.0f, -149));
- assertEquals(posZeroBits, Float.floatToIntBits(Math.scalb(1.0f, -150)));
- assertEquals(negZeroBits, Float.floatToIntBits(Math.scalb(-1.0f, -150)));
-
- // precision lost
- assertEquals(Math.scalb(21.405f, -154), Math.scalb(21.405f, -153));
- assertEquals(Float.MIN_VALUE, Math.scalb(21.405f, -154));
- assertEquals(-Float.MIN_VALUE, Math.scalb(-21.405f, -154));
- assertEquals(posZeroBits, Float.floatToIntBits(Math
- .scalb(21.405f, -155)));
- assertEquals(negZeroBits, Float.floatToIntBits(Math.scalb(-21.405f,
- -155)));
- assertEquals(posZeroBits, Float.floatToIntBits(Math.scalb(
- Float.MIN_VALUE, -1)));
- assertEquals(negZeroBits, Float.floatToIntBits(Math.scalb(
- -Float.MIN_VALUE, -1)));
- assertEquals(Float.MIN_VALUE, Math.scalb(Float.MIN_NORMAL, -23));
- assertEquals(posZeroBits, Float.floatToIntBits(Math.scalb(
- Float.MIN_NORMAL, -24)));
- assertEquals(negZeroBits, Float.floatToIntBits(Math.scalb(
- -Float.MIN_NORMAL, -24)));
- assertEquals(Float.MIN_VALUE, Math.scalb(Float.MAX_VALUE, -277));
- assertEquals(posZeroBits, Float.floatToIntBits(Math.scalb(
- Float.MAX_VALUE, -278)));
- assertEquals(negZeroBits, Float.floatToIntBits(Math.scalb(
- -Float.MAX_VALUE, -278)));
- assertEquals(Float.MIN_VALUE, Math.scalb(Float.MIN_NORMAL / 3, -22));
- assertEquals(posZeroBits, Float.floatToIntBits(Math.scalb(
- Float.MIN_NORMAL / 3, -23)));
- assertEquals(negZeroBits, Float.floatToIntBits(Math.scalb(
- -Float.MIN_NORMAL / 3, -23)));
- float subnormal = Math.scalb(Float.MIN_NORMAL / 3, -11);
- assertEquals(1.913E-42f, subnormal);
- // precision lost
- assertFalse(Float.MIN_NORMAL / 3 == Math.scalb(subnormal, 11));
-
- assertEquals(68747264, Float.floatToIntBits(Math.scalb(
- Float.MIN_VALUE * 153, 23)));
- assertEquals(-2078736384, Float.floatToIntBits(Math.scalb(
- -Float.MIN_VALUE * 153, 23)));
-
- assertEquals(4896, Float.floatToIntBits(Math.scalb(
- Float.MIN_VALUE * 153, 5)));
- assertEquals(-2147478752, Float.floatToIntBits(Math.scalb(
- -Float.MIN_VALUE * 153, 5)));
-
- // NaN
- assertTrue(Float.isNaN(Math.scalb(Float.NaN, 1)));
- assertTrue(Float.isNaN(Math.scalb(Float.NaN, 0)));
- assertTrue(Float.isNaN(Math.scalb(Float.NaN, -120)));
-
- // test for exception
- try {
- Math.scalb((Float) null, (Integer) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.scalb(1.0f, (Integer) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- Math.scalb((Float) null, 1);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
-
- int b1em126 = 0x00800000; // bit representation of Float.MIN_NORMAL
- int b1em127 = 0x00400000; // bit representation of half
- // Float.MIN_NORMAL
- // assert exact identity
- assertEquals(b1em127, Float.floatToIntBits(Math.scalb(Float
- .intBitsToFloat(b1em126), -1)));
- }
-
- /**
- * @tests java.lang.Math#signum(double)
- */
- public void test_signum_D() {
- assertTrue(Double.isNaN(Math.signum(Double.NaN)));
- assertTrue(Double.isNaN(Math.signum(Double.NaN)));
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .signum(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.signum(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.signum(-0.0)));
-
- assertEquals(1.0, Math.signum(253681.2187962), 0D);
- assertEquals(-1.0, Math.signum(-125874693.56), 0D);
- assertEquals(1.0, Math.signum(1.2587E-308), 0D);
- assertEquals(-1.0, Math.signum(-1.2587E-308), 0D);
-
- assertEquals(1.0, Math.signum(Double.MAX_VALUE), 0D);
- assertEquals(1.0, Math.signum(Double.MIN_VALUE), 0D);
- assertEquals(-1.0, Math.signum(-Double.MAX_VALUE), 0D);
- assertEquals(-1.0, Math.signum(-Double.MIN_VALUE), 0D);
- assertEquals(1.0, Math.signum(Double.POSITIVE_INFINITY), 0D);
- assertEquals(-1.0, Math.signum(Double.NEGATIVE_INFINITY), 0D);
- }
-
- /**
- * @tests java.lang.Math#signum(float)
- */
- public void test_signum_F() {
- assertTrue(Float.isNaN(Math.signum(Float.NaN)));
- assertEquals(Float.floatToIntBits(0.0f), Float
- .floatToIntBits(Math.signum(0.0f)));
- assertEquals(Float.floatToIntBits(+0.0f), Float
- .floatToIntBits(Math.signum(+0.0f)));
- assertEquals(Float.floatToIntBits(-0.0f), Float
- .floatToIntBits(Math.signum(-0.0f)));
-
- assertEquals(1.0f, Math.signum(253681.2187962f), 0f);
- assertEquals(-1.0f, Math.signum(-125874693.56f), 0f);
- assertEquals(1.0f, Math.signum(1.2587E-11f), 0f);
- assertEquals(-1.0f, Math.signum(-1.2587E-11f), 0f);
-
- assertEquals(1.0f, Math.signum(Float.MAX_VALUE), 0f);
- assertEquals(1.0f, Math.signum(Float.MIN_VALUE), 0f);
- assertEquals(-1.0f, Math.signum(-Float.MAX_VALUE), 0f);
- assertEquals(-1.0f, Math.signum(-Float.MIN_VALUE), 0f);
- assertEquals(1.0f, Math.signum(Float.POSITIVE_INFINITY), 0f);
- assertEquals(-1.0f, Math.signum(Float.NEGATIVE_INFINITY), 0f);
- }
-
- /**
- * @tests java.lang.Math#sin(double)
- */
- public void test_sinD() {
- // Test for method double java.lang.Math.sin(double)
- assertEquals("Incorrect answer", 0.0, Math.sin(0), 0D);
- assertEquals("Incorrect answer", 0.8414709848078965, Math.sin(1), 0D);
- }
-
- /**
- * @tests java.lang.Math#sinh(double)
- */
- public void test_sinh_D() {
- // Test for special situations
- assertTrue("Should return NaN", Double.isNaN(Math.sinh(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.sinh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, Math.sinh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .sinh(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.sinh(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.sinh(-0.0)));
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.sinh(1234.56), 0D);
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, Math.sinh(-1234.56), 0D);
- assertEquals("Should return 1.0000000000001666E-6",
- 1.0000000000001666E-6, Math.sinh(0.000001), 0D);
- assertEquals("Should return -1.0000000000001666E-6",
- -1.0000000000001666E-6, Math.sinh(-0.000001), 0D);
- assertEquals("Should return 5.115386441963859", 5.115386441963859, Math
- .sinh(2.33482), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.sinh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 4.9E-324", 4.9E-324, Math
- .sinh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#sqrt(double)
- */
- public void test_sqrtD() {
- // Test for method double java.lang.Math.sqrt(double)
- assertEquals("Incorrect root returned2", 7, Math.sqrt(49), 0);
- }
-
- /**
- * @tests java.lang.Math#tan(double)
- */
- public void test_tanD() {
- // Test for method double java.lang.Math.tan(double)
- assertEquals("Incorrect answer", 0.0, Math.tan(0), 0D);
- assertEquals("Incorrect answer", 1.5574077246549023, Math.tan(1), 0D);
-
- }
-
- /**
- * @tests java.lang.Math#tanh(double)
- */
- public void test_tanh_D() {
- // Test for special situations
- assertTrue("Should return NaN", Double.isNaN(Math.tanh(Double.NaN)));
- assertEquals("Should return +1.0", +1.0, Math
- .tanh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return -1.0", -1.0, Math
- .tanh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .tanh(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.tanh(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.tanh(-0.0)));
-
- assertEquals("Should return 1.0", 1.0, Math.tanh(1234.56), 0D);
- assertEquals("Should return -1.0", -1.0, Math.tanh(-1234.56), 0D);
- assertEquals("Should return 9.999999999996666E-7",
- 9.999999999996666E-7, Math.tanh(0.000001), 0D);
- assertEquals("Should return 0.981422884124941", 0.981422884124941, Math
- .tanh(2.33482), 0D);
- assertEquals("Should return 1.0", 1.0, Math.tanh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 4.9E-324", 4.9E-324, Math
- .tanh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#random()
- */
- public void test_random() {
- // There isn't a place for these tests so just stick them here
- assertEquals("Wrong value E",
- 4613303445314885481L, Double.doubleToLongBits(Math.E));
- assertEquals("Wrong value PI",
- 4614256656552045848L, Double.doubleToLongBits(Math.PI));
-
- for (int i = 500; i >= 0; i--) {
- double d = Math.random();
- assertTrue("Generated number is out of range: " + d, d >= 0.0
- && d < 1.0);
- }
- }
-
- /**
- * @tests java.lang.Math#toRadians(double)
- */
- public void test_toRadiansD() {
- for (double d = 500; d >= 0; d -= 1.0) {
- double converted = Math.toDegrees(Math.toRadians(d));
- assertTrue("Converted number not equal to original. d = " + d,
- converted >= d * 0.99999999 && converted <= d * 1.00000001);
- }
- }
-
- /**
- * @tests java.lang.Math#toDegrees(double)
- */
- public void test_toDegreesD() {
- for (double d = 500; d >= 0; d -= 1.0) {
- double converted = Math.toRadians(Math.toDegrees(d));
- assertTrue("Converted number not equal to original. d = " + d,
- converted >= d * 0.99999999 && converted <= d * 1.00000001);
- }
- }
-
- /**
- * @tests java.lang.Math#ulp(double)
- */
- @SuppressWarnings("boxing")
- public void test_ulp_D() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(Math.ulp(Double.NaN)));
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, Math
- .ulp(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, Math
- .ulp(Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(0.0), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(+0.0), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(-0.0), 0D);
- assertEquals("Returned incorrect value", Math.pow(2, 971), Math
- .ulp(Double.MAX_VALUE), 0D);
- assertEquals("Returned incorrect value", Math.pow(2, 971), Math
- .ulp(-Double.MAX_VALUE), 0D);
-
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(Double.MIN_VALUE), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(-Double.MIN_VALUE), 0D);
-
- assertEquals("Returned incorrect value", 2.220446049250313E-16, Math
- .ulp(1.0), 0D);
- assertEquals("Returned incorrect value", 2.220446049250313E-16, Math
- .ulp(-1.0), 0D);
- assertEquals("Returned incorrect value", 2.2737367544323206E-13, Math
- .ulp(1153.0), 0D);
- }
-
- /**
- * @tests java.lang.Math#ulp(float)
- */
- @SuppressWarnings("boxing")
- public void test_ulp_f() {
- // Test for special cases
- assertTrue("Should return NaN", Float.isNaN(Math.ulp(Float.NaN)));
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY, Math
- .ulp(Float.POSITIVE_INFINITY), 0f);
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY, Math
- .ulp(Float.NEGATIVE_INFINITY), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, Math
- .ulp(0.0f), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, Math
- .ulp(+0.0f), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, Math
- .ulp(-0.0f), 0f);
- assertEquals("Returned incorrect value", 2.028241E31f, Math
- .ulp(Float.MAX_VALUE), 0f);
- assertEquals("Returned incorrect value", 2.028241E31f, Math
- .ulp(-Float.MAX_VALUE), 0f);
-
- assertEquals("Returned incorrect value", 1.4E-45f, Math
- .ulp(Float.MIN_VALUE), 0f);
- assertEquals("Returned incorrect value", 1.4E-45f, Math
- .ulp(-Float.MIN_VALUE), 0f);
-
- assertEquals("Returned incorrect value", 1.1920929E-7f, Math.ulp(1.0f),
- 0f);
- assertEquals("Returned incorrect value", 1.1920929E-7f,
- Math.ulp(-1.0f), 0f);
- assertEquals("Returned incorrect value", 1.2207031E-4f, Math
- .ulp(1153.0f), 0f);
- assertEquals("Returned incorrect value", 5.6E-45f, Math
- .ulp(9.403954E-38f), 0f);
- }
-
- /**
- * @tests {@link java.lang.Math#shiftIntBits(int, int)}
- *
- * @since 1.6
- */
- public void test_shiftIntBits_II() {
- class Tuple {
- public int result;
-
- public int value;
-
- public int factor;
-
- public Tuple(int result, int value, int factor) {
- this.result = result;
- this.value = value;
- this.factor = factor;
- }
- }
- final Tuple[] TUPLES = new Tuple[] {
- // sub-normal to sub-normal
- new Tuple(0x00000000, 0x00000001, -1),
- // round to even
- new Tuple(0x00000002, 0x00000003, -1),
- // round to even
- new Tuple(0x00000001, 0x00000005, -3),
- // round to infinity
- new Tuple(0x00000002, 0x0000000d, -3),
- // round to infinity
-
- // normal to sub-normal
- new Tuple(0x00000002, 0x01a00000, -24),
- // round to even
- new Tuple(0x00000004, 0x01e00000, -24),
- // round to even
- new Tuple(0x00000003, 0x01c80000, -24),
- // round to infinity
- new Tuple(0x00000004, 0x01e80000, -24),
- // round to infinity
- };
- for (int i = 0; i < TUPLES.length; ++i) {
- Tuple tuple = TUPLES[i];
- assertEquals(tuple.result, Float.floatToIntBits(Math.scalb(Float
- .intBitsToFloat(tuple.value), tuple.factor)));
- assertEquals(tuple.result, Float.floatToIntBits(-Math.scalb(-Float
- .intBitsToFloat(tuple.value), tuple.factor)));
- }
- }
-
- /**
- * @tests {@link java.lang.Math#shiftLongBits(long, long)}
- *
- * Round result to nearest value on precision lost.
- *
- * @since 1.6
- */
- public void test_shiftLongBits_LL() {
- class Tuple {
- public long result;
-
- public long value;
-
- public int factor;
-
- public Tuple(long result, long value, int factor) {
- this.result = result;
- this.value = value;
- this.factor = factor;
- }
- }
- final Tuple[] TUPLES = new Tuple[] {
- // sub-normal to sub-normal
- new Tuple(0x00000000L, 0x00000001L, -1),
- //round to even
- new Tuple(0x00000002L, 0x00000003L, -1),
- //round to even
- new Tuple(0x00000001L, 0x00000005L, -3),
- //round to infinity
- new Tuple(0x00000002L, 0x0000000dL, -3),
- //round to infinity
-
- // normal to sub-normal
- new Tuple(0x0000000000000002L, 0x0034000000000000L, -53), // round to even
- new Tuple(0x0000000000000004L, 0x003c000000000000L, -53), // round to even
- new Tuple(0x0000000000000003L, 0x0035000000000000L, -53), // round to infinity
- new Tuple(0x0000000000000004L, 0x003d000000000000L, -53), // round to infinity
- };
- for (int i = 0; i < TUPLES.length; ++i) {
- Tuple tuple = TUPLES[i];
- assertEquals(tuple.result, Double.doubleToLongBits(Math.scalb(
- Double.longBitsToDouble(tuple.value), tuple.factor)));
- assertEquals(tuple.result, Double.doubleToLongBits(-Math.scalb(
- -Double.longBitsToDouble(tuple.value), tuple.factor)));
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockEnum.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockEnum.java
deleted file mode 100644
index 147e7a8..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockEnum.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.Serializable;
-
-class MockEnum implements Serializable {
- private static final long serialVersionUID = -1678507713086705252L;
-
- enum Sample {
- LARRY, MOE, CURLY
- }
-
- enum Sample2 {
- RED, BLUE, YELLO
- }
-
- String str;
-
- int i;
-
- Sample2 samEnum;
-
- Sample larry = Sample.LARRY;
-
- MockEnum() {
- str = "test";
- i = 99;
- samEnum = Sample2.BLUE;
- }
-
- public boolean equals(Object arg0) {
- if (!(arg0 instanceof MockEnum)) {
- return false;
- }
- MockEnum test = (MockEnum) arg0;
- if (str.equals(test.str) && i == test.i && samEnum == test.samEnum) {
- return true;
- }
- return false;
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockEnum2.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockEnum2.java
deleted file mode 100644
index cd3a8b7..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockEnum2.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.Serializable;
-
-class MockEnum2 implements Serializable {
-
- private static final long serialVersionUID = -4812214670022262730L;
-
- enum Sample {
- LARRY, MOE, CURLY
- }
-
- enum Sample2 {
- RED, BLUE, YELLO
- }
-
- String str;
-
- int i;
-
- Sample samEnum;
-
- Sample larry = Sample.LARRY;
-
- String myStr = "LARRY";
-
- MockEnum2() {
- str = "test";
- i = 99;
- samEnum = larry;
- }
-
- public boolean equals(Object arg0) {
- if (!(arg0 instanceof MockEnum2)) {
- return false;
- }
- MockEnum2 test = (MockEnum2) arg0;
- if (str.equals(test.str) && i == test.i && samEnum == test.samEnum
- && myStr.equals(test.myStr)) {
- return true;
- }
- return false;
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockSecurityManager.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockSecurityManager.java
deleted file mode 100644
index adbbedf..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MockSecurityManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.FilePermission;
-import java.security.Permission;
-import java.security.SecurityPermission;
-import java.util.PropertyPermission;
-
-class MockSecurityManager extends SecurityManager {
-
- String deletedFile = "/";
- String readedFile = "/";
- String writedFile = "/";
-
- public void setInCheck(boolean inCheck) {
- super.inCheck = inCheck;
- }
-
- @Override
- public int classDepth(String name) {
- return super.classDepth(name);
- }
-
- @Override
- public int classLoaderDepth() {
- return super.classLoaderDepth();
- }
-
- @Override
- public void checkPermission(Permission perm) {
- if (perm.equals(new RuntimePermission("createSecurityManager")) ||
-// perm.equals(new AWTPermission("accessEventQueue")) ||
- perm.equals(new RuntimePermission("createClassLoader")) ||
- perm.equals(new FilePermission(deletedFile,"delete")) ||
- perm.equals(new FilePermission(readedFile,"read")) ||
- perm.equals(new PropertyPermission("*", "read,write")) ||
- perm.equals(new PropertyPermission("key", "read")) ||
- perm.equals(new SecurityPermission("getPolicy")) ||
-// perm.equals(new AWTPermission("accessClipboard")) ||
- perm.equals(new FilePermission(writedFile,"write"))) {
- throw
- new SecurityException("Unable to create Security Manager");
- }
- }
-
- @Override
- public ClassLoader currentClassLoader() {
- return super.currentClassLoader();
- }
-
- @Override
- public Class<?> currentLoadedClass() {
- return super.currentLoadedClass();
- }
-
- @Override
- public Class[] getClassContext() {
- return super.getClassContext();
- }
-
- @Override
- public boolean inClass(String name) {
- return super.inClass(name);
- }
-
- @Override
- public boolean inClassLoader() {
- return super.inClassLoader();
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java
deleted file mode 100644
index 36b8766..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MutableSecurityManager.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.net.SocketPermission;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-
-class MutableSecurityManager extends SecurityManager {
-
- static final RuntimePermission SET_SECURITY_MANAGER = new RuntimePermission("setSecurityManager");
-
- private PermissionCollection enabled;
-
- private PermissionCollection denied;
-
- public boolean isCheckAcceptCalled = false;
- public boolean isCheckAccessThreadCalled = false;
- public boolean isCheckAccessThreadGroupCalled = false;
-
- public MutableSecurityManager() {
- super();
- this.enabled = new Permissions();
- }
-
- public MutableSecurityManager(Permission... permissions) {
- this();
- for (int i = 0; i < permissions.length; i++) {
- this.enabled.add(permissions[i]);
- }
- }
-
- void addPermission(Permission permission) {
- enabled.add(permission);
- }
-
- void clearPermissions() {
- enabled = new Permissions();
- }
-
- void denyPermission(Permission p) {
- if (denied == null) {
- denied = p.newPermissionCollection();
- }
- denied.add(p);
- }
-
- @Override
- public void checkPermission(Permission permission)
- {
- if (permission != null) {
- if (denied != null && denied.implies(permission)){
-
- throw new SecurityException("Denied " + permission);
- }
-
- if (enabled.implies(permission)) {
- return;
- }
- }
-
- super.checkPermission(permission);
- }
-
- @Override
- public void checkPermission(Permission permission, Object context)
- {
- if (permission != null) {
- if (denied != null && denied.implies(permission)){
-
- throw new SecurityException("Denied " + permission);
- }
-
- if (enabled.implies(permission)) {
- return;
- }
- }
-
- super.checkPermission(permission, context);
- }
-
- // @Override
- public void checkAccept(String host, int port) {
- isCheckAcceptCalled = true;
- super.checkAccept(host, port);
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java
deleted file mode 100644
index 93b6dbd..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class NegativeArraySizeExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.NegativeArraySizeException#NegativeArraySizeException()
- */
- public void test_Constructor() {
- NegativeArraySizeException e = new NegativeArraySizeException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.NegativeArraySizeException#NegativeArraySizeException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- NegativeArraySizeException e = new NegativeArraySizeException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java
deleted file mode 100644
index db7dced..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class NoClassDefFoundErrorTest extends TestCase {
-
- /**
- * @tests java.lang.NoClassDefFoundError#NoClassDefFoundError()
- */
- public void test_Constructor() {
- NoClassDefFoundError e = new NoClassDefFoundError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.NoClassDefFoundError#NoClassDefFoundError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- NoClassDefFoundError e = new NoClassDefFoundError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java
deleted file mode 100644
index 88889e5..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class NoSuchFieldErrorTest extends TestCase {
-
- /**
- * @tests java.lang.NoSuchFieldError#NoSuchFieldError()
- */
- public void test_Constructor() {
- NoSuchFieldError e = new NoSuchFieldError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.NoSuchFieldError#NoSuchFieldError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- NoSuchFieldError e = new NoSuchFieldError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java
deleted file mode 100644
index 5902d86..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class NoSuchFieldExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.NoSuchFieldException#NoSuchFieldException()
- */
- public void test_Constructor() {
- NoSuchFieldException e = new NoSuchFieldException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.NoSuchFieldException#NoSuchFieldException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- NoSuchFieldException e = new NoSuchFieldException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java
deleted file mode 100644
index b7e711b..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class NoSuchMethodErrorTest extends TestCase {
-
- /**
- * @tests java.lang.NoSuchMethodError#NoSuchMethodError()
- */
- public void test_Constructor() {
- NoSuchMethodError e = new NoSuchMethodError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.NoSuchMethodError#NoSuchMethodError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- NoSuchMethodError e = new NoSuchMethodError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java
deleted file mode 100644
index 68d46a2..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class NoSuchMethodExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.NoSuchMethodException#NoSuchMethodException()
- */
- public void test_Constructor() {
- NoSuchMethodException e = new NoSuchMethodException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.NoSuchMethodException#NoSuchMethodException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- NoSuchMethodException e = new NoSuchMethodException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java
deleted file mode 100644
index a3df668..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class NullPointerExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.NullPointerException#NullPointerException()
- */
- public void test_Constructor() {
- NullPointerException e = new NullPointerException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.NullPointerException#NullPointerException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- NullPointerException e = new NullPointerException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java
deleted file mode 100644
index 3cdf445..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class NumberFormatExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.NumberFormatException#NumberFormatException()
- */
- public void test_Constructor() {
- NumberFormatException e = new NumberFormatException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.NumberFormatException#NumberFormatException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- NumberFormatException e = new NumberFormatException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java
deleted file mode 100644
index 5b7d7f7..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class NumberTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.Number#byteValue()
- */
- public void test_byteValue() {
- int number = 1231243;
- assertTrue("Incorrect byte returned for: " + number,
- ((byte) new Integer(number).intValue()) == new Integer(number)
- .byteValue());
- number = 0;
- assertTrue("Incorrect byte returned for: " + number,
- ((byte) new Integer(number).intValue()) == new Integer(number)
- .byteValue());
- number = -1;
- assertTrue("Incorrect byte returned for: " + number,
- ((byte) new Integer(number).intValue()) == new Integer(number)
- .byteValue());
- number = -84109328;
- assertTrue("Incorrect byte returned for: " + number,
- ((byte) new Integer(number).intValue()) == new Integer(number)
- .byteValue());
- }
-
- /**
- * @tests java.lang.Number#shortValue()
- */
- public void test_shortValue() {
- int number = 1231243;
- assertTrue("Incorrect byte returned for: " + number,
- ((short) new Integer(number).intValue()) == new Integer(number)
- .shortValue());
- number = 0;
- assertTrue("Incorrect byte returned for: " + number,
- ((short) new Integer(number).intValue()) == new Integer(number)
- .shortValue());
- number = -1;
- assertTrue("Incorrect byte returned for: " + number,
- ((short) new Integer(number).intValue()) == new Integer(number)
- .shortValue());
- number = -84109328;
- assertTrue("Incorrect byte returned for: " + number,
- ((short) new Integer(number).intValue()) == new Integer(number)
- .shortValue());
-
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java
deleted file mode 100644
index 2b3c3f3..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java
+++ /dev/null
@@ -1,673 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.util.Vector;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.SideEffect;
-
-@TestTargetClass(Object.class)
-public class ObjectTest extends junit.framework.TestCase {
-
- public boolean isCalled = false;
- /**
- * Test objects.
- */
- Object obj1 = new Object();
-
- Object obj2 = new Object();
-
- /**
- * Generic state indicator.
- */
- int status = 0;
-
- int ready = 0;
- TestThread1 thr1;
- TestThread2 thr2;
-
- /**
- * @tests java.lang.Object#Object()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Object",
- args = {}
- )
- public void test_Constructor() {
- // Test for method java.lang.Object()
- assertNotNull("Constructor failed !!!", new Object());
- }
-
- /**
- * @tests java.lang.Object#equals(java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "equals",
- args = {java.lang.Object.class}
- )
- public void test_equalsLjava_lang_Object() {
- // Test for method boolean java.lang.Object.equals(java.lang.Object)
- assertTrue("Same object should be equal", obj1.equals(obj1));
- assertTrue("Different objects should not be equal", !obj1.equals(obj2));
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "finalize",
- args = {}
- )
- @SideEffect("Causes OutOfMemoryError to test finalization")
- public void test_finalize() {
- isCalled = false;
- class TestObject extends Object {
-
- Vector<StringBuffer> v = new Vector<StringBuffer>();
- public void add() {
- v.add(new StringBuffer(10000));
- }
-
- protected void finalize() throws Throwable {
- isCalled = true;
- super.finalize();
- }
- }
-
- TestObject to = new TestObject();
-
- try {
- while(true) {
- to.add();
- }
- } catch(OutOfMemoryError oome) {
- //expected
- to = null;
- }
- System.gc();
- System.runFinalization();
- assertTrue(isCalled);
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "clone",
- args = {}
- )
- public void test_clone() {
- MockCloneableObject mco = new MockCloneableObject();
- try {
- assertFalse(mco.equals(mco.clone()));
- assertEquals(mco.getClass(), mco.clone().getClass());
- } catch(CloneNotSupportedException cnse) {
- fail("CloneNotSupportedException was thrown.");
- }
-
- MockObject mo = new MockObject();
- try {
- mo.clone();
- fail("CloneNotSupportedException was not thrown.");
- } catch(CloneNotSupportedException cnse) {
- //expected
- }
- }
- class MockCloneableObject extends Object implements Cloneable {
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
- }
-
- class MockObject extends Object {
-
- boolean isCalled = false;
-
- public void finalize() throws Throwable {
- super.finalize();
- isCalled = true;
- }
-
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
- }
-
- /**
- * @tests java.lang.Object#getClass()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getClass",
- args = {}
- )
- public void test_getClass() {
- // Test for method java.lang.Class java.lang.Object.getClass()
- String classNames[] = { "java.lang.Object", "java.lang.Throwable",
- "java.lang.StringBuffer" };
- Class<?> classToTest = null;
- Object instanceToTest = null;
-
- status = 0;
- for (int i = 0; i < classNames.length; ++i) {
- try {
- classToTest = Class.forName(classNames[i]);
- instanceToTest = classToTest.newInstance();
- assertTrue("Instance didn't match creator class.",
- instanceToTest.getClass() == classToTest);
- assertTrue("Instance didn't match class with matching name.",
- instanceToTest.getClass() == Class
- .forName(classNames[i]));
- } catch (Exception ex) {
- fail("Unexpected exception : " + ex.getMessage());
- }
- }
- }
-
- /**
- * @tests java.lang.Object#hashCode()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "hashCode",
- args = {}
- )
- public void test_hashCode() {
- // Test for method int java.lang.Object.hashCode()
- assertTrue("Same object should have same hash.",
- obj1.hashCode() == obj1.hashCode());
- assertTrue("Same object should have same hash.",
- obj2.hashCode() == obj2.hashCode());
- }
-
- /**
- * @tests java.lang.Object#notify()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "notify",
- args = {}
- )
- public void test_notify() {
- // Test for method void java.lang.Object.notify()
-
- // Inner class to run test thread.
- class TestThread implements Runnable {
- public void run() {
- synchronized (obj1) {
- try {
- ready += 1;
- obj1.wait();// Wait for ever.
- status += 1;
- } catch (InterruptedException ex) {
- status = -1000;
- }
- }
- }
- }
- ;
-
- // Start of test code.
-
- // Warning:
- // This code relies on each thread getting serviced within
- // 200 mSec of when it is notified. Although this
- // seems reasonable, it could lead to false-failures.
-
- ready = 0;
- status = 0;
- final int readyWaitSecs = 3;
-
- final int threadCount = 20;
- for (int i = 0; i < threadCount; ++i) {
- new Thread(new TestThread()).start();
- }
- synchronized (obj1) {
- try {
-
- // Wait up to readyWaitSeconds for all threads to be waiting on
- // monitor
- for (int i = 0; i < readyWaitSecs; i++) {
- obj1.wait(1000, 0);
- if (ready == threadCount) {
- break;
- }
- }
-
- // Check pre-conditions of testing notifyAll
- assertTrue("Not all launched threads are waiting. (ready = "
- + ready + ")", ready == threadCount);
- assertTrue("Thread woke too early. (status = " + status + ")",
- status == 0);
-
- for (int i = 1; i <= threadCount; ++i) {
- obj1.notify();
- obj1.wait(200, 0);
- assertTrue("Out of sync. (expected " + i + " but got "
- + status + ")", status == i);
- }
-
- } catch (InterruptedException ex) {
- fail(
- "Unexpectedly got an InterruptedException. (status = "
- + status + ")");
- }
- }
-
- try {
- Object obj = new Object();
- obj.notify();
- fail("IllegalMonitorStateException was not thrown.");
- } catch(IllegalMonitorStateException imse) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Object#notifyAll()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "notifyAll",
- args = {}
- )
- public void test_notifyAll() {
- // Test for method void java.lang.Object.notifyAll()
-
- // Inner class to run test thread.
- class TestThread implements Runnable {
- public void run() {
- synchronized (obj1) {
- try {
- ready += 1;
- obj1.wait();// Wait for ever.
- status += 1;
- } catch (InterruptedException ex) {
- status = -1000;
- }
- }
- }
- }
- ;
-
- // Start of test code.
-
- // Warning:
- // This code relies on all threads getting serviced within
- // 5 seconds of when they are notified. Although this
- // seems reasonable, it could lead to false-failures.
-
- status = 0;
- ready = 0;
- final int readyWaitSecs = 3;
- final int threadCount = 20;
- for (int i = 0; i < threadCount; ++i) {
- new Thread(new TestThread()).start();
- }
-
- synchronized (obj1) {
-
- try {
-
- // Wait up to readyWaitSeconds for all threads to be waiting on
- // monitor
- for (int i = 0; i < readyWaitSecs; i++) {
- obj1.wait(1000, 0);
- if (ready == threadCount) {
- break;
- }
- }
-
- // Check pre-conditions of testing notifyAll
- assertTrue("Not all launched threads are waiting. (ready = "
- + ready + ")", ready == threadCount);
- assertTrue("At least one thread woke too early. (status = "
- + status + ")", status == 0);
-
- obj1.notifyAll();
-
- obj1.wait(5000, 0);
-
- assertTrue(
- "At least one thread did not get notified. (status = "
- + status + ")", status == threadCount);
-
- } catch (InterruptedException ex) {
- fail(
- "Unexpectedly got an InterruptedException. (status = "
- + status + ")");
- }
-
- }
-
- try {
- Object obj = new Object();
- obj.notifyAll();
- fail("IllegalMonitorStateException was not thrown.");
- } catch(IllegalMonitorStateException imse) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.Object#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() {
- // Test for method java.lang.String java.lang.Object.toString()
- assertNotNull("Object toString returned null.", obj1.toString());
- }
-
- /**
- * @tests java.lang.Object#wait()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "wait",
- args = {}
- )
- public void test_wait() {
- // Test for method void java.lang.Object.wait()
-
- // Inner class to run test thread.
- class TestThread implements Runnable {
- public void run() {
- synchronized (obj1) {
- try {
- obj1.wait();// Wait for ever.
- status = 1;
- } catch (InterruptedException ex) {
- status = -1;
- }
- }
- }
- }
-
-
- // Start of test code.
-
- // Warning:
- // This code relies on threads getting serviced within
- // 1 second of when they are notified. Although this
- // seems reasonable, it could lead to false-failures.
-
- status = 0;
- new Thread(new TestThread()).start();
- synchronized (obj1) {
- try {
- obj1.wait(1000, 0);
- assertTrue("Thread woke too early. (status = " + status + ")",
- status == 0);
- obj1.notifyAll();
- obj1.wait(1000, 0);
- assertTrue("Thread did not get notified. (status = " + status
- + ")", status == 1);
- } catch (InterruptedException ex) {
- fail(
- "Unexpectedly got an InterruptedException. (status = "
- + status + ")");
- }
- }
-
- try {
- Object obj = new Object();
- obj.wait();
- fail("IllegalMonitorStateException was not thrown.");
- } catch(IllegalMonitorStateException imse) {
- //expected
- } catch(InterruptedException ex) {
- fail("InterruptedException was thrown.");
- }
-
- try {
- thr1 = new TestThread1(TestThread1.CASE_WAIT);
- thr2 = new TestThread2();
- thr1.start();
- thr2.start();
- thr2.join();
- thr1.join();
- thr1 = null;
- thr2 = null;
- } catch(InterruptedException e) {
- fail("InterruptedException was thrown.");
- }
- assertEquals(3, status);
- }
-
- class TestThread1 extends Thread {
-
- static final int CASE_WAIT = 0;
- static final int CASE_WAIT_LONG = 1;
- static final int CASE_WAIT_LONG_INT = 2;
-
- int testCase = CASE_WAIT;
-
- public TestThread1(int option) {
- testCase = option;
- }
-
- public void run() {
- synchronized (obj1) {
- try {
- switch(testCase) {
- case CASE_WAIT:
- obj1.wait();// Wait for ever.
- break;
- case CASE_WAIT_LONG:
- obj1.wait(5000L);
- break;
- case CASE_WAIT_LONG_INT:
- obj1.wait(10000L, 999999);
- break;
- }
-
- } catch (InterruptedException ex) {
- status = 3;
- }
- }
- }
- }
-
- class TestThread2 extends Thread {
- public void run() {
- thr1.interrupt();
- }
- }
-
- /**
- * @tests java.lang.Object#wait(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "wait",
- args = {long.class}
- )
- public void test_waitJ() {
- // Test for method void java.lang.Object.wait(long)
-
- // Start of test code.
-
- final int loopCount = 20;
- final int allowableError = 100; // millesconds
- final int delay = 200; // milliseconds
- synchronized (obj1) {
- try {
- int count = 0;
- long[][] toLong = new long[3][3];
- for (int i = 0; i < loopCount; ++i) {
- long before = System.currentTimeMillis();
- obj1.wait(delay, 0);
- long after = System.currentTimeMillis();
- long error = (after - before - delay);
- if (error < 0)
- error = -error;
- if (i > 0 && error > allowableError) {
- // Allow jit to warm up before testing
- if (count < toLong.length) {
- toLong[count][0] = i;
- toLong[count][1] = before;
- toLong[count][2] = after;
- count++;
- }
- if (error > (1000 + delay) || count == toLong.length) {
- StringBuffer sb = new StringBuffer();
- for (int j = 0; j < count; j++) {
- sb
- .append("wakeup time too inaccurate, iteration ");
- sb.append(toLong[j][0]);
- sb.append(", before: ");
- sb.append(toLong[j][1]);
- sb.append(" after: ");
- sb.append(toLong[j][2]);
- sb.append(" diff: ");
- sb.append(toLong[j][2] - toLong[j][1]);
- sb.append("\n");
- }
- fail(sb.toString());
- }
- }
- }
- } catch (InterruptedException ex) {
- fail(
- "Unexpectedly got an InterruptedException. (status = "
- + status + ")");
- }
- }
-
- try {
- Object obj = new Object();
- obj.wait(5000L);
- fail("IllegalMonitorStateException was not thrown.");
- } catch(IllegalMonitorStateException imse) {
- //expected
- } catch(InterruptedException ex) {
- fail("InterruptedException was thrown.");
- }
-
- try {
- thr1 = new TestThread1(TestThread1.CASE_WAIT_LONG);
- thr2 = new TestThread2();
- thr1.start();
- thr2.start();
- thr2.join();
- thr1.join();
- thr1 = null;
- thr2 = null;
- } catch(InterruptedException e) {
- fail("InterruptedException was thrown.");
- }
- assertEquals(3, status);
- }
-
- /**
- * @tests java.lang.Object#wait(long, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "wait",
- args = {long.class, int.class}
- )
- public void test_waitJI() {
- // Test for method void java.lang.Object.wait(long, int)
-
- // Inner class to run test thread.
- class TestThread implements Runnable {
- public void run() {
- synchronized (obj1) {
- try {
- obj1.wait(0, 1); // Don't wait very long.
- status = 1;
- obj1.wait(0, 0); // Wait for ever.
- status = 2;
- } catch (InterruptedException ex) {
- status = -1;
- }
- }
- }
- }
-
-
- // Start of test code.
-
- // Warning:
- // This code relies on threads getting serviced within
- // 1 second of when they are notified. Although this
- // seems reasonable, it could lead to false-failures.
-
- status = 0;
- new Thread(new TestThread()).start();
- synchronized (obj1) {
- try {
- obj1.wait(1000, 0);
- assertTrue("Thread did not wake after 1 ms. (status = "
- + status + ")", status == 1);
- obj1.notifyAll();
- obj1.wait(1000, 0);
- assertTrue("Thread did not get notified. (status = " + status
- + ")", status == 2);
- } catch (InterruptedException ex) {
- fail(
- "Unexpectedly got an InterruptedException. (status = "
- + status + ")");
- }
- }
-
- try {
- Object obj = new Object();
- obj.wait(5000L, 1);
- fail("IllegalMonitorStateException was not thrown.");
- } catch(IllegalMonitorStateException imse) {
- //expected
- } catch(InterruptedException ex) {
- fail("InterruptedException was thrown.");
- }
-
- try {
- thr1 = new TestThread1(TestThread1.CASE_WAIT_LONG_INT);
- thr2 = new TestThread2();
- thr1.start();
- thr2.start();
- thr2.join();
- thr1.join();
- thr1 = null;
- thr2 = null;
- } catch(InterruptedException e) {
- fail("InterruptedException was thrown.");
- }
- assertEquals(3, status);
-
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java
deleted file mode 100644
index 72b6d3d..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/OutOfMemoryErrorTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class OutOfMemoryErrorTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.OutOfMemoryError#OutOfMemoryError()
- */
- public void test_Constructor() {
- // Test for method java.lang.OutOfMemoryError()
- Error e = new OutOfMemoryError();
- assertNull(e.getCause());
- assertNull(e.getMessage());
- }
-
- /**
- * @tests java.lang.OutOfMemoryError#OutOfMemoryError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.lang.OutOfMemoryError(java.lang.String)
- Error e = new OutOfMemoryError(null);
- assertNull(e.getMessage());
- assertNull(e.getCause());
-
- e= new OutOfMemoryError("msg");
- assertEquals("msg", e.getMessage());
- assertNull(e.getCause());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PublicClassLoader.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PublicClassLoader.java
deleted file mode 100644
index 6735f1e..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PublicClassLoader.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
- class PublicClassLoader extends ClassLoader {
-
- public PublicClassLoader() {
- super();
- }
-
- public PublicClassLoader(ClassLoader cl) {
- super(cl);
- }
-
- private byte[] getBytes( String filename ) throws IOException {
-
- File file = new File( filename );
- long len = file.length();
- byte raw[] = new byte[(int)len];
- FileInputStream fin = new FileInputStream( file );
- int r = fin.read( raw );
- if (r != len)
- throw new IOException( "Can't read all, "+r+" != "+len );
- fin.close();
- return raw;
- }
-
- public Class<?> loadClass(String name, boolean resolve)
- throws ClassNotFoundException {
-
- Class clazz = findLoadedClass(name);
- String classFileName = name.replace( '.', '/' ) + ".class";
- File classFile = new File(classFileName);
- if (classFile.exists()) {
- try {
- byte raw[] = getBytes(classFileName);
- clazz = defineClass( name, raw, 0, raw.length );
- } catch(Exception ioe) {}
- }
-
- if (clazz == null) {
- Package p = getClass().getPackage();
- InputStream is = getResourceAsStream("/" + classFileName);
- byte[] buf = new byte[512];
- int len;
- try {
- len = is.read(buf);
- clazz = defineClass(name, buf, 0, len);
- } catch (IOException e) {
- }
- }
-
- if (clazz == null) {
- clazz = findSystemClass(name);
- }
-
- if(clazz == null)
- throw new ClassNotFoundException(name);
- return clazz;
- }
-
- public Class<?> defineClassTest(byte[] b, int off, int len) {
- return defineClass(b, off, len);
- }
-
- public Package getPackage(String name) {
- return super.getPackage(name);
- }
-
- public Package [] getPackages() {
- return super.getPackages();
- }
-
- public InputStream getResourceAsStream(String name) {
- return getClass().getResourceAsStream("/" + getClass().getPackage().
- getName().replace(".", "/") + "/" + name);
- }
- }
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PublicTestClass.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PublicTestClass.java
deleted file mode 100644
index a377dbc..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PublicTestClass.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.Serializable;
-
-interface TestInterface {
-
- public static int TEST_INTERFACE_FIELD = 0;
-
- int getCount();
- void setCount(int value);
-}
-
-@TestAnnotation("org.apache.harmony.luni.tests.java.lang.PublicTestClass")
-public class PublicTestClass implements TestInterface, Serializable, Cloneable {
-
- private static final long serialVersionUID = 1L;
-
- public static String TEST_FIELD = "test field";
-
- Object clazz;
-
- public PublicTestClass() {
- class LocalClass { }
-
- clazz = new LocalClass();
- }
-
- public Object getLocalClass() {
- class LocalClass {}
- Object returnedObject = new LocalClass();
- return returnedObject;
- }
-
- int count = 0;
-
- public int getCount() {
- return count;
- }
-
- public void setCount(int value) {
- count = value;
- }
-
- private class PrivateClass1 {
-
- public String toString() {
- return "PrivateClass0";
- }
- }
-
- public class PrivateClass2 {
-
- public String toString() {
- return "PrivateClass1";
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java
deleted file mode 100644
index 94e01ed..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimeExceptionTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-@TestTargetClass(RuntimeException.class)
-public class RuntimeExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.RuntimeException#RuntimeException()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "RuntimeException",
- args = {}
- )
- public void test_Constructor() {
- RuntimeException e = new RuntimeException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.RuntimeException#RuntimeException(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "RuntimeException",
- args = {java.lang.String.class}
- )
- public void test_ConstructorLjava_lang_String() {
- RuntimeException e = new RuntimeException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "RuntimeException",
- args = {java.lang.String.class, java.lang.Throwable.class}
- )
- public void test_ConstructorLStringLThrowable() {
- String message = "Test message";
- NullPointerException npe = new NullPointerException();
- RuntimeException re = new RuntimeException(message, npe);
- assertEquals(message, re.getMessage());
- assertEquals(npe, re.getCause());
-
- re = new RuntimeException(null, npe);
- assertNull(re.getMessage());
-
- re = new RuntimeException(message, null);
- assertNull(re.getCause());
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "RuntimeException",
- args = {java.lang.Throwable.class}
- )
- public void test_ConstructorLThrowable() {
- NullPointerException npe = new NullPointerException();
- RuntimeException re = new RuntimeException(npe);
- assertEquals(npe, re.getCause());
-
- re = new RuntimeException((Throwable) null);
- assertNull(re.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java
deleted file mode 100644
index 1d62ad9..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class RuntimePermissionTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.RuntimePermission#RuntimePermission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.lang.RuntimePermission(java.lang.String)
- RuntimePermission r = new RuntimePermission("createClassLoader");
- assertEquals("Returned incorrect name",
- "createClassLoader", r.getName());
-
- }
-
- /**
- * @tests java.lang.RuntimePermission#RuntimePermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.lang.RuntimePermission(java.lang.String,
- // java.lang.String)
- RuntimePermission r = new RuntimePermission("createClassLoader", null);
- assertEquals("Returned incorrect name",
- "createClassLoader", r.getName());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java
deleted file mode 100644
index 471dd1c..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityExceptionTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-public class SecurityExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.SecurityException#SecurityException()
- */
- public void test_Constructor() {
- SecurityException e = new SecurityException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.SecurityException#SecurityException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- SecurityException e = new SecurityException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.SecurityException#SecurityException(String, Throwable)
- */
- @SuppressWarnings("nls")
- public void test_ConstructorLjava_lang_StringLjava_lang_Throwable() {
- NullPointerException npe = new NullPointerException();
- SecurityException e = new SecurityException("fixture", npe);
- assertSame("fixture", e.getMessage());
- assertSame(npe, e.getCause());
- }
-
- /**
- * @tests java.lang.SecurityException#SecurityException(Throwable)
- */
- @SuppressWarnings("nls")
- public void test_ConstructorLjava_lang_Throwable() {
- NullPointerException npe = new NullPointerException();
- SecurityException e = new SecurityException(npe);
- assertSame(npe, e.getCause());
- }
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- SerializationTest.verifySelf(new SecurityException());
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this, new SecurityException());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java
deleted file mode 100644
index 607f388..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SecurityManagerTest.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FilePermission;
-import java.net.InetAddress;
-import java.net.SocketPermission;
-import java.net.UnknownHostException;
-import java.security.AccessControlContext;
-import java.security.AllPermission;
-import java.security.Permission;
-import java.security.ProtectionDomain;
-import java.security.Security;
-
-import junit.framework.TestCase;
-import tests.support.Support_Exec;
-
-/**
- * Test case for java.lang.SecurityManager
- */
-public class SecurityManagerTest extends TestCase {
- MutableSecurityManager mutableSM = null;
-
- MockSecurityManager mockSM = null;
-
- /**
- * @tests java.lang.SecurityManager#checkPackageAccess(String)
- */
- public void test_checkPackageAccessLjava_lang_String() {
- final String old = Security.getProperty("package.access");
- Security.setProperty("package.access", "a.,bbb, c.d.");
-
- mutableSM
- .denyPermission(new RuntimePermission("accessClassInPackage.*"));
-
- try {
- mutableSM.checkPackageAccess("z.z.z");
- mutableSM.checkPackageAccess("aa");
- mutableSM.checkPackageAccess("bb");
- mutableSM.checkPackageAccess("c");
-
- try {
- mutableSM.checkPackageAccess("a");
- fail("This should throw a SecurityException.");
- } catch (SecurityException ok) {
- }
-
- try {
- mutableSM.checkPackageAccess("bbb");
- fail("This should throw a SecurityException.");
- } catch (SecurityException ok) {
- }
-
- try {
- mutableSM.checkPackageAccess("c.d.e");
- fail("This should throw a SecurityException.");
- } catch (SecurityException ok) {
- }
-
- Security.setProperty("package.access", "QWERTY");
- mutableSM.checkPackageAccess("a");
- mutableSM.checkPackageAccess("qwerty");
- try {
- mutableSM.checkPackageAccess("QWERTY");
- fail("This should throw a SecurityException.");
- } catch (SecurityException ok) {
- }
-
- } finally {
- Security.setProperty("package.access", old == null ? "" : old);
- }
- }
-
- /**
- * @tests java.lang.SecurityManager#checkPackageDefinition(String)
- */
- public void test_checkPackageDefinitionLjava_lang_String() {
- final String old = Security.getProperty("package.definition");
- Security.setProperty("package.definition", "a.,bbb, c.d.");
-
- mutableSM
- .denyPermission(new RuntimePermission("defineClassInPackage.*"));
-
- try {
- mutableSM.checkPackageDefinition("z.z.z");
- mutableSM.checkPackageDefinition("aa");
- mutableSM.checkPackageDefinition("bb");
- mutableSM.checkPackageDefinition("c");
-
- try {
- mutableSM.checkPackageDefinition("a");
- fail("This should throw a SecurityException.");
- } catch (SecurityException ok) {
- }
-
- try {
- mutableSM.checkPackageDefinition("bbb");
- fail("This should throw a SecurityException.");
- } catch (SecurityException ok) {
- }
-
- try {
- mutableSM.checkPackageDefinition("c.d.e");
- fail("This should throw a SecurityException.");
- } catch (SecurityException ok) {
- }
-
- Security.setProperty("package.definition", "QWERTY");
- mutableSM.checkPackageDefinition("a");
- mutableSM.checkPackageDefinition("qwerty");
- try {
- mutableSM.checkPackageDefinition("QWERTY");
- fail("This should throw a SecurityException.");
- } catch (SecurityException ok) {
- }
-
- } finally {
- Security.setProperty("package.definition", old == null ? "" : old);
- }
- }
-
- /**
- * @tests java.lang.SecurityManager#checkAccess(java.lang.Thread)
- */
- public void test_checkAccessLjava_lang_Thread() throws InterruptedException {
- // Regression for HARMONY-66
- Thread t = new Thread() {
- @Override
- public void run() {
- };
- };
- t.start();
- t.join();
- new SecurityManager().checkAccess(t);
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkConnect(String, int, Object)}
- */
- @SuppressWarnings("nls")
- public void test_checkConnectLjava_lang_String_int_Ljava_lang_Object() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new SocketPermission("localhost:1024-",
- "accept, connect, listen"));
- ProtectionDomain pDomain = this.getClass().getProtectionDomain();
- ProtectionDomain[] pd = { pDomain };
- AccessControlContext acc = new AccessControlContext(pd);
- try {
- mutableSM.checkConnect("localhost", 1024, acc);
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkExec(String)}
- */
- @SuppressWarnings("nls")
- public void test_checkExecLjava_lang_String() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new FilePermission("<<ALL FILES>>", "execute"));
- try {
- mutableSM.checkExec("java");
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkExit(int)}
- */
- @SuppressWarnings("nls")
- public void test_checkExit_int() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new RuntimePermission("exitVM"));
- try {
- mutableSM.checkExit(0);
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkLink(String)}
- */
- @SuppressWarnings("nls")
- public void test_checkLinkLjava_lang_String() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new RuntimePermission("loadLibrary.harmony"));
- try {
- mutableSM.checkLink("harmony");
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkListen(int)}
- */
- @SuppressWarnings("nls")
- public void test_checkListen_int() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM
- .denyPermission(new SocketPermission("localhost:80", "listen"));
-
- try {
- mutableSM.checkListen(80);
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new SocketPermission("localhost:1024-",
- "listen"));
- try {
- mutableSM.checkListen(0);
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @throws UnknownHostException
- * @tests {@link java.lang.SecurityManager#checkMulticast(java.net.InetAddress)}
- */
- @SuppressWarnings("nls")
- public void test_checkMulticastLjava_net_InetAddress()
- throws UnknownHostException {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new SocketPermission(InetAddress.getByName(
- "localhost").getHostAddress(), "accept,connect"));
- try {
- mutableSM.checkMulticast(InetAddress.getByName("localhost"));
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @throws UnknownHostException
- * @tests {@link java.lang.SecurityManager#checkMulticast(java.net.InetAddress,byte)}
- */
- @SuppressWarnings( { "nls", "deprecation" })
- public void test_checkMulticastLjava_net_InetAddress_int()
- throws UnknownHostException {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new SocketPermission(InetAddress.getByName(
- "localhost").getHostAddress(), "accept,connect"));
- try {
- // the second parameter is the TTL(time to live)
- mutableSM.checkMulticast(InetAddress.getByName("localhost"),
- (byte) 0);
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- *
- * @tests {@link java.lang.SecurityManager#checkPermission(Permission, Object)}
- */
- @SuppressWarnings("nls")
- public void test_checkPermissionLjava_security_PermissionLjava_lang_Object() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- Permission denyp = new SocketPermission("localhost:1024-",
- "accept, connect, listen");
- mutableSM.denyPermission(denyp);
- ProtectionDomain pDomain = this.getClass().getProtectionDomain();
- ProtectionDomain[] pd = { pDomain };
- AccessControlContext acc = new AccessControlContext(pd);
- try {
- mutableSM.checkPermission(denyp, acc);
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkPrintJobAccess()}
- */
- @SuppressWarnings("nls")
- public void test_checkPrintJobAccess() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new RuntimePermission("queuePrintJob"));
- try {
- mutableSM.checkPrintJobAccess();
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkRead(FileDescriptor)}
- */
- @SuppressWarnings("nls")
- public void test_checkReadLjava_io_FileDescriptor() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new RuntimePermission("readFileDescriptor"));
- try {
- mutableSM.checkRead(new FileDescriptor());
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkRead(String,Object)}
- */
- @SuppressWarnings("nls")
- public void test_checkReadLjava_lang_StringLjava_lang_Object() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new FilePermission("<<ALL FILES>>", "read"));
- ProtectionDomain pDomain = this.getClass().getProtectionDomain();
- ProtectionDomain[] pd = { pDomain };
- AccessControlContext acc = new AccessControlContext(pd);
- try {
- mutableSM.checkRead("aa", acc);
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#checkSetFactory()}
- */
- @SuppressWarnings("nls")
- public void test_checkSetFactory() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new RuntimePermission("setFactory"));
- try {
- mutableSM.checkSetFactory();
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#getInCheck()}
- */
- public void test_getIncheck() {
- mockSM.setInCheck(false);
- assertFalse(mockSM.getInCheck());
- mockSM.setInCheck(true);
- assertTrue(mockSM.getInCheck());
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#getSecurityContext()}
- */
- @SuppressWarnings("nls")
- public void test_getSecurityContext() {
- // enable all but one check
- mutableSM.addPermission(new AllPermission());
- mutableSM.denyPermission(new FilePermission("<<ALL FILES>>", "read"));
- try {
- mutableSM.checkRead("aa", mutableSM.getSecurityContext());
- fail("This should throw a SecurityException.");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#classDepth(String)}
- */
- @SuppressWarnings("nls")
- public void test_classDepthLjava_lang_String() {
- assertEquals(-1, mockSM.classDepth("nothing"));
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#classLoaderDepth()}
- */
- public void test_classLoaderDepth() {
- assertEquals(-1, mockSM.classLoaderDepth());
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#currentClassLoader()}
- */
- public void test_currentClassLoader() {
- assertNull(mockSM.currentClassLoader());
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#currentLoadedClass()}
- */
- public void test_currentLoadedClass() {
- assertNull(mockSM.currentLoadedClass());
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#inClass(String)}
- */
- @SuppressWarnings("nls")
- public void test_inClassLjava_lang_String() {
- assertFalse(mockSM.inClass("nothing"));
- assertTrue(mockSM.inClass(MockSecurityManager.class.getName()));
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#inClassLoader()}
- */
- public void test_inClassLoader() {
- assertFalse(mockSM.inClassLoader());
- }
-
- /**
- * @tests {@link java.lang.SecurityManager#inClassLoader()}
- */
- public void test_getClassContext() {
- assertEquals("MockSecurityManager should be the first in the classes stack",
- mockSM.getClassContext()[0], MockSecurityManager.class);
- }
-
- // set some protected method to public for testing
- class MockSecurityManager extends SecurityManager {
-
- public void setInCheck(boolean inCheck) {
- super.inCheck = inCheck;
- }
-
- @Override
- public int classDepth(String name) {
- return super.classDepth(name);
- }
-
- @Override
- public int classLoaderDepth() {
- return super.classLoaderDepth();
- }
-
- @Override
- public ClassLoader currentClassLoader() {
- return super.currentClassLoader();
- }
-
- @Override
- public Class<?> currentLoadedClass() {
- return super.currentLoadedClass();
- }
-
- @Override
- public Class[] getClassContext() {
- return super.getClassContext();
- }
-
- @Override
- public boolean inClass(String name) {
- return super.inClass(name);
- }
-
- @Override
- public boolean inClassLoader() {
- return super.inClassLoader();
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mutableSM = new MutableSecurityManager();
- mockSM = new MockSecurityManager();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ShortTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ShortTest.java
deleted file mode 100644
index e1dc2d3..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ShortTest.java
+++ /dev/null
@@ -1,660 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class ShortTest extends TestCase {
- private Short sp = new Short((short) 18000);
- private Short sn = new Short((short) -19000);
-
- /**
- * @tests java.lang.Short#byteValue()
- */
- public void test_byteValue() {
- // Test for method byte java.lang.Short.byteValue()
- assertEquals("Returned incorrect byte value", 0, new Short(Short.MIN_VALUE)
- .byteValue());
- assertEquals("Returned incorrect byte value", -1, new Short(Short.MAX_VALUE)
- .byteValue());
- }
-
- /**
- * @tests java.lang.Short#compareTo(java.lang.Short)
- */
- public void test_compareToLjava_lang_Short() {
- // Test for method int java.lang.Short.compareTo(java.lang.Short)
- Short s = new Short((short) 1);
- Short x = new Short((short) 3);
- assertTrue(
- "Should have returned negative value when compared to greater short",
- s.compareTo(x) < 0);
- x = new Short((short) -1);
- assertTrue(
- "Should have returned positive value when compared to lesser short",
- s.compareTo(x) > 0);
- x = new Short((short) 1);
- assertEquals("Should have returned zero when compared to equal short",
- 0, s.compareTo(x));
-
- try {
- new Short((short)0).compareTo(null);
- fail("No NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.Short#decode(java.lang.String)
- */
- public void test_decodeLjava_lang_String2() {
- // Test for method java.lang.Short
- // java.lang.Short.decode(java.lang.String)
- assertTrue("Did not decode -1 correctly", Short.decode("-1")
- .shortValue() == (short) -1);
- assertTrue("Did not decode -100 correctly", Short.decode("-100")
- .shortValue() == (short) -100);
- assertTrue("Did not decode 23 correctly", Short.decode("23")
- .shortValue() == (short) 23);
- assertTrue("Did not decode 0x10 correctly", Short.decode("0x10")
- .shortValue() == (short) 16);
- assertTrue("Did not decode 32767 correctly", Short.decode("32767")
- .shortValue() == (short) 32767);
- assertTrue("Did not decode -32767 correctly", Short.decode("-32767")
- .shortValue() == (short) -32767);
- assertTrue("Did not decode -32768 correctly", Short.decode("-32768")
- .shortValue() == (short) -32768);
-
- boolean exception = false;
- try {
- Short.decode("123s");
- } catch (NumberFormatException e) {
- // correct
- exception = true;
- }
- assertTrue("Did not throw NumberFormatException decoding 123s",
- exception);
-
- exception = false;
- try {
- Short.decode("32768");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Short.decode("-32769");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Short.decode("0x8000");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Short.decode("-0x8001");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MIN_VALUE - 1", exception);
- }
-
- /**
- * @tests java.lang.Short#parseShort(java.lang.String)
- */
- public void test_parseShortLjava_lang_String2() {
- // Test for method short java.lang.Short.parseShort(java.lang.String)
- short sp = Short.parseShort("32746");
- short sn = Short.parseShort("-32746");
-
- assertTrue("Incorrect parse of short", sp == (short) 32746
- && (sn == (short) -32746));
- assertEquals("Returned incorrect value for 0", 0, Short.parseShort("0"));
- assertTrue("Returned incorrect value for most negative value", Short
- .parseShort("-32768") == (short) 0x8000);
- assertTrue("Returned incorrect value for most positive value", Short
- .parseShort("32767") == 0x7fff);
-
- boolean exception = false;
- try {
- Short.parseShort("32768");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Short.parseShort("-32769");
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
- }
-
- /**
- * @tests java.lang.Short#parseShort(java.lang.String, int)
- */
- public void test_parseShortLjava_lang_StringI2() {
- // Test for method short java.lang.Short.parseShort(java.lang.String,
- // int)
- boolean aThrow = true;
- assertEquals("Incorrectly parsed hex string",
- 255, Short.parseShort("FF", 16));
- assertEquals("Incorrectly parsed oct string",
- 16, Short.parseShort("20", 8));
- assertEquals("Incorrectly parsed dec string",
- 20, Short.parseShort("20", 10));
- assertEquals("Incorrectly parsed bin string",
- 4, Short.parseShort("100", 2));
- assertEquals("Incorrectly parsed -hex string", -255, Short
- .parseShort("-FF", 16));
- assertEquals("Incorrectly parsed -oct string",
- -16, Short.parseShort("-20", 8));
- assertEquals("Incorrectly parsed -bin string", -4, Short
- .parseShort("-100", 2));
- assertEquals("Returned incorrect value for 0 hex", 0, Short.parseShort("0",
- 16));
- assertTrue("Returned incorrect value for most negative value hex",
- Short.parseShort("-8000", 16) == (short) 0x8000);
- assertTrue("Returned incorrect value for most positive value hex",
- Short.parseShort("7fff", 16) == 0x7fff);
- assertEquals("Returned incorrect value for 0 decimal", 0, Short.parseShort(
- "0", 10));
- assertTrue("Returned incorrect value for most negative value decimal",
- Short.parseShort("-32768", 10) == (short) 0x8000);
- assertTrue("Returned incorrect value for most positive value decimal",
- Short.parseShort("32767", 10) == 0x7fff);
-
- try {
- Short.parseShort("FF", 2);
- } catch (NumberFormatException e) {
- // Correct
- aThrow = false;
- }
- if (aThrow) {
- fail(
- "Failed to throw exception when passed hex string and base 2 radix");
- }
-
- boolean exception = false;
- try {
- Short.parseShort("10000000000", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue(
- "Failed to throw exception when passed string larger than 16 bits",
- exception);
-
- exception = false;
- try {
- Short.parseShort("32768", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Short.parseShort("-32769", 10);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for MIN_VALUE - 1", exception);
-
- exception = false;
- try {
- Short.parseShort("8000", 16);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MAX_VALUE + 1", exception);
-
- exception = false;
- try {
- Short.parseShort("-8001", 16);
- } catch (NumberFormatException e) {
- // Correct
- exception = true;
- }
- assertTrue("Failed to throw exception for hex MIN_VALUE + 1", exception);
- }
-
- /**
- * @tests java.lang.Short#toString()
- */
- public void test_toString2() {
- // Test for method java.lang.String java.lang.Short.toString()
- assertTrue("Invalid string returned", sp.toString().equals("18000")
- && (sn.toString().equals("-19000")));
- assertEquals("Returned incorrect string", "32767", new Short((short) 32767)
- .toString());
- assertEquals("Returned incorrect string", "-32767", new Short((short) -32767)
- .toString());
- assertEquals("Returned incorrect string", "-32768", new Short((short) -32768)
- .toString());
- }
-
- /**
- * @tests java.lang.Short#toString(short)
- */
- public void test_toStringS2() {
- // Test for method java.lang.String java.lang.Short.toString(short)
- assertEquals("Returned incorrect string", "32767", Short.toString((short) 32767)
- );
- assertEquals("Returned incorrect string", "-32767", Short.toString((short) -32767)
- );
- assertEquals("Returned incorrect string", "-32768", Short.toString((short) -32768)
- );
- }
-
- /**
- * @tests java.lang.Short#valueOf(java.lang.String)
- */
- public void test_valueOfLjava_lang_String2() {
- // Test for method java.lang.Short
- // java.lang.Short.valueOf(java.lang.String)
- assertEquals("Returned incorrect short", -32768, Short.valueOf("-32768")
- .shortValue());
- assertEquals("Returned incorrect short", 32767, Short.valueOf("32767")
- .shortValue());
- }
-
- /**
- * @tests java.lang.Short#valueOf(java.lang.String, int)
- */
- public void test_valueOfLjava_lang_StringI2() {
- // Test for method java.lang.Short
- // java.lang.Short.valueOf(java.lang.String, int)
- boolean aThrow = true;
- assertEquals("Incorrectly parsed hex string", 255, Short.valueOf("FF", 16)
- .shortValue());
- assertEquals("Incorrectly parsed oct string", 16, Short.valueOf("20", 8)
- .shortValue());
- assertEquals("Incorrectly parsed dec string", 20, Short.valueOf("20", 10)
- .shortValue());
- assertEquals("Incorrectly parsed bin string", 4, Short.valueOf("100", 2)
- .shortValue());
- assertEquals("Incorrectly parsed -hex string", -255, Short.valueOf("-FF", 16)
- .shortValue());
- assertEquals("Incorrectly parsed -oct string", -16, Short.valueOf("-20", 8)
- .shortValue());
- assertEquals("Incorrectly parsed -bin string", -4, Short.valueOf("-100", 2)
- .shortValue());
- assertTrue("Did not decode 32767 correctly", Short.valueOf("32767", 10)
- .shortValue() == (short) 32767);
- assertTrue("Did not decode -32767 correctly", Short.valueOf("-32767",
- 10).shortValue() == (short) -32767);
- assertTrue("Did not decode -32768 correctly", Short.valueOf("-32768",
- 10).shortValue() == (short) -32768);
- try {
- Short.valueOf("FF", 2);
- } catch (NumberFormatException e) {
- // Correct
- aThrow = false;
- }
- if (aThrow) {
- fail(
- "Failed to throw exception when passed hex string and base 2 radix");
- }
- try {
- Short.valueOf("10000000000", 10);
- } catch (NumberFormatException e) {
- // Correct
- return;
- }
- fail(
- "Failed to throw exception when passed string larger than 16 bits");
- }
- /**
- * @tests java.lang.Short#valueOf(byte)
- */
- public void test_valueOfS() {
- assertEquals(new Short(Short.MIN_VALUE), Short.valueOf(Short.MIN_VALUE));
- assertEquals(new Short(Short.MAX_VALUE), Short.valueOf(Short.MAX_VALUE));
- assertEquals(new Short((short) 0), Short.valueOf((short) 0));
-
- short s = -128;
- while (s < 128) {
- assertEquals(new Short(s), Short.valueOf(s));
- assertSame(Short.valueOf(s), Short.valueOf(s));
- s++;
- }
- }
-
- /**
- * @tests java.lang.Short#hashCode()
- */
- public void test_hashCode() {
- assertEquals(1, new Short((short)1).hashCode());
- assertEquals(2, new Short((short)2).hashCode());
- assertEquals(0, new Short((short)0).hashCode());
- assertEquals(-1, new Short((short)-1).hashCode());
- }
-
- /**
- * @tests java.lang.Short#Short(String)
- */
- public void test_ConstructorLjava_lang_String() {
- assertEquals(new Short((short)0), new Short("0"));
- assertEquals(new Short((short)1), new Short("1"));
- assertEquals(new Short((short)-1), new Short("-1"));
-
- try {
- new Short("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Short("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Short("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- new Short(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Short#Short(short)
- */
- public void test_ConstructorS() {
- assertEquals(1, new Short((short)1).shortValue());
- assertEquals(2, new Short((short)2).shortValue());
- assertEquals(0, new Short((short)0).shortValue());
- assertEquals(-1, new Short((short)-1).shortValue());
- }
-
- /**
- * @tests java.lang.Short#byteValue()
- */
- public void test_booleanValue() {
- assertEquals(1, new Short((short)1).byteValue());
- assertEquals(2, new Short((short)2).byteValue());
- assertEquals(0, new Short((short)0).byteValue());
- assertEquals(-1, new Short((short)-1).byteValue());
- }
-
- /**
- * @tests java.lang.Short#equals(Object)
- */
- public void test_equalsLjava_lang_Object() {
- assertEquals(new Short((short)0), Short.valueOf((short)0));
- assertEquals(new Short((short)1), Short.valueOf((short)1));
- assertEquals(new Short((short)-1), Short.valueOf((short)-1));
-
- Short fixture = new Short((short)25);
- assertEquals(fixture, fixture);
- assertFalse(fixture.equals(null));
- assertFalse(fixture.equals("Not a Short"));
- }
-
- /**
- * @tests java.lang.Short#toString()
- */
- public void test_toString() {
- assertEquals("-1", new Short((short)-1).toString());
- assertEquals("0", new Short((short)0).toString());
- assertEquals("1", new Short((short)1).toString());
- assertEquals("-1", new Short((short)0xFFFF).toString());
- }
-
- /**
- * @tests java.lang.Short#toString(short)
- */
- public void test_toStringS() {
- assertEquals("-1", Short.toString((short)-1));
- assertEquals("0", Short.toString((short)0));
- assertEquals("1", Short.toString((short)1));
- assertEquals("-1", Short.toString((short)0xFFFF));
- }
-
- /**
- * @tests java.lang.Short#valueOf(String)
- */
- public void test_valueOfLjava_lang_String() {
- assertEquals(new Short((short)0), Short.valueOf("0"));
- assertEquals(new Short((short)1), Short.valueOf("1"));
- assertEquals(new Short((short)-1), Short.valueOf("-1"));
-
- try {
- Short.valueOf("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.valueOf("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.valueOf("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.valueOf(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Short#valueOf(String,int)
- */
- public void test_valueOfLjava_lang_StringI() {
- assertEquals(new Short((short)0), Short.valueOf("0", 10));
- assertEquals(new Short((short)1), Short.valueOf("1", 10));
- assertEquals(new Short((short)-1), Short.valueOf("-1", 10));
-
- //must be consistent with Character.digit()
- assertEquals(Character.digit('1', 2), Short.valueOf("1", 2).byteValue());
- assertEquals(Character.digit('F', 16), Short.valueOf("F", 16).byteValue());
-
- try {
- Short.valueOf("0x1", 10);
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.valueOf("9.2", 10);
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.valueOf("", 10);
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.valueOf(null, 10);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Short#parseShort(String)
- */
- public void test_parseShortLjava_lang_String() {
- assertEquals(0, Short.parseShort("0"));
- assertEquals(1, Short.parseShort("1"));
- assertEquals(-1, Short.parseShort("-1"));
-
- try {
- Short.parseShort("0x1");
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.parseShort("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.parseShort("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.parseShort(null);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Short#parseShort(String,int)
- */
- public void test_parseShortLjava_lang_StringI() {
- assertEquals(0, Short.parseShort("0", 10));
- assertEquals(1, Short.parseShort("1", 10));
- assertEquals(-1, Short.parseShort("-1", 10));
-
- //must be consistent with Character.digit()
- assertEquals(Character.digit('1', 2), Short.parseShort("1", 2));
- assertEquals(Character.digit('F', 16), Short.parseShort("F", 16));
-
- try {
- Short.parseShort("0x1", 10);
- fail("Expected NumberFormatException with hex string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.parseShort("9.2", 10);
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.parseShort("", 10);
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.parseShort(null, 10);
- fail("Expected NumberFormatException with null string.");
- } catch (NumberFormatException e) {}
- }
-
- /**
- * @tests java.lang.Short#decode(String)
- */
- public void test_decodeLjava_lang_String() {
- assertEquals(new Short((short)0), Short.decode("0"));
- assertEquals(new Short((short)1), Short.decode("1"));
- assertEquals(new Short((short)-1), Short.decode("-1"));
- assertEquals(new Short((short)0xF), Short.decode("0xF"));
- assertEquals(new Short((short)0xF), Short.decode("#F"));
- assertEquals(new Short((short)0xF), Short.decode("0XF"));
- assertEquals(new Short((short)07), Short.decode("07"));
-
- try {
- Short.decode("9.2");
- fail("Expected NumberFormatException with floating point string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.decode("");
- fail("Expected NumberFormatException with empty string.");
- } catch (NumberFormatException e) {}
-
- try {
- Short.decode(null);
- //undocumented NPE, but seems consistent across JREs
- fail("Expected NullPointerException with null string.");
- } catch (NullPointerException e) {}
- }
-
- /**
- * @tests java.lang.Short#doubleValue()
- */
- public void test_doubleValue() {
- assertEquals(-1D, new Short((short)-1).doubleValue(), 0D);
- assertEquals(0D, new Short((short)0).doubleValue(), 0D);
- assertEquals(1D, new Short((short)1).doubleValue(), 0D);
- }
-
- /**
- * @tests java.lang.Short#floatValue()
- */
- public void test_floatValue() {
- assertEquals(-1F, new Short((short)-1).floatValue(), 0F);
- assertEquals(0F, new Short((short)0).floatValue(), 0F);
- assertEquals(1F, new Short((short)1).floatValue(), 0F);
- }
-
- /**
- * @tests java.lang.Short#intValue()
- */
- public void test_intValue() {
- assertEquals(-1, new Short((short)-1).intValue());
- assertEquals(0, new Short((short)0).intValue());
- assertEquals(1, new Short((short)1).intValue());
- }
-
- /**
- * @tests java.lang.Short#longValue()
- */
- public void test_longValue() {
- assertEquals(-1L, new Short((short)-1).longValue());
- assertEquals(0L, new Short((short)0).longValue());
- assertEquals(1L, new Short((short)1).longValue());
- }
-
- /**
- * @tests java.lang.Short#shortValue()
- */
- public void test_shortValue() {
- assertEquals(-1, new Short((short)-1).shortValue());
- assertEquals(0, new Short((short)0).shortValue());
- assertEquals(1, new Short((short)1).shortValue());
- }
-
- /**
- * @tests java.lang.Short#reverseBytes(short)
- */
- public void test_reverseBytesS() {
- assertEquals((short)0xABCD, Short.reverseBytes((short)0xCDAB));
- assertEquals((short)0x1234, Short.reverseBytes((short)0x3412));
- assertEquals((short)0x0011, Short.reverseBytes((short)0x1100));
- assertEquals((short)0x2002, Short.reverseBytes((short)0x0220));
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackOverflowErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackOverflowErrorTest.java
deleted file mode 100644
index b4e928f..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackOverflowErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class StackOverflowErrorTest extends TestCase {
-
- /**
- * @tests java.lang.StackOverflowError#StackOverflowError()
- */
- public void test_Constructor() {
- StackOverflowError e = new StackOverflowError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.StackOverflowError#StackOverflowError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- StackOverflowError e = new StackOverflowError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackTraceElementOriginal.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackTraceElementOriginal.java
deleted file mode 100644
index 27b5e4f..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StackTraceElementOriginal.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargetClass;
-import junit.framework.TestCase;
-
-@TestTargetClass(StackTraceElement.class)
-public class StackTraceElementOriginal extends TestCase {
-
- public void pureJavaMethod(Object test) throws Exception {
- throw new Exception("pure java method");
- }
-
- native public void pureNativeMethod(Object test);
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java
deleted file mode 100644
index 472e27d3..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java
+++ /dev/null
@@ -1,1490 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import static org.apache.harmony.luni.tests.java.lang.MathTest.COPYSIGN_DD_CASES;
-import static org.apache.harmony.luni.tests.java.lang.MathTest.COPYSIGN_FF_CASES;
-import static org.apache.harmony.luni.tests.java.lang.MathTest.GETEXPONENT_D_CASES;
-import static org.apache.harmony.luni.tests.java.lang.MathTest.GETEXPONENT_D_RESULTS;
-import static org.apache.harmony.luni.tests.java.lang.MathTest.GETEXPONENT_F_CASES;
-import static org.apache.harmony.luni.tests.java.lang.MathTest.GETEXPONENT_F_RESULTS;
-import static org.apache.harmony.luni.tests.java.lang.MathTest.NEXTAFTER_DD_START_CASES;
-import static org.apache.harmony.luni.tests.java.lang.MathTest.NEXTAFTER_DD_FD_DIRECTION_CASES;
-import static org.apache.harmony.luni.tests.java.lang.MathTest.NEXTAFTER_FD_START_CASES;
-
-public class StrictMathTest extends junit.framework.TestCase {
-
- double HYP = StrictMath.sqrt(2.0);
-
- double OPP = 1.0;
-
- double ADJ = 1.0;
-
- /* Required to make previous preprocessor flags work - do not remove */
- int unused = 0;
-
- /**
- * @tests java.lang.StrictMath#abs(double)
- */
- public void test_absD() {
- // Test for method double java.lang.StrictMath.abs(double)
-
- assertTrue("Incorrect double abs value",
- (StrictMath.abs(-1908.8976) == 1908.8976));
- assertTrue("Incorrect double abs value",
- (StrictMath.abs(1908.8976) == 1908.8976));
- }
-
- /**
- * @tests java.lang.StrictMath#abs(float)
- */
- public void test_absF() {
- // Test for method float java.lang.StrictMath.abs(float)
- assertTrue("Incorrect float abs value",
- (StrictMath.abs(-1908.8976f) == 1908.8976f));
- assertTrue("Incorrect float abs value",
- (StrictMath.abs(1908.8976f) == 1908.8976f));
- }
-
- /**
- * @tests java.lang.StrictMath#abs(int)
- */
- public void test_absI() {
- // Test for method int java.lang.StrictMath.abs(int)
- assertTrue("Incorrect int abs value",
- (StrictMath.abs(-1908897) == 1908897));
- assertTrue("Incorrect int abs value",
- (StrictMath.abs(1908897) == 1908897));
- }
-
- /**
- * @tests java.lang.StrictMath#abs(long)
- */
- public void test_absJ() {
- // Test for method long java.lang.StrictMath.abs(long)
- assertTrue("Incorrect long abs value", (StrictMath
- .abs(-19088976000089L) == 19088976000089L));
- assertTrue("Incorrect long abs value",
- (StrictMath.abs(19088976000089L) == 19088976000089L));
- }
-
- /**
- * @tests java.lang.StrictMath#acos(double)
- */
- public void test_acosD() {
- // Test for method double java.lang.StrictMath.acos(double)
- assertTrue("Returned incorrect arc cosine", StrictMath.cos(StrictMath
- .acos(ADJ / HYP)) == ADJ / HYP);
- }
-
- /**
- * @tests java.lang.StrictMath#asin(double)
- */
- public void test_asinD() {
- // Test for method double java.lang.StrictMath.asin(double)
- assertTrue("Returned incorrect arc sine", StrictMath.sin(StrictMath
- .asin(OPP / HYP)) == OPP / HYP);
- }
-
- /**
- * @tests java.lang.StrictMath#atan(double)
- */
- public void test_atanD() {
- // Test for method double java.lang.StrictMath.atan(double)
- double answer = StrictMath.tan(StrictMath.atan(1.0));
- assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
- && answer >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.StrictMath#atan2(double, double)
- */
- public void test_atan2DD() {
- // Test for method double java.lang.StrictMath.atan2(double, double)
- double answer = StrictMath.atan(StrictMath.tan(1.0));
- assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
- && answer >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.StrictMath#cbrt(double)
- */
- @SuppressWarnings("boxing")
- public void test_cbrt_D() {
- // Test for special situations
- assertTrue("Should return Double.NaN", Double.isNaN(StrictMath
- .cbrt(Double.NaN)));
- assertEquals("Should return Double.POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .cbrt(Double.POSITIVE_INFINITY));
- assertEquals("Should return Double.NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath
- .cbrt(Double.NEGATIVE_INFINITY));
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.cbrt(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.cbrt(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.cbrt(-0.0)));
-
- assertEquals("Should return 3.0", 3.0, StrictMath.cbrt(27.0));
- assertEquals("Should return 23.111993172558684", 23.111993172558684,
- StrictMath.cbrt(12345.6));
- assertEquals("Should return 5.643803094122362E102",
- 5.643803094122362E102, StrictMath.cbrt(Double.MAX_VALUE));
- assertEquals("Should return 0.01", 0.01, StrictMath.cbrt(0.000001));
-
- assertEquals("Should return -3.0", -3.0, StrictMath.cbrt(-27.0));
- assertEquals("Should return -23.111993172558684", -23.111993172558684,
- StrictMath.cbrt(-12345.6));
- assertEquals("Should return 1.7031839360032603E-108",
- 1.7031839360032603E-108, StrictMath.cbrt(Double.MIN_VALUE));
- assertEquals("Should return -0.01", -0.01, StrictMath.cbrt(-0.000001));
-
- try{
- StrictMath.cbrt((Double)null);
- fail("Should throw NullPointerException");
- }catch(NullPointerException e){
- //expected
- }
- }
-
- /**
- * @tests java.lang.StrictMath#ceil(double)
- */
- public void test_ceilD() {
- // Test for method double java.lang.StrictMath.ceil(double)
- assertEquals("Incorrect ceiling for double",
- 79, StrictMath.ceil(78.89), 0.0);
- assertEquals("Incorrect ceiling for double",
- -78, StrictMath.ceil(-78.89), 0.0);
- }
-
- /**
- * @tests {@link java.lang.StrictMath#copySign(double, double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_copySign_DD() {
- for (int i = 0; i < COPYSIGN_DD_CASES.length; i++) {
- final double magnitude = COPYSIGN_DD_CASES[i];
- final long absMagnitudeBits = Double.doubleToLongBits(StrictMath
- .abs(magnitude));
- final long negMagnitudeBits = Double.doubleToLongBits(-StrictMath
- .abs(magnitude));
-
- // cases for NaN
- assertEquals("If the sign is NaN, the result should be positive.",
- absMagnitudeBits, Double.doubleToLongBits(StrictMath
- .copySign(magnitude, Double.NaN)));
- assertTrue("The result should be NaN.", Double.isNaN(StrictMath
- .copySign(Double.NaN, magnitude)));
-
- for (int j = 0; j < COPYSIGN_DD_CASES.length; j++) {
- final double sign = COPYSIGN_DD_CASES[j];
- final long resultBits = Double.doubleToLongBits(StrictMath
- .copySign(magnitude, sign));
-
- if (sign > 0 || Double.valueOf(+0.0).equals(sign)
- || Double.valueOf(0.0).equals(sign)) {
- assertEquals(
- "If the sign is positive, the result should be positive.",
- absMagnitudeBits, resultBits);
- }
- if (sign < 0 || Double.valueOf(-0.0).equals(sign)) {
- assertEquals(
- "If the sign is negative, the result should be negative.",
- negMagnitudeBits, resultBits);
- }
- }
- }
-
- assertTrue("The result should be NaN.", Double.isNaN(StrictMath
- .copySign(Double.NaN, Double.NaN)));
-
- try {
- StrictMath.copySign((Double) null, 2.3);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.copySign(2.3, (Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.copySign((Double) null, (Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
-
- double d = Double.longBitsToDouble(0xfff8000000000000L);
- assertEquals(1.0, StrictMath.copySign(1.0, d), 0d);
- }
-
- /**
- * @tests {@link java.lang.StrictMath#copySign(float, float)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_copySign_FF() {
- for (int i = 0; i < COPYSIGN_FF_CASES.length; i++) {
- final float magnitude = COPYSIGN_FF_CASES[i];
- final int absMagnitudeBits = Float.floatToIntBits(StrictMath
- .abs(magnitude));
- final int negMagnitudeBits = Float.floatToIntBits(-StrictMath
- .abs(magnitude));
-
- // cases for NaN
- assertEquals("If the sign is NaN, the result should be positive.",
- absMagnitudeBits, Float.floatToIntBits(StrictMath.copySign(
- magnitude, Float.NaN)));
- assertTrue("The result should be NaN.", Float.isNaN(StrictMath
- .copySign(Float.NaN, magnitude)));
-
- for (int j = 0; j < COPYSIGN_FF_CASES.length; j++) {
- final float sign = COPYSIGN_FF_CASES[j];
- final int resultBits = Float.floatToIntBits(StrictMath
- .copySign(magnitude, sign));
- if (sign > 0 || Float.valueOf(+0.0f).equals(sign)
- || Float.valueOf(0.0f).equals(sign)) {
- assertEquals(
- "If the sign is positive, the result should be positive.",
- absMagnitudeBits, resultBits);
- }
- if (sign < 0 || Float.valueOf(-0.0f).equals(sign)) {
- assertEquals(
- "If the sign is negative, the result should be negative.",
- negMagnitudeBits, resultBits);
- }
- }
- }
-
- assertTrue("The result should be NaN.", Float.isNaN(StrictMath
- .copySign(Float.NaN, Float.NaN)));
-
- try {
- StrictMath.copySign((Float) null, 2.3f);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.copySign(2.3f, (Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.copySign((Float) null, (Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
-
- float f = Float.intBitsToFloat(0xffc00000);
- assertEquals(1.0f, StrictMath.copySign(1.0f, f), 0f);
- }
-
- /**
- * @tests java.lang.StrictMath#cos(double)
- */
- public void test_cosD() {
- // Test for method double java.lang.StrictMath.cos(double)
-
- assertTrue("Returned incorrect cosine", StrictMath.cos(StrictMath
- .acos(ADJ / HYP)) == ADJ / HYP);
- }
-
- /**
- * @tests java.lang.StrictMath#cosh(double)
- */
- @SuppressWarnings("boxing")
- public void test_cosh_D() {
- // Test for special situations
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .cosh(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .cosh(Double.POSITIVE_INFINITY));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .cosh(Double.NEGATIVE_INFINITY));
- assertEquals("Should return 1.0", 1.0, StrictMath.cosh(+0.0));
- assertEquals("Should return 1.0", 1.0, StrictMath.cosh(-0.0));
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.cosh(1234.56));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.cosh(-1234.56));
- assertEquals("Should return 1.0000000000005", 1.0000000000005,
- StrictMath.cosh(0.000001));
- assertEquals("Should return 1.0000000000005", 1.0000000000005,
- StrictMath.cosh(-0.000001));
- assertEquals("Should return 5.212214351945598", 5.212214351945598,
- StrictMath.cosh(2.33482));
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.cosh(Double.MAX_VALUE));
- assertEquals("Should return 1.0", 1.0, StrictMath
- .cosh(Double.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.StrictMath#exp(double)
- */
- public void test_expD() {
- // Test for method double java.lang.StrictMath.exp(double)
- assertTrue("Incorrect answer returned for simple power", StrictMath
- .abs(StrictMath.exp(4D) - StrictMath.E * StrictMath.E
- * StrictMath.E * StrictMath.E) < 0.1D);
- assertTrue("Incorrect answer returned for larger power", StrictMath
- .log(StrictMath.abs(StrictMath.exp(5.5D)) - 5.5D) < 10.0D);
- }
-
- /**
- * @tests java.lang.StrictMath#expm1(double)
- */
- @SuppressWarnings("boxing")
- public void test_expm1_D() {
- //Test for special cases
- assertTrue("Should return NaN", Double.isNaN(StrictMath.expm1(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.expm1(Double.POSITIVE_INFINITY));
- assertEquals("Should return -1.0", -1.0, StrictMath
- .expm1(Double.NEGATIVE_INFINITY));
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.expm1(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.expm1(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.expm1(-0.0)));
-
- assertEquals("Should return -9.999950000166666E-6",
- -9.999950000166666E-6, StrictMath.expm1(-0.00001));
- assertEquals("Should return 1.0145103074469635E60",
- 1.0145103074469635E60, StrictMath.expm1(138.16951162));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .expm1(123456789123456789123456789.4521584223));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.expm1(Double.MAX_VALUE));
- assertEquals("Should return MIN_VALUE", Double.MIN_VALUE, StrictMath
- .expm1(Double.MIN_VALUE));
-
- }
-
- /**
- * @tests java.lang.StrictMath#floor(double)
- */
- public void test_floorD() {
- // Test for method double java.lang.StrictMath.floor(double)
- assertEquals("Incorrect floor for double",
- 78, StrictMath.floor(78.89), 0.0);
- assertEquals("Incorrect floor for double",
- -79, StrictMath.floor(-78.89), 0.0);
- }
-
- /**
- * @tests {@link java.lang.StrictMath#getExponent(double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_getExponent_D() {
- for (int i = 0; i < GETEXPONENT_D_CASES.length; i++) {
- final double number = GETEXPONENT_D_CASES[i];
- final int result = GETEXPONENT_D_RESULTS[i];
- assertEquals("Wrong result of getExponent(double).", result,
- StrictMath.getExponent(number));
- }
-
- try {
- StrictMath.getExponent((Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests {@link java.lang.StrictMath#getExponent(float)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_getExponent_F() {
- for (int i = 0; i < GETEXPONENT_F_CASES.length; i++) {
- final float number = GETEXPONENT_F_CASES[i];
- final int result = GETEXPONENT_F_RESULTS[i];
- assertEquals("Wrong result of getExponent(float).", result,
- StrictMath.getExponent(number));
- }
- try {
- StrictMath.getExponent((Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StrictMath#hypot(double, double)
- */
- @SuppressWarnings("boxing")
- public void test_hypot_DD() {
- // Test for special cases
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(Double.POSITIVE_INFINITY,
- 1.0));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(Double.NEGATIVE_INFINITY,
- 123.324));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(-758.2587,
- Double.POSITIVE_INFINITY));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(5687.21,
- Double.NEGATIVE_INFINITY));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(Double.POSITIVE_INFINITY,
- Double.NEGATIVE_INFINITY));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(Double.NEGATIVE_INFINITY,
- Double.POSITIVE_INFINITY));
- assertTrue("Should return NaN",Double.isNaN(StrictMath.hypot(Double.NaN,
- 2342301.89843)));
- assertTrue("Should return NaN",Double.isNaN(StrictMath.hypot(-345.2680,
- Double.NaN)));
-
- assertEquals("Should return 2396424.905416697", 2396424.905416697, StrictMath
- .hypot(12322.12, -2396393.2258));
- assertEquals("Should return 138.16958070558556", 138.16958070558556,
- StrictMath.hypot(-138.16951162, 0.13817035864));
- assertEquals("Should return 1.7976931348623157E308",
- 1.7976931348623157E308, StrictMath.hypot(Double.MAX_VALUE, 211370.35));
- assertEquals("Should return 5413.7185", 5413.7185, StrictMath.hypot(
- -5413.7185, Double.MIN_VALUE));
-
- }
-
- /**
- * @tests java.lang.StrictMath#IEEEremainder(double, double)
- */
- public void test_IEEEremainderDD() {
- // Test for method double java.lang.StrictMath.IEEEremainder(double,
- // double)
- assertEquals("Incorrect remainder returned", 0.0, StrictMath.IEEEremainder(
- 1.0, 1.0), 0.0);
- assertTrue(
- "Incorrect remainder returned",
- StrictMath.IEEEremainder(1.32, 89.765) >= 1.4705063220631647E-2
- || StrictMath.IEEEremainder(1.32, 89.765) >= 1.4705063220631649E-2);
- }
-
- /**
- * @tests java.lang.StrictMath#log(double)
- */
- public void test_logD() {
- // Test for method double java.lang.StrictMath.log(double)
- for (double d = 10; d >= -10; d -= 0.5) {
- double answer = StrictMath.log(StrictMath.exp(d));
- assertTrue("Answer does not equal expected answer for d = " + d
- + " answer = " + answer,
- StrictMath.abs(answer - d) <= StrictMath
- .abs(d * 0.00000001));
- }
- }
-
- /**
- * @tests java.lang.StrictMath#log10(double)
- */
- @SuppressWarnings("boxing")
- public void test_log10_D() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .log10(Double.NaN)));
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .log10(-2541.05745687234187532)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .log10(Double.POSITIVE_INFINITY));
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath.log10(0.0));
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath.log10(+0.0));
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath.log10(-0.0));
- assertEquals("Should return 14.0", 14.0, StrictMath.log10(StrictMath
- .pow(10, 14)));
-
- assertEquals("Should return 3.7389561269540406", 3.7389561269540406,
- StrictMath.log10(5482.2158));
- assertEquals("Should return 14.661551142893833", 14.661551142893833,
- StrictMath.log10(458723662312872.125782332587));
- assertEquals("Should return -0.9083828622192334", -0.9083828622192334,
- StrictMath.log10(0.12348583358871));
- assertEquals("Should return 308.25471555991675", 308.25471555991675,
- StrictMath.log10(Double.MAX_VALUE));
- assertEquals("Should return -323.3062153431158", -323.3062153431158,
- StrictMath.log10(Double.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.StrictMath#log1p(double)
- */
- @SuppressWarnings("boxing")
- public void test_log1p_D() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .log1p(Double.NaN)));
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .log1p(-32.0482175)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .log1p(Double.POSITIVE_INFINITY));
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.log1p(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.log1p(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.log1p(-0.0)));
-
- assertEquals("Should return -0.2941782295312541", -0.2941782295312541,
- StrictMath.log1p(-0.254856327));
- assertEquals("Should return 7.368050685564151", 7.368050685564151,
- StrictMath.log1p(1583.542));
- assertEquals("Should return 0.4633708685409921", 0.4633708685409921,
- StrictMath.log1p(0.5894227));
- assertEquals("Should return 709.782712893384", 709.782712893384,
- StrictMath.log1p(Double.MAX_VALUE));
- assertEquals("Should return Double.MIN_VALUE", Double.MIN_VALUE,
- StrictMath.log1p(Double.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.StrictMath#max(double, double)
- */
- public void test_maxDD() {
- // Test for method double java.lang.StrictMath.max(double, double)
- assertEquals("Incorrect double max value", 1908897.6000089, StrictMath.max(
- -1908897.6000089, 1908897.6000089), 0D);
- assertEquals("Incorrect double max value", 1908897.6000089, StrictMath.max(2.0,
- 1908897.6000089), 0D);
- assertEquals("Incorrect double max value", -2.0, StrictMath.max(-2.0,
- -1908897.6000089), 0D);
-
- }
-
- /**
- * @tests java.lang.StrictMath#max(float, float)
- */
- public void test_maxFF() {
- // Test for method float java.lang.StrictMath.max(float, float)
- assertTrue("Incorrect float max value", StrictMath.max(-1908897.600f,
- 1908897.600f) == 1908897.600f);
- assertTrue("Incorrect float max value", StrictMath.max(2.0f,
- 1908897.600f) == 1908897.600f);
- assertTrue("Incorrect float max value", StrictMath.max(-2.0f,
- -1908897.600f) == -2.0f);
- }
-
- /**
- * @tests java.lang.StrictMath#max(int, int)
- */
- public void test_maxII() {
- // Test for method int java.lang.StrictMath.max(int, int)
- assertEquals("Incorrect int max value", 19088976, StrictMath.max(-19088976,
- 19088976));
- assertEquals("Incorrect int max value",
- 19088976, StrictMath.max(20, 19088976));
- assertEquals("Incorrect int max value",
- -20, StrictMath.max(-20, -19088976));
- }
-
- /**
- * @tests java.lang.StrictMath#max(long, long)
- */
- public void test_maxJJ() {
- // Test for method long java.lang.StrictMath.max(long, long)
- assertEquals("Incorrect long max value", 19088976000089L, StrictMath.max(-19088976000089L,
- 19088976000089L));
- assertEquals("Incorrect long max value", 19088976000089L, StrictMath.max(20,
- 19088976000089L));
- assertEquals("Incorrect long max value", -20, StrictMath.max(-20,
- -19088976000089L));
- }
-
- /**
- * @tests java.lang.StrictMath#min(double, double)
- */
- public void test_minDD() {
- // Test for method double java.lang.StrictMath.min(double, double)
- assertEquals("Incorrect double min value", -1908897.6000089, StrictMath.min(
- -1908897.6000089, 1908897.6000089), 0D);
- assertEquals("Incorrect double min value", 2.0, StrictMath.min(2.0,
- 1908897.6000089), 0D);
- assertEquals("Incorrect double min value", -1908897.6000089, StrictMath.min(-2.0,
- -1908897.6000089), 0D);
- }
-
- /**
- * @tests java.lang.StrictMath#min(float, float)
- */
- public void test_minFF() {
- // Test for method float java.lang.StrictMath.min(float, float)
- assertTrue("Incorrect float min value", StrictMath.min(-1908897.600f,
- 1908897.600f) == -1908897.600f);
- assertTrue("Incorrect float min value", StrictMath.min(2.0f,
- 1908897.600f) == 2.0f);
- assertTrue("Incorrect float min value", StrictMath.min(-2.0f,
- -1908897.600f) == -1908897.600f);
- }
-
- /**
- * @tests java.lang.StrictMath#min(int, int)
- */
- public void test_minII() {
- // Test for method int java.lang.StrictMath.min(int, int)
- assertEquals("Incorrect int min value", -19088976, StrictMath.min(-19088976,
- 19088976));
- assertEquals("Incorrect int min value",
- 20, StrictMath.min(20, 19088976));
- assertEquals("Incorrect int min value",
- -19088976, StrictMath.min(-20, -19088976));
-
- }
-
- /**
- * @tests java.lang.StrictMath#min(long, long)
- */
- public void test_minJJ() {
- // Test for method long java.lang.StrictMath.min(long, long)
- assertEquals("Incorrect long min value", -19088976000089L, StrictMath.min(-19088976000089L,
- 19088976000089L));
- assertEquals("Incorrect long min value", 20, StrictMath.min(20,
- 19088976000089L));
- assertEquals("Incorrect long min value", -19088976000089L, StrictMath.min(-20,
- -19088976000089L));
- }
-
- /**
- * @tests {@link java.lang.StrictMath#nextAfter(double, double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_nextAfter_DD() {
- // test for most cases without exception
- for (int i = 0; i < NEXTAFTER_DD_START_CASES.length; i++) {
- final double start = NEXTAFTER_DD_START_CASES[i][0];
- final long nextUpBits = Double
- .doubleToLongBits(NEXTAFTER_DD_START_CASES[i][1]);
- final long nextDownBits = Double
- .doubleToLongBits(NEXTAFTER_DD_START_CASES[i][2]);
-
- for (int j = 0; j < NEXTAFTER_DD_FD_DIRECTION_CASES.length; j++) {
- final double direction = NEXTAFTER_DD_FD_DIRECTION_CASES[j];
- final long resultBits = Double.doubleToLongBits(StrictMath
- .nextAfter(start, direction));
- final long directionBits = Double.doubleToLongBits(direction);
- if (direction > start) {
- assertEquals("Result should be next up-number.",
- nextUpBits, resultBits);
- } else if (direction < start) {
- assertEquals("Result should be next down-number.",
- nextDownBits, resultBits);
- } else {
- assertEquals("Result should be direction.", directionBits,
- resultBits);
- }
- }
- }
-
- // test for cases with NaN
- for (int i = 0; i < NEXTAFTER_DD_START_CASES.length; i++) {
- assertTrue("The result should be NaN.", Double.isNaN(StrictMath
- .nextAfter(NEXTAFTER_DD_START_CASES[i][0], Double.NaN)));
- }
- for (int i = 0; i < NEXTAFTER_DD_FD_DIRECTION_CASES.length; i++) {
- assertTrue("The result should be NaN.", Double.isNaN(StrictMath
- .nextAfter(Double.NaN, NEXTAFTER_DD_FD_DIRECTION_CASES[i])));
- }
- assertTrue("The result should be NaN.", Double.isNaN(StrictMath
- .nextAfter(Double.NaN, Double.NaN)));
-
- // test for exception
- try {
- StrictMath.nextAfter((Double) null, 2.3);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.nextAfter(2.3, (Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.nextAfter((Double) null, (Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests {@link java.lang.StrictMath#nextAfter(float, double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_nextAfter_FD() {
- // test for most cases without exception
- for (int i = 0; i < NEXTAFTER_FD_START_CASES.length; i++) {
- final float start = NEXTAFTER_FD_START_CASES[i][0];
- final int nextUpBits = Float
- .floatToIntBits(NEXTAFTER_FD_START_CASES[i][1]);
- final int nextDownBits = Float
- .floatToIntBits(NEXTAFTER_FD_START_CASES[i][2]);
-
- for (int j = 0; j < NEXTAFTER_DD_FD_DIRECTION_CASES.length; j++) {
- final double direction = NEXTAFTER_DD_FD_DIRECTION_CASES[j];
- final int resultBits = Float.floatToIntBits(StrictMath
- .nextAfter(start, direction));
- if (direction > start) {
- assertEquals("Result should be next up-number.",
- nextUpBits, resultBits);
- } else if (direction < start) {
- assertEquals("Result should be next down-number.",
- nextDownBits, resultBits);
- } else {
- final int equivalentBits = Float.floatToIntBits(new Float(
- direction));
- assertEquals(
- "Result should be a number equivalent to direction.",
- equivalentBits, resultBits);
- }
- }
- }
-
- // test for cases with NaN
- for (int i = 0; i < NEXTAFTER_FD_START_CASES.length; i++) {
- assertTrue("The result should be NaN.", Float.isNaN(StrictMath
- .nextAfter(NEXTAFTER_FD_START_CASES[i][0], Float.NaN)));
- }
- for (int i = 0; i < NEXTAFTER_DD_FD_DIRECTION_CASES.length; i++) {
- assertTrue("The result should be NaN.", Float.isNaN(StrictMath
- .nextAfter(Float.NaN, NEXTAFTER_DD_FD_DIRECTION_CASES[i])));
- }
- assertTrue("The result should be NaN.", Float.isNaN(StrictMath
- .nextAfter(Float.NaN, Float.NaN)));
-
- // test for exception
- try {
- StrictMath.nextAfter((Float) null, 2.3);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.nextAfter(2.3, (Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.nextAfter((Float) null, (Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests {@link java.lang.StrictMath#nextUp(double)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_nextUp_D() {
- // This method is semantically equivalent to nextAfter(d,
- // Double.POSITIVE_INFINITY),
- // so we use the data of test_nextAfter_DD
- for (int i = 0; i < NEXTAFTER_DD_START_CASES.length; i++) {
- final double start = NEXTAFTER_DD_START_CASES[i][0];
- final long nextUpBits = Double
- .doubleToLongBits(NEXTAFTER_DD_START_CASES[i][1]);
- final long resultBits = Double.doubleToLongBits(StrictMath
- .nextUp(start));
- assertEquals("Result should be next up-number.", nextUpBits,
- resultBits);
- }
-
- // test for cases with NaN
- assertTrue("The result should be NaN.", Double.isNaN(StrictMath
- .nextUp(Double.NaN)));
-
- // test for exception
- try {
- StrictMath.nextUp((Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests {@link java.lang.StrictMath#nextUp(float)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_nextUp_F() {
- // This method is semantically equivalent to nextAfter(f,
- // Float.POSITIVE_INFINITY),
- // so we use the data of test_nextAfter_FD
- for (int i = 0; i < NEXTAFTER_FD_START_CASES.length; i++) {
- final float start = NEXTAFTER_FD_START_CASES[i][0];
- final int nextUpBits = Float
- .floatToIntBits(NEXTAFTER_FD_START_CASES[i][1]);
- final int resultBits = Float.floatToIntBits(StrictMath
- .nextUp(start));
- assertEquals("Result should be next up-number.", nextUpBits,
- resultBits);
- }
-
- // test for cases with NaN
- assertTrue("The result should be NaN.", Float.isNaN(StrictMath
- .nextUp(Float.NaN)));
-
- // test for exception
- try {
- StrictMath.nextUp((Float) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StrictMath#pow(double, double)
- */
- public void test_powDD() {
- // Test for method double java.lang.StrictMath.pow(double, double)
- assertTrue("pow returned incorrect value",
- (long) StrictMath.pow(2, 8) == 256l);
- assertTrue("pow returned incorrect value",
- StrictMath.pow(2, -8) == 0.00390625d);
- }
-
- /**
- * @tests java.lang.StrictMath#rint(double)
- */
- public void test_rintD() {
- // Test for method double java.lang.StrictMath.rint(double)
- assertEquals("Failed to round properly - up to odd",
- 3.0, StrictMath.rint(2.9), 0D);
- assertTrue("Failed to round properly - NaN", Double.isNaN(StrictMath
- .rint(Double.NaN)));
- assertEquals("Failed to round properly down to even", 2.0, StrictMath
- .rint(2.1), 0D);
- assertTrue("Failed to round properly " + 2.5 + " to even", StrictMath
- .rint(2.5) == 2.0);
- }
-
- /**
- * @tests java.lang.StrictMath#round(double)
- */
- public void test_roundD() {
- // Test for method long java.lang.StrictMath.round(double)
- assertEquals("Incorrect rounding of a float",
- -91, StrictMath.round(-90.89d));
- }
-
- /**
- * @tests java.lang.StrictMath#round(float)
- */
- public void test_roundF() {
- // Test for method int java.lang.StrictMath.round(float)
- assertEquals("Incorrect rounding of a float",
- -91, StrictMath.round(-90.89f));
- }
-
- /**
- * @tests {@link java.lang.StrictMath#scalb(double, int)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_scalb_DI() {
- // result is normal
- assertEquals(4.1422946304E7, StrictMath.scalb(1.2345, 25));
- assertEquals(3.679096698760986E-8, StrictMath.scalb(1.2345, -25));
- assertEquals(1.2345, StrictMath.scalb(1.2345, 0));
- assertEquals(7868514.304, StrictMath.scalb(0.2345, 25));
-
- double normal = StrictMath.scalb(0.2345, -25);
- assertEquals(6.98864459991455E-9, normal);
- // precision kept
- assertEquals(0.2345, StrictMath.scalb(normal, 25));
-
- assertEquals(0.2345, StrictMath.scalb(0.2345, 0));
- assertEquals(-4.1422946304E7, StrictMath.scalb(-1.2345, 25));
- assertEquals(-6.98864459991455E-9, StrictMath.scalb(-0.2345, -25));
- assertEquals(2.0, StrictMath.scalb(Double.MIN_NORMAL / 2, 1024));
- assertEquals(64.0, StrictMath.scalb(Double.MIN_VALUE, 1080));
- assertEquals(234, StrictMath.getExponent(StrictMath.scalb(1.0, 234)));
- assertEquals(3.9999999999999996, StrictMath.scalb(Double.MAX_VALUE,
- Double.MIN_EXPONENT));
-
- // result is near infinity
- double halfMax = StrictMath.scalb(1.0, Double.MAX_EXPONENT);
- assertEquals(8.98846567431158E307, halfMax);
- assertEquals(Double.MAX_VALUE, halfMax - StrictMath.ulp(halfMax)
- + halfMax);
- assertEquals(Double.POSITIVE_INFINITY, halfMax + halfMax);
- assertEquals(1.7976931348623155E308, StrictMath.scalb(1.0 - StrictMath
- .ulp(1.0), Double.MAX_EXPONENT + 1));
- assertEquals(Double.POSITIVE_INFINITY, StrictMath.scalb(
- 1.0 - StrictMath.ulp(1.0), Double.MAX_EXPONENT + 2));
-
- halfMax = StrictMath.scalb(-1.0, Double.MAX_EXPONENT);
- assertEquals(-8.98846567431158E307, halfMax);
- assertEquals(-Double.MAX_VALUE, halfMax + StrictMath.ulp(halfMax)
- + halfMax);
- assertEquals(Double.NEGATIVE_INFINITY, halfMax + halfMax);
-
- assertEquals(Double.POSITIVE_INFINITY, StrictMath.scalb(0.345, 1234));
- assertEquals(Double.POSITIVE_INFINITY, StrictMath
- .scalb(44.345E102, 934));
- assertEquals(Double.NEGATIVE_INFINITY, StrictMath.scalb(-44.345E102,
- 934));
-
- assertEquals(Double.POSITIVE_INFINITY, StrictMath.scalb(
- Double.MIN_NORMAL / 2, 4000));
- assertEquals(Double.POSITIVE_INFINITY, StrictMath.scalb(
- Double.MIN_VALUE, 8000));
- assertEquals(Double.POSITIVE_INFINITY, StrictMath.scalb(
- Double.MAX_VALUE, 1));
- assertEquals(Double.POSITIVE_INFINITY, StrictMath.scalb(
- Double.POSITIVE_INFINITY, 0));
- assertEquals(Double.POSITIVE_INFINITY, StrictMath.scalb(
- Double.POSITIVE_INFINITY, -1));
- assertEquals(Double.NEGATIVE_INFINITY, StrictMath.scalb(
- Double.NEGATIVE_INFINITY, -1));
- assertEquals(Double.NEGATIVE_INFINITY, StrictMath.scalb(
- Double.NEGATIVE_INFINITY, Double.MIN_EXPONENT));
-
- // result is subnormal/zero
- long posZeroBits = Double.doubleToLongBits(+0.0);
- long negZeroBits = Double.doubleToLongBits(-0.0);
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- +0.0, Integer.MAX_VALUE)));
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- +0.0, -123)));
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- +0.0, 0)));
- assertEquals(negZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- -0.0, 123)));
- assertEquals(negZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- -0.0, Integer.MIN_VALUE)));
-
- assertEquals(Double.MIN_VALUE, StrictMath.scalb(1.0, -1074));
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(1.0,
- -1075)));
- assertEquals(negZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- -1.0, -1075)));
-
- // precision lost
- assertEquals(StrictMath.scalb(21.405, -1078), StrictMath.scalb(21.405,
- -1079));
- assertEquals(Double.MIN_VALUE, StrictMath.scalb(21.405, -1079));
- assertEquals(-Double.MIN_VALUE, StrictMath.scalb(-21.405, -1079));
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- 21.405, -1080)));
- assertEquals(negZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- -21.405, -1080)));
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- Double.MIN_VALUE, -1)));
- assertEquals(negZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- -Double.MIN_VALUE, -1)));
- assertEquals(Double.MIN_VALUE, StrictMath.scalb(Double.MIN_NORMAL, -52));
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- Double.MIN_NORMAL, -53)));
- assertEquals(negZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- -Double.MIN_NORMAL, -53)));
- assertEquals(Double.MIN_VALUE, StrictMath
- .scalb(Double.MAX_VALUE, -2098));
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- Double.MAX_VALUE, -2099)));
- assertEquals(negZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- -Double.MAX_VALUE, -2099)));
- assertEquals(Double.MIN_VALUE, StrictMath.scalb(Double.MIN_NORMAL / 3,
- -51));
- assertEquals(posZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- Double.MIN_NORMAL / 3, -52)));
- assertEquals(negZeroBits, Double.doubleToLongBits(StrictMath.scalb(
- -Double.MIN_NORMAL / 3, -52)));
- double subnormal = StrictMath.scalb(Double.MIN_NORMAL / 3, -25);
- assertEquals(2.2104123E-316, subnormal);
- // precision lost
- assertFalse(Double.MIN_NORMAL / 3 == StrictMath.scalb(subnormal, 25));
-
- // NaN
- assertTrue(Double.isNaN(StrictMath.scalb(Double.NaN, 1)));
- assertTrue(Double.isNaN(StrictMath.scalb(Double.NaN, 0)));
- assertTrue(Double.isNaN(StrictMath.scalb(Double.NaN, -120)));
-
- assertEquals(1283457024, Double.doubleToLongBits(StrictMath.scalb(
- Double.MIN_VALUE * 153, 23)));
- assertEquals(-9223372035571318784L, Double.doubleToLongBits(StrictMath
- .scalb(-Double.MIN_VALUE * 153, 23)));
- assertEquals(36908406321184768L, Double.doubleToLongBits(StrictMath
- .scalb(Double.MIN_VALUE * 153, 52)));
- assertEquals(-9186463630533591040L, Double.doubleToLongBits(StrictMath
- .scalb(-Double.MIN_VALUE * 153, 52)));
-
- // test for exception
- try {
- StrictMath.scalb((Double) null, (Integer) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.scalb(1.0, (Integer) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.scalb((Double) null, 1);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests {@link java.lang.StrictMath#scalb(float, int)}
- * @since 1.6
- */
- @SuppressWarnings("boxing")
- public void test_scalb_FI() {
- // result is normal
- assertEquals(4.1422946304E7f, StrictMath.scalb(1.2345f, 25));
- assertEquals(3.679096698760986E-8f, StrictMath.scalb(1.2345f, -25));
- assertEquals(1.2345f, StrictMath.scalb(1.2345f, 0));
- assertEquals(7868514.304f, StrictMath.scalb(0.2345f, 25));
-
- float normal = StrictMath.scalb(0.2345f, -25);
- assertEquals(6.98864459991455E-9f, normal);
- // precision kept
- assertEquals(0.2345f, StrictMath.scalb(normal, 25));
-
- assertEquals(0.2345f, StrictMath.scalb(0.2345f, 0));
- assertEquals(-4.1422946304E7f, StrictMath.scalb(-1.2345f, 25));
- assertEquals(-6.98864459991455E-9f, StrictMath.scalb(-0.2345f, -25));
- assertEquals(2.0f, StrictMath.scalb(Float.MIN_NORMAL / 2, 128));
- assertEquals(64.0f, StrictMath.scalb(Float.MIN_VALUE, 155));
- assertEquals(34, StrictMath.getExponent(StrictMath.scalb(1.0f, 34)));
- assertEquals(3.9999998f, StrictMath.scalb(Float.MAX_VALUE,
- Float.MIN_EXPONENT));
-
- // result is near infinity
- float halfMax = StrictMath.scalb(1.0f, Float.MAX_EXPONENT);
- assertEquals(1.7014118E38f, halfMax);
- assertEquals(Float.MAX_VALUE, halfMax - StrictMath.ulp(halfMax)
- + halfMax);
- assertEquals(Float.POSITIVE_INFINITY, halfMax + halfMax);
- assertEquals(3.4028233E38f, StrictMath.scalb(1.0f - StrictMath
- .ulp(1.0f), Float.MAX_EXPONENT + 1));
- assertEquals(Float.POSITIVE_INFINITY, StrictMath.scalb(
- 1.0f - StrictMath.ulp(1.0f), Float.MAX_EXPONENT + 2));
-
- halfMax = StrictMath.scalb(-1.0f, Float.MAX_EXPONENT);
- assertEquals(-1.7014118E38f, halfMax);
- assertEquals(-Float.MAX_VALUE, halfMax + StrictMath.ulp(halfMax)
- + halfMax);
- assertEquals(Float.NEGATIVE_INFINITY, halfMax + halfMax);
-
- assertEquals(Float.POSITIVE_INFINITY, StrictMath.scalb(0.345f, 1234));
- assertEquals(Float.POSITIVE_INFINITY, StrictMath.scalb(44.345E10f, 934));
- assertEquals(Float.NEGATIVE_INFINITY, StrictMath
- .scalb(-44.345E10f, 934));
-
- assertEquals(Float.POSITIVE_INFINITY, StrictMath.scalb(
- Float.MIN_NORMAL / 2, 400));
- assertEquals(Float.POSITIVE_INFINITY, StrictMath.scalb(Float.MIN_VALUE,
- 800));
- assertEquals(Float.POSITIVE_INFINITY, StrictMath.scalb(Float.MAX_VALUE,
- 1));
- assertEquals(Float.POSITIVE_INFINITY, StrictMath.scalb(
- Float.POSITIVE_INFINITY, 0));
- assertEquals(Float.POSITIVE_INFINITY, StrictMath.scalb(
- Float.POSITIVE_INFINITY, -1));
- assertEquals(Float.NEGATIVE_INFINITY, StrictMath.scalb(
- Float.NEGATIVE_INFINITY, -1));
- assertEquals(Float.NEGATIVE_INFINITY, StrictMath.scalb(
- Float.NEGATIVE_INFINITY, Float.MIN_EXPONENT));
-
- // result is subnormal/zero
- int posZeroBits = Float.floatToIntBits(+0.0f);
- int negZeroBits = Float.floatToIntBits(-0.0f);
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(+0.0f,
- Integer.MAX_VALUE)));
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(+0.0f,
- -123)));
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(+0.0f,
- 0)));
- assertEquals(negZeroBits, Float.floatToIntBits(StrictMath.scalb(-0.0f,
- 123)));
- assertEquals(negZeroBits, Float.floatToIntBits(StrictMath.scalb(-0.0f,
- Integer.MIN_VALUE)));
-
- assertEquals(Float.MIN_VALUE, StrictMath.scalb(1.0f, -149));
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(1.0f,
- -150)));
- assertEquals(negZeroBits, Float.floatToIntBits(StrictMath.scalb(-1.0f,
- -150)));
-
- // precision lost
- assertEquals(StrictMath.scalb(21.405f, -154), StrictMath.scalb(21.405f,
- -153));
- assertEquals(Float.MIN_VALUE, StrictMath.scalb(21.405f, -154));
- assertEquals(-Float.MIN_VALUE, StrictMath.scalb(-21.405f, -154));
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(
- 21.405f, -155)));
- assertEquals(negZeroBits, Float.floatToIntBits(StrictMath.scalb(
- -21.405f, -155)));
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(
- Float.MIN_VALUE, -1)));
- assertEquals(negZeroBits, Float.floatToIntBits(StrictMath.scalb(
- -Float.MIN_VALUE, -1)));
- assertEquals(Float.MIN_VALUE, StrictMath.scalb(Float.MIN_NORMAL, -23));
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(
- Float.MIN_NORMAL, -24)));
- assertEquals(negZeroBits, Float.floatToIntBits(StrictMath.scalb(
- -Float.MIN_NORMAL, -24)));
- assertEquals(Float.MIN_VALUE, StrictMath.scalb(Float.MAX_VALUE, -277));
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(
- Float.MAX_VALUE, -278)));
- assertEquals(negZeroBits, Float.floatToIntBits(StrictMath.scalb(
- -Float.MAX_VALUE, -278)));
- assertEquals(Float.MIN_VALUE, StrictMath.scalb(Float.MIN_NORMAL / 3,
- -22));
- assertEquals(posZeroBits, Float.floatToIntBits(StrictMath.scalb(
- Float.MIN_NORMAL / 3, -23)));
- assertEquals(negZeroBits, Float.floatToIntBits(StrictMath.scalb(
- -Float.MIN_NORMAL / 3, -23)));
- float subnormal = StrictMath.scalb(Float.MIN_NORMAL / 3, -11);
- assertEquals(1.913E-42f, subnormal);
- // precision lost
- assertFalse(Float.MIN_NORMAL / 3 == StrictMath.scalb(subnormal, 11));
-
- assertEquals(68747264, Float.floatToIntBits(StrictMath.scalb(
- Float.MIN_VALUE * 153, 23)));
- assertEquals(-2078736384, Float.floatToIntBits(StrictMath.scalb(
- -Float.MIN_VALUE * 153, 23)));
-
- assertEquals(4896, Float.floatToIntBits(StrictMath.scalb(
- Float.MIN_VALUE * 153, 5)));
- assertEquals(-2147478752, Float.floatToIntBits(StrictMath.scalb(
- -Float.MIN_VALUE * 153, 5)));
-
- // NaN
- assertTrue(Float.isNaN(StrictMath.scalb(Float.NaN, 1)));
- assertTrue(Float.isNaN(StrictMath.scalb(Float.NaN, 0)));
- assertTrue(Float.isNaN(StrictMath.scalb(Float.NaN, -120)));
-
- // test for exception
- try {
- StrictMath.scalb((Float) null, (Integer) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.scalb(1.0f, (Integer) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- try {
- StrictMath.scalb((Float) null, 1);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StrictMath#signum(double)
- */
- public void test_signum_D() {
- assertTrue(Double.isNaN(StrictMath.signum(Double.NaN)));
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.signum(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.signum(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.signum(-0.0)));
-
- assertEquals(1.0, StrictMath.signum(253681.2187962), 0D);
- assertEquals(-1.0, StrictMath.signum(-125874693.56), 0D);
- assertEquals(1.0, StrictMath.signum(1.2587E-308), 0D);
- assertEquals(-1.0, StrictMath.signum(-1.2587E-308), 0D);
-
- assertEquals(1.0, StrictMath.signum(Double.MAX_VALUE), 0D);
- assertEquals(1.0, StrictMath.signum(Double.MIN_VALUE), 0D);
- assertEquals(-1.0, StrictMath.signum(-Double.MAX_VALUE), 0D);
- assertEquals(-1.0, StrictMath.signum(-Double.MIN_VALUE), 0D);
- assertEquals(1.0, StrictMath.signum(Double.POSITIVE_INFINITY), 0D);
- assertEquals(-1.0, StrictMath.signum(Double.NEGATIVE_INFINITY), 0D);
-
- }
-
- /**
- * @tests java.lang.StrictMath#signum(float)
- */
- public void test_signum_F() {
- assertTrue(Float.isNaN(StrictMath.signum(Float.NaN)));
- assertEquals(Float.floatToIntBits(0.0f), Float
- .floatToIntBits(StrictMath.signum(0.0f)));
- assertEquals(Float.floatToIntBits(+0.0f), Float
- .floatToIntBits(StrictMath.signum(+0.0f)));
- assertEquals(Float.floatToIntBits(-0.0f), Float
- .floatToIntBits(StrictMath.signum(-0.0f)));
-
- assertEquals(1.0f, StrictMath.signum(253681.2187962f), 0f);
- assertEquals(-1.0f, StrictMath.signum(-125874693.56f), 0f);
- assertEquals(1.0f, StrictMath.signum(1.2587E-11f), 0f);
- assertEquals(-1.0f, StrictMath.signum(-1.2587E-11f), 0f);
-
- assertEquals(1.0f, StrictMath.signum(Float.MAX_VALUE), 0f);
- assertEquals(1.0f, StrictMath.signum(Float.MIN_VALUE), 0f);
- assertEquals(-1.0f, StrictMath.signum(-Float.MAX_VALUE), 0f);
- assertEquals(-1.0f, StrictMath.signum(-Float.MIN_VALUE), 0f);
- assertEquals(1.0f, StrictMath.signum(Float.POSITIVE_INFINITY), 0f);
- assertEquals(-1.0f, StrictMath.signum(Float.NEGATIVE_INFINITY), 0f);
- }
-
- /**
- * @tests java.lang.StrictMath#sin(double)
- */
- public void test_sinD() {
- // Test for method double java.lang.StrictMath.sin(double)
- assertTrue("Returned incorrect sine", StrictMath.sin(StrictMath
- .asin(OPP / HYP)) == OPP / HYP);
- }
-
- /**
- * @tests java.lang.StrictMath#sinh(double)
- */
- public void test_sinh_D() {
- // Test for special situations
- assertTrue(Double.isNaN(StrictMath.sinh(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .sinh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath
- .sinh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.sinh(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.sinh(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.sinh(-0.0)));
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.sinh(1234.56), 0D);
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath.sinh(-1234.56), 0D);
- assertEquals("Should return 1.0000000000001666E-6",
- 1.0000000000001666E-6, StrictMath.sinh(0.000001), 0D);
- assertEquals("Should return -1.0000000000001666E-6",
- -1.0000000000001666E-6, StrictMath.sinh(-0.000001), 0D);
- assertEquals("Should return 5.115386441963859", 5.115386441963859,
- StrictMath.sinh(2.33482), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.sinh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 4.9E-324", 4.9E-324, StrictMath
- .sinh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.StrictMath#sqrt(double)
- */
- public void test_sqrtD() {
- // Test for method double java.lang.StrictMath.sqrt(double)
- assertEquals("Incorrect root returned1",
- 2, StrictMath.sqrt(StrictMath.pow(StrictMath.sqrt(2), 4)), 0.0);
- assertEquals("Incorrect root returned2", 7, StrictMath.sqrt(49), 0.0);
- }
-
- /**
- * @tests java.lang.StrictMath#tan(double)
- */
- public void test_tanD() {
- // Test for method double java.lang.StrictMath.tan(double)
- assertTrue(
- "Returned incorrect tangent: ",
- StrictMath.tan(StrictMath.atan(1.0)) <= 1.0
- || StrictMath.tan(StrictMath.atan(1.0)) >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.StrictMath#tanh(double)
- */
- public void test_tanh_D() {
- // Test for special situations
- assertTrue(Double.isNaN(StrictMath.tanh(Double.NaN)));
- assertEquals("Should return +1.0", +1.0, StrictMath
- .tanh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return -1.0", -1.0, StrictMath
- .tanh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.tanh(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.tanh(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.tanh(-0.0)));
-
- assertEquals("Should return 1.0", 1.0, StrictMath.tanh(1234.56), 0D);
- assertEquals("Should return -1.0", -1.0, StrictMath.tanh(-1234.56), 0D);
- assertEquals("Should return 9.999999999996666E-7",
- 9.999999999996666E-7, StrictMath.tanh(0.000001), 0D);
- assertEquals("Should return 0.981422884124941", 0.981422884124941,
- StrictMath.tanh(2.33482), 0D);
- assertEquals("Should return 1.0", 1.0, StrictMath
- .tanh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 4.9E-324", 4.9E-324, StrictMath
- .tanh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.StrictMath#random()
- */
- public void test_random() {
- // There isn't a place for these tests so just stick them here
- assertEquals("Wrong value E",
- 4613303445314885481L, Double.doubleToLongBits(StrictMath.E));
- assertEquals("Wrong value PI",
- 4614256656552045848L, Double.doubleToLongBits(StrictMath.PI));
-
- for (int i = 500; i >= 0; i--) {
- double d = StrictMath.random();
- assertTrue("Generated number is out of range: " + d, d >= 0.0
- && d < 1.0);
- }
- }
-
- /**
- * @tests java.lang.StrictMath#toRadians(double)
- */
- public void test_toRadiansD() {
- for (double d = 500; d >= 0; d -= 1.0) {
- double converted = StrictMath.toDegrees(StrictMath.toRadians(d));
- assertTrue("Converted number not equal to original. d = " + d,
- converted >= d * 0.99999999 && converted <= d * 1.00000001);
- }
- }
-
- /**
- * @tests java.lang.StrictMath#toDegrees(double)
- */
- public void test_toDegreesD() {
- for (double d = 500; d >= 0; d -= 1.0) {
- double converted = StrictMath.toRadians(StrictMath.toDegrees(d));
- assertTrue("Converted number not equal to original. d = " + d,
- converted >= d * 0.99999999 && converted <= d * 1.00000001);
- }
- }
-
- /**
- * @tests java.lang.StrictMath#ulp(double)
- */
- @SuppressWarnings("boxing")
- public void test_ulp_D() {
- // Test for special cases
- assertTrue("Should return NaN", Double
- .isNaN(StrictMath.ulp(Double.NaN)));
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY,
- StrictMath.ulp(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY,
- StrictMath.ulp(Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(0.0), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(+0.0), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(-0.0), 0D);
- assertEquals("Returned incorrect value", StrictMath.pow(2, 971),
- StrictMath.ulp(Double.MAX_VALUE), 0D);
- assertEquals("Returned incorrect value", StrictMath.pow(2, 971),
- StrictMath.ulp(-Double.MAX_VALUE), 0D);
-
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(Double.MIN_VALUE), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(-Double.MIN_VALUE), 0D);
-
- assertEquals("Returned incorrect value", 2.220446049250313E-16,
- StrictMath.ulp(1.0), 0D);
- assertEquals("Returned incorrect value", 2.220446049250313E-16,
- StrictMath.ulp(-1.0), 0D);
- assertEquals("Returned incorrect value", 2.2737367544323206E-13,
- StrictMath.ulp(1153.0), 0D);
- }
-
- /**
- * @tests java.lang.StrictMath#ulp(float)
- */
- @SuppressWarnings("boxing")
- public void test_ulp_f() {
- // Test for special cases
- assertTrue("Should return NaN", Float.isNaN(StrictMath.ulp(Float.NaN)));
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY,
- StrictMath.ulp(Float.POSITIVE_INFINITY), 0f);
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY,
- StrictMath.ulp(Float.NEGATIVE_INFINITY), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, StrictMath
- .ulp(0.0f), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, StrictMath
- .ulp(+0.0f), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, StrictMath
- .ulp(-0.0f), 0f);
- assertEquals("Returned incorrect value", 2.028241E31f, StrictMath
- .ulp(Float.MAX_VALUE), 0f);
- assertEquals("Returned incorrect value", 2.028241E31f, StrictMath
- .ulp(-Float.MAX_VALUE), 0f);
-
- assertEquals("Returned incorrect value", 1.4E-45f, StrictMath
- .ulp(Float.MIN_VALUE), 0f);
- assertEquals("Returned incorrect value", 1.4E-45f, StrictMath
- .ulp(-Float.MIN_VALUE), 0f);
-
- assertEquals("Returned incorrect value", 1.1920929E-7f, StrictMath
- .ulp(1.0f), 0f);
- assertEquals("Returned incorrect value", 1.1920929E-7f, StrictMath
- .ulp(-1.0f), 0f);
- assertEquals("Returned incorrect value", 1.2207031E-4f, StrictMath
- .ulp(1153.0f), 0f);
- assertEquals("Returned incorrect value", 5.6E-45f, Math
- .ulp(9.403954E-38f), 0f);
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java
deleted file mode 100644
index 0fa41b9..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuffer2Test.java
+++ /dev/null
@@ -1,1106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-@TestTargetClass(StringBuffer.class)
-public class StringBuffer2Test extends junit.framework.TestCase {
-
- StringBuffer testBuffer;
-
- /**
- * @tests java.lang.StringBuffer#StringBuffer()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "StringBuffer",
- args = {}
- )
- public void test_Constructor() {
- // Test for method java.lang.StringBuffer()
- new StringBuffer();
- assertTrue("Invalid buffer created", true);
- }
-
- /**
- * @tests java.lang.StringBuffer#StringBuffer(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "StringBuffer",
- args = {int.class}
- )
- public void test_ConstructorI() {
- // Test for method java.lang.StringBuffer(int)
- StringBuffer sb = new StringBuffer(8);
- assertEquals("Newly constructed buffer is of incorrect length", 0, sb
- .length());
- }
-
- /**
- * @tests java.lang.StringBuffer#StringBuffer(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "StringBuffer",
- args = {java.lang.String.class}
- )
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.lang.StringBuffer(java.lang.String)
-
- StringBuffer sb = new StringBuffer("HelloWorld");
-
- assertTrue("Invalid buffer created", sb.length() == 10
- && (sb.toString().equals("HelloWorld")));
-
- boolean pass = false;
- try {
- new StringBuffer(null);
- } catch (NullPointerException e) {
- pass = true;
- }
- assertTrue("Should throw NullPointerException", pass);
- }
-
- /**
- * @tests java.lang.StringBuffer#append(char[])
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {char[].class}
- )
- public void test_append$C() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(char [])
- char buf[] = new char[4];
- "char".getChars(0, 4, buf, 0);
- testBuffer.append(buf);
- assertEquals("Append of char[] failed",
- "This is a test bufferchar", testBuffer.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer#append(char[], int, int)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "",
- method = "append",
- args = {char[].class, int.class, int.class}
- )
- public void test_append$CII() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(char [], int, int)
- StringBuffer sb = new StringBuffer();
- char[] buf1 = { 'H', 'e', 'l', 'l', 'o' };
- char[] buf2 = { 'W', 'o', 'r', 'l', 'd' };
- sb.append(buf1, 0, buf1.length);
- assertEquals("Buffer is invalid length after append", 5, sb.length());
- sb.append(buf2, 0, buf2.length);
- assertEquals("Buffer is invalid length after append", 10, sb.length());
- assertTrue("Buffer contains invalid chars", (sb.toString()
- .equals("HelloWorld")));
- }
-
- /**
- * @tests java.lang.StringBuffer#append(char)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {char.class}
- )
- public void test_appendC() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(char)
- StringBuffer sb = new StringBuffer();
- char buf1 = 'H';
- char buf2 = 'W';
- sb.append(buf1);
- assertEquals("Buffer is invalid length after append", 1, sb.length());
- sb.append(buf2);
- assertEquals("Buffer is invalid length after append", 2, sb.length());
- assertTrue("Buffer contains invalid chars",
- (sb.toString().equals("HW")));
- }
-
- /**
- * @tests java.lang.StringBuffer#append(double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {double.class}
- )
- public void test_appendD() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(double)
- StringBuffer sb = new StringBuffer();
- sb.append(Double.MAX_VALUE);
- assertEquals("Buffer is invalid length after append", 22, sb.length());
- assertEquals("Buffer contains invalid characters",
- "1.7976931348623157E308", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer#append(float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {float.class}
- )
- public void test_appendF() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(float)
- StringBuffer sb = new StringBuffer();
- final float floatNum = 900.87654F;
- sb.append(floatNum);
- assertTrue("Buffer is invalid length after append: " + sb.length(), sb
- .length() == String.valueOf(floatNum).length());
- assertTrue("Buffer contains invalid characters", sb.toString().equals(
- String.valueOf(floatNum)));
- }
-
- /**
- * @tests java.lang.StringBuffer#append(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {int.class}
- )
- public void test_appendI() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(int)
- StringBuffer sb = new StringBuffer();
- sb.append(9000);
- assertEquals("Buffer is invalid length after append", 4, sb.length());
- sb.append(1000);
- assertEquals("Buffer is invalid length after append", 8, sb.length());
- assertEquals("Buffer contains invalid characters",
- "90001000", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer#append(long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {long.class}
- )
- public void test_appendJ() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(long)
-
- StringBuffer sb = new StringBuffer();
- long t = 927654321098L;
- sb.append(t);
- assertEquals("Buffer is of invlaid length", 12, sb.length());
- assertEquals("Buffer contains invalid characters",
- "927654321098", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer#append(java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {java.lang.Object.class}
- )
- public void test_appendLjava_lang_Object() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(java.lang.Object)
- StringBuffer sb = new StringBuffer();
- Object obj1 = new Object();
- Object obj2 = new Object();
- sb.append(obj1);
- sb.append(obj2);
- assertTrue("Buffer contains invalid characters", sb.toString().equals(
- obj1.toString() + obj2.toString()));
- }
-
- /**
- * @tests java.lang.StringBuffer#append(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {java.lang.String.class}
- )
- public void test_appendLjava_lang_String() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(java.lang.String)
- StringBuffer sb = new StringBuffer();
- String buf1 = "Hello";
- String buf2 = "World";
- sb.append(buf1);
- assertEquals("Buffer is invalid length after append", 5, sb.length());
- sb.append(buf2);
- assertEquals("Buffer is invalid length after append", 10, sb.length());
- assertTrue("Buffer contains invalid chars", (sb.toString()
- .equals("HelloWorld")));
- }
-
- /**
- * @tests java.lang.StringBuffer#append(boolean)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "append",
- args = {boolean.class}
- )
- public void test_appendZ() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.append(boolean)
- StringBuffer sb = new StringBuffer();
- sb.append(false);
- assertEquals("Buffer is invalid length after append", 5, sb.length());
- sb.append(true);
- assertEquals("Buffer is invalid length after append", 9, sb.length());
- assertTrue("Buffer is invalid length after append", (sb.toString()
- .equals("falsetrue")));
- }
-
- /**
- * @tests java.lang.StringBuffer#capacity()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "capacity",
- args = {}
- )
- public void test_capacity() {
- // Test for method int java.lang.StringBuffer.capacity()
- StringBuffer sb = new StringBuffer(10);
- assertEquals("Returned incorrect capacity", 10, sb.capacity());
- sb.ensureCapacity(100);
- assertTrue("Returned incorrect capacity", sb.capacity() >= 100);
- }
-
- /**
- * @tests java.lang.StringBuffer#charAt(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "charAt",
- args = {int.class}
- )
- public void test_charAtI() {
- // Test for method char java.lang.StringBuffer.charAt(int)
- assertEquals("Returned incorrect char", 's', testBuffer.charAt(3));
-
- // Test for StringIndexOutOfBoundsException
- boolean exception = false;
- try {
- testBuffer.charAt(-1);
- } catch (StringIndexOutOfBoundsException e) {
- exception = true;
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- assertTrue("Should throw StringIndexOutOfBoundsException", exception);
- }
-
- /**
- * @tests java.lang.StringBuffer#delete(int, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "delete",
- args = {int.class, int.class}
- )
- public void test_deleteII() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.delete(int, int)
- testBuffer.delete(7, 7);
- assertEquals("Deleted chars when start == end", "This is a test buffer", testBuffer.toString()
- );
- testBuffer.delete(4, 14);
- assertEquals("Deleted incorrect chars",
- "This buffer", testBuffer.toString());
-
- testBuffer = new StringBuffer("This is a test buffer");
- String sharedStr = testBuffer.toString();
- testBuffer.delete(0, testBuffer.length());
- assertEquals("Didn't clone shared buffer", "This is a test buffer", sharedStr
- );
- assertTrue("Deleted incorrect chars", testBuffer.toString().equals(""));
- testBuffer.append("more stuff");
- assertEquals("Didn't clone shared buffer 2", "This is a test buffer", sharedStr
- );
- assertEquals("Wrong contents", "more stuff", testBuffer.toString());
- try {
- testBuffer.delete(-5, 2);
- } catch (IndexOutOfBoundsException e) {
- }
- assertEquals("Wrong contents 2",
- "more stuff", testBuffer.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer#deleteCharAt(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "deleteCharAt",
- args = {int.class}
- )
- public void test_deleteCharAtI() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.deleteCharAt(int)
- testBuffer.deleteCharAt(3);
- assertEquals("Deleted incorrect char",
- "Thi is a test buffer", testBuffer.toString());
- try {
- testBuffer.deleteCharAt(testBuffer.length() + 1);
- fail("StringIndexOutOfBoundsException was not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.deleteCharAt(-1);
- fail("StringIndexOutOfBoundsException was not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#ensureCapacity(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "ensureCapacity",
- args = {int.class}
- )
- public void test_ensureCapacityI() {
- // Test for method void java.lang.StringBuffer.ensureCapacity(int)
- StringBuffer sb = new StringBuffer(10);
-
- sb.ensureCapacity(-2);
- assertEquals("Failed to increase capacity.", 10, sb.capacity());
-
- sb.ensureCapacity(100);
- assertTrue("Failed to increase capacity", sb.capacity() >= 100);
-
- try {
- sb.ensureCapacity(Integer.MAX_VALUE);
- fail("OutOfMemoryError should be thrown.");
- } catch(java.lang.OutOfMemoryError oome) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#getChars(int, int, char[], int)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "Doesn't check exceptions.",
- method = "getChars",
- args = {int.class, int.class, char[].class, int.class}
- )
- public void test_getCharsII$CI() {
- // Test for method void java.lang.StringBuffer.getChars(int, int, char
- // [], int)
-
- char[] buf = new char[10];
- testBuffer.getChars(4, 8, buf, 2);
- assertTrue("Returned incorrect chars", new String(buf, 2, 4)
- .equals(testBuffer.toString().substring(4, 8)));
-
- StringBuffer buf2 = new StringBuffer("");
- try {
- buf2.getChars(-1, 0, new char[5], 2);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
- }
-
- try {
- buf2.getChars(0, -1, new char[5], 2);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
- }
-
- try {
- buf2.getChars(0, -1, new char[5], 2);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
- }
-
- try {
- buf2.getChars(2, 1, new char[5], 2);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
- }
-
- try {
- buf2.getChars(0, 6, new char[5], 2);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
- }
-
- try {
- buf2.getChars(0, 6, new char[10], 5);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch (IndexOutOfBoundsException e) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, char[])
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, char[].class}
- )
- public void test_insertI$C() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, char [])
- char buf[] = new char[4];
- "char".getChars(0, 4, buf, 0);
- testBuffer.insert(15, buf);
- assertEquals("Insert test failed",
- "This is a test charbuffer", testBuffer.toString());
-
- boolean exception = false;
- StringBuffer buf1 = new StringBuffer("abcd");
- try {
- buf1.insert(-1, (char[]) null);
- } catch (StringIndexOutOfBoundsException e) {
- exception = true;
- } catch (NullPointerException e) {
- }
- assertTrue("Should throw StringIndexOutOfBoundsException", exception);
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, char[], int, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, char[].class, int.class, int.class}
- )
- public void test_insertI$CII() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, char [], int, int)
- char[] c = new char[] { 'n', 'o', 't', ' ' };
- testBuffer.insert(8, c, 0, 4);
- assertEquals("This is not a test buffer", testBuffer.toString());
-
- StringBuffer buf1 = new StringBuffer("abcd");
- try {
- buf1.insert(-1, (char[]) null, 0, 0);
- fail("Should throw StringIndexOutOfBoundsException");
- } catch (StringIndexOutOfBoundsException e) {
- //expected
- }
-
- try {
- testBuffer.insert(testBuffer.length() - 1, c, -1, 1);
- } catch (StringIndexOutOfBoundsException e) {
- //expected
- }
-
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, char)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "IndexOutOfBoundsException is not verified.",
- method = "insert",
- args = {int.class, char.class}
- )
- public void test_insertIC() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, char)
- testBuffer.insert(15, 'T');
- assertEquals("Insert test failed",
- "This is a test Tbuffer", testBuffer.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, double)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, double.class}
- )
- public void test_insertID() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, double)
- testBuffer.insert(15, Double.MAX_VALUE);
- assertTrue("Insert test failed", testBuffer.toString().equals(
- "This is a test " + Double.MAX_VALUE + "buffer"));
- try {
- testBuffer.insert(-1, Double.MAX_VALUE);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.insert(testBuffer.length() + 1, Double.MAX_VALUE);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, float)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, float.class}
- )
- public void test_insertIF() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, float)
- testBuffer.insert(15, Float.MAX_VALUE);
- String testBufferString = testBuffer.toString();
- String expectedResult = "This is a test "
- + String.valueOf(Float.MAX_VALUE) + "buffer";
- assertTrue("Insert test failed, got: " + "\'" + testBufferString + "\'"
- + " but wanted: " + "\'" + expectedResult + "\'",
- testBufferString.equals(expectedResult));
-
- try {
- testBuffer.insert(-1, Float.MAX_VALUE);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.insert(testBuffer.length() + 1, Float.MAX_VALUE);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, int.class}
- )
- public void test_insertII() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, int)
- testBuffer.insert(15, 100);
- assertEquals("Insert test failed",
- "This is a test 100buffer", testBuffer.toString());
-
- try {
- testBuffer.insert(-1, Integer.MAX_VALUE);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.insert(testBuffer.length() + 1, Integer.MAX_VALUE);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, long)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, long.class}
- )
- public void test_insertIJ() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, long)
- testBuffer.insert(15, 88888888888888888L);
- assertEquals("Insert test failed",
- "This is a test 88888888888888888buffer", testBuffer.toString());
-
- try {
- testBuffer.insert(-1, Long.MAX_VALUE);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.insert(testBuffer.length() + 1, Long.MAX_VALUE);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, java.lang.Object.class}
- )
- public void test_insertILjava_lang_Object() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, java.lang.Object)
- Object obj1 = new Object();
- testBuffer.insert(15, obj1);
- assertTrue("Insert test failed", testBuffer.toString().equals(
- "This is a test " + obj1.toString() + "buffer"));
-
- try {
- testBuffer.insert(-1, obj1);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.insert(testBuffer.length() + 1, obj1);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, java.lang.String.class}
- )
- public void test_insertILjava_lang_String() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, java.lang.String)
-
- testBuffer.insert(15, "STRING ");
- assertEquals("Insert test failed",
- "This is a test STRING buffer", testBuffer.toString());
-
- try {
- testBuffer.insert(-1, "");
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.insert(testBuffer.length() + 1, "");
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#insert(int, boolean)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "insert",
- args = {int.class, boolean.class}
- )
- public void test_insertIZ() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.insert(int, boolean)
- testBuffer.insert(15, true);
- assertEquals("Insert test failed",
- "This is a test truebuffer", testBuffer.toString());
- try {
- testBuffer.insert(testBuffer.length() + 1, true);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.insert(-1, true);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#length()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "length",
- args = {}
- )
- public void test_length() {
- // Test for method int java.lang.StringBuffer.length()
- assertEquals("Incorrect length returned", 21, testBuffer.length());
- }
-
- /**
- * @tests java.lang.StringBuffer#replace(int, int, java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "replace",
- args = {int.class, int.class, java.lang.String.class}
- )
- public void test_replaceIILjava_lang_String() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.replace(int, int, java.lang.String)
- testBuffer.replace(5, 9, "is a replaced");
- assertTrue("Replace failed, wanted: " + "\'"
- + "This is a replaced test buffer" + "\'" + " but got: " + "\'"
- + testBuffer.toString() + "\'", testBuffer.toString().equals(
- "This is a replaced test buffer"));
- assertEquals("insert1", "text", new StringBuffer().replace(0, 0, "text")
- .toString());
- assertEquals("insert2", "123text", new StringBuffer("123").replace(3, 3, "text")
- .toString());
- assertEquals("insert2", "1text23", new StringBuffer("123").replace(1, 1, "text")
- .toString());
-
- try {
- testBuffer.replace(-1, 0, "text");
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.replace(0, -1, "text");
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.replace(2, 1, "text");
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
-
- try {
- testBuffer.replace(testBuffer.length() + 1, testBuffer.length() + 1,
- "text");
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException sioobe) {
- //expected
- }
- }
-
- private String writeString(String in) {
- StringBuffer result = new StringBuffer();
- result.append("\"");
- for (int i = 0; i < in.length(); i++) {
- result.append(" 0x" + Integer.toHexString(in.charAt(i)));
- }
- result.append("\"");
- return result.toString();
- }
-
- private void reverseTest(String id, String org, String rev, String back) {
- // create non-shared StringBuffer
- StringBuffer sb = new StringBuffer(org);
- sb.reverse();
- String reversed = sb.toString();
- assertTrue("reversed surrogate " + id + ": " + writeString(reversed),
- reversed.equals(rev));
- // create non-shared StringBuffer
- sb = new StringBuffer(reversed);
- sb.reverse();
- reversed = sb.toString();
- assertTrue("reversed surrogate " + id + "a: " + writeString(reversed),
- reversed.equals(back));
-
- // test algorithm when StringBuffer is shared
- sb = new StringBuffer(org);
- String copy = sb.toString();
- assertEquals(org, copy);
- sb.reverse();
- reversed = sb.toString();
- assertTrue("reversed surrogate " + id + ": " + writeString(reversed),
- reversed.equals(rev));
- sb = new StringBuffer(reversed);
- copy = sb.toString();
- assertEquals(rev, copy);
- sb.reverse();
- reversed = sb.toString();
- assertTrue("reversed surrogate " + id + "a: " + writeString(reversed),
- reversed.equals(back));
-
- }
-
- /**
- * @tests java.lang.StringBuffer#reverse()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "reverse",
- args = {}
- )
- public void test_reverse() {
- // Test for method java.lang.StringBuffer
- // java.lang.StringBuffer.reverse()
- String org;
- org = "a";
- reverseTest("0", org, org, org);
-
- org = "ab";
- reverseTest("1", org, "ba", org);
-
- org = "abcdef";
- reverseTest("2", org, "fedcba", org);
-
- org = "abcdefg";
- reverseTest("3", org, "gfedcba", org);
-
- }
-
- /**
- * @tests java.lang.StringBuffer#setCharAt(int, char)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "setCharAt",
- args = {int.class, char.class}
- )
- public void test_setCharAtIC() {
- // Test for method void java.lang.StringBuffer.setCharAt(int, char)
- StringBuffer s = new StringBuffer("HelloWorld");
- s.setCharAt(4, 'Z');
- assertEquals("Returned incorrect char", 'Z', s.charAt(4));
-
- try {
- s.setCharAt(-1, 'Z');
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
- try {
- s.setCharAt(s.length() + 1, 'Z');
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#setLength(int)
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL_COMPLETE,
- notes = "IndexOutOfBoundsException is not verified.",
- method = "setLength",
- args = {int.class}
- )
- public void test_setLengthI() {
- // Test for method void java.lang.StringBuffer.setLength(int)
- testBuffer.setLength(1000);
- assertEquals("Failed to increase length", 1000, testBuffer.length());
- assertTrue("Increase in length trashed buffer", testBuffer.toString()
- .startsWith("This is a test buffer"));
- testBuffer.setLength(2);
- assertEquals("Failed to decrease length", 2, testBuffer.length());
- assertEquals("Decrease in length failed",
- "Th", testBuffer.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer#substring(int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "substring",
- args = {int.class}
- )
- public void test_substringI() {
- // Test for method java.lang.String
- // java.lang.StringBuffer.substring(int)
- assertEquals("Returned incorrect substring", "is a test buffer",
- testBuffer.substring(5));
-
- try {
- testBuffer.substring(testBuffer.length() + 1);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException oobe) {
- //expected
- }
-
- try {
- testBuffer.substring(-1);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException oobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#substring(int, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "substring",
- args = {int.class, int.class}
- )
- public void test_substringII() {
- // Test for method java.lang.String
- // java.lang.StringBuffer.substring(int, int)
- assertEquals("Returned incorrect substring", "is",
- testBuffer.substring(5, 7));
-
- try {
- testBuffer.substring(-1, testBuffer.length());
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException oobe) {
- //expected
- }
-
- try {
- testBuffer.substring(0, -1);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException oobe) {
- //expected
- }
-
- try {
- testBuffer.substring(2, 1);
- fail("StringIndexOutOfBoundsException is not thrown.");
- } catch(StringIndexOutOfBoundsException oobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() {
- // Test for method java.lang.String java.lang.StringBuffer.toString()
- assertEquals("Incorrect string value returned", "This is a test buffer", testBuffer.toString()
- );
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "subSequence",
- args = {int.class, int.class}
- )
- public void test_subSequence() {
-
- assertEquals("Incorrect substring returned", " is",
- testBuffer.subSequence(4, 7));
- assertEquals("Incorrect substring returned", "test buffer",
- testBuffer.subSequence(10, 21));
- assertEquals("not identical", "This is a test buffer",
- testBuffer.subSequence(0, testBuffer.length()));
-
- try {
- testBuffer.subSequence(0, Integer.MAX_VALUE);
- fail("IndexOutOfBoundsException was not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- testBuffer.subSequence(Integer.MAX_VALUE, testBuffer.length());
- fail("IndexOutOfBoundsException was not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- testBuffer.subSequence(-1, testBuffer.length());
- fail("IndexOutOfBoundsException was not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
- }
-
- @Override
- protected void setUp() {
- testBuffer = new StringBuffer("This is a test buffer");
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java
deleted file mode 100644
index c5499e7..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBufferTest.java
+++ /dev/null
@@ -1,622 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.Serializable;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-public class StringBufferTest extends TestCase {
-
- /**
- * @tests java.lang.StringBuffer#setLength(int)
- */
- public void test_setLengthI() {
- // Regression for HARMONY-90
- StringBuffer buffer = new StringBuffer("abcde");
- try {
- buffer.setLength(-1);
- fail("Assert 0: IndexOutOfBoundsException must be thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- assertEquals("abcde", buffer.toString());
- buffer.setLength(1);
- buffer.append('f');
- assertEquals("af", buffer.toString());
-
- buffer = new StringBuffer("abcde");
- assertEquals("cde", buffer.substring(2));
- buffer.setLength(3);
- buffer.append('f');
- assertEquals("abcf", buffer.toString());
-
- buffer = new StringBuffer("abcde");
- buffer.setLength(2);
- try {
- buffer.charAt(3);
- fail("should throw IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- buffer = new StringBuffer();
- buffer.append("abcdefg");
- buffer.setLength(2);
- buffer.setLength(5);
- for (int i = 2; i < 5; i++) {
- assertEquals(0, buffer.charAt(i));
- }
-
- buffer = new StringBuffer();
- buffer.append("abcdefg");
- buffer.delete(2, 4);
- buffer.setLength(7);
- assertEquals('a', buffer.charAt(0));
- assertEquals('b', buffer.charAt(1));
- assertEquals('e', buffer.charAt(2));
- assertEquals('f', buffer.charAt(3));
- assertEquals('g', buffer.charAt(4));
- for (int i = 5; i < 7; i++) {
- assertEquals(0, buffer.charAt(i));
- }
-
- buffer = new StringBuffer();
- buffer.append("abcdefg");
- buffer.replace(2, 5, "z");
- buffer.setLength(7);
- for (int i = 5; i < 7; i++) {
- assertEquals(0, buffer.charAt(i));
- }
- }
-
- /**
- * @tests java.lang.StringBuffer#toString()
- */
- public void test_toString() throws Exception {
- StringBuffer buffer = new StringBuffer();
- assertEquals("", buffer.toString());
-
- buffer.append("abcde");
- assertEquals("abcde", buffer.toString());
- buffer.setLength(1000);
- byte[] bytes = buffer.toString().getBytes("GB18030");
- for (int i = 5; i < bytes.length; i++) {
- assertEquals(0, bytes[i]);
- }
-
- buffer.setLength(5);
- buffer.append("fghij");
- assertEquals("abcdefghij", buffer.toString());
- }
-
- /**
- * @tests StringBuffer.StringBuffer(CharSequence);
- */
- public void test_constructorLjava_lang_CharSequence() {
- try {
- new StringBuffer((CharSequence) null);
- fail("Assert 0: NPE must be thrown.");
- } catch (NullPointerException e) {}
-
- assertEquals("Assert 1: must equal 'abc'.", "abc", new StringBuffer((CharSequence)"abc").toString());
- }
-
- public void test_trimToSize() {
- StringBuffer buffer = new StringBuffer(25);
- buffer.append("abc");
- int origCapacity = buffer.capacity();
- buffer.trimToSize();
- int trimCapacity = buffer.capacity();
- assertTrue("Assert 0: capacity must be smaller.", trimCapacity < origCapacity);
- assertEquals("Assert 1: length must still be 3", 3, buffer.length());
- assertEquals("Assert 2: value must still be 'abc'.", "abc", buffer.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer.append(CharSequence)
- */
- public void test_appendLjava_lang_CharSequence() {
- StringBuffer sb = new StringBuffer();
- assertSame(sb, sb.append((CharSequence) "ab"));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) "cd"));
- assertEquals("cd", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) null));
- assertEquals("null", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer.append(CharSequence, int, int)
- */
- @SuppressWarnings("cast")
- public void test_appendLjava_lang_CharSequenceII() {
- StringBuffer sb = new StringBuffer();
- assertSame(sb, sb.append((CharSequence) "ab", 0, 2));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) "cd", 0, 2));
- assertEquals("cd", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) "abcd", 0, 2));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) "abcd", 2, 4));
- assertEquals("cd", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) null, 0, 2));
- assertEquals("nu", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer.append(char[], int, int)
- */
- public void test_append$CII_2() {
- StringBuffer obj = new StringBuffer();
- try {
- obj.append(new char[0], -1, -1);
- fail("ArrayIndexOutOfBoundsException expected");
- } catch (ArrayIndexOutOfBoundsException e) {
- // expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.append(char[], int, int)
- */
- public void test_append$CII_3() throws Exception {
- StringBuffer obj = new StringBuffer();
- try {
- obj.append((char[]) null, -1, -1);
- fail("NullPointerException expected");
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.insert(int, CharSequence)
- */
- public void test_insertILjava_lang_CharSequence() {
- final String fixture = "0000";
- StringBuffer sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(0, (CharSequence) "ab"));
- assertEquals("ab0000", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(2, (CharSequence) "ab"));
- assertEquals("00ab00", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) "ab"));
- assertEquals("0000ab", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) null));
- assertEquals("0000null", sb.toString());
- assertEquals(8, sb.length());
-
- try {
- sb = new StringBuffer(fixture);
- sb.insert(-1, (CharSequence) "ab");
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuffer(fixture);
- sb.insert(5, (CharSequence) "ab");
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.insert(int, CharSequence, int, int)
- */
- @SuppressWarnings("cast")
- public void test_insertILjava_lang_CharSequenceII() {
- final String fixture = "0000";
- StringBuffer sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(0, (CharSequence) "ab", 0, 2));
- assertEquals("ab0000", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(0, (CharSequence) "ab", 0, 1));
- assertEquals("a0000", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(2, (CharSequence) "ab", 0, 2));
- assertEquals("00ab00", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(2, (CharSequence) "ab", 0, 1));
- assertEquals("00a00", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) "ab", 0, 2));
- assertEquals("0000ab", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) "ab", 0, 1));
- assertEquals("0000a", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuffer(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) null, 0, 2));
- assertEquals("0000nu", sb.toString());
- assertEquals(6, sb.length());
-
- try {
- sb = new StringBuffer(fixture);
- sb.insert(-1, (CharSequence) "ab", 0, 2);
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuffer(fixture);
- sb.insert(5, (CharSequence) "ab", 0, 2);
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuffer(fixture);
- sb.insert(5, (CharSequence) "ab", -1, 2);
- fail("no IOOBE, negative offset");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuffer(fixture);
- sb.insert(5, new char[] { 'a', 'b' }, 0, -1);
- fail("no IOOBE, negative length");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuffer(fixture);
- sb.insert(5, new char[] { 'a', 'b' }, 0, 3);
- fail("no IOOBE, too long");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.insert(int, char)
- */
- public void test_insertIC() {
- StringBuffer obj = new StringBuffer();
- try {
- obj.insert(-1, ' ');
- fail("ArrayIndexOutOfBoundsException expected");
- } catch (ArrayIndexOutOfBoundsException e) {
- // expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.appendCodePoint(int)'
- */
- public void test_appendCodePointI() {
- StringBuffer sb = new StringBuffer();
- sb.appendCodePoint(0x10000);
- assertEquals("\uD800\uDC00", sb.toString());
- sb.append("fixture");
- assertEquals("\uD800\uDC00fixture", sb.toString());
- sb.appendCodePoint(0x00010FFFF);
- assertEquals("\uD800\uDC00fixture\uDBFF\uDFFF", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuffer.codePointAt(int)
- */
- public void test_codePointAtI() {
- StringBuffer sb = new StringBuffer("abc");
- assertEquals('a', sb.codePointAt(0));
- assertEquals('b', sb.codePointAt(1));
- assertEquals('c', sb.codePointAt(2));
-
- sb = new StringBuffer("\uD800\uDC00");
- assertEquals(0x10000, sb.codePointAt(0));
- assertEquals('\uDC00', sb.codePointAt(1));
-
- try {
- sb.codePointAt(-1);
- fail("No IOOBE on negative index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointAt(sb.length());
- fail("No IOOBE on index equal to length.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointAt(sb.length() + 1);
- fail("No IOOBE on index greater than length.");
- } catch (IndexOutOfBoundsException e) {
-
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.codePointBefore(int)
- */
- public void test_codePointBeforeI() {
- StringBuffer sb = new StringBuffer("abc");
- assertEquals('a', sb.codePointBefore(1));
- assertEquals('b', sb.codePointBefore(2));
- assertEquals('c', sb.codePointBefore(3));
-
- sb = new StringBuffer("\uD800\uDC00");
- assertEquals(0x10000, sb.codePointBefore(2));
- assertEquals('\uD800', sb.codePointBefore(1));
-
- try {
- sb.codePointBefore(0);
- fail("No IOOBE on zero index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointBefore(-1);
- fail("No IOOBE on negative index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointBefore(sb.length() + 1);
- fail("No IOOBE on index greater than length.");
- } catch (IndexOutOfBoundsException e) {
-
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.codePointCount(int, int)
- */
- public void test_codePointCountII() {
- assertEquals(1, new StringBuffer("\uD800\uDC00").codePointCount(0, 2));
- assertEquals(1, new StringBuffer("\uD800\uDC01").codePointCount(0, 2));
- assertEquals(1, new StringBuffer("\uD801\uDC01").codePointCount(0, 2));
- assertEquals(1, new StringBuffer("\uDBFF\uDFFF").codePointCount(0, 2));
-
- assertEquals(3, new StringBuffer("a\uD800\uDC00b").codePointCount(0, 4));
- assertEquals(4, new StringBuffer("a\uD800\uDC00b\uD800").codePointCount(0, 5));
-
- StringBuffer sb = new StringBuffer("abc");
- try {
- sb.codePointCount(-1, 2);
- fail("No IOOBE for negative begin index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointCount(0, 4);
- fail("No IOOBE for end index that's too large.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointCount(3, 2);
- fail("No IOOBE for begin index larger than end index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.getChars(int, int, char[], int)
- */
- public void test_getCharsII$CI() {
- StringBuffer obj = new StringBuffer();
- try {
- obj.getChars(0, 0, new char[0], -1);
- fail("ArrayIndexOutOfBoundsException expected");
- } catch (ArrayIndexOutOfBoundsException e) {
- // expected
- }
- }
-
- /**
- * @tests java.lang.StringBuffer.offsetByCodePoints(int, int)'
- */
- public void test_offsetByCodePointsII() {
- int result = new StringBuffer("a\uD800\uDC00b").offsetByCodePoints(0, 2);
- assertEquals(3, result);
-
- result = new StringBuffer("abcd").offsetByCodePoints(3, -1);
- assertEquals(2, result);
-
- result = new StringBuffer("a\uD800\uDC00b").offsetByCodePoints(0, 3);
- assertEquals(4, result);
-
- result = new StringBuffer("a\uD800\uDC00b").offsetByCodePoints(3, -1);
- assertEquals(1, result);
-
- result = new StringBuffer("a\uD800\uDC00b").offsetByCodePoints(3, 0);
- assertEquals(3, result);
-
- result = new StringBuffer("\uD800\uDC00bc").offsetByCodePoints(3, 0);
- assertEquals(3, result);
-
- result = new StringBuffer("a\uDC00bc").offsetByCodePoints(3, -1);
- assertEquals(2, result);
-
- result = new StringBuffer("a\uD800bc").offsetByCodePoints(3, -1);
- assertEquals(2, result);
-
- StringBuffer sb = new StringBuffer("abc");
- try {
- sb.offsetByCodePoints(-1, 1);
- fail("No IOOBE for negative index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.offsetByCodePoints(0, 4);
- fail("No IOOBE for offset that's too large.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.offsetByCodePoints(3, -4);
- fail("No IOOBE for offset that's too small.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.offsetByCodePoints(3, 1);
- fail("No IOOBE for index that's too large.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.offsetByCodePoints(4, -1);
- fail("No IOOBE for index that's too large.");
- } catch (IndexOutOfBoundsException e) {
-
- }
- }
-
- /**
- * @tests {@link java.lang.StringBuffer#indexOf(String, int)}
- */
- @SuppressWarnings("nls")
- public void test_IndexOfStringInt() {
- final String fixture = "0123456789";
- StringBuffer sb = new StringBuffer(fixture);
- assertEquals(0, sb.indexOf("0"));
- assertEquals(0, sb.indexOf("012"));
- assertEquals(-1, sb.indexOf("02"));
- assertEquals(8, sb.indexOf("89"));
-
- assertEquals(0, sb.indexOf("0"), 0);
- assertEquals(0, sb.indexOf("012"), 0);
- assertEquals(-1, sb.indexOf("02"), 0);
- assertEquals(8, sb.indexOf("89"), 0);
-
- assertEquals(-1, sb.indexOf("0"), 5);
- assertEquals(-1, sb.indexOf("012"), 5);
- assertEquals(-1, sb.indexOf("02"), 0);
- assertEquals(8, sb.indexOf("89"), 5);
-
- try {
- sb.indexOf(null, 0);
- fail("Should throw a NullPointerExceptionE");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests {@link java.lang.StringBuffer#lastIndexOf(String, int)}
- */
- @SuppressWarnings("nls")
- public void test_lastIndexOfLjava_lang_StringI() {
- final String fixture = "0123456789";
- StringBuffer sb = new StringBuffer(fixture);
- assertEquals(0, sb.lastIndexOf("0"));
- assertEquals(0, sb.lastIndexOf("012"));
- assertEquals(-1, sb.lastIndexOf("02"));
- assertEquals(8, sb.lastIndexOf("89"));
-
- assertEquals(0, sb.lastIndexOf("0"), 0);
- assertEquals(0, sb.lastIndexOf("012"), 0);
- assertEquals(-1, sb.lastIndexOf("02"), 0);
- assertEquals(8, sb.lastIndexOf("89"), 0);
-
- assertEquals(-1, sb.lastIndexOf("0"), 5);
- assertEquals(-1, sb.lastIndexOf("012"), 5);
- assertEquals(-1, sb.lastIndexOf("02"), 0);
- assertEquals(8, sb.lastIndexOf("89"), 5);
-
- try {
- sb.lastIndexOf(null, 0);
- fail("Should throw a NullPointerException");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- // comparator for StringBuffer objects
- private static final SerializableAssert STRING_BUFFER_COMPARATOR = new SerializableAssert() {
- public void assertDeserialized(Serializable initial,
- Serializable deserialized) {
-
- StringBuffer init = (StringBuffer) initial;
- StringBuffer desr = (StringBuffer) deserialized;
-
- // serializable fields are: 'count', 'shared', 'value'
- // serialization of 'shared' is not verified
- // 'count' + 'value' should result in required string
- assertEquals("toString", init.toString(), desr.toString());
- }
- };
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- SerializationTest.verifySelf(new StringBuffer("0123456789"),
- STRING_BUFFER_COMPARATOR);
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this, new StringBuffer("0123456789"),
- STRING_BUFFER_COMPARATOR);
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuilderTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuilderTest.java
deleted file mode 100644
index d9acab0..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringBuilderTest.java
+++ /dev/null
@@ -1,1984 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.io.Serializable;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-public class StringBuilderTest extends TestCase {
-
- /**
- * @tests java.lang.StringBuilder.StringBuilder()
- */
- public void test_Constructor() {
- StringBuilder sb = new StringBuilder();
- assertNotNull(sb);
- assertEquals(16, sb.capacity());
- }
-
- /**
- * @tests java.lang.StringBuilder.StringBuilder(int)
- */
- public void test_ConstructorI() {
- StringBuilder sb = new StringBuilder(24);
- assertNotNull(sb);
- assertEquals(24, sb.capacity());
-
- try {
- new StringBuilder(-1);
- fail("no exception");
- } catch (NegativeArraySizeException e) {
- // Expected
- }
-
- assertNotNull(new StringBuilder(0));
- }
-
- /**
- * @tests java.lang.StringBuilder.StringBuilder(CharSequence)
- */
- @SuppressWarnings("cast")
- public void test_ConstructorLjava_lang_CharSequence() {
- StringBuilder sb = new StringBuilder((CharSequence) "fixture");
- assertEquals("fixture", sb.toString());
- assertEquals("fixture".length() + 16, sb.capacity());
-
- sb = new StringBuilder((CharSequence) new StringBuffer("fixture"));
- assertEquals("fixture", sb.toString());
- assertEquals("fixture".length() + 16, sb.capacity());
-
- try {
- new StringBuilder((CharSequence) null);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.StringBuilder(String)
- */
- public void test_ConstructorLjava_lang_String() {
- StringBuilder sb = new StringBuilder("fixture");
- assertEquals("fixture", sb.toString());
- assertEquals("fixture".length() + 16, sb.capacity());
-
- try {
- new StringBuilder((String) null);
- fail("no NPE");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.append(boolean)
- */
- public void test_appendZ() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(true));
- assertEquals("true", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(false));
- assertEquals("false", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(char)
- */
- public void test_appendC() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append('a'));
- assertEquals("a", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append('b'));
- assertEquals("b", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(char[])
- */
- public void test_append$C() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(new char[] { 'a', 'b' }));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(new char[] { 'c', 'd' }));
- assertEquals("cd", sb.toString());
- try {
- sb.append((char[]) null);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.append(char[], int, int)
- */
- public void test_append$CII() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(new char[] { 'a', 'b' }, 0, 2));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(new char[] { 'c', 'd' }, 0, 2));
- assertEquals("cd", sb.toString());
-
- sb.setLength(0);
- assertSame(sb, sb.append(new char[] { 'a', 'b', 'c', 'd' }, 0, 2));
- assertEquals("ab", sb.toString());
-
- sb.setLength(0);
- assertSame(sb, sb.append(new char[] { 'a', 'b', 'c', 'd' }, 2, 2));
- assertEquals("cd", sb.toString());
-
- sb.setLength(0);
- assertSame(sb, sb.append(new char[] { 'a', 'b', 'c', 'd' }, 2, 0));
- assertEquals("", sb.toString());
-
- try {
- sb.append((char[]) null, 0, 2);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- sb.append(new char[] { 'a', 'b', 'c', 'd' }, -1, 2);
- fail("no IOOBE, negative offset");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.append(new char[] { 'a', 'b', 'c', 'd' }, 0, -1);
- fail("no IOOBE, negative length");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.append(new char[] { 'a', 'b', 'c', 'd' }, 2, 3);
- fail("no IOOBE, offset and length overflow");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.append(CharSequence)
- */
- public void test_appendLjava_lang_CharSequence() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append((CharSequence) "ab"));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) "cd"));
- assertEquals("cd", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) null));
- assertEquals("null", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(CharSequence, int, int)
- */
- @SuppressWarnings("cast")
- public void test_appendLjava_lang_CharSequenceII() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append((CharSequence) "ab", 0, 2));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) "cd", 0, 2));
- assertEquals("cd", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) "abcd", 0, 2));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) "abcd", 2, 4));
- assertEquals("cd", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((CharSequence) null, 0, 2));
- assertEquals("nu", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(double)
- */
- public void test_appendD() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(1D));
- assertEquals(String.valueOf(1D), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(0D));
- assertEquals(String.valueOf(0D), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(-1D));
- assertEquals(String.valueOf(-1D), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Double.NaN));
- assertEquals(String.valueOf(Double.NaN), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Double.NEGATIVE_INFINITY));
- assertEquals(String.valueOf(Double.NEGATIVE_INFINITY), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Double.POSITIVE_INFINITY));
- assertEquals(String.valueOf(Double.POSITIVE_INFINITY), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Double.MIN_VALUE));
- assertEquals(String.valueOf(Double.MIN_VALUE), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Double.MAX_VALUE));
- assertEquals(String.valueOf(Double.MAX_VALUE), sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(float)
- */
- public void test_appendF() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(1F));
- assertEquals(String.valueOf(1F), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(0F));
- assertEquals(String.valueOf(0F), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(-1F));
- assertEquals(String.valueOf(-1F), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Float.NaN));
- assertEquals(String.valueOf(Float.NaN), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Float.NEGATIVE_INFINITY));
- assertEquals(String.valueOf(Float.NEGATIVE_INFINITY), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Float.POSITIVE_INFINITY));
- assertEquals(String.valueOf(Float.POSITIVE_INFINITY), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Float.MIN_VALUE));
- assertEquals(String.valueOf(Float.MIN_VALUE), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Float.MAX_VALUE));
- assertEquals(String.valueOf(Float.MAX_VALUE), sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(int)
- */
- public void test_appendI() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(1));
- assertEquals(String.valueOf(1), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(0));
- assertEquals(String.valueOf(0), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(-1));
- assertEquals(String.valueOf(-1), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Integer.MIN_VALUE));
- assertEquals(String.valueOf(Integer.MIN_VALUE), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Integer.MAX_VALUE));
- assertEquals(String.valueOf(Integer.MAX_VALUE), sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(long)
- */
- public void test_appendL() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(1L));
- assertEquals(String.valueOf(1L), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(0L));
- assertEquals(String.valueOf(0L), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(-1L));
- assertEquals(String.valueOf(-1L), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Integer.MIN_VALUE));
- assertEquals(String.valueOf(Integer.MIN_VALUE), sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(Integer.MAX_VALUE));
- assertEquals(String.valueOf(Integer.MAX_VALUE), sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(Object)'
- */
- public void test_appendLjava_lang_Object() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(Fixture.INSTANCE));
- assertEquals(Fixture.INSTANCE.toString(), sb.toString());
-
- sb.setLength(0);
- assertSame(sb, sb.append((Object) null));
- assertEquals("null", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(String)
- */
- public void test_appendLjava_lang_String() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append("ab"));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append("cd"));
- assertEquals("cd", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((String) null));
- assertEquals("null", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.append(StringBuffer)
- */
- public void test_appendLjava_lang_StringBuffer() {
- StringBuilder sb = new StringBuilder();
- assertSame(sb, sb.append(new StringBuffer("ab")));
- assertEquals("ab", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append(new StringBuffer("cd")));
- assertEquals("cd", sb.toString());
- sb.setLength(0);
- assertSame(sb, sb.append((StringBuffer) null));
- assertEquals("null", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.appendCodePoint(int)'
- */
- public void test_appendCodePointI() {
- StringBuilder sb = new StringBuilder();
- sb.appendCodePoint(0x10000);
- assertEquals("\uD800\uDC00", sb.toString());
- sb.append("fixture");
- assertEquals("\uD800\uDC00fixture", sb.toString());
- sb.appendCodePoint(0x00010FFFF);
- assertEquals("\uD800\uDC00fixture\uDBFF\uDFFF", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.capacity()'
- */
- public void test_capacity() {
- StringBuilder sb = new StringBuilder();
- assertEquals(16, sb.capacity());
- sb.append("0123456789ABCDEF0123456789ABCDEF");
- assertTrue(sb.capacity() > 16);
- }
-
- /**
- * @tests java.lang.StringBuilder.charAt(int)'
- */
- public void test_charAtI() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- for (int i = 0; i < fixture.length(); i++) {
- assertEquals((char) ('0' + i), sb.charAt(i));
- }
-
- try {
- sb.charAt(-1);
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.charAt(fixture.length());
- fail("no IOOBE, equal to length");
- } catch (IndexOutOfBoundsException e) {
- }
-
- try {
- sb.charAt(fixture.length() + 1);
- fail("no IOOBE, greater than length");
- } catch (IndexOutOfBoundsException e) {
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.codePointAt(int)
- */
- public void test_codePointAtI() {
- StringBuilder sb = new StringBuilder("abc");
- assertEquals('a', sb.codePointAt(0));
- assertEquals('b', sb.codePointAt(1));
- assertEquals('c', sb.codePointAt(2));
-
- sb = new StringBuilder("\uD800\uDC00");
- assertEquals(0x10000, sb.codePointAt(0));
- assertEquals('\uDC00', sb.codePointAt(1));
-
- sb = new StringBuilder();
- sb.append("abc");
- try {
- sb.codePointAt(-1);
- fail("No IOOBE on negative index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointAt(sb.length());
- fail("No IOOBE on index equal to length.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointAt(sb.length() + 1);
- fail("No IOOBE on index greater than length.");
- } catch (IndexOutOfBoundsException e) {
-
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.codePointBefore(int)
- */
- public void test_codePointBeforeI() {
- StringBuilder sb = new StringBuilder("abc");
- assertEquals('a', sb.codePointBefore(1));
- assertEquals('b', sb.codePointBefore(2));
- assertEquals('c', sb.codePointBefore(3));
-
- sb = new StringBuilder("\uD800\uDC00");
- assertEquals(0x10000, sb.codePointBefore(2));
- assertEquals('\uD800', sb.codePointBefore(1));
-
- sb = new StringBuilder();
- sb.append("abc");
-
- try {
- sb.codePointBefore(0);
- fail("No IOOBE on zero index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointBefore(-1);
- fail("No IOOBE on negative index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointBefore(sb.length() + 1);
- fail("No IOOBE on index greater than length.");
- } catch (IndexOutOfBoundsException e) {
-
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.codePointCount(int, int)
- */
- public void test_codePointCountII() {
- assertEquals(1, new StringBuilder("\uD800\uDC00").codePointCount(0, 2));
- assertEquals(1, new StringBuilder("\uD800\uDC01").codePointCount(0, 2));
- assertEquals(1, new StringBuilder("\uD801\uDC01").codePointCount(0, 2));
- assertEquals(1, new StringBuilder("\uDBFF\uDFFF").codePointCount(0, 2));
-
- assertEquals(3, new StringBuilder("a\uD800\uDC00b").codePointCount(0, 4));
- assertEquals(4, new StringBuilder("a\uD800\uDC00b\uD800").codePointCount(0, 5));
-
- StringBuilder sb = new StringBuilder();
- sb.append("abc");
- try {
- sb.codePointCount(-1, 2);
- fail("No IOOBE for negative begin index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointCount(0, 4);
- fail("No IOOBE for end index that's too large.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.codePointCount(3, 2);
- fail("No IOOBE for begin index larger than end index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.delete(int, int)
- */
- public void test_deleteII() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.delete(0, 0));
- assertEquals(fixture, sb.toString());
- assertSame(sb, sb.delete(5, 5));
- assertEquals(fixture, sb.toString());
- assertSame(sb, sb.delete(0, 1));
- assertEquals("123456789", sb.toString());
- assertEquals(9, sb.length());
- assertSame(sb, sb.delete(0, sb.length()));
- assertEquals("", sb.toString());
- assertEquals(0, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.delete(0, 11));
- assertEquals("", sb.toString());
- assertEquals(0, sb.length());
-
- try {
- new StringBuilder(fixture).delete(-1, 2);
- fail("no SIOOBE, negative start");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- new StringBuilder(fixture).delete(11, 12);
- fail("no SIOOBE, start too far");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- new StringBuilder(fixture).delete(13, 12);
- fail("no SIOOBE, start larger than end");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- // HARMONY 6212
- sb = new StringBuilder();
- sb.append("abcde");
- String str = sb.toString();
- sb.delete(0, sb.length());
- sb.append("YY");
- assertEquals("abcde", str);
- assertEquals("YY", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.deleteCharAt(int)
- */
- public void test_deleteCharAtI() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.deleteCharAt(0));
- assertEquals("123456789", sb.toString());
- assertEquals(9, sb.length());
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.deleteCharAt(5));
- assertEquals("012346789", sb.toString());
- assertEquals(9, sb.length());
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.deleteCharAt(9));
- assertEquals("012345678", sb.toString());
- assertEquals(9, sb.length());
-
- try {
- new StringBuilder(fixture).deleteCharAt(-1);
- fail("no SIOOBE, negative index");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- new StringBuilder(fixture).deleteCharAt(fixture.length());
- fail("no SIOOBE, index equals length");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- new StringBuilder(fixture).deleteCharAt(fixture.length() + 1);
- fail("no SIOOBE, index exceeds length");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.ensureCapacity(int)'
- */
- public void test_ensureCapacityI() {
- StringBuilder sb = new StringBuilder(5);
- assertEquals(5, sb.capacity());
- sb.ensureCapacity(10);
- assertEquals(12, sb.capacity());
- sb.ensureCapacity(26);
- assertEquals(26, sb.capacity());
- sb.ensureCapacity(55);
- assertEquals(55, sb.capacity());
- }
-
- /**
- * @tests java.lang.StringBuilder.getChars(int, int, char[], int)'
- */
- public void test_getCharsII$CI() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- char[] dst = new char[10];
- sb.getChars(0, 10, dst, 0);
- assertTrue(Arrays.equals(fixture.toCharArray(), dst));
-
- Arrays.fill(dst, '\0');
- sb.getChars(0, 5, dst, 0);
- char[] fixtureChars = new char[10];
- fixture.getChars(0, 5, fixtureChars, 0);
- assertTrue(Arrays.equals(fixtureChars, dst));
-
- Arrays.fill(dst, '\0');
- Arrays.fill(fixtureChars, '\0');
- sb.getChars(0, 5, dst, 5);
- fixture.getChars(0, 5, fixtureChars, 5);
- assertTrue(Arrays.equals(fixtureChars, dst));
-
- Arrays.fill(dst, '\0');
- Arrays.fill(fixtureChars, '\0');
- sb.getChars(5, 10, dst, 1);
- fixture.getChars(5, 10, fixtureChars, 1);
- assertTrue(Arrays.equals(fixtureChars, dst));
-
- try {
- sb.getChars(0, 10, null, 0);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- sb.getChars(-1, 10, dst, 0);
- fail("no IOOBE, srcBegin negative");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.getChars(0, 10, dst, -1);
- fail("no IOOBE, dstBegin negative");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.getChars(5, 4, dst, 0);
- fail("no IOOBE, srcBegin > srcEnd");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.getChars(0, 11, dst, 0);
- fail("no IOOBE, srcEnd > length");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.getChars(0, 10, dst, 5);
- fail("no IOOBE, dstBegin and src size too large for what's left in dst");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.indexOf(String)
- */
- public void test_indexOfLjava_lang_String() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertEquals(0, sb.indexOf("0"));
- assertEquals(0, sb.indexOf("012"));
- assertEquals(-1, sb.indexOf("02"));
- assertEquals(8, sb.indexOf("89"));
-
- try {
- sb.indexOf(null);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.indexOf(String, int)
- */
- public void test_IndexOfStringInt() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertEquals(0, sb.indexOf("0"));
- assertEquals(0, sb.indexOf("012"));
- assertEquals(-1, sb.indexOf("02"));
- assertEquals(8, sb.indexOf("89"));
-
- assertEquals(0, sb.indexOf("0"), 0);
- assertEquals(0, sb.indexOf("012"), 0);
- assertEquals(-1, sb.indexOf("02"), 0);
- assertEquals(8, sb.indexOf("89"), 0);
-
- assertEquals(-1, sb.indexOf("0"), 5);
- assertEquals(-1, sb.indexOf("012"), 5);
- assertEquals(-1, sb.indexOf("02"), 0);
- assertEquals(8, sb.indexOf("89"), 5);
-
- try {
- sb.indexOf(null, 0);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, boolean)
- */
- public void test_insertIZ() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, true));
- assertEquals("true0000", sb.toString());
- assertEquals(8, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, false));
- assertEquals("false0000", sb.toString());
- assertEquals(9, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, false));
- assertEquals("00false00", sb.toString());
- assertEquals(9, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, false));
- assertEquals("0000false", sb.toString());
- assertEquals(9, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, false);
- fail("no SIOOBE, negative index");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, false);
- fail("no SIOOBE, index too large index");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, char)
- */
- public void test_insertIC() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, 'a'));
- assertEquals("a0000", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, 'b'));
- assertEquals("b0000", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, 'b'));
- assertEquals("00b00", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, 'b'));
- assertEquals("0000b", sb.toString());
- assertEquals(5, sb.length());
-
- // FIXME this fails on Sun JRE 5.0_5
-// try {
-// sb = new StringBuilder(fixture);
-// sb.insert(-1, 'a');
-// fail("no SIOOBE, negative index");
-// } catch (StringIndexOutOfBoundsException e) {
-// // Expected
-// }
-
- /*
- * FIXME This fails on Sun JRE 5.0_5, but that seems like a bug, since
- * the 'insert(int, char[]) behaves this way.
- */
-// try {
-// sb = new StringBuilder(fixture);
-// sb.insert(5, 'a');
-// fail("no SIOOBE, index too large index");
-// } catch (StringIndexOutOfBoundsException e) {
-// // Expected
-// }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, char)
- */
- public void test_insertIC_2() {
- StringBuilder obj = new StringBuilder();
- try {
- obj.insert(-1, '?');
- fail("ArrayIndexOutOfBoundsException expected");
- } catch (ArrayIndexOutOfBoundsException e) {
- // expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, char[])'
- */
- public void test_insertI$C() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, new char[] { 'a', 'b' }));
- assertEquals("ab0000", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, new char[] { 'a', 'b' }));
- assertEquals("00ab00", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, new char[] { 'a', 'b' }));
- assertEquals("0000ab", sb.toString());
- assertEquals(6, sb.length());
-
- /*
- * TODO This NPE is the behavior on Sun's JRE 5.0_5, but it's
- * undocumented. The assumption is that this method behaves like
- * String.valueOf(char[]), which does throw a NPE too, but that is also
- * undocumented.
- */
-
- try {
- sb.insert(0, (char[]) null);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, new char[] { 'a', 'b' });
- fail("no SIOOBE, negative index");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, new char[] { 'a', 'b' });
- fail("no SIOOBE, index too large index");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, char[], int, int)
- */
- public void test_insertI$CII() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, new char[] { 'a', 'b' }, 0, 2));
- assertEquals("ab0000", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, new char[] { 'a', 'b' }, 0, 1));
- assertEquals("a0000", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, new char[] { 'a', 'b' }, 0, 2));
- assertEquals("00ab00", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, new char[] { 'a', 'b' }, 0, 1));
- assertEquals("00a00", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, new char[] { 'a', 'b' }, 0, 2));
- assertEquals("0000ab", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, new char[] { 'a', 'b' }, 0, 1));
- assertEquals("0000a", sb.toString());
- assertEquals(5, sb.length());
-
- /*
- * TODO This NPE is the behavior on Sun's JRE 5.0_5, but it's
- * undocumented. The assumption is that this method behaves like
- * String.valueOf(char[]), which does throw a NPE too, but that is also
- * undocumented.
- */
-
- try {
- sb.insert(0, (char[]) null, 0, 2);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, new char[] { 'a', 'b' }, 0, 2);
- fail("no SIOOBE, negative index");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, new char[] { 'a', 'b' }, 0, 2);
- fail("no SIOOBE, index too large index");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, new char[] { 'a', 'b' }, -1, 2);
- fail("no SIOOBE, negative offset");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, new char[] { 'a', 'b' }, 0, -1);
- fail("no SIOOBE, negative length");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, new char[] { 'a', 'b' }, 0, 3);
- fail("no SIOOBE, too long");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, CharSequence)
- */
- public void test_insertILjava_lang_CharSequence() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, (CharSequence) "ab"));
- assertEquals("ab0000", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, (CharSequence) "ab"));
- assertEquals("00ab00", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) "ab"));
- assertEquals("0000ab", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) null));
- assertEquals("0000null", sb.toString());
- assertEquals(8, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, (CharSequence) "ab");
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, (CharSequence) "ab");
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, CharSequence, int, int)
- */
- @SuppressWarnings("cast")
- public void test_insertILjava_lang_CharSequenceII() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, (CharSequence) "ab", 0, 2));
- assertEquals("ab0000", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, (CharSequence) "ab", 0, 1));
- assertEquals("a0000", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, (CharSequence) "ab", 0, 2));
- assertEquals("00ab00", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, (CharSequence) "ab", 0, 1));
- assertEquals("00a00", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) "ab", 0, 2));
- assertEquals("0000ab", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) "ab", 0, 1));
- assertEquals("0000a", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, (CharSequence) null, 0, 2));
- assertEquals("0000nu", sb.toString());
- assertEquals(6, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, (CharSequence) "ab", 0, 2);
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, (CharSequence) "ab", 0, 2);
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, (CharSequence) "ab", -1, 2);
- fail("no IOOBE, negative offset");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, new char[] { 'a', 'b' }, 0, -1);
- fail("no IOOBE, negative length");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, new char[] { 'a', 'b' }, 0, 3);
- fail("no IOOBE, too long");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, double)
- */
- public void test_insertID() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, -1D));
- assertEquals("-1.00000", sb.toString());
- assertEquals(8, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, 0D));
- assertEquals("0.00000", sb.toString());
- assertEquals(7, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, 1D));
- assertEquals("001.000", sb.toString());
- assertEquals(7, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, 2D));
- assertEquals("00002.0", sb.toString());
- assertEquals(7, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, 1D);
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, 1D);
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, float)
- */
- public void test_insertIF() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, -1F));
- assertEquals("-1.00000", sb.toString());
- assertEquals(8, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, 0F));
- assertEquals("0.00000", sb.toString());
- assertEquals(7, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, 1F));
- assertEquals("001.000", sb.toString());
- assertEquals(7, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, 2F));
- assertEquals("00002.0", sb.toString());
- assertEquals(7, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, 1F);
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, 1F);
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, int)
- */
- public void test_insertII() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, -1));
- assertEquals("-10000", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, 0));
- assertEquals("00000", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, 1));
- assertEquals("00100", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, 2));
- assertEquals("00002", sb.toString());
- assertEquals(5, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, 1);
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, 1);
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, long)
- */
- public void test_insertIJ() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, -1L));
- assertEquals("-10000", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, 0L));
- assertEquals("00000", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, 1L));
- assertEquals("00100", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, 2L));
- assertEquals("00002", sb.toString());
- assertEquals(5, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, 1L);
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, 1L);
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, Object)
- */
- public void test_insertILjava_lang_Object() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, Fixture.INSTANCE));
- assertEquals("fixture0000", sb.toString());
- assertEquals(11, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, Fixture.INSTANCE));
- assertEquals("00fixture00", sb.toString());
- assertEquals(11, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, Fixture.INSTANCE));
- assertEquals("0000fixture", sb.toString());
- assertEquals(11, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, (Object) null));
- assertEquals("0000null", sb.toString());
- assertEquals(8, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, Fixture.INSTANCE);
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, Fixture.INSTANCE);
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.insert(int, String)
- */
- public void test_insertILjava_lang_String() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(0, "fixture"));
- assertEquals("fixture0000", sb.toString());
- assertEquals(11, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(2, "fixture"));
- assertEquals("00fixture00", sb.toString());
- assertEquals(11, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, "fixture"));
- assertEquals("0000fixture", sb.toString());
- assertEquals(11, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.insert(4, (Object) null));
- assertEquals("0000null", sb.toString());
- assertEquals(8, sb.length());
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(-1, "fixture");
- fail("no IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.insert(5, "fixture");
- fail("no IOOBE, index too large index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.lastIndexOf(String)
- */
- public void test_lastIndexOfLjava_lang_String() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertEquals(0, sb.lastIndexOf("0"));
- assertEquals(0, sb.lastIndexOf("012"));
- assertEquals(-1, sb.lastIndexOf("02"));
- assertEquals(8, sb.lastIndexOf("89"));
-
- try {
- sb.lastIndexOf(null);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.lastIndexOf(String, int)
- */
- public void test_lastIndexOfLjava_lang_StringI() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertEquals(0, sb.lastIndexOf("0"));
- assertEquals(0, sb.lastIndexOf("012"));
- assertEquals(-1, sb.lastIndexOf("02"));
- assertEquals(8, sb.lastIndexOf("89"));
-
- assertEquals(0, sb.lastIndexOf("0"), 0);
- assertEquals(0, sb.lastIndexOf("012"), 0);
- assertEquals(-1, sb.lastIndexOf("02"), 0);
- assertEquals(8, sb.lastIndexOf("89"), 0);
-
- assertEquals(-1, sb.lastIndexOf("0"), 5);
- assertEquals(-1, sb.lastIndexOf("012"), 5);
- assertEquals(-1, sb.lastIndexOf("02"), 0);
- assertEquals(8, sb.lastIndexOf("89"), 5);
-
- try {
- sb.lastIndexOf(null, 0);
- fail("no NPE");
- } catch (NullPointerException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.length()
- */
- public void test_length() {
- StringBuilder sb = new StringBuilder();
- assertEquals(0, sb.length());
- sb.append("0000");
- assertEquals(4, sb.length());
- }
-
- /**
- * @tests java.lang.StringBuilder.offsetByCodePoints(int, int)'
- */
- public void test_offsetByCodePointsII() {
- int result = new StringBuilder("a\uD800\uDC00b").offsetByCodePoints(0, 2);
- assertEquals(3, result);
-
- result = new StringBuilder("abcd").offsetByCodePoints(3, -1);
- assertEquals(2, result);
-
- result = new StringBuilder("a\uD800\uDC00b").offsetByCodePoints(0, 3);
- assertEquals(4, result);
-
- result = new StringBuilder("a\uD800\uDC00b").offsetByCodePoints(3, -1);
- assertEquals(1, result);
-
- result = new StringBuilder("a\uD800\uDC00b").offsetByCodePoints(3, 0);
- assertEquals(3, result);
-
- result = new StringBuilder("\uD800\uDC00bc").offsetByCodePoints(3, 0);
- assertEquals(3, result);
-
- result = new StringBuilder("a\uDC00bc").offsetByCodePoints(3, -1);
- assertEquals(2, result);
-
- result = new StringBuilder("a\uD800bc").offsetByCodePoints(3, -1);
- assertEquals(2, result);
-
- StringBuilder sb = new StringBuilder();
- sb.append("abc");
- try {
- sb.offsetByCodePoints(-1, 1);
- fail("No IOOBE for negative index.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.offsetByCodePoints(0, 4);
- fail("No IOOBE for offset that's too large.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.offsetByCodePoints(3, -4);
- fail("No IOOBE for offset that's too small.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.offsetByCodePoints(3, 1);
- fail("No IOOBE for index that's too large.");
- } catch (IndexOutOfBoundsException e) {
-
- }
-
- try {
- sb.offsetByCodePoints(4, -1);
- fail("No IOOBE for index that's too large.");
- } catch (IndexOutOfBoundsException e) {
-
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.replace(int, int, String)'
- */
- public void test_replaceIILjava_lang_String() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.replace(1, 3, "11"));
- assertEquals("0110", sb.toString());
- assertEquals(4, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.replace(1, 2, "11"));
- assertEquals("01100", sb.toString());
- assertEquals(5, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.replace(4, 5, "11"));
- assertEquals("000011", sb.toString());
- assertEquals(6, sb.length());
-
- sb = new StringBuilder(fixture);
- assertSame(sb, sb.replace(4, 6, "11"));
- assertEquals("000011", sb.toString());
- assertEquals(6, sb.length());
-
- // FIXME Undocumented NPE in Sun's JRE 5.0_5
- try {
- sb.replace(1, 2, null);
- fail("No NPE");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.replace(-1, 2, "11");
- fail("No SIOOBE, negative start");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.replace(5, 2, "11");
- fail("No SIOOBE, start > length");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb = new StringBuilder(fixture);
- sb.replace(3, 2, "11");
- fail("No SIOOBE, start > end");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- // Regression for HARMONY-348
- StringBuilder buffer = new StringBuilder("1234567");
- buffer.replace(2, 6, "XXX");
- assertEquals("12XXX7",buffer.toString());
- }
-
- private void reverseTest(String org, String rev, String back) {
- // create non-shared StringBuilder
- StringBuilder sb = new StringBuilder(org);
- sb.reverse();
- String reversed = sb.toString();
- assertEquals(rev, reversed);
- // create non-shared StringBuilder
- sb = new StringBuilder(reversed);
- sb.reverse();
- reversed = sb.toString();
- assertEquals(back, reversed);
-
- // test algorithm when StringBuilder is shared
- sb = new StringBuilder(org);
- String copy = sb.toString();
- assertEquals(org, copy);
- sb.reverse();
- reversed = sb.toString();
- assertEquals(rev, reversed);
- sb = new StringBuilder(reversed);
- copy = sb.toString();
- assertEquals(rev, copy);
- sb.reverse();
- reversed = sb.toString();
- assertEquals(back, reversed);
- }
-
- /**
- * @tests java.lang.StringBuilder.reverse()
- */
- public void test_reverse() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertSame(sb, sb.reverse());
- assertEquals("9876543210", sb.toString());
-
- sb = new StringBuilder("012345678");
- assertSame(sb, sb.reverse());
- assertEquals("876543210", sb.toString());
-
- sb.setLength(1);
- assertSame(sb, sb.reverse());
- assertEquals("8", sb.toString());
-
- sb.setLength(0);
- assertSame(sb, sb.reverse());
- assertEquals("", sb.toString());
-
- String str;
- str = "a";
- reverseTest(str, str, str);
-
- str = "ab";
- reverseTest(str, "ba", str);
-
- str = "abcdef";
- reverseTest(str, "fedcba", str);
-
- str = "abcdefg";
- reverseTest(str, "gfedcba", str);
-
- str = "\ud800\udc00";
- reverseTest(str, str, str);
-
- str = "\udc00\ud800";
- reverseTest(str, "\ud800\udc00", "\ud800\udc00");
-
- str = "a\ud800\udc00";
- reverseTest(str, "\ud800\udc00a", str);
-
- str = "ab\ud800\udc00";
- reverseTest(str, "\ud800\udc00ba", str);
-
- str = "abc\ud800\udc00";
- reverseTest(str, "\ud800\udc00cba", str);
-
- str = "\ud800\udc00\udc01\ud801\ud802\udc02";
- reverseTest(str, "\ud802\udc02\ud801\udc01\ud800\udc00",
- "\ud800\udc00\ud801\udc01\ud802\udc02");
-
- str = "\ud800\udc00\ud801\udc01\ud802\udc02";
- reverseTest(str, "\ud802\udc02\ud801\udc01\ud800\udc00", str);
-
- str = "\ud800\udc00\udc01\ud801a";
- reverseTest(str, "a\ud801\udc01\ud800\udc00",
- "\ud800\udc00\ud801\udc01a");
-
- str = "a\ud800\udc00\ud801\udc01";
- reverseTest(str, "\ud801\udc01\ud800\udc00a", str);
-
- str = "\ud800\udc00\udc01\ud801ab";
- reverseTest(str, "ba\ud801\udc01\ud800\udc00",
- "\ud800\udc00\ud801\udc01ab");
-
- str = "ab\ud800\udc00\ud801\udc01";
- reverseTest(str, "\ud801\udc01\ud800\udc00ba", str);
-
- str = "\ud800\udc00\ud801\udc01";
- reverseTest(str, "\ud801\udc01\ud800\udc00", str);
-
- str = "a\ud800\udc00z\ud801\udc01";
- reverseTest(str, "\ud801\udc01z\ud800\udc00a", str);
-
- str = "a\ud800\udc00bz\ud801\udc01";
- reverseTest(str, "\ud801\udc01zb\ud800\udc00a", str);
-
- str = "abc\ud802\udc02\ud801\udc01\ud800\udc00";
- reverseTest(str, "\ud800\udc00\ud801\udc01\ud802\udc02cba", str);
-
- str = "abcd\ud802\udc02\ud801\udc01\ud800\udc00";
- reverseTest(str, "\ud800\udc00\ud801\udc01\ud802\udc02dcba", str);
- }
-
- /**
- * @tests java.lang.StringBuilder.setCharAt(int, char)
- */
- public void test_setCharAtIC() {
- final String fixture = "0000";
- StringBuilder sb = new StringBuilder(fixture);
- sb.setCharAt(0, 'A');
- assertEquals("A000", sb.toString());
- sb.setCharAt(1, 'B');
- assertEquals("AB00", sb.toString());
- sb.setCharAt(2, 'C');
- assertEquals("ABC0", sb.toString());
- sb.setCharAt(3, 'D');
- assertEquals("ABCD", sb.toString());
-
- try {
- sb.setCharAt(-1, 'A');
- fail("No IOOBE, negative index");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.setCharAt(4, 'A');
- fail("No IOOBE, index == length");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.setCharAt(5, 'A');
- fail("No IOOBE, index > length");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.setLength(int)'
- */
- public void test_setLengthI() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- sb.setLength(5);
- assertEquals(5, sb.length());
- assertEquals("01234", sb.toString());
- sb.setLength(6);
- assertEquals(6, sb.length());
- assertEquals("01234\0", sb.toString());
- sb.setLength(0);
- assertEquals(0, sb.length());
- assertEquals("", sb.toString());
-
- try {
- sb.setLength(-1);
- fail("No IOOBE, negative length.");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- sb = new StringBuilder("abcde");
- assertEquals("abcde", sb.toString());
- sb.setLength(1);
- sb.append('g');
- assertEquals("ag", sb.toString());
-
- sb = new StringBuilder("abcde");
- sb.setLength(3);
- sb.append('g');
- assertEquals("abcg", sb.toString());
-
- sb = new StringBuilder("abcde");
- sb.setLength(2);
- try {
- sb.charAt(3);
- fail("should throw IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- sb = new StringBuilder();
- sb.append("abcdefg");
- sb.setLength(2);
- sb.setLength(5);
- for (int i = 2; i < 5; i++) {
- assertEquals(0, sb.charAt(i));
- }
-
- sb = new StringBuilder();
- sb.append("abcdefg");
- sb.delete(2, 4);
- sb.setLength(7);
- assertEquals('a', sb.charAt(0));
- assertEquals('b', sb.charAt(1));
- assertEquals('e', sb.charAt(2));
- assertEquals('f', sb.charAt(3));
- assertEquals('g', sb.charAt(4));
- for (int i = 5; i < 7; i++) {
- assertEquals(0, sb.charAt(i));
- }
-
- sb = new StringBuilder();
- sb.append("abcdefg");
- sb.replace(2, 5, "z");
- sb.setLength(7);
- for (int i = 5; i < 7; i++) {
- assertEquals(0, sb.charAt(i));
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.subSequence(int, int)
- */
- public void test_subSequenceII() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- CharSequence ss = sb.subSequence(0, 5);
- assertEquals("01234", ss.toString());
-
- ss = sb.subSequence(0, 0);
- assertEquals("", ss.toString());
-
- try {
- sb.subSequence(-1, 1);
- fail("No IOOBE, negative start.");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.subSequence(0, -1);
- fail("No IOOBE, negative end.");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.subSequence(0, fixture.length() + 1);
- fail("No IOOBE, end > length.");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.subSequence(3, 2);
- fail("No IOOBE, start > end.");
- } catch (IndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.substring(int)
- */
- public void test_substringI() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- String ss = sb.substring(0);
- assertEquals(fixture, ss);
-
- ss = sb.substring(10);
- assertEquals("", ss);
-
- try {
- sb.substring(-1);
- fail("No SIOOBE, negative start.");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.substring(0, -1);
- fail("No SIOOBE, negative end.");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.substring(fixture.length() + 1);
- fail("No SIOOBE, start > length.");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.substring(int, int)
- */
- public void test_substringII() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- String ss = sb.substring(0, 5);
- assertEquals("01234", ss);
-
- ss = sb.substring(0, 0);
- assertEquals("", ss);
-
- try {
- sb.substring(-1, 1);
- fail("No SIOOBE, negative start.");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.substring(0, -1);
- fail("No SIOOBE, negative end.");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.substring(0, fixture.length() + 1);
- fail("No SIOOBE, end > length.");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
-
- try {
- sb.substring(3, 2);
- fail("No SIOOBE, start > end.");
- } catch (StringIndexOutOfBoundsException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.lang.StringBuilder.toString()'
- */
- public void test_toString() throws Exception {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertEquals(fixture, sb.toString());
-
- sb.setLength(0);
- sb.append("abcde");
- assertEquals("abcde", sb.toString());
- sb.setLength(1000);
- byte[] bytes = sb.toString().getBytes("GB18030");
- for (int i = 5; i < bytes.length; i++) {
- assertEquals(0, bytes[i]);
- }
-
- sb.setLength(5);
- sb.append("fghij");
- assertEquals("abcdefghij", sb.toString());
- }
-
- /**
- * @tests java.lang.StringBuilder.trimToSize()'
- */
- public void test_trimToSize() {
- final String fixture = "0123456789";
- StringBuilder sb = new StringBuilder(fixture);
- assertTrue(sb.capacity() > fixture.length());
- assertEquals(fixture.length(), sb.length());
- assertEquals(fixture, sb.toString());
- int prevCapacity = sb.capacity();
- sb.trimToSize();
- assertTrue(prevCapacity > sb.capacity());
- assertEquals(fixture.length(), sb.length());
- assertEquals(fixture, sb.toString());
- }
-
- // comparator for StringBuilder objects
- private static final SerializableAssert STRING_BILDER_COMPARATOR = new SerializableAssert() {
- public void assertDeserialized(Serializable initial,
- Serializable deserialized) {
-
- StringBuilder init = (StringBuilder) initial;
- StringBuilder desr = (StringBuilder) deserialized;
-
- assertEquals("toString", init.toString(), desr.toString());
- }
- };
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- SerializationTest.verifySelf(new StringBuilder("0123456789"),
- STRING_BILDER_COMPARATOR);
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this, new StringBuilder("0123456789"),
- STRING_BILDER_COMPARATOR);
- }
-
- private static final class Fixture {
- static final Fixture INSTANCE = new Fixture();
-
- private Fixture() {
- super();
- }
-
- @Override
- public String toString() {
- return "fixture";
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringIndexOutOfBoundsExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringIndexOutOfBoundsExceptionTest.java
deleted file mode 100644
index 8ffeb3a..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringIndexOutOfBoundsExceptionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class StringIndexOutOfBoundsExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.StringIndexOutOfBoundsException#StringIndexOutOfBoundsException()
- */
- public void test_Constructor() {
- StringIndexOutOfBoundsException e = new StringIndexOutOfBoundsException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.StringIndexOutOfBoundsException#StringIndexOutOfBoundsException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- StringIndexOutOfBoundsException e = new StringIndexOutOfBoundsException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java
deleted file mode 100644
index c5e5688..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java
+++ /dev/null
@@ -1,895 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.nio.channels.Channel;
-import java.nio.channels.spi.SelectorProvider;
-import java.security.Permission;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Vector;
-
-@TestTargetClass(System.class)
-public class SystemTest extends junit.framework.TestCase {
-
- static boolean flag = false;
-
- static boolean ranFinalize = false;
-
- /**
- * @tests java.lang.System#setIn(java.io.InputStream)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "setIn",
- args = {java.io.InputStream.class}
- )
- public void test_setInLjava_io_InputStream() {
- InputStream orgIn = System.in;
- InputStream in = new ByteArrayInputStream(new byte[0]);
- System.setIn(in);
- assertTrue("in not set", System.in == in);
- System.setIn(orgIn);
- }
-
- /**
- * @tests java.lang.System#setOut(java.io.PrintStream)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "setOut",
- args = {java.io.PrintStream.class}
- )
- public void test_setOutLjava_io_PrintStream() {
- PrintStream orgOut = System.out;
- PrintStream out = new PrintStream(new ByteArrayOutputStream());
- System.setOut(out);
- assertTrue("out not set", System.out == out);
- System.setOut(orgOut);
- }
-
- /**
- * @tests java.lang.System#setErr(java.io.PrintStream)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "setErr",
- args = {java.io.PrintStream.class}
- )
- public void test_setErrLjava_io_PrintStream() {
- PrintStream orgErr = System.err;
- PrintStream err = new PrintStream(new ByteArrayOutputStream());
- System.setErr(err);
- assertTrue("err not set", System.err == err);
- System.setErr(orgErr);
- }
-
- /**
- * @tests java.lang.System#arraycopy(java.lang.Object, int,
- * java.lang.Object, int, int)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "arraycopy",
- args = {java.lang.Object.class, int.class, java.lang.Object.class,
- int.class, int.class}
- )
- public void test_arraycopyLjava_lang_ObjectILjava_lang_ObjectII() {
- // Test for method void java.lang.System.arraycopy(java.lang.Object,
- // int, java.lang.Object, int, int)
- Integer a[] = new Integer[20];
- Integer b[] = new Integer[20];
- int i = 0;
- while (i < a.length) {
- a[i] = new Integer(i);
- ++i;
- }
- System.arraycopy(a, 0, b, 0, a.length);
- for (i = 0; i < a.length; i++)
- assertTrue("Copied elements incorrectly", a[i].equals(b[i]));
-
- /* Non primitive array types don't need to be identical */
- String[] source1 = new String[] { "element1" };
- Object[] dest1 = new Object[1];
- System.arraycopy(source1, 0, dest1, 0, dest1.length);
- assertTrue("Invalid copy 1", dest1[0] == source1[0]);
-
- char[][] source = new char[][] { { 'H', 'e', 'l', 'l', 'o' },
- { 'W', 'o', 'r', 'l', 'd' } };
- char[][] dest = new char[2][];
- System.arraycopy(source, 0, dest, 0, dest.length);
- assertTrue("Invalid copy 2", dest[0] == source[0]
- && dest[1] == source[1]);
-
- try {
- // copy from non array object into Object array
- System.arraycopy(new Object(), 0, b, 0, 0);
- fail("ArrayStoreException is not thrown.");
- } catch(ArrayStoreException ase) {
- //expected
- }
-
- try {
- // copy from Object array into non array object
- System.arraycopy(a, 0, new Object(), 0, 0);
- fail("ArrayStoreException is not thrown.");
- } catch(ArrayStoreException ase) {
- //expected
- }
-
- try {
- // copy from primitive array into object array
- System.arraycopy(new char[] {'a'}, 0, new String[1], 0, 1);
- fail("ArrayStoreException is not thrown.");
- } catch(ArrayStoreException ase) {
- //expected
- }
-
- try {
- // copy from object array into primitive array
- System.arraycopy(new String[] {"a"}, 0, new char[1], 0, 1);
- fail("ArrayStoreException is not thrown.");
- } catch(ArrayStoreException ase) {
- //expected
- }
-
- try {
- // copy from primitive array into an array of another primitive type
- System.arraycopy(new char[] {'a'}, 0, new int[1], 0, 1);
- fail("ArrayStoreException is not thrown.");
- } catch(ArrayStoreException ase) {
- //expected
- }
-
- try {
- // copy from object array into an array of another Object type
- System.arraycopy(new Character[] {'a'}, 0, new Integer[1], 0, 1);
- fail("ArrayStoreException is not thrown.");
- } catch(ArrayStoreException ase) {
- //expected
- }
-
- try {
- // copy from null into an array of a primitive type
- System.arraycopy(null, 0, new int[1], 0, 1);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
-
- try {
- // copy from a primitive array into null
- System.arraycopy(new int[]{'1'}, 0, null, 0, 1);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
-
- try {
- System.arraycopy(a, a.length + 1, b, 0, 1);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- System.arraycopy(a, -1, b, 0, 1);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- System.arraycopy(a, 0, b, -1, 1);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- System.arraycopy(a, 0, b, 0, -1);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- System.arraycopy(a, 11, b, 0, 10);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- System.arraycopy(a, Integer.MAX_VALUE, b, 0, 10);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- System.arraycopy(a, 0, b, Integer.MAX_VALUE, 10);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
-
- try {
- System.arraycopy(a, 0, b, 10, Integer.MAX_VALUE);
- fail("IndexOutOfBoundsException is not thrown.");
- } catch(IndexOutOfBoundsException ioobe) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.System#currentTimeMillis()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "currentTimeMillis",
- args = {}
- )
- public void test_currentTimeMillis() {
- // Test for method long java.lang.System.currentTimeMillis()
- try {
- long firstRead = System.currentTimeMillis();
- try {
- Thread.sleep(150);
- } catch (InterruptedException e) {
- }
- long secondRead = System.currentTimeMillis();
- assertTrue("Incorrect times returned: " + firstRead + ", "
- + secondRead, firstRead < secondRead);
- } catch (Exception e) {
- fail("Exception during test: " + e.toString());
- }
- }
-
- /**
- * @tests java.lang.System#getProperties()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getProperties",
- args = {}
- )
- public void test_getProperties() {
-
- // Test for method java.util.Properties java.lang.System.getProperties()
- /* String[] props = { "java.version", "java.vendor", "java.vendor.url",
- "java.home", "java.vm.specification.version",
- "java.vm.specification.vendor", "java.vm.specification.name",
- "java.vm.version", "java.vm.vendor", "java.vm.name",
- "java.specification.name", "java.specification.vendor",
- "java.specification.name", "java.class.version",
- "java.class.path", "java.ext.dirs", "os.name", "os.arch",
- "os.version", "file.separator", "path.separator",
- "line.separator", "user.name", "user.home", "user.dir", };
- */
-
- String [] props = {"java.vendor.url",
- "java.class.path", "user.home",
- "java.class.version", "os.version",
- "java.vendor", "user.dir",
- /*"user.timezone",*/ "path.separator",
- "os.name", "os.arch",
- "line.separator", "file.separator",
- "user.name", "java.version", "java.home" };
-
- /* Available properties.
- String [] props = {"java.boot.class.path", "java.class.path",
- "java.class.version", "java.compiler", "java.ext.dirs",
- "java.home", "java.io.tmpdir", "java.library.path",
- "java.vendor", "java.vendor.url", "java.version",
- "java.vm.name", "java.vm.specification.name",
- "java.vm.specification.vendor", "java.vm.specification.version",
- "java.vm.vendor", "java.vm.version", "java.specification.name",
- "java.specification.vendor", "java.specification.version",
- "os.arch", "os.name", "os.version", "user.home", "user.name",
- "user.dir", "file.separator", "line.separator",
- "path.separator", "java.runtime.name", "java.runtime.version",
- "java.vm.vendor.url", "file.encoding","user.language",
- "user.region"};
- */
-
- Properties p = System.getProperties();
- assertTrue(p.size() > 0);
-
- // Ensure spec'ed properties are non-null. See System.getProperties()
- // spec.
-
- for (int i = 0; i < props.length; i++) {
- assertNotNull("There is no property among returned properties: "
- + props[i], p.getProperty(props[i]));
- assertNotNull("System property is null: " + props[i],
- System.getProperty(props[i]));
- }
- }
-
- /**
- * @tests java.lang.System#getProperty(java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getProperty",
- args = {java.lang.String.class}
- )
- public void test_getPropertyLjava_lang_String() {
- // Test for method java.lang.String
- // java.lang.System.getProperty(java.lang.String)
- assertTrue("Failed to return correct property value", System
- .getProperty("line.separator").indexOf("\n", 0) >= 0);
-
- boolean is8859_1 = true;
- String encoding = System.getProperty("file.encoding");
- byte[] bytes = new byte[128];
- char[] chars = new char[128];
- for (int i = 0; i < bytes.length; i++) {
- bytes[i] = (byte) (i + 128);
- chars[i] = (char) (i + 128);
- }
- String charResult = new String(bytes);
- byte[] byteResult = new String(chars).getBytes();
- if (charResult.length() == 128 && byteResult.length == 128) {
- for (int i = 0; i < bytes.length; i++) {
- if (charResult.charAt(i) != (char) (i + 128)
- || byteResult[i] != (byte) (i + 128))
- is8859_1 = false;
- }
- } else
- is8859_1 = false;
- String[] possibles = new String[] { "ISO8859_1", "8859_1", "ISO8859-1",
- "ISO-8859-1", "ISO_8859-1", "ISO_8859-1:1978", "ISO-IR-100",
- "LATIN1", "CSISOLATIN1" };
- boolean found8859_1 = false;
- for (int i = 0; i < possibles.length; i++) {
- if (possibles[i].equals(encoding)) {
- found8859_1 = true;
- break;
- }
- }
- assertTrue("Wrong encoding: " + encoding, !is8859_1 || found8859_1);
-
- try {
- System.getProperty(null);
- fail("NullPointerException should be thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
-
- try {
- System.getProperty("");
- fail("IllegalArgumentException should be thrown.");
- } catch(IllegalArgumentException iae) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.System#getProperty(java.lang.String, java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getProperty",
- args = {java.lang.String.class, java.lang.String.class}
- )
- public void test_getPropertyLjava_lang_StringLjava_lang_String() {
- // Test for method java.lang.String
- // java.lang.System.getProperty(java.lang.String, java.lang.String)
- assertTrue("Failed to return correct property value: "
- + System.getProperty("line.separator", "99999"), System
- .getProperty("line.separator", "99999").indexOf("\n", 0) >= 0);
- assertEquals("Failed to return correct property value", "bogus", System
- .getProperty("bogus.prop", "bogus"));
-
- try {
- System.getProperty(null, "0.0");
- fail("NullPointerException should be thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
-
- try {
- System.getProperty("", "0");
- fail("IllegalArgumentException should be thrown.");
- } catch(IllegalArgumentException iae) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.System#setProperty(java.lang.String, java.lang.String)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "setProperty",
- args = {java.lang.String.class, java.lang.String.class}
- )
- public void test_setPropertyLjava_lang_StringLjava_lang_String() {
- // Test for method java.lang.String
- // java.lang.System.setProperty(java.lang.String, java.lang.String)
-
- assertNull("Failed to return null", System.setProperty("testing",
- "value1"));
- assertTrue("Failed to return old value", System.setProperty("testing",
- "value2") == "value1");
- assertTrue("Failed to find value",
- System.getProperty("testing") == "value2");
-
- boolean exception = false;
- try {
- System.setProperty("", "default");
- } catch (IllegalArgumentException e) {
- exception = true;
- }
- assertTrue("Expected IllegalArgumentException", exception);
- }
-
- /**
- * @tests java.lang.System#getSecurityManager()
- */
- @TestTargetNew(
- level = TestLevel.PARTIAL,
- notes = "Doesn't check positive functionality.",
- method = "getSecurityManager",
- args = {}
- )
- public void test_getSecurityManager() {
- // Test for method java.lang.SecurityManager
- // java.lang.System.getSecurityManager()
- assertNull("Returned incorrect SecurityManager", System
- .getSecurityManager());
- }
-
- /**
- * @tests java.lang.System#identityHashCode(java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "identityHashCode",
- args = {java.lang.Object.class}
- )
- public void test_identityHashCodeLjava_lang_Object() {
- // Test for method int
- // java.lang.System.identityHashCode(java.lang.Object)
- Object o = new Object();
- String s = "Gabba";
- assertEquals("Nonzero returned for null",
- 0, System.identityHashCode(null));
- assertTrue("Nonequal has returned for Object", System
- .identityHashCode(o) == o.hashCode());
- assertTrue("Same as usual hash returned for String", System
- .identityHashCode(s) != s.hashCode());
- }
-
- /**
- * @throws IOException
- * @tests java.lang.System#inheritedChannel()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "inheritedChannel",
- args = {}
- )
- public void test_inheritedChannel() throws IOException {
- Channel iChannel = System.inheritedChannel();
- assertNull("Incorrect value of channel", iChannel);
- SelectorProvider sp = SelectorProvider.provider();
- assertEquals("Incorrect value of channel",
- sp.inheritedChannel(), iChannel);
- }
-
- /**
- * @tests java.lang.System#runFinalization()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "runFinalization",
- args = {}
- )
- public void test_runFinalization() {
- // Test for method void java.lang.System.runFinalization()
-
- flag = true;
- createInstance();
- int count = 10;
- // the gc below likely bogosifies the test, but will have to do for
- // the moment
- while (!ranFinalize && count-- > 0) {
- System.gc();
- System.runFinalization();
- }
- assertTrue("Failed to run finalization", ranFinalize);
- }
-
- /**
- * @tests java.lang.System#runFinalizersOnExit(boolean)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "runFinalizersOnExit",
- args = {boolean.class}
- )
- @SuppressWarnings("deprecation")
- public void test_runFinalizersOnExitZ() {
- // Can we call the method at least?
- try {
- System.runFinalizersOnExit(false);
- } catch (Throwable t) {
- fail("Failed to set runFinalizersOnExit");
- }
-
- try {
- System.runFinalizersOnExit(true);
- } catch (Throwable t) {
- fail("Failed to set runFinalizersOnExit");
- }
- }
-
- /**
- * @tests java.lang.System#setProperties(java.util.Properties)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "setProperties",
- args = {java.util.Properties.class}
- )
- public void test_setPropertiesLjava_util_Properties() {
- // Test for method void
- // java.lang.System.setProperties(java.util.Properties)
-
- Properties orgProps = System.getProperties();
- java.util.Properties tProps = new java.util.Properties();
- tProps.put("test.prop", "this is a test property");
- tProps.put("bogus.prop", "bogus");
- System.setProperties(tProps);
- try {
- assertEquals("Failed to set properties", "this is a test property", System.getProperties()
- .getProperty("test.prop"));
- } finally {
- // restore the original properties
- System.setProperties(orgProps);
- }
- }
-
- //Regression Test for Harmony-2356
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getenv",
- args = {}
- )
- public void testEnvUnmodifiable() {
- Map map = System.getenv();
- try {
- map.containsKey(null);
- fail("Should throw NullPointerExcepiton.");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- map.containsKey(new Integer(10));
- fail("Should throw ClassCastException.");
- } catch (ClassCastException e) {
- // expected
- }
-
- try {
- map.containsValue(null);
- fail("Should throw NullPointerExcepiton.");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- map.containsValue(new Integer(10));
- fail("Should throw ClassCastException.");
- } catch (ClassCastException e) {
- // expected
- }
-
- try {
- map.get(null);
- fail("Should throw NullPointerExcepiton.");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- map.get(new Integer(10));
- fail("Should throw ClassCastException.");
- } catch (ClassCastException e) {
- // expected
- }
-
- try {
- map.put(null, "AAA");
- fail("Should throw UnsupportedOperationExcepiton.");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- map.put("AAA", new Integer(10));
- fail("Should throw UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- map.put("AAA", "BBB");
- fail("Should throw UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- map.clear();
- fail("Should throw UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- try {
- map.remove(null);
- fail("Should throw UnsupportedOperationException.");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- }
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "clearProperty",
- args = {java.lang.String.class}
- )
- public void test_clearProperty() {
- System.setProperty("test", "value");
- System.clearProperty("test");
- assertNull("Property was not deleted.", System.getProperty("test"));
-
- try {
- System.clearProperty(null);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
-
- try {
- System.clearProperty("");
- fail("IllegalArgumentException is not thrown.");
- } catch(IllegalArgumentException iae) {
- //expected
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "gc",
- args = {}
- )
- public void test_gc() {
- Runtime rt = Runtime.getRuntime();
- Vector<StringBuffer> vec = new Vector<StringBuffer>();
- long beforeTest = rt.freeMemory();
- while(rt.freeMemory() < beforeTest * 2/3) {
- vec.add(new StringBuffer(1000));
- }
- vec = null;
- long beforeGC = rt.freeMemory();
- System.gc();
- long afterGC = rt.freeMemory();
- assertTrue("memory was not released after calling System.gc()." +
- "before gc: " + beforeGC + "; after gc: " + afterGC,
- beforeGC < afterGC);
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getenv",
- args = {}
- )
- public void test_getenv() {
-
- // String[] props = { "PATH", "HOME", "USER"};
- // only PATH of these three exists on android
- String[] props = { "PATH" };
-
- Map<String,String> envMap = System.getenv();
- assertFalse("environment map is empty.", envMap.isEmpty());
- assertTrue("env map contains less than 3 keys.",
- props.length < envMap.keySet().size());
- for(int i = 0; i < props.length; i++) {
- assertNotNull("There is no property: " + props[i],
- envMap.get(props[i]));
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getenv",
- args = {java.lang.String.class}
- )
- public void test_getenvLString() {
-
- assertNotNull("PATH environment variable is not found",
- System.getenv("PATH"));
-
- assertNull("Doesn't return NULL for non existent property",
- System.getenv("nonexistent.property"));
-
- try {
- System.getenv(null);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "load",
- args = {java.lang.String.class}
- )
- public void test_load() {
- try {
- Runtime.getRuntime().load("nonExistentLibrary");
- fail("UnsatisfiedLinkError was not thrown.");
- } catch(UnsatisfiedLinkError e) {
- //expected
- }
-
- try {
- System.load("nonExistentLibrary");
- fail("UnsatisfiedLinkError was not thrown.");
- } catch(UnsatisfiedLinkError ule) {
- //expected
- }
-
- try {
- System.load(null);
- fail("NullPointerException was not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "loadLibrary",
- args = {java.lang.String.class}
- )
- public void test_loadLibrary() {
-
- try {
- System.loadLibrary("nonExistentLibrary");
- fail("UnsatisfiedLinkError was not thrown.");
- } catch(UnsatisfiedLinkError ule) {
- //expected
- }
-
- try {
- System.loadLibrary(null);
- fail("NullPointerException was not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "mapLibraryName",
- args = {java.lang.String.class}
- )
- public void test_mapLibraryName() {
- assertEquals("libname.so", System.mapLibraryName("name"));
-
- try {
- System.mapLibraryName(null);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException npe) {
- //expected
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "nanoTime",
- args = {}
- )
- public void test_nanoTime() {
- long sleepTime = 5000;
- long beginTime = System.nanoTime();
- try {
- Thread.sleep(sleepTime);
- } catch(Exception e) {
- fail("Unknown exception was thrown.");
- }
- long endTime = System.nanoTime();
- assertTrue((endTime - beginTime) > sleepTime * 1000000);
- }
-
- @Override
- protected void setUp() {
- flag = false;
- ranFinalize = false;
- }
-
- @Override protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- protected SystemTest createInstance() {
- return new SystemTest("FT");
- }
-
- @Override
- protected void finalize() {
- if (flag)
- ranFinalize = true;
- }
-
- public SystemTest() {
- }
-
- public SystemTest(String name) {
- super(name);
- }
-
- private class MockSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission perm) {
- if (perm.equals(new RuntimePermission("inheritedChannel")))
- throw new SecurityException("Incorrect permission");
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAnnotation.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAnnotation.java
deleted file mode 100644
index 45d16ad..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAnnotation.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface TestAnnotation {
- String value();
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAssertions.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAssertions.java
deleted file mode 100644
index 3006553..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAssertions.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class TestAssertions {
- boolean isTrue = false;
-
- TestAssertions() {
-
- }
-
- public void test() throws AssertionError {
- assert (isTrue == true);
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAssertions1.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAssertions1.java
deleted file mode 100644
index 16958cb..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestAssertions1.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class TestAssertions1 {
- boolean isTrue = true;
-
- TestAssertions1() {
-
- }
-
- public void test() throws AssertionError {
- assert (isTrue == false);
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1.java
deleted file mode 100644
index 2d21de6..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class TestClass1 {
- static TestClass2 tc = new TestClass2(0);
-
- TestClass1() {
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1B.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1B.java
deleted file mode 100644
index 7891613..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1B.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class TestClass1B {
- static TestClass2 tc = new TestClass2(0);
-
- TestClass1B() {
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1C.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1C.java
deleted file mode 100644
index 37c890f..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass1C.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class TestClass1C {
- static TestClass2 tc = new TestClass2(0);
-
- TestClass1C() {
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass2.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass2.java
deleted file mode 100644
index 26be6fa..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass2.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class TestClass2 {
-
- public TestClass2(int i) throws IllegalArgumentException {
- throw new IllegalArgumentException();
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass3.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass3.java
deleted file mode 100644
index 21ebb38..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass3.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class TestClass3 {
- private TestClass3() {}
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass4.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass4.java
deleted file mode 100644
index e69de29..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TestClass4.java
+++ /dev/null
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadDeathTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadDeathTest.java
deleted file mode 100644
index c40e0b0..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadDeathTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-public class ThreadDeathTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.ThreadDeath#ThreadDeath()
- */
- public void test_Constructor() {
- ThreadDeath td = new ThreadDeath();
- assertNull(td.getCause());
- assertNull(td.getMessage());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadLocalTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadLocalTest.java
deleted file mode 100644
index 659a839..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThreadLocalTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-@TestTargetClass(ThreadLocal.class)
-public class ThreadLocalTest extends TestCase {
-
- /**
- * @tests java.lang.ThreadLocal#ThreadLocal()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "ThreadLocal",
- args = {}
- )
- public void test_Constructor() {
- new ThreadLocal<Object>();
- }
-
- /**
- * @tests java.lang.ThreadLocal#remove()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "remove",
- args = {}
- )
- public void test_remove() {
- ThreadLocal<String> tl = new ThreadLocal<String>() {
- @Override
- protected String initialValue() {
- return "initial";
- }
- };
-
- assertEquals("initial", tl.get());
- tl.set("fixture");
- assertEquals("fixture", tl.get());
- tl.remove();
- assertEquals("initial", tl.get());
- }
-
- /**
- * @tests java.lang.ThreadLocal#get()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "get",
- args = {}
- )
- public void test_get() {
- // Test for method java.lang.Object java.lang.ThreadLocal.get()
- ThreadLocal<Object> l = new ThreadLocal<Object>();
- assertNull("ThreadLocal's initial value is null", l.get());
-
- // The ThreadLocal has to run once for each thread that touches the
- // ThreadLocal
- final Object INITIAL_VALUE = "'foo'";
- final ThreadLocal<Object> l1 = new ThreadLocal<Object>() {
- @Override
- protected Object initialValue() {
- return INITIAL_VALUE;
- }
- };
-
- assertTrue("ThreadLocal's initial value should be " + INITIAL_VALUE
- + " but is " + l1.get(), l1.get() == INITIAL_VALUE);
-
- // We need this because inner types cannot assign to variables in
- // container method. But assigning to object slots in the container
- // method is ok.
- class ResultSlot {
- public Object result = null;
- }
-
- final ResultSlot THREADVALUE = new ResultSlot();
- Thread t = new Thread() {
- @Override
- public void run() {
- THREADVALUE.result = l1.get();
- }
- };
-
- // Wait for the other Thread assign what it observes as the value of the
- // variable
- t.start();
- try {
- t.join();
- } catch (InterruptedException ie) {
- fail("Interrupted!!");
- }
-
- assertTrue("ThreadLocal's initial value in other Thread should be "
- + INITIAL_VALUE, THREADVALUE.result == INITIAL_VALUE);
-
- /* Regression test for implementation vulnerability reported
- * on Harmony dev list.
- */
- ThreadLocal<Object> thrVar = new ThreadLocal<Object>() {
- public int hashCode() {
- fail("ThreadLocal should not be asked for it's hashCode");
- return 0; // never reached
- }
- };
- thrVar.get();
- }
-
- /**
- * @tests java.lang.ThreadLocal#set(java.lang.Object)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "set",
- args = {java.lang.Object.class}
- )
- public void test_setLjava_lang_Object() {
- // Test for method void java.lang.ThreadLocal.set(java.lang.Object)
-
- final Object OBJ = new Object();
- final ThreadLocal<Object> l = new ThreadLocal<Object>();
- l.set(OBJ);
- assertTrue("ThreadLocal's initial value is " + OBJ, l.get() == OBJ);
-
- // We need this because inner types cannot assign to variables in
- // container method.
- // But assigning to object slots in the container method is ok.
- class ResultSlot {
- public Object result = null;
- }
-
- final ResultSlot THREADVALUE = new ResultSlot();
- Thread t = new Thread() {
- @Override
- public void run() {
- THREADVALUE.result = l.get();
- }
- };
-
- // Wait for the other Thread assign what it observes as the value of the
- // variable
- t.start();
- try {
- t.join();
- } catch (InterruptedException ie) {
- fail("Interrupted!!");
- }
-
- // ThreadLocal is not inherited, so the other Thread should see it as
- // null
- assertNull("ThreadLocal's value in other Thread should be null",
- THREADVALUE.result);
-
- }
-
- /**
- * @tests java.lang.InheritableThreadLocal
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "get",
- args = {}
- )
- public void test_Ljava_lang_InheritableThreadLocal()
- throws InterruptedException {
- final Object value = new Object();
- final Object inheritedValue = new Object();
- final ThreadLocal<Object> threadLocal
- = new InheritableThreadLocal<Object>() {
- @Override
- protected Object childValue(Object parentValue) {
- assertSame(value, parentValue);
- return inheritedValue;
- }
- };
- threadLocal.set(value);
- final Object[] holder = new Object[1];
- Thread thread = new Thread() {
- public void run() {
- holder[0] = threadLocal.get();
- }
- };
- thread.start();
- thread.join();
- assertSame(value, threadLocal.get());
- assertSame(inheritedValue, holder[0]);
-
- // Cleanup properly, so other tests are not affected.
- threadLocal.remove();
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThrowableTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThrowableTest.java
deleted file mode 100644
index a8e5c7f..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ThrowableTest.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.harmony.luni.tests.java.lang;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-@TestTargetClass(Throwable.class)
-public class ThrowableTest extends TestCase {
-
- /**
- * @tests java.lang.Throwable#Throwable()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Throwable",
- args = {}
- )
- public void test_Constructor() {
- Throwable e = new Throwable();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.Throwable#Throwable(java.lang.String)
- */
- @TestTargets({
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Throwable",
- args = {java.lang.String.class}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getMessage",
- args = {}
- )
- })
- public void test_ConstructorLjava_lang_String() {
- Throwable e = new Throwable("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- @TestTargets({
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Throwable",
- args = {java.lang.String.class, java.lang.Throwable.class}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getCause",
- args = {}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getMessage",
- args = {}
- )
- })
- public void test_ConstructorLStringLThrowable() {
- String message = "Test message";
- NullPointerException npe = new NullPointerException();
- Throwable thr = new Throwable(message, npe);
- assertEquals("message is incorrect.", message, thr.getMessage());
- assertEquals("cause is incorrect.", npe, thr.getCause());
-
- thr = new Throwable(null, npe);
- assertNull("message is not null.", thr.getMessage());
- assertEquals("cause is incorrect.", npe, thr.getCause());
-
- thr = new Throwable(message, null);
- assertEquals("message is incorrect.", message, thr.getMessage());
- assertNull("cause is not null.", thr.getCause());
- }
-
- @TestTargets({
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "Throwable",
- args = {java.lang.Throwable.class}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getCause",
- args = {}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getMessage",
- args = {}
- )
- })
- public void test_ConstructorLThrowable() {
-
- NullPointerException npe = new NullPointerException();
- Throwable thr = new Throwable(npe);
-
- assertEquals("Returned cause is incorrect.", npe, thr.getCause());
-
- thr = new Throwable((Throwable) null);
- assertNull("The cause is not null.", thr.getCause());
- }
-
- /**
- * @tests java.lang.Throwable#fillInStackTrace()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "fillInStackTrace",
- args = {}
- )
- public void test_fillInStackTrace() {
- // Test for method java.lang.Throwable
- // java.lang.Throwable.fillInStackTrace()
- class Test implements Runnable {
- public int x;
-
- public Test(int x) {
- this.x = x;
- }
-
- public void anotherMethod() {
- if (true)
- throw new IndexOutOfBoundsException();
- }
-
- public void run() {
- if (x == 0)
- throw new IndexOutOfBoundsException();
- try {
- anotherMethod();
- } catch (IndexOutOfBoundsException e) {
- e.fillInStackTrace();
- throw e;
- }
- }
- }
- ByteArrayOutputStream bao = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(bao);
- try {
- new Test(0).run();
- } catch (Throwable e) {
- e.printStackTrace(ps);
- }
- ps.flush();
- String s = fixStacktrace(new String(bao.toByteArray(), 0, bao.size()));
-
- bao.reset();
- try {
- new Test(1).run();
- } catch (Throwable e) {
- e.printStackTrace(ps);
- }
- ps.close();
- String s2 = fixStacktrace(new String(bao.toByteArray(), 0, bao.size()));
- assertTrue("Invalid stackTrace? length: " + s2.length() + "\n" + s2, s2
- .length() > 300);
- assertTrue("Incorrect stackTrace printed: \n" + s2
- + "\n\nCompared with:\n" + s, s2.equals(s));
- }
-
- private String fixStacktrace(String trace) {
- // remove linenumbers
- StringBuffer sb = new StringBuffer();
- int lastIndex = 0;
- while (lastIndex < trace.length()) {
- int index = trace.indexOf('\n', lastIndex);
- if (index == -1)
- index = trace.length();
- String line = trace.substring(lastIndex, index);
- lastIndex = index + 1;
-
- index = line.indexOf("(");
- if (index > -1) {
- line = line.substring(0, index);
- }
- // Usually the construction of the exception is removed
- // however if running with the JIT, it may not be removed
- if (line.indexOf("java.lang.Throwable") > -1)
- continue;
- sb.append(line);
- sb.append('\n');
- }
- return sb.toString();
- }
-
- /**
- * @tests java.lang.Throwable#printStackTrace()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "printStackTrace",
- args = {}
- )
- public void test_printStackTrace() {
- // Test for method void java.lang.Throwable.printStackTrace()
- Throwable x = new ClassNotFoundException("A Test Message");
- ByteArrayOutputStream bao = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(bao);
- PrintStream err = System.err;
- System.setErr(ps);
- x.printStackTrace();
- System.setErr(err);
- ps.close();
- String s = new String(bao.toByteArray(), 0, bao.size());
- assertTrue("Incorrect stackTrace printed:\n" + s, s != null
- && s.length() > 400);
- }
-
- /**
- * @tests java.lang.Throwable#printStackTrace(java.io.PrintStream)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "printStackTrace",
- args = {java.io.PrintStream.class}
- )
- public void test_printStackTraceLjava_io_PrintStream() {
- // Test for method void
- // java.lang.Throwable.printStackTrace(java.io.PrintStream)
- ByteArrayOutputStream bao = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(bao);
- Throwable x = new java.net.UnknownHostException("A Message");
- x.printStackTrace(ps);
- ps.close();
- String s = new String(bao.toByteArray(), 0, bao.size());
- assertTrue("Incorrect stackTrace printed:\n" + s, s != null
- && s.length() > 400);
- }
-
- /**
- * @tests java.lang.Throwable#printStackTrace(java.io.PrintWriter)
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "printStackTrace",
- args = {java.io.PrintWriter.class}
- )
- public void test_printStackTraceLjava_io_PrintWriter() {
- // Test for method void
- // java.lang.Throwable.printStackTrace(java.io.PrintWriter)
- // SM
- ByteArrayOutputStream bao = new ByteArrayOutputStream();
- PrintWriter pw = new PrintWriter(bao);
- Throwable x = new java.net.UnknownHostException("A Message");
- x.printStackTrace(pw);
- pw.close();
- String s = new String(bao.toByteArray(), 0, bao.size());
- assertTrue("Incorrect stackTrace printed:\n" + s, s != null
- && s.length() > 400);
- }
-
- /**
- * @tests java.lang.Throwable#toString()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "toString",
- args = {}
- )
- public void test_toString() {
- Throwable e = new Throwable("Throw");
- assertEquals("java.lang.Throwable: Throw", e.toString());
-
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getLocalizedMessage",
- args = {}
- )
- public void test_getLocalizedMessage() {
- String testMessage = "Test message";
- Throwable e = new Throwable(testMessage);
- assertEquals("Returned incorrect localized message.",
- testMessage, e.getLocalizedMessage());
-
- TestThrowable tt = new TestThrowable(testMessage);
- assertEquals("localized message", tt.getLocalizedMessage());
- }
-
- class TestThrowable extends Throwable {
-
- public TestThrowable(String message) {
- super(message);
- }
-
- public String getLocalizedMessage() {
- return "localized message";
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getStackTrace",
- args = {}
- )
- public void test_getStackTrace() {
- String message = "Test message";
- NullPointerException npe = new NullPointerException();
- Throwable thr = new Throwable(message, npe);
- StackTraceElement[] ste = thr.getStackTrace();
- assertNotNull("Returned stack trace is empty", ste.length != 0);
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "initCause",
- args = {java.lang.Throwable.class}
- )
- public void test_initCause() {
- String message = "Test message";
- NullPointerException npe = new NullPointerException();
- IllegalArgumentException iae = new IllegalArgumentException();
- Throwable thr = new Throwable();
- thr.initCause(iae);
- assertEquals("getCause returns incorrect cause.", iae, thr.getCause());
-
- thr = new Throwable("message");
- thr.initCause(npe);
- assertEquals("getCause returns incorrect cause.", npe, thr.getCause());
-
- thr = new Throwable(message, npe);
- try {
- thr.initCause(iae);
- fail("IllegalStateException was not thrown.");
- } catch(IllegalStateException ise) {
- //expected
- }
-
- thr = new Throwable(npe);
- try {
- thr.initCause(iae);
- fail("IllegalStateException was not thrown.");
- } catch(IllegalStateException ise) {
- //expected
- }
-
- thr = new Throwable();
- try {
- thr.initCause(thr);
- fail("IllegalArgumentException was not thrown.");
- } catch(IllegalArgumentException ise) {
- //expected
- }
- }
-
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "setStackTrace",
- args = {java.lang.StackTraceElement[].class}
- )
- public void test_setStackTrace() {
- NullPointerException npe = new NullPointerException();
- Throwable thr = new Throwable(npe);
- StackTraceElement[] ste = thr.getStackTrace();
- Throwable thr1 = new Throwable(npe);
- thr1.setStackTrace(ste);
- assertEquals(ste.length, thr1.getStackTrace().length);
-
- try {
- thr.setStackTrace(null);
- fail("NullPointerException is not thrown.");
- } catch(NullPointerException np) {
- //expected
- }
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TypeNotPresentExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TypeNotPresentExceptionTest.java
deleted file mode 100644
index 76df014..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/TypeNotPresentExceptionTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class TypeNotPresentExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.TypeNotPresentException.TypeNotPresentException(String, Throwable)
- */
- public void test_constructorLjava_lang_StringLjava_lang_Throwable() {
- TypeNotPresentException e = new TypeNotPresentException(null, null);
- assertNotNull(e);
- String m = e.getMessage();
- assertNotNull(m);
-
- e = new TypeNotPresentException(getClass().getName(), null);
- assertNotNull(e);
- m = e.getMessage();
- assertNotNull(m);
-
- NullPointerException npe = new NullPointerException();
- e = new TypeNotPresentException(getClass().getName(), npe);
- assertNotNull(e.getMessage());
- assertSame(npe, e.getCause());
- }
-
- /**
- * @tests java.lang.TypeNotPresentException.typeName()
- */
- public void test_typeName() {
- TypeNotPresentException e = new TypeNotPresentException(null, null);
- assertNull(e.typeName());
-
- e = new TypeNotPresentException(getClass().getName(), null);
- assertEquals(getClass().getName(), e.typeName());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnknownErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnknownErrorTest.java
deleted file mode 100644
index 15f264b..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnknownErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class UnknownErrorTest extends TestCase {
-
- /**
- * @tests java.lang.UnknownError#UnknownError()
- */
- public void test_Constructor() {
- UnknownError e = new UnknownError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.UnknownError#UnknownError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- UnknownError e = new UnknownError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsatisfiedLinkErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsatisfiedLinkErrorTest.java
deleted file mode 100644
index 84229d8..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsatisfiedLinkErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class UnsatisfiedLinkErrorTest extends TestCase {
-
- /**
- * @tests java.lang.UnsatisfiedLinkError#UnsatisfiedLinkError()
- */
- public void test_Constructor() {
- UnsatisfiedLinkError e = new UnsatisfiedLinkError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.UnsatisfiedLinkError#UnsatisfiedLinkError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- UnsatisfiedLinkError e = new UnsatisfiedLinkError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsupportedClassVersionErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsupportedClassVersionErrorTest.java
deleted file mode 100644
index 791ec16..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsupportedClassVersionErrorTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase; // android-changed
-
-public class UnsupportedClassVersionErrorTest extends TestCase { // android-changed
- /**
- * Thrown when the Java Virtual Machine attempts to read a class file and
- * determines that the major and minor version numbers in the file are not
- * supported.
- */
-
- /**
- * @tests java.lang.UnsupportedClassVersionError#UnsupportedClassVersionError()
- */
- public void test_UnsupportedClassVersionError() {
- UnsupportedClassVersionError error = new UnsupportedClassVersionError();
- assertNotNull(error);
- assertNull(error.getMessage());
- }
-
- /**
- *@tests java.lang.UnsupportedClassVersionError#UnsupportedClassVersionError(java.lang.String)
- */
- public void test_UnsupportedClassVersionError_LString() {
- UnsupportedClassVersionError e = new UnsupportedClassVersionError(
- "Some Error Message");
- assertEquals("Wrong message", "Some Error Message", e.getMessage());
- }
-
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsupportedOperationExceptionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsupportedOperationExceptionTest.java
deleted file mode 100644
index 4b1dbd8..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/UnsupportedOperationExceptionTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-public class UnsupportedOperationExceptionTest extends TestCase {
-
- /**
- * @tests java.lang.UnsupportedOperationException#UnsupportedOperationException()
- */
- public void test_Constructor() {
- UnsupportedOperationException e = new UnsupportedOperationException();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.UnsupportedOperationException#UnsupportedOperationException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- UnsupportedOperationException e = new UnsupportedOperationException("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests {@link java.land.UnsupportedOperationException#UnsupportedOperationException(java.lang.Throwable)}
- */
- public void test_ConstructorLjava_lang_Throwable() {
- Throwable emptyThrowable = new Exception();
- UnsupportedOperationException emptyException = new UnsupportedOperationException(
- emptyThrowable);
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getMessage());
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getLocalizedMessage());
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getCause().toString());
-
- Throwable throwable = new Exception("msg");
- UnsupportedOperationException exception = new UnsupportedOperationException(throwable);
- assertEquals(throwable.getClass().getName() + ": " + "msg", exception.getMessage());
- assertEquals(throwable.getClass().getName(), emptyException.getLocalizedMessage());
- assertEquals(throwable.getClass().getName(), emptyException.getCause().toString());
- }
-
- /**
- * @tests {@link java.land.UnsupportedOperationException#UnsupportedOperationException(java.lang.String, java.lang.Throwable)}
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_Throwable() {
- Throwable emptyThrowable = new Exception();
- UnsupportedOperationException emptyException = new UnsupportedOperationException(
- "msg", emptyThrowable);
- assertEquals("msg", emptyException.getMessage());
- assertEquals("msg", emptyException.getLocalizedMessage());
- assertEquals(emptyThrowable.getClass().getName(), emptyException.getCause().toString());
-
- Throwable throwable = new Exception("msg_exception");
- UnsupportedOperationException exception = new UnsupportedOperationException(
- "msg", throwable);
- assertEquals("msg", exception.getMessage());
- assertEquals("msg", exception.getLocalizedMessage());
- assertEquals(throwable.getClass().getName() + ": " + throwable.getMessage(), exception
- .getCause().toString());
- }
-
-
- /**
- * @tests serialization/deserialization.
- */
- public void testSerializationSelf() throws Exception {
-
- SerializationTest.verifySelf(new UnsupportedOperationException());
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this,
- new UnsupportedOperationException());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/VerifyErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/VerifyErrorTest.java
deleted file mode 100644
index 7bd2581..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/VerifyErrorTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-public class VerifyErrorTest extends TestCase {
-
- /**
- * @tests java.lang.VerifyError#VerifyError()
- */
- public void test_Constructor() {
- VerifyError e = new VerifyError();
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.VerifyError#VerifyError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- VerifyError e = new VerifyError("fixture");
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/VirtualMachineErrorTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/VirtualMachineErrorTest.java
deleted file mode 100644
index c8ce58c..0000000
--- a/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/VirtualMachineErrorTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.lang;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("serial")
-public class VirtualMachineErrorTest extends TestCase {
-
- /**
- * @tests java.lang.VirtualMachineError#VirtualMachineError()
- */
- public void test_Constructor() {
- VirtualMachineError e = new VirtualMachineError() {};
- assertNull(e.getMessage());
- assertNull(e.getLocalizedMessage());
- assertNull(e.getCause());
- }
-
- /**
- * @tests java.lang.VirtualMachineError#VirtualMachineError(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- VirtualMachineError e = new VirtualMachineError("fixture") {};
- assertEquals("fixture", e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/luni/src/test/java/tests/luni/AllTestsLang.java b/luni/src/test/java/tests/luni/AllTestsLang.java
index 3da5bb4..a7a18a8 100644
--- a/luni/src/test/java/tests/luni/AllTestsLang.java
+++ b/luni/src/test/java/tests/luni/AllTestsLang.java
@@ -33,8 +33,6 @@
public static final Test suite() {
TestSuite suite = new TestSuite("Tests for java.lang");
- suite.addTest(org.apache.harmony.luni.tests.java.lang.AllTests.suite());
-
suite.addTest(tests.api.java.lang.AllTests.suite());
suite.addTest(tests.api.java.lang.ref.AllTests.suite());
diff --git a/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/HelloWorld.txt b/luni/src/test/resources/libcore/java/lang/HelloWorld.txt
similarity index 100%
rename from luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/HelloWorld.txt
rename to luni/src/test/resources/libcore/java/lang/HelloWorld.txt
diff --git a/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/HelloWorld1.txt b/luni/src/test/resources/libcore/java/lang/HelloWorld1.txt
similarity index 100%
rename from luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/HelloWorld1.txt
rename to luni/src/test/resources/libcore/java/lang/HelloWorld1.txt