Source Code Cross Referenced for ArraysTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » luni » tests » java » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » org package » org.apache.harmony.luni.tests.java.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
0003:         *  contributor license agreements.  See the NOTICE file distributed with
0004:         *  this work for additional information regarding copyright ownership.
0005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
0006:         *  (the "License"); you may not use this file except in compliance with
0007:         *  the License.  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         *  Unless required by applicable law or agreed to in writing, software
0012:         *  distributed under the License is distributed on an "AS IS" BASIS,
0013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         *  See the License for the specific language governing permissions and
0015:         *  limitations under the License.
0016:         */
0017:        package org.apache.harmony.luni.tests.java.util;
0018:
0019:        import java.lang.reflect.Method;
0020:        import java.util.Arrays;
0021:        import java.util.Comparator;
0022:        import java.util.LinkedList;
0023:        import java.util.List;
0024:
0025:        import tests.support.Support_UnmodifiableCollectionTest;
0026:
0027:        public class ArraysTest extends junit.framework.TestCase {
0028:
0029:            public static class ReversedIntegerComparator implements  Comparator {
0030:                public int compare(Object o1, Object o2) {
0031:                    return -(((Integer) o1).compareTo((Integer) o2));
0032:                }
0033:
0034:                public boolean equals(Object o1, Object o2) {
0035:                    return ((Integer) o1).compareTo((Integer) o2) == 0;
0036:                }
0037:            }
0038:
0039:            static class MockComparable implements  Comparable {
0040:                public int compareTo(Object o) {
0041:                    return 0;
0042:                }
0043:            }
0044:
0045:            final static int arraySize = 100;
0046:
0047:            static Object[] objArray;
0048:
0049:            static boolean[] booleanArray;
0050:
0051:            static byte[] byteArray;
0052:
0053:            static char[] charArray;
0054:
0055:            static double[] doubleArray;
0056:
0057:            static float[] floatArray;
0058:
0059:            static int[] intArray;
0060:
0061:            static long[] longArray;
0062:
0063:            static Object[] objectArray;
0064:
0065:            static short[] shortArray;
0066:            {
0067:                objArray = new Object[arraySize];
0068:                for (int i = 0; i < objArray.length; i++)
0069:                    objArray[i] = new Integer(i);
0070:            }
0071:
0072:            /**
0073:             * @tests java.util.Arrays#asList(java.lang.Object[])
0074:             */
0075:            public void test_asList$Ljava_lang_Object() {
0076:                // Test for method java.util.List
0077:                // java.util.Arrays.asList(java.lang.Object [])
0078:                List convertedList = Arrays.asList(objectArray);
0079:                for (int counter = 0; counter < arraySize; counter++) {
0080:                    assertTrue(
0081:                            "Array and List converted from array do not contain identical elements",
0082:                            convertedList.get(counter) == objectArray[counter]);
0083:                }
0084:                convertedList.set(50, new Integer(1000));
0085:                assertTrue("set/get did not work on coverted list",
0086:                        convertedList.get(50).equals(new Integer(1000)));
0087:                convertedList.set(50, new Integer(50));
0088:                new Support_UnmodifiableCollectionTest("", convertedList)
0089:                        .runTest();
0090:
0091:                Object[] myArray = (Object[]) (objectArray.clone());
0092:                myArray[30] = null;
0093:                myArray[60] = null;
0094:                convertedList = Arrays.asList(myArray);
0095:                for (int counter = 0; counter < arraySize; counter++) {
0096:                    assertTrue(
0097:                            "Array and List converted from array do not contain identical elements",
0098:                            convertedList.get(counter) == myArray[counter]);
0099:                }
0100:
0101:                try {
0102:                    Arrays.asList((Object[]) null);
0103:                    fail("asList with null arg didn't throw NPE");
0104:                } catch (NullPointerException e) {
0105:                    // Expected
0106:                }
0107:            }
0108:
0109:            /**
0110:             * @tests java.util.Arrays#binarySearch(byte[], byte)
0111:             */
0112:            public void test_binarySearch$BB() {
0113:                // Test for method int java.util.Arrays.binarySearch(byte [], byte)
0114:                for (byte counter = 0; counter < arraySize; counter++)
0115:                    assertTrue(
0116:                            "Binary search on byte[] answered incorrect position",
0117:                            Arrays.binarySearch(byteArray, counter) == counter);
0118:                assertEquals(
0119:                        "Binary search succeeded for value not present in array 1",
0120:                        -1, Arrays.binarySearch(intArray, (byte) -1));
0121:                assertTrue(
0122:                        "Binary search succeeded for value not present in array 2",
0123:                        Arrays.binarySearch(intArray, (byte) arraySize) == -(arraySize + 1));
0124:                for (byte counter = 0; counter < arraySize; counter++)
0125:                    byteArray[counter] -= 50;
0126:                for (byte counter = 0; counter < arraySize; counter++)
0127:                    assertTrue(
0128:                            "Binary search on byte[] involving negative numbers answered incorrect position",
0129:                            Arrays.binarySearch(byteArray,
0130:                                    (byte) (counter - 50)) == counter);
0131:            }
0132:
0133:            /**
0134:             * @tests java.util.Arrays#binarySearch(char[], char)
0135:             */
0136:            public void test_binarySearch$CC() {
0137:                // Test for method int java.util.Arrays.binarySearch(char [], char)
0138:                for (char counter = 0; counter < arraySize; counter++)
0139:                    assertTrue(
0140:                            "Binary search on char[] answered incorrect position",
0141:                            Arrays
0142:                                    .binarySearch(charArray,
0143:                                            (char) (counter + 1)) == counter);
0144:                assertEquals(
0145:                        "Binary search succeeded for value not present in array 1",
0146:                        -1, Arrays.binarySearch(charArray, '\u0000'));
0147:                assertTrue(
0148:                        "Binary search succeeded for value not present in array 2",
0149:                        Arrays.binarySearch(charArray, (char) (arraySize + 1)) == -(arraySize + 1));
0150:            }
0151:
0152:            /**
0153:             * @tests java.util.Arrays#binarySearch(double[], double)
0154:             */
0155:            public void test_binarySearch$DD() {
0156:                // Test for method int java.util.Arrays.binarySearch(double [], double)
0157:                for (int counter = 0; counter < arraySize; counter++)
0158:                    assertTrue(
0159:                            "Binary search on double[] answered incorrect position",
0160:                            Arrays.binarySearch(doubleArray, (double) counter) == (double) counter);
0161:                assertEquals(
0162:                        "Binary search succeeded for value not present in array 1",
0163:                        -1, Arrays.binarySearch(doubleArray, (double) -1));
0164:                assertTrue(
0165:                        "Binary search succeeded for value not present in array 2",
0166:                        Arrays.binarySearch(doubleArray, (double) arraySize) == -(arraySize + 1));
0167:                for (int counter = 0; counter < arraySize; counter++)
0168:                    doubleArray[counter] -= (double) 50;
0169:                for (int counter = 0; counter < arraySize; counter++)
0170:                    assertTrue(
0171:                            "Binary search on double[] involving negative numbers answered incorrect position",
0172:                            Arrays.binarySearch(doubleArray,
0173:                                    (double) (counter - 50)) == (double) counter);
0174:
0175:                double[] specials = new double[] { Double.NEGATIVE_INFINITY,
0176:                        -Double.MAX_VALUE, -2d, -Double.MIN_VALUE, -0d, 0d,
0177:                        Double.MIN_VALUE, 2d, Double.MAX_VALUE,
0178:                        Double.POSITIVE_INFINITY, Double.NaN };
0179:                for (int i = 0; i < specials.length; i++) {
0180:                    int result = Arrays.binarySearch(specials, specials[i]);
0181:                    assertTrue(specials[i] + " invalid: " + result, result == i);
0182:                }
0183:                assertEquals("-1d", -4, Arrays.binarySearch(specials, -1d));
0184:                assertEquals("1d", -8, Arrays.binarySearch(specials, 1d));
0185:
0186:            }
0187:
0188:            /**
0189:             * @tests java.util.Arrays#binarySearch(float[], float)
0190:             */
0191:            public void test_binarySearch$FF() {
0192:                // Test for method int java.util.Arrays.binarySearch(float [], float)
0193:                for (int counter = 0; counter < arraySize; counter++)
0194:                    assertTrue(
0195:                            "Binary search on float[] answered incorrect position",
0196:                            Arrays.binarySearch(floatArray, (float) counter) == (float) counter);
0197:                assertEquals(
0198:                        "Binary search succeeded for value not present in array 1",
0199:                        -1, Arrays.binarySearch(floatArray, (float) -1));
0200:                assertTrue(
0201:                        "Binary search succeeded for value not present in array 2",
0202:                        Arrays.binarySearch(floatArray, (float) arraySize) == -(arraySize + 1));
0203:                for (int counter = 0; counter < arraySize; counter++)
0204:                    floatArray[counter] -= (float) 50;
0205:                for (int counter = 0; counter < arraySize; counter++)
0206:                    assertTrue(
0207:                            "Binary search on float[] involving negative numbers answered incorrect position",
0208:                            Arrays.binarySearch(floatArray,
0209:                                    (float) counter - 50) == (float) counter);
0210:
0211:                float[] specials = new float[] { Float.NEGATIVE_INFINITY,
0212:                        -Float.MAX_VALUE, -2f, -Float.MIN_VALUE, -0f, 0f,
0213:                        Float.MIN_VALUE, 2f, Float.MAX_VALUE,
0214:                        Float.POSITIVE_INFINITY, Float.NaN };
0215:                for (int i = 0; i < specials.length; i++) {
0216:                    int result = Arrays.binarySearch(specials, specials[i]);
0217:                    assertTrue(specials[i] + " invalid: " + result, result == i);
0218:                }
0219:                assertEquals("-1f", -4, Arrays.binarySearch(specials, -1f));
0220:                assertEquals("1f", -8, Arrays.binarySearch(specials, 1f));
0221:            }
0222:
0223:            /**
0224:             * @tests java.util.Arrays#binarySearch(int[], int)
0225:             */
0226:            public void test_binarySearch$II() {
0227:                // Test for method int java.util.Arrays.binarySearch(int [], int)
0228:                for (int counter = 0; counter < arraySize; counter++)
0229:                    assertTrue(
0230:                            "Binary search on int[] answered incorrect position",
0231:                            Arrays.binarySearch(intArray, counter) == counter);
0232:                assertEquals(
0233:                        "Binary search succeeded for value not present in array 1",
0234:                        -1, Arrays.binarySearch(intArray, -1));
0235:                assertTrue(
0236:                        "Binary search succeeded for value not present in array 2",
0237:                        Arrays.binarySearch(intArray, arraySize) == -(arraySize + 1));
0238:                for (int counter = 0; counter < arraySize; counter++)
0239:                    intArray[counter] -= 50;
0240:                for (int counter = 0; counter < arraySize; counter++)
0241:                    assertTrue(
0242:                            "Binary search on int[] involving negative numbers answered incorrect position",
0243:                            Arrays.binarySearch(intArray, counter - 50) == counter);
0244:            }
0245:
0246:            /**
0247:             * @tests java.util.Arrays#binarySearch(long[], long)
0248:             */
0249:            public void test_binarySearch$JJ() {
0250:                // Test for method int java.util.Arrays.binarySearch(long [], long)
0251:                for (long counter = 0; counter < arraySize; counter++)
0252:                    assertTrue(
0253:                            "Binary search on long[] answered incorrect position",
0254:                            Arrays.binarySearch(longArray, counter) == counter);
0255:                assertEquals(
0256:                        "Binary search succeeded for value not present in array 1",
0257:                        -1, Arrays.binarySearch(longArray, (long) -1));
0258:                assertTrue(
0259:                        "Binary search succeeded for value not present in array 2",
0260:                        Arrays.binarySearch(longArray, (long) arraySize) == -(arraySize + 1));
0261:                for (long counter = 0; counter < arraySize; counter++)
0262:                    longArray[(int) counter] -= (long) 50;
0263:                for (long counter = 0; counter < arraySize; counter++)
0264:                    assertTrue(
0265:                            "Binary search on long[] involving negative numbers answered incorrect position",
0266:                            Arrays.binarySearch(longArray, counter - (long) 50) == counter);
0267:            }
0268:
0269:            /**
0270:             * @tests java.util.Arrays#binarySearch(java.lang.Object[],
0271:             *        java.lang.Object)
0272:             */
0273:            public void test_binarySearch$Ljava_lang_ObjectLjava_lang_Object() {
0274:                // Test for method int java.util.Arrays.binarySearch(java.lang.Object
0275:                // [], java.lang.Object)
0276:                assertEquals(
0277:                        "Binary search succeeded for non-comparable value in empty array",
0278:                        -1, Arrays.binarySearch(new Object[] {}, new Object()));
0279:                assertEquals(
0280:                        "Binary search succeeded for comparable value in empty array",
0281:                        -1, Arrays.binarySearch(new Object[] {},
0282:                                new Integer(-1)));
0283:                for (int counter = 0; counter < arraySize; counter++)
0284:                    assertTrue(
0285:                            "Binary search on Object[] answered incorrect position",
0286:                            Arrays.binarySearch(objectArray, objArray[counter]) == counter);
0287:                assertEquals(
0288:                        "Binary search succeeded for value not present in array 1",
0289:                        -1, Arrays.binarySearch(objectArray, new Integer(-1)));
0290:                assertTrue(
0291:                        "Binary search succeeded for value not present in array 2",
0292:                        Arrays
0293:                                .binarySearch(objectArray, new Integer(
0294:                                        arraySize)) == -(arraySize + 1));
0295:
0296:                Object object = new Object();
0297:                Object[] objects = new MockComparable[] { new MockComparable() };
0298:                assertEquals("Should always return 0", 0, Arrays.binarySearch(
0299:                        objects, object));
0300:
0301:                Object[] string_objects = new String[] { "one" };
0302:                try {
0303:                    Arrays.binarySearch(string_objects, object);
0304:                    fail("No expected ClassCastException");
0305:                } catch (ClassCastException e) {
0306:                    // Expected
0307:                }
0308:            }
0309:
0310:            /**
0311:             * @tests java.util.Arrays#binarySearch(java.lang.Object[],
0312:             *        java.lang.Object, java.util.Comparator)
0313:             */
0314:            public void test_binarySearch$Ljava_lang_ObjectLjava_lang_ObjectLjava_util_Comparator() {
0315:                // Test for method int java.util.Arrays.binarySearch(java.lang.Object
0316:                // [], java.lang.Object, java.util.Comparator)
0317:                Comparator comp = new ReversedIntegerComparator();
0318:                for (int counter = 0; counter < arraySize; counter++)
0319:                    objectArray[counter] = objArray[arraySize - counter - 1];
0320:                assertTrue(
0321:                        "Binary search succeeded for value not present in array 1",
0322:                        Arrays.binarySearch(objectArray, new Integer(-1), comp) == -(arraySize + 1));
0323:                assertEquals(
0324:                        "Binary search succeeded for value not present in array 2",
0325:                        -1, Arrays.binarySearch(objectArray, new Integer(
0326:                                arraySize), comp));
0327:                for (int counter = 0; counter < arraySize; counter++)
0328:                    assertTrue(
0329:                            "Binary search on Object[] with custom comparator answered incorrect position",
0330:                            Arrays.binarySearch(objectArray, objArray[counter],
0331:                                    comp) == arraySize - counter - 1);
0332:            }
0333:
0334:            /**
0335:             * @tests java.util.Arrays#binarySearch(short[], short)
0336:             */
0337:            public void test_binarySearch$SS() {
0338:                // Test for method int java.util.Arrays.binarySearch(short [], short)
0339:                for (short counter = 0; counter < arraySize; counter++)
0340:                    assertTrue(
0341:                            "Binary search on short[] answered incorrect position",
0342:                            Arrays.binarySearch(shortArray, counter) == counter);
0343:                assertEquals(
0344:                        "Binary search succeeded for value not present in array 1",
0345:                        -1, Arrays.binarySearch(intArray, (short) -1));
0346:                assertTrue(
0347:                        "Binary search succeeded for value not present in array 2",
0348:                        Arrays.binarySearch(intArray, (short) arraySize) == -(arraySize + 1));
0349:                for (short counter = 0; counter < arraySize; counter++)
0350:                    shortArray[counter] -= 50;
0351:                for (short counter = 0; counter < arraySize; counter++)
0352:                    assertTrue(
0353:                            "Binary search on short[] involving negative numbers answered incorrect position",
0354:                            Arrays.binarySearch(shortArray,
0355:                                    (short) (counter - 50)) == counter);
0356:            }
0357:
0358:            /**
0359:             * @tests java.util.Arrays#fill(byte[], byte)
0360:             */
0361:            public void test_fill$BB() {
0362:                // Test for method void java.util.Arrays.fill(byte [], byte)
0363:
0364:                byte d[] = new byte[1000];
0365:                Arrays.fill(d, Byte.MAX_VALUE);
0366:                for (int i = 0; i < d.length; i++)
0367:                    assertTrue("Failed to fill byte array correctly",
0368:                            d[i] == Byte.MAX_VALUE);
0369:            }
0370:
0371:            /**
0372:             * @tests java.util.Arrays#fill(byte[], int, int, byte)
0373:             */
0374:            public void test_fill$BIIB() {
0375:                // Test for method void java.util.Arrays.fill(byte [], int, int, byte)
0376:                byte val = Byte.MAX_VALUE;
0377:                byte d[] = new byte[1000];
0378:                Arrays.fill(d, 400, d.length, val);
0379:                for (int i = 0; i < 400; i++)
0380:                    assertTrue("Filled elements not in range", !(d[i] == val));
0381:                for (int i = 400; i < d.length; i++)
0382:                    assertTrue("Failed to fill byte array correctly",
0383:                            d[i] == val);
0384:
0385:                int result;
0386:                try {
0387:                    Arrays.fill(new byte[2], 2, 1, (byte) 27);
0388:                    result = 0;
0389:                } catch (ArrayIndexOutOfBoundsException e) {
0390:                    result = 1;
0391:                } catch (IllegalArgumentException e) {
0392:                    result = 2;
0393:                }
0394:                assertEquals("Wrong exception1", 2, result);
0395:                try {
0396:                    Arrays.fill(new byte[2], -1, 1, (byte) 27);
0397:                    result = 0;
0398:                } catch (ArrayIndexOutOfBoundsException e) {
0399:                    result = 1;
0400:                } catch (IllegalArgumentException e) {
0401:                    result = 2;
0402:                }
0403:                assertEquals("Wrong exception2", 1, result);
0404:                try {
0405:                    Arrays.fill(new byte[2], 1, 4, (byte) 27);
0406:                    result = 0;
0407:                } catch (ArrayIndexOutOfBoundsException e) {
0408:                    result = 1;
0409:                } catch (IllegalArgumentException e) {
0410:                    result = 2;
0411:                }
0412:                assertEquals("Wrong exception", 1, result);
0413:            }
0414:
0415:            /**
0416:             * @tests java.util.Arrays#fill(short[], short)
0417:             */
0418:            public void test_fill$SS() {
0419:                // Test for method void java.util.Arrays.fill(short [], short)
0420:
0421:                short d[] = new short[1000];
0422:                Arrays.fill(d, Short.MAX_VALUE);
0423:                for (int i = 0; i < d.length; i++)
0424:                    assertTrue("Failed to fill short array correctly",
0425:                            d[i] == Short.MAX_VALUE);
0426:            }
0427:
0428:            /**
0429:             * @tests java.util.Arrays#fill(short[], int, int, short)
0430:             */
0431:            public void test_fill$SIIS() {
0432:                // Test for method void java.util.Arrays.fill(short [], int, int, short)
0433:                short val = Short.MAX_VALUE;
0434:                short d[] = new short[1000];
0435:                Arrays.fill(d, 400, d.length, val);
0436:                for (int i = 0; i < 400; i++)
0437:                    assertTrue("Filled elements not in range", !(d[i] == val));
0438:                for (int i = 400; i < d.length; i++)
0439:                    assertTrue("Failed to fill short array correctly",
0440:                            d[i] == val);
0441:            }
0442:
0443:            /**
0444:             * @tests java.util.Arrays#fill(char[], char)
0445:             */
0446:            public void test_fill$CC() {
0447:                // Test for method void java.util.Arrays.fill(char [], char)
0448:
0449:                char d[] = new char[1000];
0450:                Arrays.fill(d, 'V');
0451:                for (int i = 0; i < d.length; i++)
0452:                    assertEquals("Failed to fill char array correctly", 'V',
0453:                            d[i]);
0454:            }
0455:
0456:            /**
0457:             * @tests java.util.Arrays#fill(char[], int, int, char)
0458:             */
0459:            public void test_fill$CIIC() {
0460:                // Test for method void java.util.Arrays.fill(char [], int, int, char)
0461:                char val = 'T';
0462:                char d[] = new char[1000];
0463:                Arrays.fill(d, 400, d.length, val);
0464:                for (int i = 0; i < 400; i++)
0465:                    assertTrue("Filled elements not in range", !(d[i] == val));
0466:                for (int i = 400; i < d.length; i++)
0467:                    assertTrue("Failed to fill char array correctly",
0468:                            d[i] == val);
0469:            }
0470:
0471:            /**
0472:             * @tests java.util.Arrays#fill(int[], int)
0473:             */
0474:            public void test_fill$II() {
0475:                // Test for method void java.util.Arrays.fill(int [], int)
0476:
0477:                int d[] = new int[1000];
0478:                Arrays.fill(d, Integer.MAX_VALUE);
0479:                for (int i = 0; i < d.length; i++)
0480:                    assertTrue("Failed to fill int array correctly",
0481:                            d[i] == Integer.MAX_VALUE);
0482:            }
0483:
0484:            /**
0485:             * @tests java.util.Arrays#fill(int[], int, int, int)
0486:             */
0487:            public void test_fill$IIII() {
0488:                // Test for method void java.util.Arrays.fill(int [], int, int, int)
0489:                int val = Integer.MAX_VALUE;
0490:                int d[] = new int[1000];
0491:                Arrays.fill(d, 400, d.length, val);
0492:                for (int i = 0; i < 400; i++)
0493:                    assertTrue("Filled elements not in range", !(d[i] == val));
0494:                for (int i = 400; i < d.length; i++)
0495:                    assertTrue("Failed to fill int array correctly",
0496:                            d[i] == val);
0497:            }
0498:
0499:            /**
0500:             * @tests java.util.Arrays#fill(long[], long)
0501:             */
0502:            public void test_fill$JJ() {
0503:                // Test for method void java.util.Arrays.fill(long [], long)
0504:
0505:                long d[] = new long[1000];
0506:                Arrays.fill(d, Long.MAX_VALUE);
0507:                for (int i = 0; i < d.length; i++)
0508:                    assertTrue("Failed to fill long array correctly",
0509:                            d[i] == Long.MAX_VALUE);
0510:            }
0511:
0512:            /**
0513:             * @tests java.util.Arrays#fill(long[], int, int, long)
0514:             */
0515:            public void test_fill$JIIJ() {
0516:                // Test for method void java.util.Arrays.fill(long [], int, int, long)
0517:                long d[] = new long[1000];
0518:                Arrays.fill(d, 400, d.length, Long.MAX_VALUE);
0519:                for (int i = 0; i < 400; i++)
0520:                    assertTrue("Filled elements not in range",
0521:                            !(d[i] == Long.MAX_VALUE));
0522:                for (int i = 400; i < d.length; i++)
0523:                    assertTrue("Failed to fill long array correctly",
0524:                            d[i] == Long.MAX_VALUE);
0525:            }
0526:
0527:            /**
0528:             * @tests java.util.Arrays#fill(float[], float)
0529:             */
0530:            public void test_fill$FF() {
0531:                // Test for method void java.util.Arrays.fill(float [], float)
0532:                float d[] = new float[1000];
0533:                Arrays.fill(d, Float.MAX_VALUE);
0534:                for (int i = 0; i < d.length; i++)
0535:                    assertTrue("Failed to fill float array correctly",
0536:                            d[i] == Float.MAX_VALUE);
0537:            }
0538:
0539:            /**
0540:             * @tests java.util.Arrays#fill(float[], int, int, float)
0541:             */
0542:            public void test_fill$FIIF() {
0543:                // Test for method void java.util.Arrays.fill(float [], int, int, float)
0544:                float val = Float.MAX_VALUE;
0545:                float d[] = new float[1000];
0546:                Arrays.fill(d, 400, d.length, val);
0547:                for (int i = 0; i < 400; i++)
0548:                    assertTrue("Filled elements not in range", !(d[i] == val));
0549:                for (int i = 400; i < d.length; i++)
0550:                    assertTrue("Failed to fill float array correctly",
0551:                            d[i] == val);
0552:            }
0553:
0554:            /**
0555:             * @tests java.util.Arrays#fill(double[], double)
0556:             */
0557:            public void test_fill$DD() {
0558:                // Test for method void java.util.Arrays.fill(double [], double)
0559:
0560:                double d[] = new double[1000];
0561:                Arrays.fill(d, Double.MAX_VALUE);
0562:                for (int i = 0; i < d.length; i++)
0563:                    assertTrue("Failed to fill double array correctly",
0564:                            d[i] == Double.MAX_VALUE);
0565:            }
0566:
0567:            /**
0568:             * @tests java.util.Arrays#fill(double[], int, int, double)
0569:             */
0570:            public void test_fill$DIID() {
0571:                // Test for method void java.util.Arrays.fill(double [], int, int,
0572:                // double)
0573:                double val = Double.MAX_VALUE;
0574:                double d[] = new double[1000];
0575:                Arrays.fill(d, 400, d.length, val);
0576:                for (int i = 0; i < 400; i++)
0577:                    assertTrue("Filled elements not in range", !(d[i] == val));
0578:                for (int i = 400; i < d.length; i++)
0579:                    assertTrue("Failed to fill double array correctly",
0580:                            d[i] == val);
0581:            }
0582:
0583:            /**
0584:             * @tests java.util.Arrays#fill(boolean[], boolean)
0585:             */
0586:            public void test_fill$ZZ() {
0587:                // Test for method void java.util.Arrays.fill(boolean [], boolean)
0588:
0589:                boolean d[] = new boolean[1000];
0590:                Arrays.fill(d, true);
0591:                for (int i = 0; i < d.length; i++)
0592:                    assertTrue("Failed to fill boolean array correctly", d[i]);
0593:            }
0594:
0595:            /**
0596:             * @tests java.util.Arrays#fill(boolean[], int, int, boolean)
0597:             */
0598:            public void test_fill$ZIIZ() {
0599:                // Test for method void java.util.Arrays.fill(boolean [], int, int,
0600:                // boolean)
0601:                boolean val = true;
0602:                boolean d[] = new boolean[1000];
0603:                Arrays.fill(d, 400, d.length, val);
0604:                for (int i = 0; i < 400; i++)
0605:                    assertTrue("Filled elements not in range", !(d[i] == val));
0606:                for (int i = 400; i < d.length; i++)
0607:                    assertTrue("Failed to fill boolean array correctly",
0608:                            d[i] == val);
0609:            }
0610:
0611:            /**
0612:             * @tests java.util.Arrays#fill(java.lang.Object[], java.lang.Object)
0613:             */
0614:            public void test_fill$Ljava_lang_ObjectLjava_lang_Object() {
0615:                // Test for method void java.util.Arrays.fill(java.lang.Object [],
0616:                // java.lang.Object)
0617:                Object val = new Object();
0618:                Object d[] = new Object[1000];
0619:                Arrays.fill(d, 0, d.length, val);
0620:                for (int i = 0; i < d.length; i++)
0621:                    assertTrue("Failed to fill Object array correctly",
0622:                            d[i] == val);
0623:            }
0624:
0625:            /**
0626:             * @tests java.util.Arrays#fill(java.lang.Object[], int, int,
0627:             *        java.lang.Object)
0628:             */
0629:            public void test_fill$Ljava_lang_ObjectIILjava_lang_Object() {
0630:                // Test for method void java.util.Arrays.fill(java.lang.Object [], int,
0631:                // int, java.lang.Object)
0632:                Object val = new Object();
0633:                Object d[] = new Object[1000];
0634:                Arrays.fill(d, 400, d.length, val);
0635:                for (int i = 0; i < 400; i++)
0636:                    assertTrue("Filled elements not in range", !(d[i] == val));
0637:                for (int i = 400; i < d.length; i++)
0638:                    assertTrue("Failed to fill Object array correctly",
0639:                            d[i] == val);
0640:
0641:                Arrays.fill(d, 400, d.length, null);
0642:                for (int i = 400; i < d.length; i++)
0643:                    assertNull(
0644:                            "Failed to fill Object array correctly with nulls",
0645:                            d[i]);
0646:            }
0647:
0648:            /**
0649:             * @tests java.util.Arrays#equals(byte[], byte[])
0650:             */
0651:            public void test_equals$B$B() {
0652:                // Test for method boolean java.util.Arrays.equals(byte [], byte [])
0653:                byte d[] = new byte[1000];
0654:                byte x[] = new byte[1000];
0655:                Arrays.fill(d, Byte.MAX_VALUE);
0656:                Arrays.fill(x, Byte.MIN_VALUE);
0657:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0658:                Arrays.fill(x, Byte.MAX_VALUE);
0659:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0660:            }
0661:
0662:            /**
0663:             * @tests java.util.Arrays#equals(short[], short[])
0664:             */
0665:            public void test_equals$S$S() {
0666:                // Test for method boolean java.util.Arrays.equals(short [], short [])
0667:                short d[] = new short[1000];
0668:                short x[] = new short[1000];
0669:                Arrays.fill(d, Short.MAX_VALUE);
0670:                Arrays.fill(x, Short.MIN_VALUE);
0671:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0672:                Arrays.fill(x, Short.MAX_VALUE);
0673:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0674:            }
0675:
0676:            /**
0677:             * @tests java.util.Arrays#equals(char[], char[])
0678:             */
0679:            public void test_equals$C$C() {
0680:                // Test for method boolean java.util.Arrays.equals(char [], char [])
0681:                char d[] = new char[1000];
0682:                char x[] = new char[1000];
0683:                char c = 'T';
0684:                Arrays.fill(d, c);
0685:                Arrays.fill(x, 'L');
0686:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0687:                Arrays.fill(x, c);
0688:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0689:            }
0690:
0691:            /**
0692:             * @tests java.util.Arrays#equals(int[], int[])
0693:             */
0694:            public void test_equals$I$I() {
0695:                // Test for method boolean java.util.Arrays.equals(int [], int [])
0696:                int d[] = new int[1000];
0697:                int x[] = new int[1000];
0698:                Arrays.fill(d, Integer.MAX_VALUE);
0699:                Arrays.fill(x, Integer.MIN_VALUE);
0700:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0701:                Arrays.fill(x, Integer.MAX_VALUE);
0702:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0703:
0704:                assertTrue("wrong result for null array1", !Arrays.equals(
0705:                        new int[2], null));
0706:                assertTrue("wrong result for null array2", !Arrays.equals(null,
0707:                        new int[2]));
0708:            }
0709:
0710:            /**
0711:             * @tests java.util.Arrays#equals(long[], long[])
0712:             */
0713:            public void test_equals$J$J() {
0714:                // Test for method boolean java.util.Arrays.equals(long [], long [])
0715:                long d[] = new long[1000];
0716:                long x[] = new long[1000];
0717:                Arrays.fill(d, Long.MAX_VALUE);
0718:                Arrays.fill(x, Long.MIN_VALUE);
0719:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0720:                Arrays.fill(x, Long.MAX_VALUE);
0721:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0722:
0723:                assertTrue("should be false", !Arrays.equals(
0724:                        new long[] { 0x100000000L },
0725:                        new long[] { 0x200000000L }));
0726:
0727:            }
0728:
0729:            /**
0730:             * @tests java.util.Arrays#equals(float[], float[])
0731:             */
0732:            public void test_equals$F$F() {
0733:                // Test for method boolean java.util.Arrays.equals(float [], float [])
0734:                float d[] = new float[1000];
0735:                float x[] = new float[1000];
0736:                Arrays.fill(d, Float.MAX_VALUE);
0737:                Arrays.fill(x, Float.MIN_VALUE);
0738:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0739:                Arrays.fill(x, Float.MAX_VALUE);
0740:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0741:
0742:                assertTrue("NaN not equals", Arrays.equals(
0743:                        new float[] { Float.NaN }, new float[] { Float.NaN }));
0744:                assertTrue("0f equals -0f", !Arrays.equals(new float[] { 0f },
0745:                        new float[] { -0f }));
0746:            }
0747:
0748:            /**
0749:             * @tests java.util.Arrays#equals(double[], double[])
0750:             */
0751:            public void test_equals$D$D() {
0752:                // Test for method boolean java.util.Arrays.equals(double [], double [])
0753:                double d[] = new double[1000];
0754:                double x[] = new double[1000];
0755:                Arrays.fill(d, Double.MAX_VALUE);
0756:                Arrays.fill(x, Double.MIN_VALUE);
0757:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0758:                Arrays.fill(x, Double.MAX_VALUE);
0759:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0760:
0761:                assertTrue("should be false", !Arrays.equals(
0762:                        new double[] { 1.0 }, new double[] { 2.0 }));
0763:
0764:                assertTrue("NaN not equals", Arrays.equals(
0765:                        new double[] { Double.NaN },
0766:                        new double[] { Double.NaN }));
0767:                assertTrue("0d equals -0d", !Arrays.equals(new double[] { 0d },
0768:                        new double[] { -0d }));
0769:            }
0770:
0771:            /**
0772:             * @tests java.util.Arrays#equals(boolean[], boolean[])
0773:             */
0774:            public void test_equals$Z$Z() {
0775:                // Test for method boolean java.util.Arrays.equals(boolean [], boolean
0776:                // [])
0777:                boolean d[] = new boolean[1000];
0778:                boolean x[] = new boolean[1000];
0779:                Arrays.fill(d, true);
0780:                Arrays.fill(x, false);
0781:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0782:                Arrays.fill(x, true);
0783:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0784:            }
0785:
0786:            /**
0787:             * @tests java.util.Arrays#equals(java.lang.Object[], java.lang.Object[])
0788:             */
0789:            public void test_equals$Ljava_lang_Object$Ljava_lang_Object() {
0790:                // Test for method boolean java.util.Arrays.equals(java.lang.Object [],
0791:                // java.lang.Object [])
0792:                Object d[] = new Object[1000];
0793:                Object x[] = new Object[1000];
0794:                Object o = new Object();
0795:                Arrays.fill(d, o);
0796:                Arrays.fill(x, new Object());
0797:                assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
0798:                Arrays.fill(x, o);
0799:                d[50] = null;
0800:                x[50] = null;
0801:                assertTrue("equal arrays returned false", Arrays.equals(d, x));
0802:            }
0803:
0804:            /**
0805:             * @tests java.util.Arrays#sort(byte[])
0806:             */
0807:            public void test_sort$B() {
0808:                // Test for method void java.util.Arrays.sort(byte [])
0809:                byte[] reversedArray = new byte[arraySize];
0810:                for (int counter = 0; counter < arraySize; counter++)
0811:                    reversedArray[counter] = (byte) (arraySize - counter - 1);
0812:                Arrays.sort(reversedArray);
0813:                for (int counter = 0; counter < arraySize; counter++)
0814:                    assertTrue("Resulting array not sorted",
0815:                            reversedArray[counter] == (byte) counter);
0816:            }
0817:
0818:            /**
0819:             * @tests java.util.Arrays#sort(byte[], int, int)
0820:             */
0821:            public void test_sort$BII() {
0822:                // Test for method void java.util.Arrays.sort(byte [], int, int)
0823:                int startIndex = arraySize / 4;
0824:                int endIndex = 3 * arraySize / 4;
0825:                byte[] reversedArray = new byte[arraySize];
0826:                byte[] originalReversedArray = new byte[arraySize];
0827:                for (int counter = 0; counter < arraySize; counter++) {
0828:                    reversedArray[counter] = (byte) (arraySize - counter - 1);
0829:                    originalReversedArray[counter] = reversedArray[counter];
0830:                }
0831:                Arrays.sort(reversedArray, startIndex, endIndex);
0832:                for (int counter = 0; counter < startIndex; counter++)
0833:                    assertTrue(
0834:                            "Array modified outside of bounds",
0835:                            reversedArray[counter] == originalReversedArray[counter]);
0836:                for (int counter = startIndex; counter < endIndex - 1; counter++)
0837:                    assertTrue(
0838:                            "Array not sorted within bounds",
0839:                            reversedArray[counter] <= reversedArray[counter + 1]);
0840:                for (int counter = endIndex; counter < arraySize; counter++)
0841:                    assertTrue(
0842:                            "Array modified outside of bounds",
0843:                            reversedArray[counter] == originalReversedArray[counter]);
0844:
0845:                //exception testing
0846:                try {
0847:                    Arrays.sort(reversedArray, startIndex + 1, startIndex);
0848:                    fail("IllegalArgumentException expected");
0849:                } catch (IllegalArgumentException ignore) {
0850:                }
0851:
0852:                try {
0853:                    Arrays.sort(reversedArray, -1, startIndex);
0854:                    fail("ArrayIndexOutOfBoundsException expected (1)");
0855:                } catch (ArrayIndexOutOfBoundsException ignore) {
0856:                }
0857:
0858:                try {
0859:                    Arrays.sort(reversedArray, startIndex,
0860:                            reversedArray.length + 1);
0861:                    fail("ArrayIndexOutOfBoundsException expected (2)");
0862:                } catch (ArrayIndexOutOfBoundsException ignore) {
0863:                }
0864:
0865:                //exception order testing
0866:                try {
0867:                    Arrays.sort(new byte[1], startIndex + 1, startIndex);
0868:                    fail("IllegalArgumentException expected");
0869:                } catch (IllegalArgumentException ignore) {
0870:                }
0871:            }
0872:
0873:            /**
0874:             * @tests java.util.Arrays#sort(char[])
0875:             */
0876:            public void test_sort$C() {
0877:                // Test for method void java.util.Arrays.sort(char [])
0878:                char[] reversedArray = new char[arraySize];
0879:                for (int counter = 0; counter < arraySize; counter++)
0880:                    reversedArray[counter] = (char) (arraySize - counter - 1);
0881:                Arrays.sort(reversedArray);
0882:                for (int counter = 0; counter < arraySize; counter++)
0883:                    assertTrue("Resulting array not sorted",
0884:                            reversedArray[counter] == (char) counter);
0885:
0886:            }
0887:
0888:            /**
0889:             * @tests java.util.Arrays#sort(char[], int, int)
0890:             */
0891:            public void test_sort$CII() {
0892:                // Test for method void java.util.Arrays.sort(char [], int, int)
0893:                int startIndex = arraySize / 4;
0894:                int endIndex = 3 * arraySize / 4;
0895:                char[] reversedArray = new char[arraySize];
0896:                char[] originalReversedArray = new char[arraySize];
0897:                for (int counter = 0; counter < arraySize; counter++) {
0898:                    reversedArray[counter] = (char) (arraySize - counter - 1);
0899:                    originalReversedArray[counter] = reversedArray[counter];
0900:                }
0901:                Arrays.sort(reversedArray, startIndex, endIndex);
0902:                for (int counter = 0; counter < startIndex; counter++)
0903:                    assertTrue(
0904:                            "Array modified outside of bounds",
0905:                            reversedArray[counter] == originalReversedArray[counter]);
0906:                for (int counter = startIndex; counter < endIndex - 1; counter++)
0907:                    assertTrue(
0908:                            "Array not sorted within bounds",
0909:                            reversedArray[counter] <= reversedArray[counter + 1]);
0910:                for (int counter = endIndex; counter < arraySize; counter++)
0911:                    assertTrue(
0912:                            "Array modified outside of bounds",
0913:                            reversedArray[counter] == originalReversedArray[counter]);
0914:
0915:                //exception testing
0916:                try {
0917:                    Arrays.sort(reversedArray, startIndex + 1, startIndex);
0918:                    fail("IllegalArgumentException expected");
0919:                } catch (IllegalArgumentException ignore) {
0920:                }
0921:
0922:                try {
0923:                    Arrays.sort(reversedArray, -1, startIndex);
0924:                    fail("ArrayIndexOutOfBoundsException expected (1)");
0925:                } catch (ArrayIndexOutOfBoundsException ignore) {
0926:                }
0927:
0928:                try {
0929:                    Arrays.sort(reversedArray, startIndex,
0930:                            reversedArray.length + 1);
0931:                    fail("ArrayIndexOutOfBoundsException expected (2)");
0932:                } catch (ArrayIndexOutOfBoundsException ignore) {
0933:                }
0934:
0935:                //exception order testing
0936:                try {
0937:                    Arrays.sort(new char[1], startIndex + 1, startIndex);
0938:                    fail("IllegalArgumentException expected");
0939:                } catch (IllegalArgumentException ignore) {
0940:                }
0941:            }
0942:
0943:            /**
0944:             * @tests java.util.Arrays#sort(double[])
0945:             */
0946:            public void test_sort$D() {
0947:                // Test for method void java.util.Arrays.sort(double [])
0948:                double[] reversedArray = new double[arraySize];
0949:                for (int counter = 0; counter < arraySize; counter++)
0950:                    reversedArray[counter] = (double) (arraySize - counter - 1);
0951:                Arrays.sort(reversedArray);
0952:                for (int counter = 0; counter < arraySize; counter++)
0953:                    assertTrue("Resulting array not sorted",
0954:                            reversedArray[counter] == (double) counter);
0955:
0956:                double[] specials1 = new double[] { Double.NaN,
0957:                        Double.MAX_VALUE, Double.MIN_VALUE, 0d, -0d,
0958:                        Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY };
0959:                double[] specials2 = new double[] { 0d,
0960:                        Double.POSITIVE_INFINITY, -0d,
0961:                        Double.NEGATIVE_INFINITY, Double.MIN_VALUE, Double.NaN,
0962:                        Double.MAX_VALUE };
0963:                double[] answer = new double[] { Double.NEGATIVE_INFINITY, -0d,
0964:                        0d, Double.MIN_VALUE, Double.MAX_VALUE,
0965:                        Double.POSITIVE_INFINITY, Double.NaN };
0966:
0967:                Arrays.sort(specials1);
0968:                Object[] print1 = new Object[specials1.length];
0969:                for (int i = 0; i < specials1.length; i++)
0970:                    print1[i] = new Double(specials1[i]);
0971:                assertTrue("specials sort incorrectly 1: "
0972:                        + Arrays.asList(print1), Arrays.equals(specials1,
0973:                        answer));
0974:
0975:                Arrays.sort(specials2);
0976:                Object[] print2 = new Object[specials2.length];
0977:                for (int i = 0; i < specials2.length; i++)
0978:                    print2[i] = new Double(specials2[i]);
0979:                assertTrue("specials sort incorrectly 2: "
0980:                        + Arrays.asList(print2), Arrays.equals(specials2,
0981:                        answer));
0982:            }
0983:
0984:            /**
0985:             * @tests java.util.Arrays#sort(double[], int, int)
0986:             */
0987:            public void test_sort$DII() {
0988:                // Test for method void java.util.Arrays.sort(double [], int, int)
0989:                int startIndex = arraySize / 4;
0990:                int endIndex = 3 * arraySize / 4;
0991:                double[] reversedArray = new double[arraySize];
0992:                double[] originalReversedArray = new double[arraySize];
0993:                for (int counter = 0; counter < arraySize; counter++) {
0994:                    reversedArray[counter] = (double) (arraySize - counter - 1);
0995:                    originalReversedArray[counter] = reversedArray[counter];
0996:                }
0997:                Arrays.sort(reversedArray, startIndex, endIndex);
0998:                for (int counter = 0; counter < startIndex; counter++)
0999:                    assertTrue(
1000:                            "Array modified outside of bounds",
1001:                            reversedArray[counter] == originalReversedArray[counter]);
1002:                for (int counter = startIndex; counter < endIndex - 1; counter++)
1003:                    assertTrue(
1004:                            "Array not sorted within bounds",
1005:                            reversedArray[counter] <= reversedArray[counter + 1]);
1006:                for (int counter = endIndex; counter < arraySize; counter++)
1007:                    assertTrue(
1008:                            "Array modified outside of bounds",
1009:                            reversedArray[counter] == originalReversedArray[counter]);
1010:
1011:                //exception testing
1012:                try {
1013:                    Arrays.sort(reversedArray, startIndex + 1, startIndex);
1014:                    fail("IllegalArgumentException expected");
1015:                } catch (IllegalArgumentException ignore) {
1016:                }
1017:
1018:                try {
1019:                    Arrays.sort(reversedArray, -1, startIndex);
1020:                    fail("ArrayIndexOutOfBoundsException expected (1)");
1021:                } catch (ArrayIndexOutOfBoundsException ignore) {
1022:                }
1023:
1024:                try {
1025:                    Arrays.sort(reversedArray, startIndex,
1026:                            reversedArray.length + 1);
1027:                    fail("ArrayIndexOutOfBoundsException expected (2)");
1028:                } catch (ArrayIndexOutOfBoundsException ignore) {
1029:                }
1030:
1031:                //exception order testing
1032:                try {
1033:                    Arrays.sort(new double[1], startIndex + 1, startIndex);
1034:                    fail("IllegalArgumentException expected");
1035:                } catch (IllegalArgumentException ignore) {
1036:                }
1037:            }
1038:
1039:            /**
1040:             * @tests java.util.Arrays#sort(float[])
1041:             */
1042:            public void test_sort$F() {
1043:                // Test for method void java.util.Arrays.sort(float [])
1044:                float[] reversedArray = new float[arraySize];
1045:                for (int counter = 0; counter < arraySize; counter++)
1046:                    reversedArray[counter] = (float) (arraySize - counter - 1);
1047:                Arrays.sort(reversedArray);
1048:                for (int counter = 0; counter < arraySize; counter++)
1049:                    assertTrue("Resulting array not sorted",
1050:                            reversedArray[counter] == (float) counter);
1051:
1052:                float[] specials1 = new float[] { Float.NaN, Float.MAX_VALUE,
1053:                        Float.MIN_VALUE, 0f, -0f, Float.POSITIVE_INFINITY,
1054:                        Float.NEGATIVE_INFINITY };
1055:                float[] specials2 = new float[] { 0f, Float.POSITIVE_INFINITY,
1056:                        -0f, Float.NEGATIVE_INFINITY, Float.MIN_VALUE,
1057:                        Float.NaN, Float.MAX_VALUE };
1058:                float[] answer = new float[] { Float.NEGATIVE_INFINITY, -0f,
1059:                        0f, Float.MIN_VALUE, Float.MAX_VALUE,
1060:                        Float.POSITIVE_INFINITY, Float.NaN };
1061:
1062:                Arrays.sort(specials1);
1063:                Object[] print1 = new Object[specials1.length];
1064:                for (int i = 0; i < specials1.length; i++)
1065:                    print1[i] = new Float(specials1[i]);
1066:                assertTrue("specials sort incorrectly 1: "
1067:                        + Arrays.asList(print1), Arrays.equals(specials1,
1068:                        answer));
1069:
1070:                Arrays.sort(specials2);
1071:                Object[] print2 = new Object[specials2.length];
1072:                for (int i = 0; i < specials2.length; i++)
1073:                    print2[i] = new Float(specials2[i]);
1074:                assertTrue("specials sort incorrectly 2: "
1075:                        + Arrays.asList(print2), Arrays.equals(specials2,
1076:                        answer));
1077:            }
1078:
1079:            /**
1080:             * @tests java.util.Arrays#sort(float[], int, int)
1081:             */
1082:            public void test_sort$FII() {
1083:                // Test for method void java.util.Arrays.sort(float [], int, int)
1084:                int startIndex = arraySize / 4;
1085:                int endIndex = 3 * arraySize / 4;
1086:                float[] reversedArray = new float[arraySize];
1087:                float[] originalReversedArray = new float[arraySize];
1088:                for (int counter = 0; counter < arraySize; counter++) {
1089:                    reversedArray[counter] = (float) (arraySize - counter - 1);
1090:                    originalReversedArray[counter] = reversedArray[counter];
1091:                }
1092:                Arrays.sort(reversedArray, startIndex, endIndex);
1093:                for (int counter = 0; counter < startIndex; counter++)
1094:                    assertTrue(
1095:                            "Array modified outside of bounds",
1096:                            reversedArray[counter] == originalReversedArray[counter]);
1097:                for (int counter = startIndex; counter < endIndex - 1; counter++)
1098:                    assertTrue(
1099:                            "Array not sorted within bounds",
1100:                            reversedArray[counter] <= reversedArray[counter + 1]);
1101:                for (int counter = endIndex; counter < arraySize; counter++)
1102:                    assertTrue(
1103:                            "Array modified outside of bounds",
1104:                            reversedArray[counter] == originalReversedArray[counter]);
1105:
1106:                //exception testing
1107:                try {
1108:                    Arrays.sort(reversedArray, startIndex + 1, startIndex);
1109:                    fail("IllegalArgumentException expected");
1110:                } catch (IllegalArgumentException ignore) {
1111:                }
1112:
1113:                try {
1114:                    Arrays.sort(reversedArray, -1, startIndex);
1115:                    fail("ArrayIndexOutOfBoundsException expected (1)");
1116:                } catch (ArrayIndexOutOfBoundsException ignore) {
1117:                }
1118:
1119:                try {
1120:                    Arrays.sort(reversedArray, startIndex,
1121:                            reversedArray.length + 1);
1122:                    fail("ArrayIndexOutOfBoundsException expected (2)");
1123:                } catch (ArrayIndexOutOfBoundsException ignore) {
1124:                }
1125:
1126:                //exception order testing
1127:                try {
1128:                    Arrays.sort(new float[1], startIndex + 1, startIndex);
1129:                    fail("IllegalArgumentException expected");
1130:                } catch (IllegalArgumentException ignore) {
1131:                }
1132:            }
1133:
1134:            /**
1135:             * @tests java.util.Arrays#sort(int[])
1136:             */
1137:            public void test_sort$I() {
1138:                // Test for method void java.util.Arrays.sort(int [])
1139:                int[] reversedArray = new int[arraySize];
1140:                for (int counter = 0; counter < arraySize; counter++)
1141:                    reversedArray[counter] = arraySize - counter - 1;
1142:                Arrays.sort(reversedArray);
1143:                for (int counter = 0; counter < arraySize; counter++)
1144:                    assertTrue("Resulting array not sorted",
1145:                            reversedArray[counter] == counter);
1146:            }
1147:
1148:            /**
1149:             * @tests java.util.Arrays#sort(int[], int, int)
1150:             */
1151:            public void test_sort$III() {
1152:                // Test for method void java.util.Arrays.sort(int [], int, int)
1153:                int startIndex = arraySize / 4;
1154:                int endIndex = 3 * arraySize / 4;
1155:                int[] reversedArray = new int[arraySize];
1156:                int[] originalReversedArray = new int[arraySize];
1157:                for (int counter = 0; counter < arraySize; counter++) {
1158:                    reversedArray[counter] = arraySize - counter - 1;
1159:                    originalReversedArray[counter] = reversedArray[counter];
1160:                }
1161:                Arrays.sort(reversedArray, startIndex, endIndex);
1162:                for (int counter = 0; counter < startIndex; counter++)
1163:                    assertTrue(
1164:                            "Array modified outside of bounds",
1165:                            reversedArray[counter] == originalReversedArray[counter]);
1166:                for (int counter = startIndex; counter < endIndex - 1; counter++)
1167:                    assertTrue(
1168:                            "Array not sorted within bounds",
1169:                            reversedArray[counter] <= reversedArray[counter + 1]);
1170:                for (int counter = endIndex; counter < arraySize; counter++)
1171:                    assertTrue(
1172:                            "Array modified outside of bounds",
1173:                            reversedArray[counter] == originalReversedArray[counter]);
1174:
1175:                //exception testing
1176:                try {
1177:                    Arrays.sort(reversedArray, startIndex + 1, startIndex);
1178:                    fail("IllegalArgumentException expected");
1179:                } catch (IllegalArgumentException ignore) {
1180:                }
1181:
1182:                try {
1183:                    Arrays.sort(reversedArray, -1, startIndex);
1184:                    fail("ArrayIndexOutOfBoundsException expected (1)");
1185:                } catch (ArrayIndexOutOfBoundsException ignore) {
1186:                }
1187:
1188:                try {
1189:                    Arrays.sort(reversedArray, startIndex,
1190:                            reversedArray.length + 1);
1191:                    fail("ArrayIndexOutOfBoundsException expected (2)");
1192:                } catch (ArrayIndexOutOfBoundsException ignore) {
1193:                }
1194:
1195:                //exception order testing
1196:                try {
1197:                    Arrays.sort(new int[1], startIndex + 1, startIndex);
1198:                    fail("IllegalArgumentException expected");
1199:                } catch (IllegalArgumentException ignore) {
1200:                }
1201:            }
1202:
1203:            /**
1204:             * @tests java.util.Arrays#sort(long[])
1205:             */
1206:            public void test_sort$J() {
1207:                // Test for method void java.util.Arrays.sort(long [])
1208:                long[] reversedArray = new long[arraySize];
1209:                for (int counter = 0; counter < arraySize; counter++)
1210:                    reversedArray[counter] = (long) (arraySize - counter - 1);
1211:                Arrays.sort(reversedArray);
1212:                for (int counter = 0; counter < arraySize; counter++)
1213:                    assertTrue("Resulting array not sorted",
1214:                            reversedArray[counter] == (long) counter);
1215:
1216:            }
1217:
1218:            /**
1219:             * @tests java.util.Arrays#sort(long[], int, int)
1220:             */
1221:            public void test_sort$JII() {
1222:                // Test for method void java.util.Arrays.sort(long [], int, int)
1223:                int startIndex = arraySize / 4;
1224:                int endIndex = 3 * arraySize / 4;
1225:                long[] reversedArray = new long[arraySize];
1226:                long[] originalReversedArray = new long[arraySize];
1227:                for (int counter = 0; counter < arraySize; counter++) {
1228:                    reversedArray[counter] = (long) (arraySize - counter - 1);
1229:                    originalReversedArray[counter] = reversedArray[counter];
1230:                }
1231:                Arrays.sort(reversedArray, startIndex, endIndex);
1232:                for (int counter = 0; counter < startIndex; counter++)
1233:                    assertTrue(
1234:                            "Array modified outside of bounds",
1235:                            reversedArray[counter] == originalReversedArray[counter]);
1236:                for (int counter = startIndex; counter < endIndex - 1; counter++)
1237:                    assertTrue(
1238:                            "Array not sorted within bounds",
1239:                            reversedArray[counter] <= reversedArray[counter + 1]);
1240:                for (int counter = endIndex; counter < arraySize; counter++)
1241:                    assertTrue(
1242:                            "Array modified outside of bounds",
1243:                            reversedArray[counter] == originalReversedArray[counter]);
1244:
1245:                //exception testing
1246:                try {
1247:                    Arrays.sort(reversedArray, startIndex + 1, startIndex);
1248:                    fail("IllegalArgumentException expected");
1249:                } catch (IllegalArgumentException ignore) {
1250:                }
1251:
1252:                try {
1253:                    Arrays.sort(reversedArray, -1, startIndex);
1254:                    fail("ArrayIndexOutOfBoundsException expected (1)");
1255:                } catch (ArrayIndexOutOfBoundsException ignore) {
1256:                }
1257:
1258:                try {
1259:                    Arrays.sort(reversedArray, startIndex,
1260:                            reversedArray.length + 1);
1261:                    fail("ArrayIndexOutOfBoundsException expected (2)");
1262:                } catch (ArrayIndexOutOfBoundsException ignore) {
1263:                }
1264:
1265:                //exception order testing
1266:                try {
1267:                    Arrays.sort(new long[1], startIndex + 1, startIndex);
1268:                    fail("IllegalArgumentException expected");
1269:                } catch (IllegalArgumentException ignore) {
1270:                }
1271:            }
1272:
1273:            /**
1274:             * @tests java.util.Arrays#sort(java.lang.Object[])
1275:             */
1276:            public void test_sort$Ljava_lang_Object() {
1277:                // Test for method void java.util.Arrays.sort(java.lang.Object [])
1278:                Object[] reversedArray = new Object[arraySize];
1279:                for (int counter = 0; counter < arraySize; counter++)
1280:                    reversedArray[counter] = objectArray[arraySize - counter
1281:                            - 1];
1282:                Arrays.sort(reversedArray);
1283:                for (int counter = 0; counter < arraySize; counter++)
1284:                    assertTrue("Resulting array not sorted",
1285:                            reversedArray[counter] == objectArray[counter]);
1286:            }
1287:
1288:            /**
1289:             * @tests java.util.Arrays#sort(java.lang.Object[], int, int)
1290:             */
1291:            public void test_sort$Ljava_lang_ObjectII() {
1292:                // Test for method void java.util.Arrays.sort(java.lang.Object [], int,
1293:                // int)
1294:                int startIndex = arraySize / 4;
1295:                int endIndex = 3 * arraySize / 4;
1296:                Object[] reversedArray = new Object[arraySize];
1297:                Object[] originalReversedArray = new Object[arraySize];
1298:                for (int counter = 0; counter < arraySize; counter++) {
1299:                    reversedArray[counter] = objectArray[arraySize - counter
1300:                            - 1];
1301:                    originalReversedArray[counter] = reversedArray[counter];
1302:                }
1303:                Arrays.sort(reversedArray, startIndex, endIndex);
1304:                for (int counter = 0; counter < startIndex; counter++)
1305:                    assertTrue(
1306:                            "Array modified outside of bounds",
1307:                            reversedArray[counter] == originalReversedArray[counter]);
1308:                for (int counter = startIndex; counter < endIndex - 1; counter++)
1309:                    assertTrue("Array not sorted within bounds",
1310:                            ((Comparable) reversedArray[counter])
1311:                                    .compareTo(reversedArray[counter + 1]) <= 0);
1312:                for (int counter = endIndex; counter < arraySize; counter++)
1313:                    assertTrue(
1314:                            "Array modified outside of bounds",
1315:                            reversedArray[counter] == originalReversedArray[counter]);
1316:
1317:                //exception testing
1318:                try {
1319:                    Arrays.sort(reversedArray, startIndex + 1, startIndex);
1320:                    fail("IllegalArgumentException expected");
1321:                } catch (IllegalArgumentException ignore) {
1322:                }
1323:
1324:                try {
1325:                    Arrays.sort(reversedArray, -1, startIndex);
1326:                    fail("ArrayIndexOutOfBoundsException expected (1)");
1327:                } catch (ArrayIndexOutOfBoundsException ignore) {
1328:                }
1329:
1330:                try {
1331:                    Arrays.sort(reversedArray, startIndex,
1332:                            reversedArray.length + 1);
1333:                    fail("ArrayIndexOutOfBoundsException expected (2)");
1334:                } catch (ArrayIndexOutOfBoundsException ignore) {
1335:                }
1336:
1337:                //exception order testing
1338:                try {
1339:                    Arrays.sort(new Object[1], startIndex + 1, startIndex);
1340:                    fail("IllegalArgumentException expected");
1341:                } catch (IllegalArgumentException ignore) {
1342:                }
1343:            }
1344:
1345:            /**
1346:             * @tests java.util.Arrays#sort(java.lang.Object[], int, int,
1347:             *        java.util.Comparator)
1348:             */
1349:            public void test_sort$Ljava_lang_ObjectIILjava_util_Comparator() {
1350:                // Test for method void java.util.Arrays.sort(java.lang.Object [], int,
1351:                // int, java.util.Comparator)
1352:                int startIndex = arraySize / 4;
1353:                int endIndex = 3 * arraySize / 4;
1354:                ReversedIntegerComparator comp = new ReversedIntegerComparator();
1355:                Object[] originalArray = new Object[arraySize];
1356:                for (int counter = 0; counter < arraySize; counter++)
1357:                    originalArray[counter] = objectArray[counter];
1358:                Arrays.sort(objectArray, startIndex, endIndex, comp);
1359:                for (int counter = 0; counter < startIndex; counter++)
1360:                    assertTrue("Array modified outside of bounds",
1361:                            objectArray[counter] == originalArray[counter]);
1362:                for (int counter = startIndex; counter < endIndex - 1; counter++)
1363:                    assertTrue("Array not sorted within bounds",
1364:                            comp.compare(objectArray[counter],
1365:                                    objectArray[counter + 1]) <= 0);
1366:                for (int counter = endIndex; counter < arraySize; counter++)
1367:                    assertTrue("Array modified outside of bounds",
1368:                            objectArray[counter] == originalArray[counter]);
1369:            }
1370:
1371:            /**
1372:             * @tests java.util.Arrays#sort(java.lang.Object[], java.util.Comparator)
1373:             */
1374:            public void test_sort$Ljava_lang_ObjectLjava_util_Comparator() {
1375:                // Test for method void java.util.Arrays.sort(java.lang.Object [],
1376:                // java.util.Comparator)
1377:                ReversedIntegerComparator comp = new ReversedIntegerComparator();
1378:                Arrays.sort(objectArray, comp);
1379:                for (int counter = 0; counter < arraySize - 1; counter++)
1380:                    assertTrue(
1381:                            "Array not sorted correctly with custom comparator",
1382:                            comp.compare(objectArray[counter],
1383:                                    objectArray[counter + 1]) <= 0);
1384:            }
1385:
1386:            /**
1387:             * @tests java.util.Arrays#sort(short[])
1388:             */
1389:            public void test_sort$S() {
1390:                // Test for method void java.util.Arrays.sort(short [])
1391:                short[] reversedArray = new short[arraySize];
1392:                for (int counter = 0; counter < arraySize; counter++)
1393:                    reversedArray[counter] = (short) (arraySize - counter - 1);
1394:                Arrays.sort(reversedArray);
1395:                for (int counter = 0; counter < arraySize; counter++)
1396:                    assertTrue("Resulting array not sorted",
1397:                            reversedArray[counter] == (short) counter);
1398:            }
1399:
1400:            /**
1401:             * @tests java.util.Arrays#sort(short[], int, int)
1402:             */
1403:            public void test_sort$SII() {
1404:                // Test for method void java.util.Arrays.sort(short [], int, int)
1405:                int startIndex = arraySize / 4;
1406:                int endIndex = 3 * arraySize / 4;
1407:                short[] reversedArray = new short[arraySize];
1408:                short[] originalReversedArray = new short[arraySize];
1409:                for (int counter = 0; counter < arraySize; counter++) {
1410:                    reversedArray[counter] = (short) (arraySize - counter - 1);
1411:                    originalReversedArray[counter] = reversedArray[counter];
1412:                }
1413:                Arrays.sort(reversedArray, startIndex, endIndex);
1414:                for (int counter = 0; counter < startIndex; counter++)
1415:                    assertTrue(
1416:                            "Array modified outside of bounds",
1417:                            reversedArray[counter] == originalReversedArray[counter]);
1418:                for (int counter = startIndex; counter < endIndex - 1; counter++)
1419:                    assertTrue(
1420:                            "Array not sorted within bounds",
1421:                            reversedArray[counter] <= reversedArray[counter + 1]);
1422:                for (int counter = endIndex; counter < arraySize; counter++)
1423:                    assertTrue(
1424:                            "Array modified outside of bounds",
1425:                            reversedArray[counter] == originalReversedArray[counter]);
1426:
1427:                //exception testing
1428:                try {
1429:                    Arrays.sort(reversedArray, startIndex + 1, startIndex);
1430:                    fail("IllegalArgumentException expected");
1431:                } catch (IllegalArgumentException ignore) {
1432:                }
1433:
1434:                try {
1435:                    Arrays.sort(reversedArray, -1, startIndex);
1436:                    fail("ArrayIndexOutOfBoundsException expected (1)");
1437:                } catch (ArrayIndexOutOfBoundsException ignore) {
1438:                }
1439:
1440:                try {
1441:                    Arrays.sort(reversedArray, startIndex,
1442:                            reversedArray.length + 1);
1443:                    fail("ArrayIndexOutOfBoundsException expected (2)");
1444:                } catch (ArrayIndexOutOfBoundsException ignore) {
1445:                }
1446:
1447:                //exception order testing
1448:                try {
1449:                    Arrays.sort(new short[1], startIndex + 1, startIndex);
1450:                    fail("IllegalArgumentException expected");
1451:                } catch (IllegalArgumentException ignore) {
1452:                }
1453:            }
1454:
1455:            /**
1456:             * @tests java.util.Arrays#sort(byte[], int, int)
1457:             */
1458:            public void test_java_util_Arrays_sort_byte_array_NPE() {
1459:                byte[] byte_array_null = null;
1460:                try {
1461:                    java.util.Arrays.sort(byte_array_null);
1462:                    fail("Should throw java.lang.NullPointerException");
1463:                } catch (NullPointerException e) {
1464:                    // Expected
1465:                }
1466:                try {
1467:                    // Regression for HARMONY-378
1468:                    java.util.Arrays.sort(byte_array_null, (int) -1, (int) 1);
1469:                    fail("Should throw java.lang.NullPointerException");
1470:                } catch (NullPointerException e) {
1471:                    // Expected
1472:                }
1473:            }
1474:
1475:            /**
1476:             * @tests java.util.Arrays#sort(char[], int, int)
1477:             */
1478:            public void test_java_util_Arrays_sort_char_array_NPE() {
1479:                char[] char_array_null = null;
1480:                try {
1481:                    java.util.Arrays.sort(char_array_null);
1482:                    fail("Should throw java.lang.NullPointerException");
1483:                } catch (NullPointerException e) {
1484:                    // Expected
1485:                }
1486:                try {
1487:                    // Regression for HARMONY-378
1488:                    java.util.Arrays.sort(char_array_null, (int) -1, (int) 1);
1489:                    fail("Should throw java.lang.NullPointerException");
1490:                } catch (NullPointerException e) {
1491:                    // Expected
1492:                }
1493:            }
1494:
1495:            /**
1496:             * @tests java.util.Arrays#sort(double[], int, int)
1497:             */
1498:            public void test_java_util_Arrays_sort_double_array_NPE() {
1499:                double[] double_array_null = null;
1500:                try {
1501:                    java.util.Arrays.sort(double_array_null);
1502:                    fail("Should throw java.lang.NullPointerException");
1503:                } catch (NullPointerException e) {
1504:                    // Expected
1505:                }
1506:                try {
1507:                    // Regression for HARMONY-378
1508:                    java.util.Arrays.sort(double_array_null, (int) -1, (int) 1);
1509:                    fail("Should throw java.lang.NullPointerException");
1510:                } catch (NullPointerException e) {
1511:                    // Expected
1512:                }
1513:            }
1514:
1515:            /**
1516:             * @tests java.util.Arrays#sort(float[], int, int)
1517:             */
1518:            public void test_java_util_Arrays_sort_float_array_NPE() {
1519:                float[] float_array_null = null;
1520:                try {
1521:                    java.util.Arrays.sort(float_array_null);
1522:                    fail("Should throw java.lang.NullPointerException");
1523:                } catch (NullPointerException e) {
1524:                    // Expected
1525:                }
1526:                try {
1527:                    // Regression for HARMONY-378
1528:                    java.util.Arrays.sort(float_array_null, (int) -1, (int) 1);
1529:                    fail("Should throw java.lang.NullPointerException");
1530:                } catch (NullPointerException e) {
1531:                    // Expected
1532:                }
1533:            }
1534:
1535:            /**
1536:             * @tests java.util.Arrays#sort(int[], int, int)
1537:             */
1538:            public void test_java_util_Arrays_sort_int_array_NPE() {
1539:                int[] int_array_null = null;
1540:                try {
1541:                    java.util.Arrays.sort(int_array_null);
1542:                    fail("Should throw java.lang.NullPointerException");
1543:                } catch (NullPointerException e) {
1544:                    // Expected
1545:                }
1546:                try {
1547:                    // Regression for HARMONY-378
1548:                    java.util.Arrays.sort(int_array_null, (int) -1, (int) 1);
1549:                    fail("Should throw java.lang.NullPointerException");
1550:                } catch (NullPointerException e) {
1551:                    // Expected
1552:                }
1553:            }
1554:
1555:            /**
1556:             * @tests java.util.Arrays#sort(Object[], int, int)
1557:             */
1558:            public void test_java_util_Arrays_sort_object_array_NPE() {
1559:                Object[] object_array_null = null;
1560:                try {
1561:                    java.util.Arrays.sort(object_array_null);
1562:                    fail("Should throw java.lang.NullPointerException");
1563:                } catch (NullPointerException e) {
1564:                    // Expected
1565:                }
1566:                try {
1567:                    // Regression for HARMONY-378
1568:                    java.util.Arrays.sort(object_array_null, (int) -1, (int) 1);
1569:                    fail("Should throw java.lang.NullPointerException");
1570:                } catch (NullPointerException e) {
1571:                    // Expected
1572:                }
1573:                try {
1574:                    // Regression for HARMONY-378
1575:                    java.util.Arrays.sort(object_array_null, (int) -1, (int) 1,
1576:                            null);
1577:                    fail("Should throw java.lang.NullPointerException");
1578:                } catch (NullPointerException e) {
1579:                    // Expected
1580:                }
1581:            }
1582:
1583:            /**
1584:             * @tests java.util.Arrays#sort(long[], int, int)
1585:             */
1586:            public void test_java_util_Arrays_sort_long_array_NPE() {
1587:                long[] long_array_null = null;
1588:                try {
1589:                    java.util.Arrays.sort(long_array_null);
1590:                    fail("Should throw java.lang.NullPointerException");
1591:                } catch (NullPointerException e) {
1592:                    // Expected
1593:                }
1594:                try {
1595:                    // Regression for HARMONY-378
1596:                    java.util.Arrays.sort(long_array_null, (int) -1, (int) 1);
1597:                    fail("Should throw java.lang.NullPointerException");
1598:                } catch (NullPointerException e) {
1599:                    // Expected
1600:                }
1601:            }
1602:
1603:            /**
1604:             * @tests java.util.Arrays#sort(short[], int, int)
1605:             */
1606:            public void test_java_util_Arrays_sort_short_array_NPE() {
1607:                short[] short_array_null = null;
1608:                try {
1609:                    java.util.Arrays.sort(short_array_null);
1610:                    fail("Should throw java.lang.NullPointerException");
1611:                } catch (NullPointerException e) {
1612:                    // Expected
1613:                }
1614:                try {
1615:                    // Regression for HARMONY-378
1616:                    java.util.Arrays.sort(short_array_null, (int) -1, (int) 1);
1617:                    fail("Should throw java.lang.NullPointerException");
1618:                } catch (NullPointerException e) {
1619:                    // Expected
1620:                }
1621:            }
1622:
1623:            /**
1624:             * @tests java.util.Arrays#deepEquals(Object[], Object[])      
1625:             */
1626:            public void test_deepEquals$Ljava_lang_ObjectLjava_lang_Object() {
1627:                int[] a1 = { 1, 2, 3 };
1628:                short[] a2 = { 0, 1 };
1629:                Object[] a3 = { new Integer(1), a2 };
1630:                int[] a4 = { 6, 5, 4 };
1631:
1632:                int[] b1 = { 1, 2, 3 };
1633:                short[] b2 = { 0, 1 };
1634:                Object[] b3 = { new Integer(1), b2 };
1635:
1636:                Object a[] = { a1, a2, a3 };
1637:                Object b[] = { b1, b2, b3 };
1638:
1639:                assertFalse(Arrays.equals(a, b));
1640:                assertTrue(Arrays.deepEquals(a, b));
1641:
1642:                a[2] = a4;
1643:
1644:                assertFalse(Arrays.deepEquals(a, b));
1645:            }
1646:
1647:            /**
1648:             * @tests java.util.Arrays#deepHashCode(Object[])
1649:             */
1650:            public void test_deepHashCode$Ljava_lang_Object() {
1651:                int[] a1 = { 1, 2, 3 };
1652:                short[] a2 = { 0, 1 };
1653:                Object[] a3 = { new Integer(1), a2 };
1654:
1655:                int[] b1 = { 1, 2, 3 };
1656:                short[] b2 = { 0, 1 };
1657:                Object[] b3 = { new Integer(1), b2 };
1658:
1659:                Object a[] = { a1, a2, a3 };
1660:                Object b[] = { b1, b2, b3 };
1661:
1662:                int deep_hash_a = Arrays.deepHashCode(a);
1663:                int deep_hash_b = Arrays.deepHashCode(b);
1664:
1665:                assertEquals(deep_hash_a, deep_hash_b);
1666:            }
1667:
1668:            /**
1669:             * @tests java.util.Arrays#hashCode(boolean[] a)
1670:             */
1671:            public void test_hashCode$LZ() {
1672:                int listHashCode;
1673:                int arrayHashCode;
1674:
1675:                boolean[] boolArr = { true, false, false, true, false };
1676:                List listOfBoolean = new LinkedList();
1677:                for (int i = 0; i < boolArr.length; i++) {
1678:                    listOfBoolean.add(new Boolean(boolArr[i]));
1679:                }
1680:                listHashCode = listOfBoolean.hashCode();
1681:                arrayHashCode = Arrays.hashCode(boolArr);
1682:                assertEquals(listHashCode, arrayHashCode);
1683:            }
1684:
1685:            /**
1686:             * @tests java.util.Arrays#hashCode(int[] a)
1687:             */
1688:            public void test_hashCode$LI() {
1689:                int listHashCode;
1690:                int arrayHashCode;
1691:
1692:                int[] intArr = { 10, 5, 134, 7, 19 };
1693:                List listOfInteger = new LinkedList();
1694:
1695:                for (int i = 0; i < intArr.length; i++) {
1696:                    listOfInteger.add(new Integer(intArr[i]));
1697:                }
1698:                listHashCode = listOfInteger.hashCode();
1699:                arrayHashCode = Arrays.hashCode(intArr);
1700:                assertEquals(listHashCode, arrayHashCode);
1701:
1702:                int[] intArr2 = { 10, 5, 134, 7, 19 };
1703:                assertEquals(Arrays.hashCode(intArr2), Arrays.hashCode(intArr));
1704:            }
1705:
1706:            /**
1707:             * @tests java.util.Arrays#hashCode(char[] a)
1708:             */
1709:            public void test_hashCode$LC() {
1710:                int listHashCode;
1711:                int arrayHashCode;
1712:
1713:                char[] charArr = { 'a', 'g', 'x', 'c', 'm' };
1714:                List listOfCharacter = new LinkedList();
1715:                for (int i = 0; i < charArr.length; i++) {
1716:                    listOfCharacter.add(new Character(charArr[i]));
1717:                }
1718:                listHashCode = listOfCharacter.hashCode();
1719:                arrayHashCode = Arrays.hashCode(charArr);
1720:                assertEquals(listHashCode, arrayHashCode);
1721:            }
1722:
1723:            /**
1724:             * @tests java.util.Arrays#hashCode(byte[] a)
1725:             */
1726:            public void test_hashCode$LB() {
1727:                int listHashCode;
1728:                int arrayHashCode;
1729:
1730:                byte[] byteArr = { 5, 9, 7, 6, 17 };
1731:                List listOfByte = new LinkedList();
1732:                for (int i = 0; i < byteArr.length; i++) {
1733:                    listOfByte.add(new Byte(byteArr[i]));
1734:                }
1735:                listHashCode = listOfByte.hashCode();
1736:                arrayHashCode = Arrays.hashCode(byteArr);
1737:                assertEquals(listHashCode, arrayHashCode);
1738:            }
1739:
1740:            /**
1741:             * @tests java.util.Arrays#hashCode(long[] a)
1742:             */
1743:            public void test_hashCode$LJ() {
1744:                int listHashCode;
1745:                int arrayHashCode;
1746:
1747:                long[] longArr = { 67890234512l, 97587236923425l,
1748:                        257421912912l, 6754268100l, 5 };
1749:                List listOfLong = new LinkedList();
1750:                for (int i = 0; i < longArr.length; i++) {
1751:                    listOfLong.add(new Long(longArr[i]));
1752:                }
1753:                listHashCode = listOfLong.hashCode();
1754:                arrayHashCode = Arrays.hashCode(longArr);
1755:                assertEquals(listHashCode, arrayHashCode);
1756:            }
1757:
1758:            /**
1759:             * @tests java.util.Arrays#hashCode(float[] a)
1760:             */
1761:            public void test_hashCode$LF() {
1762:                int listHashCode;
1763:                int arrayHashCode;
1764:
1765:                float[] floatArr = { 0.13497f, 0.268934f, 12e-5f, -3e+2f,
1766:                        10e-4f };
1767:                List listOfFloat = new LinkedList();
1768:                for (int i = 0; i < floatArr.length; i++) {
1769:                    listOfFloat.add(new Float(floatArr[i]));
1770:                }
1771:                listHashCode = listOfFloat.hashCode();
1772:                arrayHashCode = Arrays.hashCode(floatArr);
1773:                assertEquals(listHashCode, arrayHashCode);
1774:
1775:                float[] floatArr2 = { 0.13497f, 0.268934f, 12e-5f, -3e+2f,
1776:                        10e-4f };
1777:                assertEquals(Arrays.hashCode(floatArr2), Arrays
1778:                        .hashCode(floatArr));
1779:            }
1780:
1781:            /**
1782:             * @tests java.util.Arrays#hashCode(double[] a)
1783:             */
1784:            public void test_hashCode$LD() {
1785:                int listHashCode;
1786:                int arrayHashCode;
1787:
1788:                double[] doubleArr = { 0.134945657, 0.0038754, 11e-150,
1789:                        -30e-300, 10e-4 };
1790:                List listOfDouble = new LinkedList();
1791:                for (int i = 0; i < doubleArr.length; i++) {
1792:                    listOfDouble.add(new Double(doubleArr[i]));
1793:                }
1794:                listHashCode = listOfDouble.hashCode();
1795:                arrayHashCode = Arrays.hashCode(doubleArr);
1796:                assertEquals(listHashCode, arrayHashCode);
1797:            }
1798:
1799:            /**
1800:             * @tests java.util.Arrays#hashCode(short[] a)
1801:             */
1802:            public void test_hashCode$LS() {
1803:                int listHashCode;
1804:                int arrayHashCode;
1805:
1806:                short[] shortArr = { 35, 13, 45, 2, 91 };
1807:                List listOfShort = new LinkedList();
1808:                for (int i = 0; i < shortArr.length; i++) {
1809:                    listOfShort.add(new Short(shortArr[i]));
1810:                }
1811:                listHashCode = listOfShort.hashCode();
1812:                arrayHashCode = Arrays.hashCode(shortArr);
1813:                assertEquals(listHashCode, arrayHashCode);
1814:            }
1815:
1816:            /**
1817:             * @tests java.util.Arrays#hashCode(Object[] a)
1818:             */
1819:            public void test_hashCode$Ljava_lang_Object() {
1820:                int listHashCode;
1821:                int arrayHashCode;
1822:
1823:                Object[] objectArr = { new Integer(1), new Float(10e-12f), null };
1824:                List listOfObject = new LinkedList();
1825:                for (int i = 0; i < objectArr.length; i++) {
1826:                    listOfObject.add(objectArr[i]);
1827:                }
1828:                listHashCode = listOfObject.hashCode();
1829:                arrayHashCode = Arrays.hashCode(objectArr);
1830:                assertEquals(listHashCode, arrayHashCode);
1831:            }
1832:
1833:            /**
1834:             * Sets up the fixture, for example, open a network connection. This method
1835:             * is called before a test is executed.
1836:             */
1837:            protected void setUp() {
1838:                booleanArray = new boolean[arraySize];
1839:                byteArray = new byte[arraySize];
1840:                charArray = new char[arraySize];
1841:                doubleArray = new double[arraySize];
1842:                floatArray = new float[arraySize];
1843:                intArray = new int[arraySize];
1844:                longArray = new long[arraySize];
1845:                objectArray = new Object[arraySize];
1846:                shortArray = new short[arraySize];
1847:
1848:                for (int counter = 0; counter < arraySize; counter++) {
1849:                    byteArray[counter] = (byte) counter;
1850:                    charArray[counter] = (char) (counter + 1);
1851:                    doubleArray[counter] = counter;
1852:                    floatArray[counter] = counter;
1853:                    intArray[counter] = counter;
1854:                    longArray[counter] = counter;
1855:                    objectArray[counter] = objArray[counter];
1856:                    shortArray[counter] = (short) counter;
1857:                }
1858:                for (int counter = 0; counter < arraySize; counter += 2) {
1859:                    booleanArray[counter] = false;
1860:                    booleanArray[counter + 1] = true;
1861:                }
1862:            }
1863:
1864:            /**
1865:             * @tests java.util.Arrays#swap(int, int, Object[])
1866:             */
1867:            public void test_swap_I_I_$Ljava_lang_Object() throws Exception {
1868:                Method m = Arrays.class.getDeclaredMethod("swap", int.class,
1869:                        int.class, Object[].class);
1870:                m.setAccessible(true);
1871:                Integer[] arr = { new Integer(0), new Integer(1),
1872:                        new Integer(2) };
1873:                m.invoke(null, 0, 1, arr);
1874:                assertEquals("should be equal to 1", 1, arr[0].intValue());
1875:                assertEquals("should be equal to 0", 0, arr[1].intValue());
1876:            }
1877:
1878:            /**
1879:             * Tears down the fixture, for example, close a network connection. This
1880:             * method is called after a test is executed.
1881:             */
1882:            protected void tearDown() {
1883:            }
1884:        }
ww___w__.__jav__a2s._c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.