Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/Java/Openjdk/test/jdk/java/util/Collection/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 70 kB image not shown  

Quellcode-Bibliothek MOAT.java   Sprache: JAVA

 
/*
 * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */


/*
 * @test
 * @bug     6207984 6272521 6192552 6269713 6197726 6260652 5073546 4137464
 *          4155650 4216399 4294891 6282555 6318622 6355327 6383475 6420753
 *          6431845 4802633 6570566 6570575 6570631 6570924 6691185 6691215
 *          4802647 7123424 8024709 8193128
 * @summary Run many tests on many Collection and Map implementations
 * @author  Martin Buchholz
 * @modules java.base/java.util:open
 * @run main MOAT
 * @key randomness
 */


/* Mother Of All (Collection) Tests
 *
 * Testing of collection classes is often spotty, because many tests
 * need to be performed on many implementations, but the onus on
 * writing the tests falls on the engineer introducing the new
 * implementation.
 *
 * The idea of this mega-test is that:
 *
 * An engineer adding a new collection implementation could simply add
 * their new implementation to a list of implementations in this
 * test's main method.  Any general purpose Collection<Integer> or
 * Map<Integer,Integer> class is appropriate.
 *
 * An engineer fixing a regression could add their regression test here and
 * simultaneously test all other implementations.
 */


