15d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao/* 25d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * Copyright (C) 2007 The Android Open Source Project 35d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * 45d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * Licensed under the Apache License, Version 2.0 (the "License"); 55d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * you may not use this file except in compliance with the License. 65d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * You may obtain a copy of the License at 75d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * 85d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * http://www.apache.org/licenses/LICENSE-2.0 95d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * 105d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * Unless required by applicable law or agreed to in writing, software 115d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * distributed under the License is distributed on an "AS IS" BASIS, 125d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * See the License for the specific language governing permissions and 145d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * limitations under the License. 155d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao */ 165d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 175d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhaoimport junit.framework.Assert; 18eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalovimport java.util.Arrays; 19eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalovimport java.lang.reflect.Method; 205d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 215d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhaopublic class Main { 22eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void main(String args[]) throws Exception { 2328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_Double_doubleToRawLongBits(); 2428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_Double_longBitsToDouble(); 2528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_Float_floatToRawIntBits(); 2628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_Float_intBitsToFloat(); 2728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_Math_abs_I(); 2828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_Math_abs_J(); 2923abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Math_min_I(); 3023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Math_max_I(); 3123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Math_min_J(); 3223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Math_max_J(); 3323abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Math_min_F(); 3423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Math_max_F(); 3523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Math_min_D(); 3623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Math_max_D(); 37ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu test_Math_sqrt(); 382eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_Math_ceil(); 392eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_Math_floor(); 402eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_Math_rint(); 412eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_Math_round_D(); 422eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_Math_round_F(); 43a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu test_Short_reverseBytes(); 44a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu test_Integer_reverseBytes(); 45a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu test_Long_reverseBytes(); 4623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Integer_reverse(); 4723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_Long_reverse(); 48bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz test_StrictMath_abs_I(); 49bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz test_StrictMath_abs_J(); 5023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_StrictMath_min_I(); 5123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_StrictMath_max_I(); 5223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_StrictMath_min_J(); 5323abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_StrictMath_max_J(); 5423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_StrictMath_min_F(); 5523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_StrictMath_max_F(); 5623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_StrictMath_min_D(); 5723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu test_StrictMath_max_D(); 58ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu test_StrictMath_sqrt(); 592eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_StrictMath_ceil(); 602eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_StrictMath_floor(); 612eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_StrictMath_rint(); 622eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_StrictMath_round_D(); 632eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu test_StrictMath_round_F(); 6428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_String_charAt(); 6528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_String_compareTo(); 6628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_String_indexOf(); 6728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_String_isEmpty(); 6828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test_String_length(); 697a94961d0917495644193b281b04a570a783bb07Andreas Gampe test_Thread_currentThread(); 70eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov initSupportMethodsForPeekPoke(); 71eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov test_Memory_peekByte(); 72eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov test_Memory_peekShort(); 73eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov test_Memory_peekInt(); 74eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov test_Memory_peekLong(); 75eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov test_Memory_pokeByte(); 76eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov test_Memory_pokeShort(); 77eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov test_Memory_pokeInt(); 78eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov test_Memory_pokeLong(); 7928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 8028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 817a94961d0917495644193b281b04a570a783bb07Andreas Gampe /** 827a94961d0917495644193b281b04a570a783bb07Andreas Gampe * Will test inlining Thread.currentThread(). 837a94961d0917495644193b281b04a570a783bb07Andreas Gampe */ 847a94961d0917495644193b281b04a570a783bb07Andreas Gampe public static void test_Thread_currentThread() { 857a94961d0917495644193b281b04a570a783bb07Andreas Gampe // 1. Do not use result. 867a94961d0917495644193b281b04a570a783bb07Andreas Gampe Thread.currentThread(); 877a94961d0917495644193b281b04a570a783bb07Andreas Gampe 887a94961d0917495644193b281b04a570a783bb07Andreas Gampe // 2. Result should not be null. 897a94961d0917495644193b281b04a570a783bb07Andreas Gampe Assert.assertNotNull(Thread.currentThread()); 907a94961d0917495644193b281b04a570a783bb07Andreas Gampe } 917a94961d0917495644193b281b04a570a783bb07Andreas Gampe 9228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_String_length() { 9328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str0 = ""; 9428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str1 = "x"; 9528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str80 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"; 9628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 9728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str0.length(), 0); 9828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str1.length(), 1); 9928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str80.length(), 80); 10028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 10128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String strNull = null; 10228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 10328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes strNull.length(); 10428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail(); 10528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (NullPointerException expected) { 10628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 10728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 10828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 10928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_String_isEmpty() { 11028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str0 = ""; 11128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str1 = "x"; 11228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 11328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(str0.isEmpty()); 11428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertFalse(str1.isEmpty()); 11528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 11628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String strNull = null; 11728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 11828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes strNull.isEmpty(); 11928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail(); 12028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (NullPointerException expected) { 1215d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao } 12228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 1235d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 12471fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe // Break up the charAt tests. The optimizing compiler doesn't optimize methods with try-catch yet, 12571fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe // so we need to separate out the tests that are expected to throw exception 12671fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe 12728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_String_charAt() { 128878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe String testStr = "Now is the time to test some stuff"; 129878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe 130878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals(testStr.length() - 1, 33); // 33 = testStr.length()-1 as a constant. 131878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals('f', testStr.charAt(33)); 132878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe 133878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe test_String_charAt(testStr, 'N', 'o', ' ', 'f'); 134878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe test_String_charAt(testStr.substring(3,15), ' ', 'i', 'm', 'e'); 135878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe } 136878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe public static void test_String_charAt(String testStr, char a, char b, char c, char d) { 137878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals(a, testStr.charAt(0)); 138878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals(b, testStr.charAt(1)); 139878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals(c, testStr.charAt(10)); 140878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals(d, testStr.charAt(testStr.length()-1)); 141878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe 142878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe test_String_charAtExc(testStr); 143878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe test_String_charAtExc2(testStr); 14471fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe } 14571fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe 146878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe private static void test_String_charAtExc(String testStr) { 14728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 14828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes testStr.charAt(-1); 14928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail(); 15028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (StringIndexOutOfBoundsException expected) { 15128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 15228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 15328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes testStr.charAt(80); 15428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail(); 15528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (StringIndexOutOfBoundsException expected) { 1565d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao } 15700ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko try { 158878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe if (testStr.length() == 34) { 159878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe testStr.charAt(34); // 34 = "Now is the time to test some stuff".length() 160878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe } else { 161878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals(testStr.length(), 12); // 12 = " is the time".length() 162878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe testStr.charAt(12); 163878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe } 16400ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko Assert.fail(); 16500ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } catch (StringIndexOutOfBoundsException expected) { 16600ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } 16700ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko try { 16800ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko test_String_charAt_inner(testStr, -1); 16900ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko Assert.fail(); 17000ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } catch (StringIndexOutOfBoundsException expected) { 17100ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } 17200ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko try { 17300ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko test_String_charAt_inner(testStr, 80); 17400ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko Assert.fail(); 17500ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } catch (StringIndexOutOfBoundsException expected) { 17600ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } 17700ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko try { 178878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe if (testStr.length() == 34) { 179878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe // 34 = "Now is the time to test some stuff".length() 180878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe test_String_charAt_inner(testStr, 34); 181878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe } else { 182878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals(testStr.length(), 12); // 12 = " is the time".length() 183878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe test_String_charAt_inner(testStr, 12); 184878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe } 18500ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko Assert.fail(); 18600ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } catch (StringIndexOutOfBoundsException expected) { 18700ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } 18800ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko 18900ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko String strEmpty = ""; 19000ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko try { 19100ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko strEmpty.charAt(0); 19200ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko Assert.fail(); 19300ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } catch (StringIndexOutOfBoundsException expected) { 19400ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } 1955d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 19628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String strNull = null; 19728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 19828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes strNull.charAt(0); 19928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail(); 20028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (NullPointerException expected) { 2015d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao } 20228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 20328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 20400ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko private static char test_String_charAt_inner(String s, int index) { 20500ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko // Using non-constant index here (assuming that this method wasn't inlined). 20600ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko return s.charAt(index); 20700ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko } 20800ca84730a21578dcc6b47bd8e08b78ab9b2ddedVladimir Marko 209878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe private static void test_String_charAtExc2(String testStr) { 21071fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe try { 211878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe test_String_charAtExc3(testStr); 212878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.fail(); 213878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe } catch (StringIndexOutOfBoundsException expected) { 214878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe } 215878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe try { 216878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe test_String_charAtExc4(testStr); 21771fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe Assert.fail(); 21871fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe } catch (StringIndexOutOfBoundsException expected) { 21971fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe } 22071fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe } 22171fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe 222878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe private static void test_String_charAtExc3(String testStr) { 22371fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe Assert.assertEquals('N', testStr.charAt(-1)); 22471fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe } 22571fb52fee246b7d511f520febbd73dc7a9bbca79Andreas Gampe 226878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe private static void test_String_charAtExc4(String testStr) { 227878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe Assert.assertEquals('N', testStr.charAt(100)); 228878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe } 229878d58cbaf6b17a9e3dcab790754527f3ebc69e5Andreas Gampe 23034fa0d935bed7a0e17bc6df4bd079e3428a179e7Yevgeny Rouban static int start; 231a1758d83e298c9ee31848bcae07c2a35f6efd618Alexei Zavjalov private static int[] negIndex = { -100000 }; 23228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_String_indexOf() { 23328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str0 = ""; 23434fa0d935bed7a0e17bc6df4bd079e3428a179e7Yevgeny Rouban String str1 = "/"; 23528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str3 = "abc"; 23628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str10 = "abcdefghij"; 23728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str40 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabc"; 23828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 23928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str0.indexOf('a'), -1); 24028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('a'), 0); 24128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('b'), 1); 24228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('c'), 2); 24328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str10.indexOf('j'), 9); 24428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str40.indexOf('a'), 0); 24528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str40.indexOf('b'), 38); 24628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str40.indexOf('c'), 39); 24728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str0.indexOf('a',20), -1); 24828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str0.indexOf('a',0), -1); 24928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str0.indexOf('a',-1), -1); 25034fa0d935bed7a0e17bc6df4bd079e3428a179e7Yevgeny Rouban Assert.assertEquals(str1.indexOf('/',++start), -1); 251a1758d83e298c9ee31848bcae07c2a35f6efd618Alexei Zavjalov Assert.assertEquals(str1.indexOf('a',negIndex[0]), -1); 25228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('a',0), 0); 25328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('a',1), -1); 25428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('a',1234), -1); 25528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('b',0), 1); 25628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('b',1), 1); 25728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str3.indexOf('c',2), 2); 25828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str10.indexOf('j',5), 9); 25928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str10.indexOf('j',9), 9); 26028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str40.indexOf('a',10), 10); 26128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str40.indexOf('b',40), -1); 2625d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 263678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe testIndexOfNull(); 264678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe 26521030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe // Same data as above, but stored so it's not a literal in the next test. -2 stands for 26621030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe // indexOf(I) instead of indexOf(II). 26721030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe start--; 26821030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe int[][] searchData = { 26921030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', -2, -1 }, 27021030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', -2, 0 }, 27121030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'b', -2, 1 }, 27221030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'c', -2, 2 }, 27321030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'j', -2, 9 }, 27421030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', -2, 0 }, 27521030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'b', -2, 38 }, 27621030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'c', -2, 39 }, 27721030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', 20, -1 }, 27821030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', 0, -1 }, 27921030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', -1, -1 }, 28021030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { '/', ++start, -1 }, 28121030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', negIndex[0], -1 }, 28221030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', 0, 0 }, 28321030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', 1, -1 }, 28421030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', 1234, -1 }, 28521030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'b', 0, 1 }, 28621030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'b', 1, 1 }, 28721030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'c', 2, 2 }, 28821030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'j', 5, 9 }, 28921030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'j', 9, 9 }, 29021030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'a', 10, 10 }, 29121030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe { 'b', 40, -1 }, 29221030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe }; 29321030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe testStringIndexOfChars(searchData); 29421030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe 295678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe testSurrogateIndexOf(); 296678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe } 297678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe 29821030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe private static void testStringIndexOfChars(int[][] searchData) { 29921030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe // Use a try-catch to avoid inlining. 30021030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe try { 30121030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe testStringIndexOfCharsImpl(searchData); 30221030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe } catch (Exception e) { 30321030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe System.out.println("Unexpected exception"); 30421030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe } 30521030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe } 30621030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe 30721030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe private static void testStringIndexOfCharsImpl(int[][] searchData) { 30821030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe String str0 = ""; 30921030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe String str1 = "/"; 31021030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe String str3 = "abc"; 31121030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe String str10 = "abcdefghij"; 31221030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe String str40 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabc"; 31321030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe 31421030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str0.indexOf(searchData[0][0]), searchData[0][2]); 31521030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[1][0]), searchData[1][2]); 31621030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[2][0]), searchData[2][2]); 31721030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[3][0]), searchData[3][2]); 31821030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str10.indexOf(searchData[4][0]), searchData[4][2]); 31921030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str40.indexOf(searchData[5][0]), searchData[5][2]); 32021030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str40.indexOf(searchData[6][0]), searchData[6][2]); 32121030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str40.indexOf(searchData[7][0]), searchData[7][2]); 32221030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str0.indexOf(searchData[8][0], searchData[8][1]), searchData[8][2]); 32321030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str0.indexOf(searchData[9][0], searchData[9][1]), searchData[9][2]); 32421030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str0.indexOf(searchData[10][0], searchData[10][1]), searchData[10][2]); 32521030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str1.indexOf(searchData[11][0], searchData[11][1]), searchData[11][2]); 32621030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str1.indexOf(searchData[12][0], searchData[12][1]), searchData[12][2]); 32721030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[13][0], searchData[13][1]), searchData[13][2]); 32821030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[14][0], searchData[14][1]), searchData[14][2]); 32921030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[15][0], searchData[15][1]), searchData[15][2]); 33021030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[16][0], searchData[16][1]), searchData[16][2]); 33121030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[17][0], searchData[17][1]), searchData[17][2]); 33221030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str3.indexOf(searchData[18][0], searchData[18][1]), searchData[18][2]); 33321030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str10.indexOf(searchData[19][0], searchData[19][1]), searchData[19][2]); 33421030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str10.indexOf(searchData[20][0], searchData[20][1]), searchData[20][2]); 33521030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str40.indexOf(searchData[21][0], searchData[21][1]), searchData[21][2]); 33621030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe Assert.assertEquals(str40.indexOf(searchData[22][0], searchData[22][1]), searchData[22][2]); 33721030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe } 33821030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe 339678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe private static void testSurrogateIndexOf() { 340678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe int supplementaryChar = 0x20b9f; 341678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe String surrogatePair = "\ud842\udf9f"; 342678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe String stringWithSurrogates = "hello " + surrogatePair + " world"; 343678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe 344678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe Assert.assertEquals(stringWithSurrogates.indexOf(supplementaryChar), "hello ".length()); 345678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe Assert.assertEquals(stringWithSurrogates.indexOf(supplementaryChar, 2), "hello ".length()); 346678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe Assert.assertEquals(stringWithSurrogates.indexOf(supplementaryChar, 6), 6); 347678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe Assert.assertEquals(stringWithSurrogates.indexOf(supplementaryChar, 7), -1); 348ce7d005c1ba0716423d44861d2d0f58f142ff06aAndreas Gampe 349ce7d005c1ba0716423d44861d2d0f58f142ff06aAndreas Gampe Assert.assertEquals(stringWithSurrogates.indexOf(supplementaryChar - 0x10000), -1); 350ce7d005c1ba0716423d44861d2d0f58f142ff06aAndreas Gampe Assert.assertEquals(stringWithSurrogates.indexOf(supplementaryChar | 0x80000000), -1); 351678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe } 352678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe 353678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe private static void testIndexOfNull() { 35428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String strNull = null; 35528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 356678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe testNullIndex(strNull, 'a'); 35728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail(); 35828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (NullPointerException expected) { 3595d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao } 36028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 361678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe testNullIndex(strNull, 'a', 0); 36228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail(); 36328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (NullPointerException expected) { 36428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 36528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 366678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe testNullIndex(strNull, 'a', -1); 36728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail(); 36828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (NullPointerException expected) { 36928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 37028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 37128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 372678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe private static int testNullIndex(String strNull, int c) { 373678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe return strNull.indexOf(c); 374678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe } 375678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe 376678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe private static int testNullIndex(String strNull, int c, int startIndex) { 377678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe return strNull.indexOf(c, startIndex); 378678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe } 379678e6959d5af8e7b07bf51f1648516c146bdf8d2Andreas Gampe 38028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_String_compareTo() { 38128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String test = "0123456789"; 38228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String test1 = new String("0123456789"); // different object 38328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String test2 = new String("0123456780"); // different value 38428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String offset = new String("xxx0123456789yyy"); 38528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String sub = offset.substring(3, 13); 38628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str32 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 38728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String str33 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy"; 38828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String lc = "abcdefg"; 38928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String uc = "ABCDEFG"; 39028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Object blah = new Object(); 39128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 39228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(lc.toUpperCase().equals(uc)); 3935d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 39428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str32.compareTo(str33), -1); 39528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(str33.compareTo(str32), 1); 39628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 39728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test.equals(test)); 39828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test.equals(test1)); 39928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertFalse(test.equals(test2)); 40028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 40128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(test.compareTo(test1), 0); 40228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test1.compareTo(test2) > 0); 40328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test2.compareTo(test1) < 0); 40428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 40528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes // Compare string with a nonzero offset, in left/right side. 40628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(test.compareTo(sub), 0); 40728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(sub.compareTo(test), 0); 40828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test.equals(sub)); 40928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(sub.equals(test)); 41028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes // Same base, one is a substring. 41128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertFalse(offset.equals(sub)); 41228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertFalse(sub.equals(offset)); 41328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes // Wrong class. 41428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertFalse(test.equals(blah)); 41528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 41628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes // Null lhs - throw. 41728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes try { 41828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test.compareTo(null); 41928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.fail("didn't get expected npe"); 42028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } catch (NullPointerException npe) { 4215d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao } 42228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes // Null rhs - okay. 42328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertFalse(test.equals(null)); 42428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 42528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test = test.substring(1); 42628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test.equals("123456789")); 42728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertFalse(test.equals(test1)); 42828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 42928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test = test.substring(1); 43028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test.equals("23456789")); 43128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 43228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test = test.substring(1); 43328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test.equals("3456789")); 43428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 43528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test = test.substring(1); 43628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test.equals("456789")); 43728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 43828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test = test.substring(3,5); 43928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertTrue(test.equals("78")); 44028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 44128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes test = "this/is/a/path"; 44228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes String[] strings = test.split("/"); 44328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(4, strings.length); 44428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 44528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals("this is a path", test.replaceAll("/", " ")); 44628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals("this is a path", test.replace("/", " ")); 44728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 44828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 44928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_Math_abs_I() { 450ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.abs(-1); 45128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(0), 0); 45228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(123), 123); 45328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(-123), 123); 45428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(Integer.MAX_VALUE), Integer.MAX_VALUE); 45528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(Integer.MIN_VALUE), Integer.MIN_VALUE); 45628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(Integer.MIN_VALUE - 1), Integer.MAX_VALUE); 457bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(Math.abs(Integer.MIN_VALUE + 1), Integer.MAX_VALUE); 45828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 45928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 46028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_Math_abs_J() { 461ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.abs(-1L); 46228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(0L), 0L); 46328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(123L), 123L); 46428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(-123L), 123L); 46528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(Long.MAX_VALUE), Long.MAX_VALUE); 46628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(Long.MIN_VALUE), Long.MIN_VALUE); 46728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.abs(Long.MIN_VALUE - 1), Long.MAX_VALUE); 4682bcf9bf784a0021630d8fe63d7230d46d6891780Andreas Gampe Assert.assertEquals(Math.abs(2147483648L), 2147483648L); 46928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 47028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 47123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Math_min_I() { 472ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.min(1, 0); 47328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.min(0, 0), 0); 47428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.min(1, 0), 0); 47528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.min(0, 1), 0); 47628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.min(0, Integer.MAX_VALUE), 0); 47728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.min(Integer.MIN_VALUE, 0), Integer.MIN_VALUE); 47828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.min(Integer.MIN_VALUE, Integer.MAX_VALUE), Integer.MIN_VALUE); 47928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 48028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 48123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Math_max_I() { 482ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.max(1, 0); 48328c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.max(0, 0), 0); 48428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.max(1, 0), 1); 48528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.max(0, 1), 1); 48628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.max(0, Integer.MAX_VALUE), Integer.MAX_VALUE); 48728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.max(Integer.MIN_VALUE, 0), 0); 48828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Math.max(Integer.MIN_VALUE, Integer.MAX_VALUE), Integer.MAX_VALUE); 48928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 49028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 49123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Math_min_J() { 492ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.min(1L, 0L); 49323abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.min(0L, 0L), 0L); 49423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.min(1L, 0L), 0L); 49523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.min(0L, 1L), 0L); 49623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.min(0L, Long.MAX_VALUE), 0L); 49723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.min(Long.MIN_VALUE, 0L), Long.MIN_VALUE); 49823abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.min(Long.MIN_VALUE, Long.MAX_VALUE), Long.MIN_VALUE); 49923abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 50023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 50123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Math_max_J() { 502ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.max(1L, 0L); 50323abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.max(0L, 0L), 0L); 50423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.max(1L, 0L), 1L); 50523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.max(0L, 1L), 1L); 50623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.max(0L, Long.MAX_VALUE), Long.MAX_VALUE); 50723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.max(Long.MIN_VALUE, 0L), 0L); 50823abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Math.max(Long.MIN_VALUE, Long.MAX_VALUE), Long.MAX_VALUE); 50923abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 51023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 51123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Math_min_F() { 512ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.min(1.0f, Float.NaN); 5131222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Float.isNaN(Math.min(1.0f, Float.NaN))); 5141222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Float.isNaN(Math.min(Float.NaN, 1.0f))); 5151222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(-0.0f, 0.0f), -0.0f); 5161222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(0.0f, -0.0f), -0.0f); 5171222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(-0.0f, -0.0f), -0.0f); 5181222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(0.0f, 0.0f), 0.0f); 5191222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(1.0f, 0.0f), 0.0f); 5201222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(0.0f, 1.0f), 0.0f); 5211222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(0.0f, Float.MAX_VALUE), 0.0f); 5221222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(Float.MIN_VALUE, 0.0f), 0.0f); 5231222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(Float.MIN_VALUE, Float.MAX_VALUE), Float.MIN_VALUE); 52423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 52523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 52623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Math_max_F() { 527ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.max(1.0f, Float.NaN); 5281222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Float.isNaN(Math.max(1.0f, Float.NaN))); 5291222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Float.isNaN(Math.max(Float.NaN, 1.0f))); 5301222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(-0.0f, 0.0f), 0.0f); 5311222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(0.0f, -0.0f), 0.0f); 5321222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(-0.0f, -0.0f), -0.0f); 5331222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(0.0f, 0.0f), 0.0f); 5341222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(1.0f, 0.0f), 1.0f); 5351222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(0.0f, 1.0f), 1.0f); 5361222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(0.0f, Float.MAX_VALUE), Float.MAX_VALUE); 5371222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(Float.MIN_VALUE, 0.0f), Float.MIN_VALUE); 5381222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(Float.MIN_VALUE, Float.MAX_VALUE), Float.MAX_VALUE); 53923abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 54023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 54123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Math_min_D() { 542ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.min(1.0d, Double.NaN); 5431222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Double.isNaN(Math.min(1.0d, Double.NaN))); 5441222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Double.isNaN(Math.min(Double.NaN, 1.0d))); 5451222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(-0.0d, 0.0d), -0.0d); 5461222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(0.0d, -0.0d), -0.0d); 5471222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(-0.0d, -0.0d), -0.0d); 5481222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(0.0d, 0.0d), 0.0d); 5491222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(1.0d, 0.0d), 0.0d); 5501222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(0.0d, 1.0d), 0.0d); 5511222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(0.0d, Double.MAX_VALUE), 0.0d); 5521222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(Double.MIN_VALUE, 0.0d), 0.0d); 5531222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.min(Double.MIN_VALUE, Double.MAX_VALUE), Double.MIN_VALUE); 55423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 55523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 55623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Math_max_D() { 557ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.max(1.0d, Double.NaN); 5581222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Double.isNaN(Math.max(1.0d, Double.NaN))); 5591222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Double.isNaN(Math.max(Double.NaN, 1.0d))); 5601222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(-0.0d, 0.0d), 0.0d); 5611222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(0.0d, -0.0d), 0.0d); 5621222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(-0.0d, -0.0d), -0.0d); 5631222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(0.0d, 0.0d), 0.0d); 5641222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(1.0d, 0.0d), 1.0d); 5651222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(0.0d, 1.0d), 1.0d); 5661222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(0.0d, Double.MAX_VALUE), Double.MAX_VALUE); 5671222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(Double.MIN_VALUE, 0.0d), Double.MIN_VALUE); 5681222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(Math.max(Double.MIN_VALUE, Double.MAX_VALUE), Double.MAX_VALUE); 56923abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 57023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 571ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu public static void test_Math_sqrt() { 572ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.sqrt(+4.0); 573ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Assert.assertEquals(Math.sqrt(+4.0), +2.0d, 0.0); 574ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Assert.assertEquals(Math.sqrt(+49.0), +7.0d, 0.0); 575ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Assert.assertEquals(Math.sqrt(+1.44), +1.2d, 0.0); 576ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu } 577ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu 5782eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_Math_ceil() { 579ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.ceil(-0.9); 5802eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(+0.0), +0.0d, 0.0); 5812eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(-0.0), -0.0d, 0.0); 5822eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(-0.9), -0.0d, 0.0); 5832eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(-0.5), -0.0d, 0.0); 5842eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(0.0), -0.0d, 0.0); 5852eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(+2.0), +2.0d, 0.0); 5862eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(+2.1), +3.0d, 0.0); 5872eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(+2.5), +3.0d, 0.0); 5882eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(+2.9), +3.0d, 0.0); 5892eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(+3.0), +3.0d, 0.0); 5902eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(-2.0), -2.0d, 0.0); 5912eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(-2.1), -2.0d, 0.0); 5922eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(-2.5), -2.0d, 0.0); 5932eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(-2.9), -2.0d, 0.0); 5942eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(-3.0), -3.0d, 0.0); 5952eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(Double.NaN), Double.NaN, 0.0); 5962eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); 5972eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.ceil(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); 5982eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 5992eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 6002eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_Math_floor() { 601ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.floor(+2.1); 6022eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(+0.0), +0.0d, 0.0); 6032eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(-0.0), -0.0d, 0.0); 6042eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(+2.0), +2.0d, 0.0); 6052eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(+2.1), +2.0d, 0.0); 6062eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(+2.5), +2.0d, 0.0); 6072eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(+2.9), +2.0d, 0.0); 6082eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(+3.0), +3.0d, 0.0); 6092eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(-2.0), -2.0d, 0.0); 6102eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(-2.1), -3.0d, 0.0); 6112eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(-2.5), -3.0d, 0.0); 6122eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(-2.9), -3.0d, 0.0); 6132eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(-3.0), -3.0d, 0.0); 6142eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(Double.NaN), Double.NaN, 0.0); 6152eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); 6162eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.floor(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); 6172eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 6182eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 6192eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_Math_rint() { 620ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.rint(+2.1); 6212eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(+0.0), +0.0d, 0.0); 6222eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(-0.0), -0.0d, 0.0); 6232eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(+2.0), +2.0d, 0.0); 6242eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(+2.1), +2.0d, 0.0); 6252eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(+2.5), +2.0d, 0.0); 6262eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(+2.9), +3.0d, 0.0); 6272eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(+3.0), +3.0d, 0.0); 6282eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(-2.0), -2.0d, 0.0); 6292eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(-2.1), -2.0d, 0.0); 6302eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(-2.5), -2.0d, 0.0); 6312eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(-2.9), -3.0d, 0.0); 6322eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(-3.0), -3.0d, 0.0); 6332eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(Double.NaN), Double.NaN, 0.0); 6342eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); 6352eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.rint(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); 6362eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 6372eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 6382eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_Math_round_D() { 639ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.round(2.1d); 6402eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(+0.0d), (long)+0.0); 6412eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-0.0d), (long)+0.0); 6422eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(2.0d), 2l); 6432eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(2.1d), 2l); 6442eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(2.5d), 3l); 6452eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(2.9d), 3l); 6462eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(3.0d), 3l); 6472eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-2.0d), -2l); 6482eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-2.1d), -2l); 6492eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-2.5d), -2l); 6502eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-2.9d), -3l); 6512eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-3.0d), -3l); 6522eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(0.49999999999999994d), 1l); 6532eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Double.NaN), (long)+0.0d); 6542eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Long.MAX_VALUE + 1.0d), Long.MAX_VALUE); 6552eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Long.MIN_VALUE - 1.0d), Long.MIN_VALUE); 6562eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Double.POSITIVE_INFINITY), Long.MAX_VALUE); 6572eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Double.NEGATIVE_INFINITY), Long.MIN_VALUE); 6582eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 6592eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 6602eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_Math_round_F() { 661ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Math.round(2.1f); 6622eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(+0.0f), (int)+0.0); 6632eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-0.0f), (int)+0.0); 6642eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(2.0f), 2); 6652eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(2.1f), 2); 6662eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(2.5f), 3); 6672eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(2.9f), 3); 6682eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(3.0f), 3); 6692eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-2.0f), -2); 6702eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-2.1f), -2); 6712eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-2.5f), -2); 6722eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-2.9f), -3); 6732eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(-3.0f), -3); 6742eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Float.NaN), (int)+0.0f); 6752eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Integer.MAX_VALUE + 1.0f), Integer.MAX_VALUE); 6762eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Integer.MIN_VALUE - 1.0f), Integer.MIN_VALUE); 6772eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Float.POSITIVE_INFINITY), Integer.MAX_VALUE); 6782eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(Math.round(Float.NEGATIVE_INFINITY), Integer.MIN_VALUE); 6792eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 6802eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 681bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz public static void test_StrictMath_abs_I() { 682ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.abs(-1); 683bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(0), 0); 684bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(123), 123); 685bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(-123), 123); 686bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(Integer.MAX_VALUE), Integer.MAX_VALUE); 687bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(Integer.MIN_VALUE), Integer.MIN_VALUE); 688bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(Integer.MIN_VALUE - 1), Integer.MAX_VALUE); 689bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(Integer.MIN_VALUE + 1), Integer.MAX_VALUE); 690bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz } 691bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz 692bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz public static void test_StrictMath_abs_J() { 693ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.abs(-1L); 694bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(0L), 0L); 695bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(123L), 123L); 696bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(-123L), 123L); 697bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(Long.MAX_VALUE), Long.MAX_VALUE); 698bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(Long.MIN_VALUE), Long.MIN_VALUE); 699bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.abs(Long.MIN_VALUE - 1), Long.MAX_VALUE); 700bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz } 701bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz 70223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_StrictMath_min_I() { 703ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.min(1, 0); 704bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.min(0, 0), 0); 705bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.min(1, 0), 0); 706bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.min(0, 1), 0); 707bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.min(0, Integer.MAX_VALUE), 0); 708bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.min(Integer.MIN_VALUE, 0), Integer.MIN_VALUE); 709bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.min(Integer.MIN_VALUE, Integer.MAX_VALUE), Integer.MIN_VALUE); 710bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz } 711bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz 71223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_StrictMath_max_I() { 713ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.max(1, 0); 714bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.max(0, 0), 0); 715bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.max(1, 0), 1); 716bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.max(0, 1), 1); 717bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.max(0, Integer.MAX_VALUE), Integer.MAX_VALUE); 718bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.max(Integer.MIN_VALUE, 0), 0); 719bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz Assert.assertEquals(StrictMath.max(Integer.MIN_VALUE, Integer.MAX_VALUE), Integer.MAX_VALUE); 720bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz } 721bf1442d5445405ddc4f67cdac2b4ebe2d37888e0Sebastien Hertz 72223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_StrictMath_min_J() { 723ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.min(1L, 0L); 72423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.min(0L, 0L), 0L); 72523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.min(1L, 0L), 0L); 72623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.min(0L, 1L), 0L); 72723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.min(0L, Long.MAX_VALUE), 0L); 72823abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.min(Long.MIN_VALUE, 0L), Long.MIN_VALUE); 72923abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.min(Long.MIN_VALUE, Long.MAX_VALUE), Long.MIN_VALUE); 73023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 73123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 73223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_StrictMath_max_J() { 733ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.max(1L, 0L); 73423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.max(0L, 0L), 0L); 73523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.max(1L, 0L), 1L); 73623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.max(0L, 1L), 1L); 73723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.max(0L, Long.MAX_VALUE), Long.MAX_VALUE); 73823abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.max(Long.MIN_VALUE, 0L), 0L); 73923abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(StrictMath.max(Long.MIN_VALUE, Long.MAX_VALUE), Long.MAX_VALUE); 74023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 74123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 74223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_StrictMath_min_F() { 743ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.min(1.0f, Float.NaN); 7441222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Float.isNaN(StrictMath.min(1.0f, Float.NaN))); 7451222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Float.isNaN(StrictMath.min(Float.NaN, 1.0f))); 7461222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(-0.0f, 0.0f), -0.0f); 7471222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(0.0f, -0.0f), -0.0f); 7481222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(-0.0f, -0.0f), -0.0f); 7491222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(0.0f, 0.0f), 0.0f); 7501222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(1.0f, 0.0f), 0.0f); 7511222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(0.0f, 1.0f), 0.0f); 7521222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(0.0f, Float.MAX_VALUE), 0.0f); 7531222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(Float.MIN_VALUE, 0.0f), 0.0f); 7541222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(Float.MIN_VALUE, Float.MAX_VALUE), Float.MIN_VALUE); 75523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 75623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 75723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_StrictMath_max_F() { 758ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.max(1.0f, Float.NaN); 7591222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Float.isNaN(StrictMath.max(1.0f, Float.NaN))); 7601222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Float.isNaN(StrictMath.max(Float.NaN, 1.0f))); 7611222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(-0.0f, 0.0f), 0.0f); 7621222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(0.0f, -0.0f), 0.0f); 7631222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(-0.0f, -0.0f), -0.0f); 7641222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(0.0f, 0.0f), 0.0f); 7651222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(1.0f, 0.0f), 1.0f); 7661222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(0.0f, 1.0f), 1.0f); 7671222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(0.0f, Float.MAX_VALUE), Float.MAX_VALUE); 7681222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(Float.MIN_VALUE, 0.0f), Float.MIN_VALUE); 7691222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(Float.MIN_VALUE, Float.MAX_VALUE), Float.MAX_VALUE); 77023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 77123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 77223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_StrictMath_min_D() { 773ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.min(1.0d, Double.NaN); 7741222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Double.isNaN(StrictMath.min(1.0d, Double.NaN))); 7751222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Double.isNaN(StrictMath.min(Double.NaN, 1.0d))); 7761222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(-0.0d, 0.0d), -0.0d); 7771222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(0.0d, -0.0d), -0.0d); 7781222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(-0.0d, -0.0d), -0.0d); 7791222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(0.0d, 0.0d), 0.0d); 7801222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(1.0d, 0.0d), 0.0d); 7811222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(0.0d, 1.0d), 0.0d); 7821222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(0.0d, Double.MAX_VALUE), 0.0d); 7831222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(Double.MIN_VALUE, 0.0d), 0.0d); 7841222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.min(Double.MIN_VALUE, Double.MAX_VALUE), Double.MIN_VALUE); 78523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 78623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 78723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_StrictMath_max_D() { 788ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.max(1.0d, Double.NaN); 7891222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Double.isNaN(StrictMath.max(1.0d, Double.NaN))); 7901222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertTrue(Double.isNaN(StrictMath.max(Double.NaN, 1.0d))); 7911222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(-0.0d, 0.0d), 0.0d); 7921222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(0.0d, -0.0d), 0.0d); 7931222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(-0.0d, -0.0d), -0.0d); 7941222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(0.0d, 0.0d), 0.0d); 7951222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(1.0d, 0.0d), 1.0d); 7961222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(0.0d, 1.0d), 1.0d); 7971222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(0.0d, Double.MAX_VALUE), Double.MAX_VALUE); 7981222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(Double.MIN_VALUE, 0.0d), Double.MIN_VALUE); 7991222c96fafe98061cfc57d3bd115f46edb64e624Alexei Zavjalov Assert.assertEquals(StrictMath.max(Double.MIN_VALUE, Double.MAX_VALUE), Double.MAX_VALUE); 80023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 80123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 802ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu public static void test_StrictMath_sqrt() { 803ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.sqrt(+4.0); 804ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Assert.assertEquals(StrictMath.sqrt(+4.0), +2.0d, 0.0); 805ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Assert.assertEquals(StrictMath.sqrt(+49.0), +7.0d, 0.0); 806ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Assert.assertEquals(StrictMath.sqrt(+1.44), +1.2d, 0.0); 807ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu } 808ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu 8092eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_StrictMath_ceil() { 810ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.ceil(-0.9); 8112eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(+0.0), +0.0d, 0.0); 8122eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(-0.0), -0.0d, 0.0); 8132eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(-0.9), -0.0d, 0.0); 8142eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(-0.5), -0.0d, 0.0); 8152eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(0.0), -0.0d, 0.0); 8162eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(+2.0), +2.0d, 0.0); 8172eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(+2.1), +3.0d, 0.0); 8182eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(+2.5), +3.0d, 0.0); 8192eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(+2.9), +3.0d, 0.0); 8202eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(+3.0), +3.0d, 0.0); 8212eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(-2.0), -2.0d, 0.0); 8222eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(-2.1), -2.0d, 0.0); 8232eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(-2.5), -2.0d, 0.0); 8242eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(-2.9), -2.0d, 0.0); 8252eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(-3.0), -3.0d, 0.0); 8262eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(Double.NaN), Double.NaN, 0.0); 8272eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); 8282eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.ceil(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); 8292eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 8302eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 8312eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_StrictMath_floor() { 832ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.floor(+2.1); 8332eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(+0.0), +0.0d, 0.0); 8342eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(-0.0), -0.0d, 0.0); 8352eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(+2.0), +2.0d, 0.0); 8362eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(+2.1), +2.0d, 0.0); 8372eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(+2.5), +2.0d, 0.0); 8382eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(+2.9), +2.0d, 0.0); 8392eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(+3.0), +3.0d, 0.0); 8402eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(-2.0), -2.0d, 0.0); 8412eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(-2.1), -3.0d, 0.0); 8422eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(-2.5), -3.0d, 0.0); 8432eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(-2.9), -3.0d, 0.0); 8442eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(-3.0), -3.0d, 0.0); 8452eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(Double.NaN), Double.NaN, 0.0); 8462eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); 8472eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.floor(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); 8482eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 8492eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 8502eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_StrictMath_rint() { 851ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.rint(+2.1); 8522eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(+0.0), +0.0d, 0.0); 8532eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(-0.0), -0.0d, 0.0); 8542eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(+2.0), +2.0d, 0.0); 8552eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(+2.1), +2.0d, 0.0); 8562eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(+2.5), +2.0d, 0.0); 8572eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(+2.9), +3.0d, 0.0); 8582eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(+3.0), +3.0d, 0.0); 8592eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(-2.0), -2.0d, 0.0); 8602eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(-2.1), -2.0d, 0.0); 8612eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(-2.5), -2.0d, 0.0); 8622eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(-2.9), -3.0d, 0.0); 8632eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(-3.0), -3.0d, 0.0); 8642eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(Double.NaN), Double.NaN, 0.0); 8652eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); 8662eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.rint(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); 8672eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 8682eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 8692eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_StrictMath_round_D() { 870ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.round(2.1d); 8712eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(+0.0d), (long)+0.0); 8722eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-0.0d), (long)+0.0); 8732eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(2.0d), 2l); 8742eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(2.1d), 2l); 8752eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(2.5d), 3l); 8762eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(2.9d), 3l); 8772eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(3.0d), 3l); 8782eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-2.0d), -2l); 8792eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-2.1d), -2l); 8802eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-2.5d), -2l); 8812eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-2.9d), -3l); 8822eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-3.0d), -3l); 8832eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(0.49999999999999994d), 1l); 8842eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Double.NaN), (long)+0.0d); 8852eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Long.MAX_VALUE + 1.0d), Long.MAX_VALUE); 8862eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Long.MIN_VALUE - 1.0d), Long.MIN_VALUE); 8872eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Double.POSITIVE_INFINITY), Long.MAX_VALUE); 8882eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Double.NEGATIVE_INFINITY), Long.MIN_VALUE); 8892eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 8902eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 8912eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu public static void test_StrictMath_round_F() { 892ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu StrictMath.round(2.1f); 8932eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(+0.0f), (int)+0.0); 8942eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-0.0f), (int)+0.0); 8952eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(2.0f), 2); 8962eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(2.1f), 2); 8972eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(2.5f), 3); 8982eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(2.9f), 3); 8992eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(3.0f), 3); 9002eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-2.0f), -2); 9012eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-2.1f), -2); 9022eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-2.5f), -2); 9032eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-2.9f), -3); 9042eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(-3.0f), -3); 9052eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Float.NaN), (int)+0.0f); 9062eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Integer.MAX_VALUE + 1.0f), Integer.MAX_VALUE); 9072eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Integer.MIN_VALUE - 1.0f), Integer.MIN_VALUE); 9082eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Float.POSITIVE_INFINITY), Integer.MAX_VALUE); 9092eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu Assert.assertEquals(StrictMath.round(Float.NEGATIVE_INFINITY), Integer.MIN_VALUE); 9102eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu } 9112eba1fa7e9e5f91e18ae3778d529520bd2c78d55Serban Constantinescu 91228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_Float_floatToRawIntBits() { 913ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Float.floatToRawIntBits(-1.0f); 91428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.floatToRawIntBits(-1.0f), 0xbf800000); 91528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.floatToRawIntBits(0.0f), 0); 91628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.floatToRawIntBits(1.0f), 0x3f800000); 91728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.floatToRawIntBits(Float.NaN), 0x7fc00000); 91828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.floatToRawIntBits(Float.POSITIVE_INFINITY), 0x7f800000); 91928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.floatToRawIntBits(Float.NEGATIVE_INFINITY), 0xff800000); 92028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 92128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 92228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_Float_intBitsToFloat() { 923ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Float.intBitsToFloat(0xbf800000); 92428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.intBitsToFloat(0xbf800000), -1.0f); 92528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.intBitsToFloat(0x00000000), 0.0f); 92628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.intBitsToFloat(0x3f800000), 1.0f); 92728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.intBitsToFloat(0x7fc00000), Float.NaN); 92828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.intBitsToFloat(0x7f800000), Float.POSITIVE_INFINITY); 92928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Float.intBitsToFloat(0xff800000), Float.NEGATIVE_INFINITY); 93028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 93128c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes 93228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_Double_doubleToRawLongBits() { 933ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Double.doubleToRawLongBits(-1.0); 93428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.doubleToRawLongBits(-1.0), 0xbff0000000000000L); 93528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.doubleToRawLongBits(0.0), 0x0000000000000000L); 93628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.doubleToRawLongBits(1.0), 0x3ff0000000000000L); 93728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.doubleToRawLongBits(Double.NaN), 0x7ff8000000000000L); 93828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.doubleToRawLongBits(Double.POSITIVE_INFINITY), 0x7ff0000000000000L); 93928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.doubleToRawLongBits(Double.NEGATIVE_INFINITY), 0xfff0000000000000L); 94028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 9415d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao 94228c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes public static void test_Double_longBitsToDouble() { 943ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Double.longBitsToDouble(0xbff0000000000000L); 94428c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.longBitsToDouble(0xbff0000000000000L), -1.0); 94528c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.longBitsToDouble(0x0000000000000000L), 0.0); 94628c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.longBitsToDouble(0x3ff0000000000000L), 1.0); 94728c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.longBitsToDouble(0x7ff8000000000000L), Double.NaN); 94828c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.longBitsToDouble(0x7ff0000000000000L), Double.POSITIVE_INFINITY); 94928c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes Assert.assertEquals(Double.longBitsToDouble(0xfff0000000000000L), Double.NEGATIVE_INFINITY); 95028c384bc3bf7244f25cfe320c55db5d3d9171832Elliott Hughes } 95123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 952a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu public static void test_Short_reverseBytes() { 953ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Short.reverseBytes((short)0x1357); 954a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Short.reverseBytes((short)0x0000), (short)0x0000); 955a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Short.reverseBytes((short)0xffff), (short)0xffff); 956a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Short.reverseBytes((short)0x8000), (short)0x0080); 957a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Short.reverseBytes((short)0x0080), (short)0x8000); 958a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Short.reverseBytes((short)0x0123), (short)0x2301); 959a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Short.reverseBytes((short)0x4567), (short)0x6745); 960a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Short.reverseBytes((short)0x89ab), (short)0xab89); 961a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Short.reverseBytes((short)0xcdef), (short)0xefcd); 962a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu } 963a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu 964a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu public static void test_Integer_reverseBytes() { 965ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Integer.reverseBytes(0x13579bdf); 966a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Integer.reverseBytes(0x00000000), 0x00000000); 967a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Integer.reverseBytes(0xffffffff), 0xffffffff); 968a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Integer.reverseBytes(0x80000000), 0x00000080); 969a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Integer.reverseBytes(0x00000080), 0x80000000); 970a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Integer.reverseBytes(0x01234567), 0x67452301); 971a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Integer.reverseBytes(0x89abcdef), 0xefcdab89); 972a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu } 973a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu 974a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu public static void test_Long_reverseBytes() { 975ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Long.reverseBytes(0x13579bdf2468ace0L); 976a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Long.reverseBytes(0x0000000000000000L), 0x0000000000000000L); 977a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Long.reverseBytes(0xffffffffffffffffL), 0xffffffffffffffffL); 978a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Long.reverseBytes(0x8000000000000000L), 0x0000000000000080L); 979a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Long.reverseBytes(0x0000000000000080L), 0x8000000000000000L); 980a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Long.reverseBytes(0x0123456789abcdefL), 0xefcdab8967452301L); 981a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu } 982a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu 98323abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Integer_reverse() { 984ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Integer.reverse(0x12345678); 98523abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Integer.reverse(1), 0x80000000); 98623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Integer.reverse(-1), 0xffffffff); 98723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Integer.reverse(0), 0); 98823abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Integer.reverse(0x12345678), 0x1e6a2c48); 98923abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Integer.reverse(0x87654321), 0x84c2a6e1); 99023abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Integer.reverse(Integer.MAX_VALUE), 0xfffffffe); 99123abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Integer.reverse(Integer.MIN_VALUE), 1); 99223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 99323abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 99423abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu public static void test_Long_reverse() { 995ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu Long.reverse(0x1234567812345678L); 99623abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Long.reverse(1L), 0x8000000000000000L); 99723abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Long.reverse(-1L), 0xffffffffffffffffL); 99823abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Long.reverse(0L), 0L); 999a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Long.reverse(0x1234567812345678L), 0x1e6a2c481e6a2c48L); 1000a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Long.reverse(0x8765432187654321L), 0x84c2a6e184c2a6e1L); 1001a3fe7422d7ce8bfb01f95decef45f91a44d39264Zheng Xu Assert.assertEquals(Long.reverse(Long.MAX_VALUE), 0xfffffffffffffffeL); 100223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu Assert.assertEquals(Long.reverse(Long.MIN_VALUE), 1L); 1003a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe 1004a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe Assert.assertEquals(test_Long_reverse_b22324327(0xaaaaaaaaaaaaaaaaL, 0x5555555555555555L), 1005a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe 157472205507277347L); 1006a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe } 1007a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe 1008a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe // A bit more complicated than the above. Use local variables to stress register allocation. 1009a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe private static long test_Long_reverse_b22324327(long l1, long l2) { 1010a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe // A couple of local integers. Use them in a loop, so they get promoted. 1011a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe int i1 = 0, i2 = 1, i3 = 2, i4 = 3, i5 = 4, i6 = 5, i7 = 6, i8 = 7; 1012a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe for (int k = 0; k < 10; k++) { 1013a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i1 += 1; 1014a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i2 += 2; 1015a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i3 += 3; 1016a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i4 += 4; 1017a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i5 += 5; 1018a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i6 += 6; 1019a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i7 += 7; 1020a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i8 += 8; 1021a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe } 1022a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe 1023a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe // Do the Long.reverse() calls, save the results. 1024a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe long r1 = Long.reverse(l1); 1025a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe long r2 = Long.reverse(l2); 1026a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe 1027a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe // Some more looping with the ints. 1028a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe for (int k = 0; k < 10; k++) { 1029a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i1 += 1; 1030a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i2 += 2; 1031a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i3 += 3; 1032a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i4 += 4; 1033a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i5 += 5; 1034a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i6 += 6; 1035a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i7 += 7; 1036a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe i8 += 8; 1037a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe } 1038a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe 1039a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe // Include everything in the result, so things are kept live. Try to be a little bit clever to 1040a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe // avoid things being folded somewhere. 1041a0b23bbed9b2199e85da401e3b2d0ddef74cd9fbAndreas Gampe return (r1 / i1) + (r2 / i2) + i3 + i4 + i5 + i6 + i7 + i8; 104223abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu } 104323abec955e2e733999a1e2c30e4e384e46e5dde4Serban Constantinescu 1044eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Object runtime; 1045eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method address_of; 1046f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang static Method new_non_movable_array; 1047eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method peek_byte; 1048eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method peek_short; 1049eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method peek_int; 1050eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method peek_long; 1051eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method poke_byte; 1052eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method poke_short; 1053eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method poke_int; 1054eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov static Method poke_long; 1055eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1056eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void initSupportMethodsForPeekPoke() throws Exception { 1057eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Class<?> vm_runtime = Class.forName("dalvik.system.VMRuntime"); 1058eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Method get_runtime = vm_runtime.getDeclaredMethod("getRuntime"); 1059eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov runtime = get_runtime.invoke(null); 1060eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov address_of = vm_runtime.getDeclaredMethod("addressOf", Object.class); 1061f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang new_non_movable_array = vm_runtime.getDeclaredMethod("newNonMovableArray", Class.class, Integer.TYPE); 1062eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1063eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Class<?> io_memory = Class.forName("libcore.io.Memory"); 1064eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov peek_byte = io_memory.getDeclaredMethod("peekByte", Long.TYPE); 1065eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov peek_int = io_memory.getDeclaredMethod("peekInt", Long.TYPE, Boolean.TYPE); 1066eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov peek_short = io_memory.getDeclaredMethod("peekShort", Long.TYPE, Boolean.TYPE); 1067eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov peek_long = io_memory.getDeclaredMethod("peekLong", Long.TYPE, Boolean.TYPE); 1068eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_byte = io_memory.getDeclaredMethod("pokeByte", Long.TYPE, Byte.TYPE); 1069eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_short = io_memory.getDeclaredMethod("pokeShort", Long.TYPE, Short.TYPE, Boolean.TYPE); 1070eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_int = io_memory.getDeclaredMethod("pokeInt", Long.TYPE, Integer.TYPE, Boolean.TYPE); 1071eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_long = io_memory.getDeclaredMethod("pokeLong", Long.TYPE, Long.TYPE, Boolean.TYPE); 1072eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 1073eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1074eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void test_Memory_peekByte() throws Exception { 1075f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang byte[] b = (byte[])new_non_movable_array.invoke(runtime, Byte.TYPE, 2); 1076eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[0] = 0x12; 1077eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[1] = 0x11; 1078eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov long address = (long)address_of.invoke(runtime, b); 1079eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertEquals((byte)peek_byte.invoke(null, address), 0x12); 1080eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertEquals((byte)peek_byte.invoke(null, address + 1), 0x11); 1081eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 1082eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1083eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void test_Memory_peekShort() throws Exception { 1084f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang byte[] b = (byte[])new_non_movable_array.invoke(runtime, Byte.TYPE, 3); 1085eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[0] = 0x13; 1086eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[1] = 0x12; 1087eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[2] = 0x11; 1088eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov long address = (long)address_of.invoke(runtime, b); 1089ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu peek_short.invoke(null, address, false); 1090eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertEquals((short)peek_short.invoke(null, address, false), 0x1213); // Aligned read 1091eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertEquals((short)peek_short.invoke(null, address + 1, false), 0x1112); // Unaligned read 1092eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 1093eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1094eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void test_Memory_peekInt() throws Exception { 1095f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang byte[] b = (byte[])new_non_movable_array.invoke(runtime, Byte.TYPE, 5); 1096eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[0] = 0x15; 1097eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[1] = 0x14; 1098eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[2] = 0x13; 1099eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[3] = 0x12; 1100eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[4] = 0x11; 1101eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov long address = (long)address_of.invoke(runtime, b); 1102ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu peek_int.invoke(null, address, false); 1103eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertEquals((int)peek_int.invoke(null, address, false), 0x12131415); 1104eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertEquals((int)peek_int.invoke(null, address + 1, false), 0x11121314); 1105eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 1106eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1107eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void test_Memory_peekLong() throws Exception { 1108f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang byte[] b = (byte[])new_non_movable_array.invoke(runtime, Byte.TYPE, 9); 1109eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[0] = 0x19; 1110eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[1] = 0x18; 1111eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[2] = 0x17; 1112eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[3] = 0x16; 1113eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[4] = 0x15; 1114eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[5] = 0x14; 1115eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[6] = 0x13; 1116eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[7] = 0x12; 1117eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[8] = 0x11; 1118eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov long address = (long)address_of.invoke(runtime, b); 1119ff87d7bdc2c06bece8ea783dd4979360f1d51103Chao-ying Fu peek_long.invoke(null, address, false); 1120eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertEquals((long)peek_long.invoke(null, address, false), 0x1213141516171819L); 1121eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertEquals((long)peek_long.invoke(null, address + 1, false), 0x1112131415161718L); 1122eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 1123eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1124eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void test_Memory_pokeByte() throws Exception { 1125eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov byte[] r = {0x11, 0x12}; 1126f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang byte[] b = (byte[])new_non_movable_array.invoke(runtime, Byte.TYPE, 2); 1127eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov long address = (long)address_of.invoke(runtime, b); 1128eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_byte.invoke(null, address, (byte)0x11); 1129eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_byte.invoke(null, address + 1, (byte)0x12); 1130eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertTrue(Arrays.equals(r, b)); 1131eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 1132eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1133eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void test_Memory_pokeShort() throws Exception { 1134eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov byte[] ra = {0x12, 0x11, 0x13}; 1135eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov byte[] ru = {0x12, 0x22, 0x21}; 1136f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang byte[] b = (byte[])new_non_movable_array.invoke(runtime, Byte.TYPE, 3); 1137eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov long address = (long)address_of.invoke(runtime, b); 1138eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1139eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov // Aligned write 1140eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[2] = 0x13; 1141eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_short.invoke(null, address, (short)0x1112, false); 1142eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertTrue(Arrays.equals(ra, b)); 1143eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1144eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov // Unaligned write 1145eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_short.invoke(null, address + 1, (short)0x2122, false); 1146eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertTrue(Arrays.equals(ru, b)); 1147eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 1148eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1149eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void test_Memory_pokeInt() throws Exception { 1150eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov byte[] ra = {0x14, 0x13, 0x12, 0x11, 0x15}; 1151eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov byte[] ru = {0x14, 0x24, 0x23, 0x22, 0x21}; 1152f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang byte[] b = (byte[])new_non_movable_array.invoke(runtime, Byte.TYPE, 5); 1153eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov long address = (long)address_of.invoke(runtime, b); 1154eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1155eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[4] = 0x15; 1156eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_int.invoke(null, address, (int)0x11121314, false); 1157eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertTrue(Arrays.equals(ra, b)); 1158eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1159eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_int.invoke(null, address + 1, (int)0x21222324, false); 1160eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertTrue(Arrays.equals(ru, b)); 1161eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 1162eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1163eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov public static void test_Memory_pokeLong() throws Exception { 1164eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov byte[] ra = {0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x19}; 1165eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov byte[] ru = {0x18, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21}; 1166f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang byte[] b = (byte[])new_non_movable_array.invoke(runtime, Byte.TYPE, 9); 1167eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov long address = (long)address_of.invoke(runtime, b); 1168eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1169eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov b[8] = 0x19; 1170eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_long.invoke(null, address, (long)0x1112131415161718L, false); 1171eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertTrue(Arrays.equals(ra, b)); 1172eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov 1173eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov poke_long.invoke(null, address + 1, (long)0x2122232425262728L, false); 1174eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov Assert.assertTrue(Arrays.equals(ru, b)); 1175eb24baec056dbe5871f1bc64b793eb2e69907866Alexei Zavjalov } 11765d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao} 1177