Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java Mon Aug 28 22:40:44 2006
@@ -1,411 +1,411 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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 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#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);
- }
-
- /**
- * @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));
- assertEquals("Incorrect answer", 0.5403023058681398, Math.cos(1));
- }
-
- /**
- * @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#floor(double)
- */
- public void test_floorD() {
- // Test for method double java.lang.Math.floor(double)
- assertEquals("Incorrect floor for double",
- 78, Math.floor(78.89), 0);
- assertEquals("Incorrect floor for double",
- -79, Math.floor(-78.89), 0);
- }
-
- /**
- * @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));
- 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#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));
- assertEquals("Incorrect double max value",
- 1908897.6000089, Math.max(2.0, 1908897.6000089));
- assertEquals("Incorrect double max value", -2.0, Math.max(-2.0,
- -1908897.6000089));
-
- }
-
- /**
- * @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);
- }
-
- /**
- * @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));
- assertEquals("Incorrect double min value",
- 2.0, Math.min(2.0, 1908897.6000089));
- assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-2.0,
- -1908897.6000089));
- }
-
- /**
- * @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);
- }
-
- /**
- * @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));
- }
-
- /**
- * @tests java.lang.Math#pow(double, double)
- */
- public void test_powDD() {
- // Test for method double java.lang.Math.pow(double, double)
- 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);
- }
-
- /**
- * @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));
- 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));
- assertTrue("Failed to round properly " + 2.5 + " to even", Math
- .rint(2.5) == 2.0);
- }
-
- /**
- * @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 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));
- assertEquals("Incorrect answer", 0.8414709848078965, Math.sin(1));
- }
-
- /**
- * @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));
- assertEquals("Incorrect answer", 1.5574077246549023, Math.tan(1));
-
- }
-
- /**
- * @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);
- }
- }
-
- /**
- * 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() {
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 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#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);
+ }
+
+ /**
+ * @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));
+ assertEquals("Incorrect answer", 0.5403023058681398, Math.cos(1));
+ }
+
+ /**
+ * @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#floor(double)
+ */
+ public void test_floorD() {
+ // Test for method double java.lang.Math.floor(double)
+ assertEquals("Incorrect floor for double",
+ 78, Math.floor(78.89), 0);
+ assertEquals("Incorrect floor for double",
+ -79, Math.floor(-78.89), 0);
+ }
+
+ /**
+ * @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));
+ 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#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));
+ assertEquals("Incorrect double max value",
+ 1908897.6000089, Math.max(2.0, 1908897.6000089));
+ assertEquals("Incorrect double max value", -2.0, Math.max(-2.0,
+ -1908897.6000089));
+
+ }
+
+ /**
+ * @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);
+ }
+
+ /**
+ * @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));
+ assertEquals("Incorrect double min value",
+ 2.0, Math.min(2.0, 1908897.6000089));
+ assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-2.0,
+ -1908897.6000089));
+ }
+
+ /**
+ * @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);
+ }
+
+ /**
+ * @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));
+ }
+
+ /**
+ * @tests java.lang.Math#pow(double, double)
+ */
+ public void test_powDD() {
+ // Test for method double java.lang.Math.pow(double, double)
+ 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);
+ }
+
+ /**
+ * @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));
+ 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));
+ assertTrue("Failed to round properly " + 2.5 + " to even", Math
+ .rint(2.5) == 2.0);
+ }
+
+ /**
+ * @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 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));
+ assertEquals("Incorrect answer", 0.8414709848078965, Math.sin(1));
+ }
+
+ /**
+ * @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));
+ assertEquals("Incorrect answer", 1.5574077246549023, Math.tan(1));
+
+ }
+
+ /**
+ * @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);
+ }
+ }
+
+ /**
+ * 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() {
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java Mon Aug 28 22:40:44 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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.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());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.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());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NegativeArraySizeExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java Mon Aug 28 22:40:44 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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.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());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.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());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoClassDefFoundErrorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java Mon Aug 28 22:40:44 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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.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());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.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());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldErrorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java Mon Aug 28 22:40:44 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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.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());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.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());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchFieldExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java Mon Aug 28 22:40:44 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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.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());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.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());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodErrorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java Mon Aug 28 22:40:44 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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.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());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.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());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NoSuchMethodExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java Mon Aug 28 22:40:44 2006
@@ -1,39 +1,39 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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.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());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.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());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NullPointerExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java Mon Aug 28 22:40:44 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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.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());
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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.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());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberFormatExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java Mon Aug 28 22:40:44 2006
@@ -1,77 +1,77 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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 NumberTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.Number#Number()
- */
- public void test_Constructor() {
- assertTrue("Nothing to test", true);
- }
-
- /**
- * @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());
-
- }
-
- protected void setUp() {
- }
-
- protected void tearDown() {
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 NumberTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.lang.Number#Number()
+ */
+ public void test_Constructor() {
+ assertTrue("Nothing to test", true);
+ }
+
+ /**
+ * @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());
+
+ }
+
+ protected void setUp() {
+ }
+
+ protected void tearDown() {
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/NumberTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java?rev=437974&r1=437973&r2=437974&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java Mon Aug 28 22:40:44 2006
@@ -1,404 +1,404 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * 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 ObjectTest extends junit.framework.TestCase {
-
- /**
- * Test objects.
- */
- Object obj1 = new Object();
-
- Object obj2 = new Object();
-
- /**
- * Generic state indicator.
- */
- int status = 0;
-
- int ready = 0;
-
- /**
- * @tests java.lang.Object#Object()
- */
- public void test_Constructor() {
- // Test for method java.lang.Object()
- assertNotNull("Constructor failed !!!", new Object());
- }
-
- /**
- * @tests java.lang.Object#equals(java.lang.Object)
- */
- 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));
- }
-
- /**
- * @tests java.lang.Object#getClass()
- */
- 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()
- */
- 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()
- */
- 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 + ")");
- }
- }
- }
-
- /**
- * @tests java.lang.Object#notifyAll()
- */
- 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 + ")");
- }
-
- }
- }
-
- /**
- * @tests java.lang.Object#toString()
- */
- 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()
- */
- 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 + ")");
- }
- }
- }
-
- /**
- * @tests java.lang.Object#wait(long)
- */
- 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 + ")");
- }
- }
- }
-
- /**
- * @tests java.lang.Object#wait(long, int)
- */
- 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 + ")");
- }
- }
-
- }
-
- /**
- * 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() {
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * 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 ObjectTest extends junit.framework.TestCase {
+
+ /**
+ * Test objects.
+ */
+ Object obj1 = new Object();
+
+ Object obj2 = new Object();
+
+ /**
+ * Generic state indicator.
+ */
+ int status = 0;
+
+ int ready = 0;
+
+ /**
+ * @tests java.lang.Object#Object()
+ */
+ public void test_Constructor() {
+ // Test for method java.lang.Object()
+ assertNotNull("Constructor failed !!!", new Object());
+ }
+
+ /**
+ * @tests java.lang.Object#equals(java.lang.Object)
+ */
+ 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));
+ }
+
+ /**
+ * @tests java.lang.Object#getClass()
+ */
+ 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()
+ */
+ 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()
+ */
+ 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 + ")");
+ }
+ }
+ }
+
+ /**
+ * @tests java.lang.Object#notifyAll()
+ */
+ 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 + ")");
+ }
+
+ }
+ }
+
+ /**
+ * @tests java.lang.Object#toString()
+ */
+ 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()
+ */
+ 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 + ")");
+ }
+ }
+ }
+
+ /**
+ * @tests java.lang.Object#wait(long)
+ */
+ 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 + ")");
+ }
+ }
+ }
+
+ /**
+ * @tests java.lang.Object#wait(long, int)
+ */
+ 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 + ")");
+ }
+ }
+
+ }
+
+ /**
+ * 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() {
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ObjectTest.java
------------------------------------------------------------------------------
svn:eol-style = native
|