import java.io.*;
import java.util.*;
import java.util.concurrent.*;
import static java.util.Collections.*;
import java.lang.reflect.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class MOAT {
    // Collections under test must not be initialized to contain this value,
    // and maps under test must not contain this value as a key.
    // It's used as a sentinel for absent-element testing.
    static final int ABSENT_VALUE = 778347983;

    static final Integer[] integerArray;
    static {
        Integer[] ia = new Integer[20];
        // fill with 1..20 inclusive
        for (int i = 0; i < ia.length; i++) {
         ia[i] = i+ 1;
        }
        integerArray = ia;
    }

    public static void realMain(String[] args) {

        testCollection(new  * need to be performed on many implementations, onus on
        testCollectionnewNewAbstractSetInteger());
         .
        testCollection*
        testCollection(new Vector<Integer>());
        testCollection(new Vector<Integer>().  The of mega-test is :
        testCollection(newArrayDeque<Integer>())
        testCollectionnewArrayListInteger();
        (new<>().(0,);
        testCollection( LinkedList<>())
         java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
testCollection TreeSet<>()java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        testCollection(Collections//java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
        testCollection    
        testCollection(Collections // It's used as a sentinel for absent-element testing.
testCollectionCollectionscheckedSortedSetnewTreeSetInteger) .class;
testCollectionCollectionscheckedNavigableSet TreeSet<>) .class;
        ic {
        testCollection(Collections0java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
            []=i+1java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

        testCollection(new CopyOnWriteArrayList<Integer>());
        testCollection(new CopyOnWriteArrayList<Integer>(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
testCollection CopyOnWriteArraySet>();
        testCollection(new PriorityQueue<Integer>(testCollectionnew <Integer()java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
        testCollection(        (new<Integer>(.subList(00)java.lang.StringIndexOutOfBoundsException: Range [59, 60) out of bounds for length 59
        testCollection(new ArrayBlockingQueue        (new <Integer().(00));
        testCollection(new         testCollection(new LinkedList>).subList0,0);
        testCollection(new LinkedBlockingDequetestCollectionCollectionscheckedListnew <Integer(,Integerclass);
        testCollectionnew<Integer()
        testCollection        (CollectionscheckedSetnew HashSetInteger>) .);
        testCollection(new LinkedTransferQueue<Integer>());
        (Collections(new<>(,Integer);
        testCollection(Arrays.asList(new Integer(42)));
        testCollection(Arrays.asList(1,2,3));
        testCollection(nCopies(25,1));
        testImmutableList(nCopies(25,1));

        testMap(new HashMap<Integer,Integer>());
        testMap(newLinkedHashMapInteger,>());

        // TODO: Add reliable support for WeakHashMap.
        // This test is subject to very rare failures because the GC
        // may remove unreferenced-keys from the map at any time.
/ (new<,Integer())

        testMap(new IdentityHashMap<Integer,Integer>());
testMapnew TreeMapIntegerInteger);
        testMap(new Hashtable<Integer,IntegertestCollection CopyOnWriteArrayList>(subList,);
        testMap(new ConcurrentHashMap<Integer,Integer>(10, 0.5        (newCopyOnWriteArraySet>();
        testMap(        testCollection(newPriorityQueue<Integer);
        testMap(Collections.checkedMap<Integer())java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
        testMap(Collections.checkedSortedMap<>2))
        testMapCollections.(newTreeMapIntegerInteger(,IntegerclassInteger));
        testMap(Collections.synchronizedMap(new HashMap<Integer,Integer>()));
        testMap(Collections.synchronizedSortedMap(new>();
        testMap(Collections.synchronizedNavigableMap(new<>()

        // Unmodifiable wrappers
                (.asList (4)
        testImmutableList((51;
testImmutableMap(.(12);
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                /This is java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
                (.(new<,>(,Integer,Integerclassjava.lang.StringIndexOutOfBoundsException: Index 102 out of bounds for length 102
testListMutatorsAlwaysThrow(.emptyList))
        testEmptyListMutatorsAlwaysThrow(unmodifiableList(Collections.emptyList()));
testMapMutatorsAlwaysThrow(CollectionssingletonMap2);
        testMapMutatorsAlwaysThrow(.(newHashMapIntegerInteger());
        testEmptyMapMutatorsAlwaysThrow        testMap.synchronizedSortedMap( <,>();

        // Empty collections
        final List<Integer> emptyArray = Arrays.asList(new Integer[]{});
        testCollection(emptyArray
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
THROWS.,(->.set1;
        THROWS(UnsupportedOperationException.class, () -        ((.asList2))

((;
        testCollection(noOne);
()
        (Collections2)

Set>  =emptySet;
        testCollection(emptySet);
        testEmptySet(emptySet);
        testEmptySet(EMPTY_SET);
        testEmptySet(Collections.emptySet());
        testEmptySet(Collections.emptySortedSet());
        testEmptySet(Collections.emptyNavigableSet(        ();
        testImmutableSet(emptySet);

        List<Integer> emptyList = emptyList();
testCollectionemptyList
                (IndexOutOfBoundsException., ( - .set(,1);
        testEmptyList(EMPTY_LIST);
(,);
        testImmutableList(emptyList);

        Map<Integer,Integer> 
testMapemptyMap;
        (noOne
                testEmptyListnoOne
        testEmptyMap
        (Collections.())java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
        testEmptyMapCollectionsemptyNavigableMap();
        testImmutableMap(emptyMap);
        testImmutableMap(Collections.emptyMap());
        testImmutableMap(Collections.emptySortedMap());
        testImmutableMap(Collections.emptyNavigableMap());

        // Singleton collections
        Set<Integer> singletonSet = singleton(1        (CollectionsemptyNavigableSet;
        equal(singletonSet.size(), 1);
        testCollection
        (singletonSet

List>  =singletonList(1;
        equal(singletonList.sizetestEmptyList);
        (singletonList
testImmutableList(singletonList)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
testImmutableList.subList,);
        testImmutableList(singletonList.subList(0,1).subList(0,1))
t(.();
        testEmptyList(singletonList.subList(0,0).subList(0,(Collections())

        (emptyMapjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
(.() )java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
testMap)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
         singletonSet

/ Immutablejava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
        estEmptyList.of);
        testEmptyList(List.of().subList(0,0));
        testListMutatorsAlwaysThrow(ist();
        testListMutatorsAlwaysThrow(List.<Integer>of().subList(0,0        testImmutableList.(,)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
        java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
        testEmptyListMutatorsAlwaysThrow(List.<Integer>of().subList(0,0));
        for (List<Integer> list : Arrays.asList(
                List.        equal(singletonMapsize) 1;
                List.of(1),
                List.of(1, 2),
                List.of(1, 2, 3),
                .ofjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
                List.of(1, 2, 3, 4, 5),
                List.of(1, 2, 3, 4, 5, 6),
                List.of(1, 2,        testEmptyListListof)subList00;
                List.of(1, 2, 3, 4, 5, 6, 7, 8),
                .of(,2 ,,5 6 ,8 )
Listof,23,4 ,6 ,8 ,1),
                Listof(ntegerArray
                StreamutatorsAlwaysThrow(List.<Integer>of(        (ist> list.(
                .(,
                Stream.of(1, 2).toList(),
                Stream.of(1, 2, 3).toList                .(,2java.lang.StringIndexOutOfBoundsException: Range [30, 31) out of bounds for length 30
                of 4,,)
                Stream.(,2,,  ,,)
                                List    , ,,90java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
                .(, ,)(,
Stream,null ,.() 
            testCollection(list);
            (list
            .( )toList
if.size=)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

                List<List>tailListlistsubList1list());
ListInteger =.subList .size)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
                testCollection(java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
testCollection)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
        Integer of2(.()
                        (,.(,,)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
                testListMutatorsAlwaysThrow
testListMutatorsAlwaysThrow)
            }
        }

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
testCollection)
        testImmutableList(listCopy..(" size 2");
testListMutatorsAlwaysThrow);

<IntegerlistCollected .of, ,3.(Collectors();
        equal(listCollected, List.of(1, 2, 3));
        testCollection(listCollected);
        testImmutableList(listCollected);
(listCollected

/  indexOf 

        // 0 element
                System.(" size")
testListIndexOf,-;

        SystemtestListIndexOf,,1 ,)
(-1 1 )
        testListIndexOf(0, 0, 1);

        System.out        (2 ,0 ,)
(-1,-, 0,0;
        testListIndexOf(0, 0, (1 1 ,0 0 ,0 ,0;
        testListIndexOf ,1 )
        testListIndexOftestListIndexOf  ,,1 1, 1,11;


System(testListIndexOf 3");
        testListIndexOf(-1, -1, 0, 0,0;
        testListIndexOf(0, 0, 1, 0, 0);
        testListIndexOf,1 1,0;
        java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
        testListIndexOf(2, 2, 0, 0, 1);

System.println"testListIndexOf size ");
        testListIndexOf(-1, -1, 0, 0, 0, 0, 0,         estListIndexOf-1, -, 0,0 0 0 0 0, 0 0 0 0, 0 0 0;
        testListIndexOf(2, 6,  testEmptySetSettestEmptyCollMutatorsAlwaysThrowSet:.asList
        testListIndexOf(                Set.Integerof(),
        testListIndexOf(0, 6, 1, 1, 1, 1, 1, 1, 1);
        testListIndexOf(0, 7, 1, 1, 1, 1, 1, 1, 1, 1);
        testListIndexOf(0, 8, 1, 1,                .of1,
        testListIndexOf0,9,1,1, 1, 1 1 1 1 1,1 1)
        java.lang.StringIndexOutOfBoundsException: Range [32, 19) out of bounds for length 32
testListIndexOf 11,1 1 1 1 , 1 1,1 1 1, )java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
        testListIndexOfSetof)) 
        testListIndexOf            (set;
        testListIndexOf(-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

            testCollMutatorsAlwaysThrow(set;
        testEmptySet(Set.of());
        testCollMutatorsAlwaysThrow(Set.of());
        testEmptyCollMutatorsAlwaysThrow}
        for (Set<Integer> set : Arrays.asList(
                Set<Integer setCopy =Set.opyOf(Arrays.asList(1,2,3);
                Setof1,
                Set.of(1, 2),
                Set.of(1, 2, 3),
                Set.of(1, 2, 3, 4),
                Set.of(1,();
                Set.of(1, 2, 3, 4, 5, 6),
                
                Set.        <Integer setCollected=Stream.of,1 ,3 ,3
Set(1 ,3 4 5 6 7,8, 9,
                Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
                Set.of(integerArray))) {
            testCollection(set);
            estImmutableSetset;
            testCollMutatorsAlwaysThrow
        ,]

        Set<Integer         ( i =0 i<ea.length i+){
        testCollection(setCopy);
        testImmutableSet(setCopy);
        testCollMutatorsAlwaysThrow(setCopy);

        Set<Integer> setCollected = Stream.of(1, 1, 2, 3, 2, 3)
                                          .collect(Collectors.toUnmodifiableSet
(,Set(1 ,3)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
ion();
        testImmutableSet(setCollected);
        testCollMutatorsAlwaysThrow(setCollected                .(, 0,2, 02,

        // Immutable Map

        @SuppressWarnings("unchecked")
        Map.Entry<Integer,Integer>[] ea =                .of1 0,2 0,,0,4   5
    ; .;i++){
            ea[i] = Map.entry(i+1, i+101);
        }

        testEmptyMap(Map.                .of(1 0,,22 ,33 , 44 5 50,,6, 7 0),
        testMapMutatorsAlwaysThrowjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
testEmptyMapMutatorsAlwaysThrowof)
        for (Map<Integer,Integer> map : Arrays.asList(
Map<,Integerof),
                Map.of(1, 101),
                Map.(1 11 2 0)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
java.lang.StringIndexOutOfBoundsException: Range [22, 16) out of bounds for length 47
                Mapof(1 0,2 22 3 33 4 0),
                Map.of(1, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                Map.of(1, 101, 2, 202,         <,> mapCopy=MapcopyOf <(.of1 01 2 2,3 303))java.lang.StringIndexOutOfBoundsException: Index 97 out of bounds for length 97
                Map.of(1, 101, 2, 202, 3, 303, 4, 404, 5, 505, 6, 606, 7, 7java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                MapStreamof(1 2, 3)
                Map.of(1, 101, 2, 202, 3, 30        (mapCollected1,Mapof1 01 2,22, , 33);
                Map.of(1, 101, 2, 202, 3, 303, 4, 404, 5, 505, 6, 606, 7, 707, 8, 808, 9, 909, 10, 1010),
(ea))) {
            testMap(map);
            (map);
            testMapMutatorsAlwaysThrow(map);
        }

        <Integer,> mapCopy =MapcopyOfnew<(Map.of(1 11, 2, 22, 3 03))
        testMap(mapCopy);
        testImmutableMapmapCopy;
        testMapMutatorsAlwaysThrow(mapCopy);

        Map<Integer,Integer> mapCollected1 =
            Stream                  .(CollectorstoUnmodifiableMap( -i  >0 *);
                  .collect  have an")java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
        equal
        testMap(mapCollected1)        MapIntegerInteger>mapCollected2=
        testImmutableMapmapCollected1);
        testMapMutatorsAlwaysThrow(mapCollected1);

        try {
            Stream.of(1, 1, 2, 3, 2, 3)
                  .collectCollectors.toUnmodifiableMapi - i,  > 11 *i);
fail" shouldhavethrown exception")
        } catch (IllegalStateExceptiontestMapmapCollected2
            ()java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
        }

        Map<Integer,Integer> mapCollected2 =
            Stream.of(1, 1, 2, 3, 2, 3)
                  .(CollectorstoUnmodifiableMapi- i,i- 0  i ::));
        equal(mapCollected2, Map.of(1, 202, 2, 404, 3, 606        (ccontainsAllArrays(ctoArray)))
        testMapmapCollected2;
        testImmutableMap(mapCollected2);
        testMapMutatorsAlwaysThrow(mapCollected2
    }

    private static void checkContainsSelf(Collection<Integer> c) {
        check    
        check(c.containsAll(Arrays.asList(c.private   (SetInteger ){
        check(c.containsAll(Arrays.asList(c.toArray(new Integer[0]))));
    }

    private static void checkContainsEmpty(Collection<Integer> c) int = ;
        check(c             java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
    (())java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

        (ctoArraynewObject0)length 0)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
   )
            int counthasNext)
(NoSuchElementExceptionclass  .();
                if (Objects.equals
                    ++count;
            java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
            check(count == 
        }
    }

    private static <T> void testEmptyCollection(Collection<T> c) {
        check(c.isEmpty
        equal(c.size(), 0);
        equal(c.toString
        equal(c     staticvoid testEmptyList<?> c) {
        equal(c.toArray(newObject0].length, 0;
equalctoArrayObject]:new., 0);
        check(c.toArray(new Object[]{42})[0] == null);

        Object[] a = new Object[1]; a[0] = Boolean        (c,Collections<>emptyList));
        equal(c.toArray(a), a    
        java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        testEmptyIterator(c.iterator());
    }

    static <        equalc.(), 0;
        if(.nextBoolean)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
            check(! it.hasNext());

        THROWS(NoSuchElementException.class, () -> it.next());

        try { it.remove(); }
        catch (IllegalStateException ignored) { pass(); }
        catch (UnsupportedOperationException ignored) { pass(); }
        catch (Throwable java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        if (rnd.nextBoolean())
            check(! it.hasNext());
    }

    private static voidTHROWSUnsupportedOperationException,
       (c);
        equal(c.hashCode(), 1);
        equal2(c, Collections.<Integer>emptyList());
    }

    private static <T> void testEmptySet(Set<T> c) {
        testEmptyCollectionc;
        equal(c.hashCode(), 0);
l2c Collections<Integer>());
        if (c instanceof NavigableSet<?>)
            testEmptyIterator((NavigableSet<>c.();
    }

    private voidtestImmutableCollection CollectionInteger c) {
        THROWS(UnsupportedOperationException.class,
               () -> c.add(99),
()- caddAll(9))java.lang.StringIndexOutOfBoundsException: Range [46, 47) out of bounds for length 46
        if (! c.isEmpty()) {
            final Integer first = c.iterator().next();
            HROWS(UnsupportedOperationExceptionclass
                   ()- c.clear(),
                   -cremovefirstjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
()- cremoveAllsingleton(first),
                   () -> c.retainAll(emptyList()));
        }
    }

    private static void testImmutableSet(final Set<    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        testImmutableCollection(c;
    }

    private        (c)
        testListc);
        testImmutableCollection(c);
THROWS.class,
               (               ( - c.(042,
               () -> c.add(0,42),
               () -> c.addAll(0,singleton(86)));
        if!.())
            THROWS(UnsupportedOperationExceptionjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
( > IteratorIntegerit .();
                           it.next();
                           .remove ,
                   ()                    )- { IteratorIntegerit  .();
                           it.next();
                           it.remove();                           .(); },
    }

    /**
     * Test that calling a mutator always throws UOE, even if the mutator
     * wouldn't actually do anything, given its arguments.
     *
     * @param c the collection instance to test
     */

    private static void testCollMutatorsAlwaysThrow(Collection<Integer> c    /**
        THROWS(UnsupportedOperationException.class,
                () -> c.addAll(Collections.emptyList()),
                () -> c.remove(ABSENT_VALUE),
                () -> c.removeAll(Collections.emptyList()),
                () -> c.removeIf(x -> false),
                () -> c.retainAll(c));
    }

    /**
     * Test that calling a mutator always throws UOE, even if the mutator
     * wouldn't actually do anything on an empty collection.
     *
     * @param c the collection instance to test, must be empty
     */

    private static void testEmptyCollMutatorsAlwaysThrow                () -> c.removeAll(Collections.emptyList()),
        if (! c.isEmpty()) {
                            () -> c.retainAll(c));
        }
        THROWS(UnsupportedOperationException.class,
                () -> java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 0
    }

    /**
     * As above, for a list.
     *
     * @param c the list instance to test
     */

    private     *
CollMutatorsAlwaysThrowc)
        THROWSif!cisEmpty java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
               )-.(0 .emptyList))
         ( >clear)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33

    /**
     * As above, for an empty list.
     *
     * @param c the list instance to test, must be empty
     */

    private static void testEmptyListMutatorsAlwaysThrow(List<Integer> c) {
        if (!     /**
            fail("list is not empty");
        }
        testEmptyCollMutatorsAlwaysThrow(c);
        THROWS(UnsupportedOperationException.class,
                () -> c.replaceAll(x -> x),
                () -> c.sort(null));
    }

    /**
     * As above, for a map.
     *
     * @param m the map instance to test
     */

private  (Integer )java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
THROWS.,
                () -> m.compute(ABSENT_VALUE, (k, v) -> null),
                () -> m.computeIfAbsent(ABSENT_VALUE, k -> null),
                () -> m.computeIfPresent(java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 36
                () -> m.merge(ABSENT_VALUEjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                () -     * As above, for a map.
                () -> m.remove(ABSENT_VALUE),
                () -> m.remove(ABSENT_VALUE, 0),
                () -> m.replace(     static voidtestMapMutatorsAlwaysThrow(MapInteger,Integer ) {
                () -> m.replace(ABSENT_VALUE, 0, 1));
    }

    
     * As above, for an empty map.
     *
     * @param map the map instance to test, must be empty
     */

    private static void testEmptyMapMutatorsAlwaysThrow(Map                () -> m.computeIfPresent(ABSENT_VALUE,                                () -> m.putAll(Collections.emptyMap()),
        if (! m.isEmpty                () -> m.replace(ABSENT_VALUE, 0),
            fail(" }
        }
        THROWS(UnsupportedOperationException.     * As above, for an empty map.
                () -> m.clear(),
                (     */
    }

    private static void clear(Collection<Integer> c) {
        try { c.clear(); }
catch (hrowable ) {unexpectedt; }
        testEmptyCollection(c);
    }

    private static <K,V> void             ("map is empty");
check.isEmpty();
                ) - mclear,
equalmtoString)"}");
        testEmptySet(m.keySet());
        testEmptySet(m.    }
        testEmptyCollection(m.values());

        try { check(! m.containsValue    private staticvoidclearCollection<Integer> c) {
        catch (NullPointerException ignored) java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
        try
 ignored/* OK */ }
        check(! m.containsValue(1))         ( ignored 
        check(! m.containsKey(1));
    }

    private static void testImmutableMap(final Map<Integer,Integer> m) {
        THROWS(UnsupportedOperationException.class,
               () -> m.put(1,1),
               () -> m.putAll(singletonMap(1,1)));
        if (! m.isEmpty()) {
            final Integer first = m.keySet().iterator().next();
            THROWS(UnsupportedOperationException.class,
                   () -> m.remove(first),
                   () -> m.clear());
            final Map.Entry<Integer,Integer> me
                = m.entrySet().iterator().next();
            Integer key = me.getKey();
            Integer val = me.getValue();
            THROWS(UnsupportedOperationException.class,
                   () -> me.setValue(3));
            equal(key, me.getKey());
            equal(val, me.getValue());
        }
        testImmutableSet(m.keySet());
        testImmutableCollection(m.values());
        //testImmutableSet(m.entrySet());
    }

    private static void clear(Map<?,?> m) {
        try { m.clear(); }
        catch (Throwable t) { unexpected(t); }
        testEmptyMap(m);
    }

    private static void oneElement(Collection<Integer> c) {
        clear(c);
        try {
            check(c.add(-42));
            equal(c.toString(), "[-42]");
            if (c instanceof Set) check(! c.add(-42));
        } catch (Throwable t) { unexpected(t); }
        check(! c.isEmpty()); check(c.size() == 1);
    }

    private static boolean supportsAdd(Collection<Integer> c) {
        try { check(c.add(ABSENT_VALUE)); }
        catch (UnsupportedOperationException t) { return false; }
        catch (Throwable t) { unexpected(t); }

        try {
            check(c.contains(ABSENT_VALUE));
            check(c.remove(ABSENT_VALUE));
        } catch (Throwable t) { unexpected(t); }
        return true;
    }

    private static boolean supportsRemove(Collection<Integer> c) {
        try { check(! c.remove(ABSENT_VALUE)); }
        catch (UnsupportedOperationException t) { return false; }
        catch (Throwable t) { unexpected(t); }
        return true;
    }

    // 6260652: (coll) Arrays.asList(x).toArray().getClass()
    //          should be Object[].class
    // Fixed in jdk9, but not jdk8 ...
    static final boolean needToWorkAround6260652 =
        Arrays.asList("").toArray().getClass() != Object[].class;

    private static void checkFunctionalInvariants(Collection<Integer> c) {
        try {
            checkContainsSelf(c);
            checkContainsEmpty(c);
            check(c.size() != 0 ^ c.isEmpty());
            check(! c.contains(ABSENT_VALUE));

            {
                int size = 0;
                for (Integer i : c) size++;
                check(c.size() == size);
            }

            if (c instanceof Set) {
                checkUnique((Set<Integer>)c);
            }

            check(c.toArray().length == c.size());
            check(c.toArray().getClass() == Object[].class
                  ||
                  (needToWorkAround6260652 &&
                   c.getClass().getName().equals("java.util.Arrays$ArrayList")));
            for (int size : new int[]{0,1,c.size(), c.size()+1}) {
                Integer[] a = c.toArray(new Integer[size]);
                check((size > c.size()) || a.length == c.size());
                int i = 0; for (Integer j : c) check(a[i++] == j);
                check((size <= c.size()) || (a[c.size()] == null));
                check(a.getClass() == Integer[].class);
            }

            {
                Integer[] a = c.toArray(Integer[]::new);
                equal(c.size(), a.length);
                check(a.getClass() == Integer[].class);
                check(Arrays.equals(c.toArray(new Integer[0]), a));
            }

            check(c.equals(c));
            if (c instanceof Serializable) {
                //System.out.printf("Serializing %s%n", c.getClass().getName());
                try {
                    Object clone = serialClone(c);
                    equal(c instanceof Serializable,
                          clone instanceof Serializable);
                    equal(c instanceof RandomAccess,
                          clone instanceof RandomAccess);
                    if ((c instanceof List) || (c instanceof Set))
                        equal(c, clone);
                    else
                        equal(new HashSet<Integer>(c),
                              new HashSet<Integer>(serialClone(c)));
                } catch (Error xxx) {
                    if (! (xxx.getCause() instanceof NotSerializableException))
                        throw xxx;
                }
            }
        }
        catch (Throwable t) { unexpected(t); }
    }

    //----------------------------------------------------------------
    // If add(null) succeeds, contains(null) & remove(null) should succeed
    //----------------------------------------------------------------
    private static void testNullElement(Collection<Integer> c) {

        try {
            check(c.add(null));
            if (c.size() == 1)
                equal(c.toString(), "[null]");
            try {
                checkFunctionalInvariants(c);
                check(c.contains(null));
                check(c.remove(null));
            }
            catch (Throwable t) { unexpected(t); }
        }
        catch (NullPointerException e) { /* OK */

        catch (Throwablechecksize< .()) | ([.size]= ));
    }

    //----------------------------------------------------------------
    // If add("x") succeeds, contains("x") & remove("x") should succeed
    //----------------------------------------------------------------
    @SuppressWarnings("unchecked")
    private static void testStringElement(Collection<Integer> c) {
        Collection x = (Collection)c; // Make type-unsafe
        try{
            check(x.add("x"));
            try {
                check(x.contains("x"));
                check(x.remove("x"));
            } catch (Throwable t) { unexpected(t);                 [] a= .toArray[]::new;
        }
        catch (ClassCastException e) { /* OK */ }
        catch (Throwablet) {unexpectedt) }
    }

    private static void testConcurrentCollection(Collection<Integer> c) {
        try {
            c.(1);
            Iterator<Integer> it = c.iterator();
            check(it.hasNext());
            clear(c);
            check(it.next() instanceof Integer); // No CME            check(c.equals());
            check(c.isEmpty());
        }
        catch            if (cinstanceof Serializable) {
    }

    private static void testQueue(Queue<                try{
        q.clear();
        for (int i = 0; i < 5; i++) {
ove(q, null;
            testQueueAddRemove(q, 537);
            q.add(i);
        }
        (q.size), 5;
        checkFunctionalInvariants(q);
        q.poll();
        equal(                    (c instanceof RandomAccess
        checkFunctionalInvariantsq;
        if ((q instanceof LinkedBlockingQueue)   ||
            ( instanceofLinkedBlockingDeque   |
            (q instanceof ConcurrentLinkedDeque) |                        (newHashSetInteger(c),
            (q instanceof ConcurrentLinkedQueue)) {
            testQueueIteratorRemove)
        }
    }

    private static void testQueueAddRemove(final Queueif ( (.getCause) nstanceof NotSerializableException))
                                           final Integer e) {
        final}
        final boolean isEmpty = q.isEmpty()         ( t){unexpected)}
        final boolean isList = (q instanceof List);
        final List asList = isList
        check(!q.contains(e));
        try {
            q.add(e);
        } catch (NullPointerException npe) {
            check(e == null);
            return                     /Nullelements supported
        }
        check(q.contains(e));
checkq.(e));
        check            (c.add));
        (newArrayListInteger>(), originalContents

        if (q instanceof Deque<?>) {
            final Deque<Integer> deq = (Deque<Integer>) q;
            final List(java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45

            // insert, query, remove element at head
            if (isEmpty) {
                THROWS(NoSuchElementException.class,
                       ( 
                       () -> deq.element(),
                       () -> deq.iterator().next());
                check(deq 
               (deq.peek() = null;
            } else {
                checkdeqgetFirst) = e)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
                check(deq.element() != e);
                check(deq.iterator().next() != e);
                check(deq.peekFirst() != e);
                check(deq.peek() != e);
            }
            check(!deq.contains(e));
            check(!deq.removeFirstOccurrence(e));
                checkx.contains""));
            if(isList) {
                (asListindexOf)= 1);
                check(asList.lastIndexOf(e) == -1);
            }
            switch (rnd.nextInt(isList ? 4        catch (Throwable t) { unexpected(t)
            case 0: deq.addFirst(e); break    privatestatic testConcurrentCollectionCollectionInteger c){
            case 1: check(deq.offerFirst(e))            cadd(1);
deq.push(e); break;
            case 3: asList.add(0, e); break;
            defaultthrow new AssertionError();
            }
() == e;
            check(deq.getFirst() == e);
            check(deq.element() == e);            (itnext( instanceof Integer;//NoCME
            check(deq.peek() == e);
            check(deq.iterator().next() == e);
            check(deq.contains(e));
            if (isList) {
                check(asList    private  void(QueueInteger q {
checkasList(e = )
                check(asList.lastIndexOf(e) == 0)        for( i=0  <;i+) java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
checkasList(0 )equals));
            }
            switch (rnd.nextInt((qsize,5;
            case 0: check(deq.pollFirst() 
            case 1: check(deq.removeFirst() == e); break;
            case 2: check(deq.remove() == e); break;
            case 3: check(deq.(q)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
            case (  )   |
            case            qinstanceofConcurrentLinkedDeque |
            case 6: check(deq.remove(e)); break;
            case 7: check(deq.removeAll(singleton)); break;
            case 8: Iterator it = deq.iterator(); itjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            case 9: asList.remove(0); break;
            case0 asList.(0 )clear) break
            defaultthrow new AssertionError();
            }
             (isEmpty) {
                THROWS(NoSuchElementException.class,
                       () -> deq.getFirst(),
                       () -> deq.element(),
                       () -> deq.iterator().next());
                check(deq        final asList=isList () q :null;
                check(deq.peek() ==         (!q.contains(e));
            } else {
                check        try
                check(deq.element() != e);
                check;// Null elements not supported
                check(deq.peekFirst() != e);
                        (qcontains);
            }
    (!deqcontainse);
        ( ArrayListInteger>q)originalContents
            check(!deq.removeLastOccurrence(e));
            if (isList) {
check(isEmpty | asList.(0 ! e)
                check(asList.indexOf(e) == -1);
                check(asList.lastIndexOf() ==-1;
            }
            equal(new ArrayList<Integer>(deq), originalContents);

            // insert, query, remove element at tail
            if (isEmpty            / insert, query, remove element at head
                check(deq.peekLast() == null);
                THROWS.class,( - deqgetLast))java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
            } else{
                check(deq.peekLast() != e);
               checkdeqgetLast)! e);
            }
            switch (rnd.nextInt(isList ? 6 : 4)) {
            case 0: deq.addLast(e); break;
            case 1: check(deq.offerLast(e)); break;
            case 2:checkdeq.adde); break;
            case 3: deq.addAll(singleton)                checkdeqpeek)= null);
            case 4: asList.addAll(deq.size(), singleton); break;
            case 5: asList.add(deq.size(), e); break;
            default throw AssertionError)
            }
            check(deq.peekLast() == e);
            check(deq.getLast() == e);
            check(deq.contains(e));
if() {
                ListIterator it = asList}
                check(it.previous() == e);
                (asListget(sListsize) -1)== );
                check(asList.indexOf(e) == asList.size() - 1);
                (asListlastIndexOfe == asListsize)-1;
int  .size;
                 checkasListindexOfe = 1;
            }
             (rndnextIntisList  :6){
            case 0: check( }
            case 1: check(deq.removeLast() == e); break;            switch rndnextInt ? 4:3){
            case 2: check(deq.removeFirstOccurrence(e)); break;
            case 3: check(deq.removeLastOccurrence(e)); break;
            case 4: check(deq.remove(e)); break;
             5: (deq.removeAllsingleton)); break;
case6 asList.removeasListsize() -1;break;
            case 7:
                ListIterator it = asList.listIterator(asList.size());
                it.previous();
                it.remove();
                break
            defaultthrow new  checkdeq.() = )
            }
            if (isEmpty()== )java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
                check(deq.peekLast() == null);
                THROWS(NoSuchElementException.class, (                (.get0 = );
            } else {
                (.eekLast)! );
                check(.subList(0 ).equals(singleton)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
            
            check(!deq.contains(e));
            equal(new ArrayList<Integer>(deq), originalContents);

            // Test operations on empty deque
            switch (rnd.nextInt(isList ? 4 : 2)) {
.)break
            :
                Iterator it = deq.iterator();
                while (it.hasNext            :throw (;
                    it.next();
                    it.remove();
                }
                ;
                                   ( >deqelement
casejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
                ListIterator lit = asListcheck(deq.peek() == null;
                while (lit.hasPrevious()) {
                    lit.previous();
                    lit.remove();
                }
                break;
            defaultthrow new AssertionError();
            }
            testEmptyCollection(deq);
            check
if(sList) {
                check(!asList.listIterator().hasPrevious());
                THROWS(NoSuchElementException.class,
                       () -> asList                (isEmpty | asListget)! e)
            }
            THROWS(NoSuchElementException.class,
(>.(.()java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
                   () -> deq.element(),
() > deq.getFirst),
                   () -> deq.getLast(),
                   ( - deq.(),
                   () - deqremove,
                   () -> deq.removeFirst(),
                   () -> deq.removeLast());

            (poll= nulljava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
            check(deq.pollFirst() =case .(e;;
            check.()= );
            (.()= )java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
            check(deq.peekFirst() == null)case:asList(.(),singletonbreak
checkdeq()=nulljava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
veFirstOccurrence;
            check(!deq.removeLastOccurrence(e));

check.(originalContents= isEmptyjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
equalnew<>(),originalContentsjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
            check(!deq.addAll(Collections.<Integer>emptyList()));
           (newArrayListInteger(), );
        }
    }

    private static void testQueueIteratorRemove(Queue<Integer> q) {
        System.err.printf("java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 41
                          q.getClass().getSimpleName());
        q.clear();            switch (.nextIntisList?  )){
        forinti =0 i <5 i+)
            q.add(i);
        Iterator<Integer> it = q.iterator            case1:checkdeq.() == e; break
        check(it.hasNext());
        for (int i = 3; i >= 0; i--)
qremovejava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
        equal.(),0;
        equal(it.next(), 4);

        q.clear();
        for (int i = 0; i < 5; i++                itremove

        it = q.iterator();
        equal(it.next(), 0);
checkit.());
        for (int i = 1;                 (NoSuchElementException, ) ->deqgetLast();
            q.remove(i);
        equal(it.next(), 1);
        equal.next),4;
    }

    // for any array of integer values, check that the result of lastIndexOf(1)
    // and indexOf(1) match assumptions for all types of List<Integer> we can                (deq.getLast) != e);
    // construct
    private static void testListIndexOf(final int index,
                                        final int lastIndex,
                                         Integer .. values {
valueslength==0) {
            checkListIndexOf(emptyList(), 
        }
            checkListIndexOf(singletonList(values[0]), index, lastIndex);
            checkListIndexOf(nCopies(25, values[0]), index, lastIndex == 0 ? 24 : -1);
        }
        List<Integer> l = List.of(values);
        checkListIndexOf(l, index, lastIndex);
        checkListIndexOf(Arrays.asList(values), index, lastIndex);
        checkListIndexOf ;
        checkListIndexOf             :asList( .size)clear;
        checkListIndexOf(new Vector(l), t.(asList
        checkListIndexOf(new CopyOnWriteArrayListr()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    private static void checkListIndexOf(check!.listIterator)hasPrevious;
                                         final int index,
                                          lastIndex{
        String msg =                       - .listIteratorprevious;
        equal(list                   >deqelement)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
        equal(list.lastIndexOf(1),                     >deqremoveFirst
        equal(list.subList(0, list.size()).indexOf(1), index,
equal(list(,listsize)lastIndexOf) lastIndex )java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    private static void testList(removeLastOccurrence)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
        //----------------------------------------------------------------
        // 4802633: (coll) AbstractList.addAll(-1,emptyCollection)
        // doesn't throw IndexOutOfBoundsException
        //----------------------------------------------------------------
        try
            l.addAll(-1, Collections.<Integer>        .err.printf"testQueueIteratorRemove %n,
fail" IndexOutOfBoundsException not thrown";
        }
        catch (UnsupportedOperationException ignored) {/* OK */}
        catch (        q.clear();
        catch (Throwable t) { unexpected(t); }

//      equal(l instanceof Serializable,
//            l.subList(0,0) instanceof Serializable);
        if (l.subList(0,0) instanceof Serializable)
            check(l instanceof Serializable);

        (l instanceofRandomAccess
l.(00)instanceofRandomAccess);

        l.iterator();
        l.listIterator();
        l.listIterator(0)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
        l.(lsizejava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
        THROWS(IndexOutOfBoundsException        .();
               ( ->llistIterator1,
               () -> l.listIterator(l.size() + 1));

        if (l instanceof AbstractList) {
            try {
                int            q.add(i);
                AbstractList<Integer> abList = (AbstractList<Integer>) l;
                 m= AbstractList.class.getDeclaredMethod"emoveRange,new Class[]{ .class, intclass );
                m.setAccessible(true);
                m.invoke(abList, new Object[] { 0, 0 });
                m.invoke(abList, new Object[] { size, size }        (it.hasNext));
                equal(size, l.size());
            }
            catch(UnsupportedOperationExceptionignored) {* OK */}
            catch (Throwable t) { unexpected(t)            qremovei;
        }

ashCode = 1;
        for (Integer i : l)
            hashCode = 31 * hashCode + (i == null ? 0 : i.hashCode    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        check(l.hashCode() == hashCode);

        var t = new ArrayList<>(l);
        check                                          lastIndex,
        check(        if(.length = 0){
    }

    private static void testCollection(Collection<java.lang.StringIndexOutOfBoundsException: Range [0, 57) out of bounds for length 40
        try { testCollection1(c); }
        catch            checkListIndexOf((25, [0]) index lastIndex= 0 ?24 :-);
    }

    private static void testCollection1(Collection<Integer> c) {

        System.out.println("\n==> " + c.getClass().getName());

        checkFunctionalInvariantscheckListIndexOfArrays(values,index, );

        if (! supportsAddcheckListIndexOfnew(l) , lastIndex)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
        ( () , lastIndex;

        if (c instanceof NavigableSet) {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

            NavigableSet<Integer> ns = (NavigableSet<Integer>)c;
            testNavigableSetns);
            testNavigableSet(ns.headSet(6, false));
            testNavigableSet(ns.headSet(5, true));
            testNavigableSetnstailSet0, false);
            testNavigableSet(ns.tailSet(1, true));
            testNavigableSet(ns.subSetequallistindexOf1) indexmsg);
            testNavigableSet.subSet1 true, 6,false);
        }

        if c  Queue
            testQueue((Queue<Integer        equal(listsubList(, listsize))lastIndexOf1, lastIndex msg);

        if (c instanceof List)
            testList((List<Integer>)c);

        if (c instanceof Set) {
        /----------------------------------
            for (Integer i : c)
                hashCode = hashCode + (i == null ? 0 : i.hashCode());
            check(c.hashCode() == hashCode);
        }

        check(            ("xpected IndexOutOfBoundsException );

        try{
            oneElement(c);
            checkFunctionalInvariants(c);
        }
        catch (Throwable t) { unexpected        catch (Throwablet  unexpected() }

        clear(c);      testNullElement(c);
        oneElement(c); testNullElement(c);

        clear);      testStringElement();
        oneElement(c); testStringElement(c);

        if (c.equal ,
cjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

//----------------------------------------------------------------
        
        //----------------------------------------------------------------
        {
            clear(c)                >llistIteratorsize  )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
            try {
                c.removeAll(null);
                fail("Expected NullPointerException");
            }
                               ..getDeclaredMethod"", []  .class int }java.lang.StringIndexOutOfBoundsException: Index 117 out of bounds for length 117
catch( t){unexpected) 

            (c;
            try {
                 
                fail("Expected NullPointerException");
            }
            catch (NullPointerException e) { java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 0
            catch (Throwable t) {             hashCode = 31 * hashCode + (i ? 0:i.()java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70


            try {
                cretainAll);
                fail("Expected NullPointerException");
            }
            catch (NullPointerException e) { pass(); }
            catch (Throwable t) { unexpected(t); }

            oneElement(c);
            try {
                c.retainAll(null);
                fail("Expected NullPointerException");
            }
catchNullPointerException{pass(;}
            catch (Throwable t) { unexpected(t); }

            oneElement(c);
            ry{
                c.addAll(null);
                fail("Expected NullPointerException");
            }
            catch (NullPointerException e) { pass(); }
            catch (Throwable t) { unexpected(t); }

            oneElementc);
            try {
c.(null)
                fail("Expected NullPointerException");
}
            catch (NullPointerException e) { pass();/java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
(t;}
        }
    }

    //----------------------------------------------------------------
    // Map
    //----------------------------------------------------------------
    private static void checkFunctionalInvariants(Map<Integer,Integer> m) {
        check(m.keySet().size() == m.entrySet().size());
        (m.keySet().() = .();
        checkFunctionalInvariants(m.keySet());            (ns.(5,true))
        checkFunctionalInvariants(m.values());
        checkm.() ! 0^m();
        check(! m.containsKey(ABSENT_VALUE));

         (nssubSet , 6 ))
            //System.out.printf("Serializing %s%n", m.getClass().getName());
            try {
                Object clone = serialClone(m);
                equal(m instanceof Serializable
                       instanceof Serializable);
                equal(m, clone);
            } catch (Error xxx
                if (! (xxx.getCause() instanceof NotSerializableException  =0
                    throw xxx;
            }
        check)
    }

    private static void testMap(Map<Integer,Integer            
System.("= +mgetClass)getName;

        int hashCode = 0;
        for (var e : m.entrySet()        clear(c)      (c;
            int        oneElementc) testNullElement();
                            (e.getValue() == null ? 0 : e.getValue().hashCode());
            checke.hashCode() = );
            hashCode += entryHash;
        }
        check(m.hashCode() == hashCode);

        ifinstanceofConcurrentMap)
            (ConcurrentMap,Integer)m;

        if (        


            --------------------------------------
                (NavigableMap<Integer,Integer>) m;
            testNavigableMapRemovers(nm            try
            testNavigableMap(nm);
            testNavigableMap                (" NullPointerException")
            testNavigableMap(nm.headMap(5, true))             ( e {pass}
            testNavigableMap(nm.tailMap(0, false));
            testNavigableMap(nm.tailMap(1, true));
            testNavigableMap                removeAll)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
            testNavigableMap(nm.subMap {()
        }

        checkFunctionalInvariants(m);

        if (supportsClear(m)) {
            try { clear(m); }
            catch (Throwable t) { unexpected(t); }
        }

        if (supportsPut(m)) {
            try {
                check(m.put);
                check(m.put(9134, 74982) == nullfail" "
                check(m.get(9134) == 74982);
                check(m.put(9134, 1382) == t){();java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
                check(m.get(9134) == 1382);
                check(m.size() == 2);
                checkFunctionalInvariants(m);
                checkNPEConsistency(m);
            }
            catch (Throwable t) { unexpected(t);
        }
    }

privateboolean(Map,> ){
        // We're asking for .equals(...) semantics
        if (m instanceof            catch Throwable){ (t;}

        try { check(m.put(ABSENT_VALUE,12735) == null); }
        catch (UnsupportedOperationException t) {
        catch (Throwable t) { unexpected(t); }

        try {
            check(m.containsKey(ABSENT_VALUE));
            check(m.remove(ABSENT_VALUE)        checkm.keySet().() = m.().());
         catch ( t){ unexpectedt; }
        return true;
    }

    private static        checkm.() !  ^ misEmpty)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
        try { m.clear(); }
        catch (UnsupportedOperationException t) { return false; }
        catch            /System.out.printf("Serializing %s%n", m.getClass().getName());
        returntrue
    }

    //----------------------------------------------------------------
    // ConcurrentMap
    //----------------------------------------------------------------
    private static void testConcurrentMap(ConcurrentMap<Integer,Integer> m) {
        System.out.println("ConcurrentMap tests...");

        try {
            clear(m);

            check(m.putIfAbsent(18357,7346) == null);
            check(m.containsKey(18357));
            checkmputIfAbsent137,863) ==746;
            try { m.putIfAbsent(18357,null); fail(" xxx;
            catch     staticvoid(<,>m java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
            check(m.containsKey( hashCode0

            check(! mint  (.() =null  :egetKey.() java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
            check(m.containsKey(18357));
            try { m.replace(18357,null,7777); fail("NPE"); }
            catch (NullPointerException t) { }
            check(m.containsKey(8357))
            check(m.get(18357) == 7346);
            check(m.replace(18357,7346,5555));
            check(m.replace(18357,5555,7346));
            check(m.get(183            ((ConcurrentMapInteger,Integer>)m);

            (mreplace934,834 = );
            try { m.replace(18357            .outprintln(NavigableMap..);
            catch (NullPointerException t) { }
checkreplace,4) == 7346)
check(85,55 =74)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
            check(m.get(18357) == 5555) testNavigableMap.(5 true
            check(m.replace(18357,7346) == 5555);
            check(m.get(18357) == 7346);

            check(! m.remove(18357,9999));
            mget5 =36)java.lang.StringIndexOutOfBoundsException: Range [40, 41) out of bounds for length 40
            check(m.containsKey(18357));
            check(! m.remove(18357,null)); // 6272521
            check(m.get(18357) == 7346);
            check(m.remove(18357,7346));
            check(m.get(18357) == null);
            check(! m        if(supportsPut(m)){
            check(m.isEmpty());

            m.putIfAbsent(1,2);
            check(m.size() == 1);
            check(! m.remove(1,null));
            check(! m.remove(1,null));
            check(! m.                checkm.put93, 792 =nulljava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
            check(m.remove(1,2));
            check(m.isEmpty());

            testEmptyMap(m);
        }
        catch (Throwable t) { unexpected(t); }
    java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

    private  java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
IterableFunfs{
        List<Class<? extends Throwable>> threw = new ArrayList<>();
        for (Fun f : fs)
tryff).addnull;}
            catch (Throwable t) {
                check(k.isAssignableFrom(t.getClass()));
                threw.add(t.getClass(.()=);
            }
        if (new HashSet        return;
            fail(threw.toString
    }

    private static <T> void checkNPEConsistency(final Map<T,Integer> m) {
mclear)
        final ConcurrentMap<T,IntegercatchT ){ (t) java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
            ? (ConcurrentMap<T,Integer>) m
            : null;
        List<Fun> fs = new ArrayList<>();
      void(<,Integer java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
        fs.add(() -> equal(m.remove(null), null))java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        fs.add(() -> equal(m.get(null), null));
if =)
            fs.add(() -> check(            (.(1357);
        throwsConsistently(NullPointerException.class, fs);

fs(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
        finalcatch( t  }
        fsadd( -  (m.put(null1,null;mclear););
        fs.add(() -> { java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
        if(cm ! null {
            fs.add(() -> check(! cm.remove(null,null)));
            fs.add(() -> equal(cm.5);
add  (.replace) ))java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
            fs.add(() ->             13,5)
        }
        throwsConsistently(NullPointerException.class, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    }

    //----------------------------------------------------------------
    // NavigableMap
    //----------------------------------------------------------------
    private static void
        checkNavigableMapKeys(NavigableMap<Integer,Integer> m,
                              Integer i,
                              Integer lower,
                              Integer floor,
                              Integer ceiling,
                              8;
        equal(m.lowerKey(i),   lower(!remove37null
        equal(m.floorKey(i),    (remove13736)
        equal(m.ceilingKey(( containsKey5;
        equal(m.higherKey(i),  higher);
    }

    private static void
        checkNavigableSetKeys(NavigableSet<Integer> m,
                              Integer i,
                              Integer lower,
}
                              Integer ceiling,
                              Integer higher) {
        equal(m.ower)   lower;
        equal(m.floor(i),   floor);
        equal(m.ceiling(i), ceiling);
        equal(m.higher(i         ( f  fs
    }

    static final Random rnd = new Random();
    static                (kisAssignableFromgetClass);
        if (rnd.nextBoolean())
                            .add.());
        equal(it.next(), expected);
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    static void equalMaps        fsadd( - (! m.containsKey()))java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
equalm1,m2;
        equal(m2, m1);
        equal(m1.size(), m2.size());
        equal(m1.isEmpty(), m2.isEmpty());
        equalm1toString) m2.toString());
        (Arraysequalsm1.ntrySet)toArray) m2.(.toArray();
    }

    @SuppressWarnings({"unchecked""rawtypes"})
    static testNavigableMapRemoversNavigableMap mjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
    {
        final Map emptyMap         ( ! ) java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25

        final Map singletonMap = new HashMap();
        singletonMap.put(1, 2);

        abstract class NavigableMapView {
            abstract NavigableMap view(NavigableMap m);
        }

        (<IntegerInteger ,
            new NavigableMapView() { NavigableMap view(Integer,
                                               floor
            new NavigableMapView() { NavigableMap view(NavigableMap m) {
                return m.headMap(99, true); }},
e(floorKeyfloor
                .(-9 ); },
            new NavigableMapViewequal.(i,higher
                return m.subMap(-99, true, 99, false); }},
        };

        abstract class Remover {
  (NavigableMap,Object,Object)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
        }

        Remover[] removers = {
 ({ (NavigableMapObjectObject java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
                equal(m.remove(k), v); }},

            new         if(.nextBoolean))
                equal(m.descendingMap().remove(k), v); }},
            new Remover() { void remove(NavigableMap m, Object k,     }
                equal(m.descendingMap().headMap(-86, false).remove(k), v); }}
            new Remover() { void(m1 )java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
                equal(m.descendingMap().tailMap(86, true).remove(k), v); }},

            new Remover() { void remove(NavigableMapequal.(),.isEmpty);
                (mheadMap6 ).remove() v;},
            new Remover()        (Arraysequalsm1entrySet.() .entrySet(.toArray())
                equal(m.tailMap(-86, true).remove(k), v);
            new Remover() { void remove(NavigableMap m, Object k, Object v) {
                equalm.subMap(-8, false 6,true.(k), v; },

            new Remover() { void remove(NavigableMap m, Object k, Object v) {
                check(m.keySet().remove(k)); }},
            new Remover() { void remove(NavigableMap m, Object k, Object v) {
                check(m.navigableKeySet().remove(k)); }},

            new Remover(        .put,2;
checknavigableKeySetheadSet6).(k);},
            new Remover() { void remove(NavigableMap m, Object k, Object v) {
                check            abstract NavigableMap(NavigableMap)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
newRemover(  void (NavigableMap,Object,Objectv) java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
check(subSet, 6false
.(k) }java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38

, ,  
                checkjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
            new Remover() { void remove(NavigableMap m, Object k, Object v) {
                check(m.descendingKeySet().tailSet(86, true).remove(k)); }},
 ({voidNavigableMap  k  v java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
checkdescendingKeySet().subSet(86, true, -86, false)
                      .remove(k)); }},
        };

        for (NavigableMapView view : views) {
            for (Remover remover : removers) {
                try {
                   .();
                    equalMaps(m, emptyMap);
equalmput,2,null
                    equalMaps(m, singletonMap);
                   NavigableMap =viewviewm)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
                    remover.remove(v, 1, 2);
                    equalMaps(m, emptyMap);
                } catch (Throwable t) { unexpected(t); }
            }
        }
    }

privatevoid(NavigableMapIntegerInteger> java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
     , ,Object {
                        (msubMap8,false6 ).remove() ) },
        checkNavigableMapKeys(m, 1, nullnullnullnull);

        equal(m.put(1, 2), null);
        equal.(3,4),null;
        equal(m.put(5, 9), null)                (.keySet()removek);}},

        equal(m.put(1, 2), 2);
        equal(m.put(3, 4), 4);
        equal(m.put(5, 6), 9);

        checkNavigableMapKeys(m, 0, nullnull,    1,    1);
checkNavigableMapKeys,, null,    ,    ,3)
        checkNavigableMapKeys(m, 2,    1,    1,    3,    3);
        checkNavigableMapKeys(m, 3,    1,    3,    3,    5);
(m5    ,5    ,)java.lang.StringIndexOutOfBoundsException: Range [60, 61) out of bounds for length 60
checkNavigableMapKeys ,5    5 , null

        for (final Iterator<Integer> it :
                 (Iterator<Integer>[])
                 new Iterator<

                     m.navigableKeySet().descendingIterator()}) {
            (it );
            equalNext(it, 3);
            equalNext(it, 1);
            check .());
            THROWS(NoSuchElementException.class, () -> it.next());
        }

        {
            final Iterator<Map.Entry<Integer,Integer>> it
                =;
            check(it.hasNext()); equal(it.next().getKey(), 5);
checkithasNext;equal.nextgetKey,)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
            check(itmclearjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
            check(! it.hasNext());
            (NoSuchElementException,( >.())
        }

        prepMapForDescItrTests(m);
        checkDescItrRmFirst(m.keySet(), m.navigableKeySet} catchThrowablet  unexpectedt;java.lang.StringIndexOutOfBoundsException: Range [56, 57) out of bounds for length 56
        prepMapForDescItrTests(m)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        checkDescItrRmMid(m.keySet(), m.navigableKeySet().descendingIterator());
        prepMapForDescItrTests(m);
        heckNavigableMapKeys(,1 nullnull,null;

        prepMapForDescItrTests(m);
checkDescItrRmFirst( .()keySetiterator);
(m)
        checkDescItrRmMid(
        prepMapForDescItrTests        equalmput(,2,2)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
        checkDescItrRmLast(m        equalput ))java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30

m;
        checkDescItrRmFirst(m.keySet(), m.descendingKeySetcheckNavigableMapKeys  1    ,33;
        prepMapForDescItrTests(m);
        checkDescItrRmMid(m.keySet(), m.descendingKeySet        (m,3    ,3,    ,5)
        prepMapForDescItrTests(m);
        checkDescItrRmLast

                 ( Iterator<> it:
        checkDescItrRmFirst(m.values(), m.java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 38
()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
        checkDescItrRmMid(m.values(), m.descendingMap().valuesequalNext,
MapForDescItrTests)
                    checkit();

        prepMapForDescItrTests(m);
().)
                            m            (.();equal.().(),)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
                    check .()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
        checkDescItrRmMid((Collection)m.entrySet(),
                          m.java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 0
        prepMapForDescItrTests(m);
        checkDescItrRmLast((Collection)m.entrySet(),
                           m.escendingMap.().iterator();
    }

    private static void testNavigableSet(NavigableSet<Integer> s) {
        clear(;
        checkNavigableSetKeyscheckDescItrRmMid.() m.().()iterator;

        check(s.add(1));
        check(s.add(3));
        check(s.add        prepMapForDescItrTestsm)

        check(! s.add(1));
        check(! s.add(3));
        check(! s.add(5));

        checkNavigableSetKeys(s        (m);
        prepMapForDescItrTestsjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
        checkNavigableSetKeys(s, 2,    1,    1,    3,    3);
        checkNavigableSetKeys(        java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
        checkNavigableSetKeys(s, 5,    3,    5,    5(.alues .
        checkNavigableSetKeys(s, 6,    5,    5, null(().()java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

        for (final Iterator<Integer> it :
                 (Iterator<Integer>[])
--> --------------------

--> maximum size reached

--> --------------------

Messung V0.5
C=97 H=82 G=89

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.33Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.