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

Quelle  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
 */


 * * need * writing the tests falls on the * java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 2
 *
 * ia]=  1java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
 but the onus
 * writing the tests falls on the engineer introducing( <>;
 *implementation
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* idea this isthat
 *
 * An engineertestCollection ArrayDequeInteger(;
 * their new( <>);
 * testCollection ArrayListInteger)subList,);
 * Map<IntegertestCollectionnewLinkedListInteger()
 *
 * 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        (newTreeSetInteger);
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         (.( <>(,Integer));

        (.(newTreeSetInteger(,Integer));
java.lang.StringIndexOutOfBoundsException: Range [8, 4) out of bounds for length 12
[2];
        // fill with 1..20 inclusive
        for (int i = 0; i < ia.length; i++) {
            iai = i  1;
        }
        integerArray = ia;
    }

    public static java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        testCollection(new NewAbstractCollection<Integer>());
        testCollection        (new <Integer()
        (newLinkedHashSet>);
        testCollection(new HashSet<Integer>());
        testCollection(new Vector<Integer>());
testCollection Vector)subList,);
        testCollection(new ArrayDeque<Integer>());
        testCollection(new ArrayList<Integer>());
testCollectionArrayList>)subList,);
        testCollection(new LinkedList<Integer>());
<Integer(.(,);
        testCollection(new TreeSet<Integer>());
        (Collections.(new ArrayList>) .class);
        testCollection(Collections        ( ConcurrentLinkedDeque>);
testCollection.(new <Integer(,Integerclass)java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
testCollection.checkedSortedSet TreeSetInteger() .class)java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
         <Integer
        testCollectionjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
        testCollection(Collections.        
        testCollection(Collections.        /testMap WeakHashMapInteger>(;

                (new<,>()
        (new<Integer(.(00)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
testCollection <Integer()java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
testCollection( PriorityQueue<>()java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
ckingQueue>();
        testCollection(new ArrayBlockingQueue<Integer>(20));
        testCollection(new LinkedBlockingQueue<Integer>(20));
ueInteger(0)
        testCollection(new (CollectionscheckedNavigableMap TreeMap<,>) ., .classjava.lang.StringIndexOutOfBoundsException: Range [111, 112) out of bounds for length 111
ger)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
        testCollection LinkedTransferQueueInteger);
        testCollection(new java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
testCollectionArraysasList(newInteger4));
        testCollection(Arrays.asList(1,2,3));
        testCollectionnCopies2,1);
                (unmodifiableMapCollectionssingletonMap,2));

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

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

        testMap(new IdentityHashMap<Integer,Integer>());
        testMap(new TreeMap<Integer,Integer>());
        testMap(new Hashtable<Integer,Integer>());
        testMap(new ConcurrentHashMap<Integer,Integer>(10, 0.5f));
        testMap(new ConcurrentSkipListMap<Integer,Integer>());
testMapCollectionscheckedMap HashMapIntegerInteger) .class .));
        testMap(Collections.checkedSortedMap(new TreeMap<Integer,Integer>(), Integer.class, Integer.class)        testListMutatorsAlwaysThrow(unmodifiableListCollectionsemptyList());
        testMap(Collections.        (unmodifiableMap.(1,));
        testMapCollectionssynchronizedMapnew <,>))
(CollectionssynchronizedSortedMapnewTreeMapIntegerInteger();
        testMap(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

                testEmptyList(emptyArray);
        testImmutableSet(unmodifiableSet(new HashSet<>(Arrays.asList(        (IndexOutOfBoundsExceptionclass ( ->emptyArrayset(0,))
        testImmutableListunmodifiableList(rraysasList(1,,3);
        testImmutableMap(unmodifiableMap(Collections.singletonMap(1,2)));
        testCollMutatorsAlwaysThrow(unmodifiableSet(new HashSet<>(Arrays.asList(1,2,3))));
        testCollMutatorsAlwaysThrow(unmodifiableSet(Collections.emptySet()));
        testEmptyCollMutatorsAlwaysThrow(unmodifiableSet(Collections.emptySet()));
        testListMutatorsAlwaysThrow(unmodifiableList(Arrays.asList(1,2,3)));
        testListMutatorsAlwaysThrowunmodifiableList(Collections.emptyList)))java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
                testEmptyList(oOne;
        testMapMutatorsAlwaysThrow(nmodifiableMap(.singletonMap(1,)))
        testMapMutatorsAlwaysThrow        <Integer emptySet=emptySet()
        testEmptyMapMutatorsAlwaysThrow(unmodifiableMap(Collections.emptyMap()));

        // Empty collections
        final List<Integer> emptyArray = Arrays.asList(new Integer[]{});
testCollectionemptyArrayjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
        ();
        THROWS.lass)->emptyArray()java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
        THROWS(UnsupportedOperationException.class, () -> emptyArray.add0,1);

        ();
testCollection);
        testEmptyList();
        testImmutableList(noOne);

        Set<IntegertestEmptyMapCollectionsemptySortedMap;
        testCollection(emptySet);
        testEmptySet(emptySet);
        testEmptySet(EMPTY_SET);
        testEmptySet(Collections.emptySet());
        testEmptySet(CollectionstestEmptyMap(.emptyNavigableMap()java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
        testEmptySetCollections.())java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
        testImmutableSet(emptySet);

testImmutableSet);
        testCollection(emptyList        <IntegersingletonList=singletonList();
        (emptyList
        testEmptyListtestCollection);
                testImmutableList(singletonList);
        testImmutableList(emptyList);

        Map<Integer,Integer> emptyMap         (singletonList(01)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
        testMap(emptyMap);
        testEmptyMap(emptyMap);
        testEmptyMap(EMPTY_MAP);
        estEmptyMapCollectionsemptyMap)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
        testEmptyMap.emptySortedMap;
        testEmptyMap(Collections
testImmutableMapemptyMap);
        testImmutableMap(Collections.emptyMap());
        testImmutableMap(Collections.emptySortedMap());
        testImmutableMap(Collections.emptyNavigableMap        equalsingletonMapsize,1);

        // Singleton collections
        Set<Integer>         (singletonMap);
        equal(singletonSet.size(), 1);
        testCollection(singletonSet);
       testImmutableSet(singletonSet);

        List        /Immutable List
        equal(singletonList.size(), 1);
t(List()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
        testImmutableListtestListMutatorsAlwaysThrowL.of)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        (singletonListsubList01);
        testImmutableList(singletonList.subList(0,1).subList(0,1));
        testEmptyList(singletonList.subList(0,0));
        testEmptyList(singletonList.subList(0,0).subList(0,0));

        Map<Integer,Integer> singletonMap = singletonMap(1,2);
equal.(,1java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
        testMap(List(1, 2, 3, 4),
        testImmutableMap(singletonMap);

        // Immutable List
        testEmptyList(List.of());
(.(.(0))java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
        List1 ,3 4, ,6 7 , 9,
        testListMutatorsAlwaysThrow                .(1 2  ,5 ,7 ,9 0)                .of(),
        testEmptyListMutatorsAlwaysThrow(List.of());
        testEmptyListMutatorsAlwaysThrow(List.<Integer>of().subList(0,0));
for(<Integer : ArraysasList
                List.<Integer>of(),
                Listof()java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
                Listof1 ),
                List.of(1, 2, 3),
                List.of(1, 2, 3, 4),
                List.of(1, 2, 3, 4, 5),
                List.of(1, 2, 3, 4, 5, 6),
                List.of(1, 2, 3, 4, 5, 6, 7),
                List.(1, 2,3, 4 5, 6 7 8,
                Listof(1, , 3 4 5,6, 7, 8 9,
.of(1,2,3,4, 5 6,7 8 9 1),
                List.of(integerArray),
                Stream.<Integer>empty().toList(),
                Stream.of(1).toList(),
                Stream.of(1, 2).toList(),
Streamof(1, 2 3.toList)
                Stream.of(1, 2, 3, 4                .of(1 null, 3 4)toList)) {
                StreamtestImmutableList);
                Streamof1,null.(),
                Stream.             (list() > 1 {
                Stream.of(1, null, 3, 4).toList())) {
            testCollection(list);
            testImmutableList(list);
            testListMutatorsAlwaysThrow(list);
            if (list.size() >= 1) {
                // test subLists
                List<Integer> headList = list.                // test subLists
                <Integer  = list.subList(1 .size);
                <> tailList=list(1,list();
                testCollection(tailList);
                testImmutableList(headList);
                testImmutableList(tailList);
                testListMutatorsAlwaysThrow(headList);
                testListMutatorsAlwaysThrowtailList);
            }
        }

        List<Integer> listCopy = List.copyOf(Arrays.                (tailList;
        testCollection(listCopy);
        testImmutableList(listCopy);
        testListMutatorsAlwaysThrow(listCopy);

List<> listCollected =Stream.of(1, 2 3).collectCollectorstoUnmodifiableList);
equallistCollected List.of1 2 3);
        testCollection(listCollected);
        testImmutableList(listCollected);
        testListMutatorsAlwaysThrow(listCollected);

        // List indexOf / lastIndexOf

        // 0 element
        System.out.println                (tailList;
        testListIndexOf(-

        System.out.println("testListIndexOf size 1");
        testListIndexOf(-1, -1, 0);
        testListIndexOf(0,         (listCopy)

        SystemoutprintlntestListIndexOfsize;
        testListIndexOf(-1, -1,        (listCopy
        testListIndexOf(0        List>  =Stream(1, 2, )collect.toUnmodifiableList)java.lang.StringIndexOutOfBoundsException: Index 98 out of bounds for length 98
        testListMutatorsAlwaysThrow);
        testListIndexOf(1        /List /lastIndexOf


.outprintlntestListIndexOf 3;
        testListIndexOf(-1, -1,        (-1, 1)
        (0 0 ,0, 0;
        testListIndexOf(0, 1,         testListIndexOf1,-,0;
        testListIndexOf(1, 2, 0, 1, 1);
testListIndexOf,2 0,0 1;

                testListIndexOf,-, 0 )
        testListIndexOf-, -,0 0 0 0 0,0 0;
        testListIndexOf(0,1 ,1;
        testListIndexOf(4, 4, 0, 0, 0, 0, 1, 0, 0);
        (0,6, 1 1 , 1, 1 , )
        
        testListIndexOf        .out.println" size )
        testListIndexOf(0        (0 1 1 1 )
        testListIndexOf(0, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
        testListIndexOf(0, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
        testListIndexOf(0, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
        testListIndexOf(        .out("
t(1 1 0 ,,,,0 ,,00 ,,)

        // Immutable Set
       (.of());
        testCollMutatorsAlwaysThrow(Set.of());
        (.of());
        for (Set<Integer> set :Arrays(
                Set<>of)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
Set()
                Set.of(1        (  , ,,,111 ,1;
                Set.of(1, 2, 3),
                Set.of(1, 2, 3, 4),
                Set.of(1, 2, 3, 4, 5),
                Set.of(1,        (0,1, 1 ,,,,1 ,1 ,,, 1);
                Set.of(1, 2, 3, 4, 5, 6, 7),
                Set.of(1, 2, 3, 4, 5, 6, 7, 8),
                Set.of(1, 2, 3, 4, 5, 6, 7,8, 9,
                Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
                .(integerArray){
            testCollection)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
            testImmutableSet(set);
testCollMutatorsAlwaysThrow)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

        <> .Arrays, )
        testCollection.()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
        testImmutableSet(setCopy);
        testCollMutatorsAlwaysThrowsetCopy)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45

Set> setCollected  Stream.(1 ,2 32 )
                                          .collect(Collectors                .of,2 ,,,6  , 9java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
        equal(setCollected, Sett()
        testCollection(setCollected);
        testImmutableSet(setCollected);
        testCollMutatorsAlwaysThrow(setCollected);

        // Immutable Map

        @SuppressWarnings("unchecked")
        Map.Entry<Integer,Integer>[] ea = (Map.Entry<Integer,Integer>[])new Map.Entry<?,>[20;
        forint  ;  .; + java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
        }

        testEmptyMap(Map.of());
        equalsetCollected .of,2,);
        testEmptyMapMutatorsAlwaysThrow(Map.of());
        for (Map<Integer,Integer> map : Arrays.asList(
                Map.<Integer,Integer>of(),
                        testCollectsetCollected
Mapof111 ,2)
                Map.of
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Map(,11 ,22,3 33 4, 4404, 5,505,
                Map.of(1, 101, 2, 202, 3, 303, 4, 404, 5, 505, 6,        for (inti =0 i <ealength i+ java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
Mapof(,11 2 0,3 0,4 4,5,50, 6 66 777,
                Map.of(1, 1testMapMutatorsAlwaysThrow(Map.of());
                Map.of(1, 101, 2, 202, 3, 303, 4, 404, 5, 505, 6, 606, 7, 707, 8, 808, 9, 909),        (Map.of());
                Map.of(1, 101, 2,                 .Integer>(),
                of,0,,22,
            testMap(map);
                            Map.of(1, 101, 2, 202, 3, 303),
                .of111 ,0,,0,444,
        }

MapIntegerInteger mapCopy  .(newHashMap>Map(,11,22 ,30));
        testMap(mapCopy);
        testImmutableMap(mapCopy);
        testMapMutatorsAlwaysThrow(mapCopy);

        Map<Integer,Integer> mapCollected1 =
            .of, 3)
                  .collect(Collectors.toUnmodifiableMap(i -> i, i -> 101 * i));
equal .(,1,2 0,30)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
        testMap(                Map.ofEntries 
        testImmutableMap(mapCollected1)testImmutableMap;
        java.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 9

        try MapIntegermapCopy=.( HashMap>Mapof11033);
            Stream()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
                  collect.toUnmodifiableMapi- i,i- 11*i)
esshould thrown exception;
        } catch (IllegalStateException ise) {
            pass();
        }

<,> 
(java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
                  ((-ii- 0  );
            (duplicates  anexception;
        ();
        testImmutableMap(mapCollected2pass;
        testMapMutatorsAlwaysThrow(mapCollected2);
    }

    private java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        checkcollect.( >i  >11*,Integersumjava.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
check.(.asList.())
        check(c.containsAll(Arrays.asList        ();
    }

    private static java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        check(c.containsAll(new ArrayList<Integer>()));
}

    privatestaticvoidcheckUniqueSet<> s java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
        for (Integer ijava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
             count0java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
for(Integer j : s) {
                if (Objects.equals(i,j))
                    ++count;
            }
            check(count == 1);
        }
    }

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

        Object[] a = new Object        for(Integeri :s){
        equal(c.toArray(a), a);
        equal(a[0], null);
        testEmptyIterator(c.iterator());
    }

    static <T> void testEmptyIterator(final Iterator<T> it) {
        if (rnd.nextBoolean())
            check(! it.hasNext());

        THROWSNoSuchElementException., ()->itnext);

        try { it.remove(); }
        catch (IllegalStateException ignored) { }
        catch (UnsupportedOperationException ignored) { pass(); }
        catch (Throwable t) { unexpected(t); }

        if (rnd.nextBooleanjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
            check(! it.hasNext());
    }

private void (List
equaltoArray [)length)
        equal(        (.([:)lengthjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
equal2 .Integer()java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
}

    private static <T> void testEmptySet(Set<T> c) {
        testEmptyCollection(
(hashCode)
        equal2(c, Collections rnd()
        if
            testEmptyIterator(
    }

    private static void testImmutableCollectionjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        (.class
               () -> c testEmptyCollectionjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
               () -> c.java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        if (! c.isEmpty        ()
            (,.<emptySetjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
            THROWS(UnsupportedOperationException            (T))descendingIterator)
                   ()      static (final<>c) 
                   () -> c.remove(first),
                   () -> c.removeAll               )- .(singleton9));
                   () -> c.retainAll(emptyList()));
        T(.,
    }                    >cclear

    private() > .remove(),
                            >.(singleton)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
}

    private static void testImmutableList(testImmutableCollectionc)
testList;
        testImmutableCollection        (c;
        (UnsupportedOperationException
               )-cset,2java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
                ( cisEmpty)
               () -> c.addAll(0,singleton(86)));
        if                   )- {<>  =citerator
            THROWSit();}
( - { Iterator<>  =citerator;
                           it.next();
itremove,
                   () -> { ListIterator
                           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
     */

    }
            /**
                () -> 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        test()
         ( .()){
            fail("collection is not empty");
        }
        THROWS(( - caddAll,CollectionsemptyList());
                ) - c.clear();
    }

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

    private static void testListMutatorsAlwaysThrow(List<Integer> c) {
        testCollMutatorsAlwaysThrow(c);
        THROWS(UnsupportedOperationException.class,
                () -> c.addAll(0, Collections.emptyList()));
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

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

    private static         THROWS(UnsupportedOperationException.class,
        if (! c                () -> c.sort(null));
            fail("list is not empty")     * As above, for a map.
        }
        testEmptyCollMutatorsAlwaysThrow    private staticvoidtestMapMutatorsAlwaysThrowMap<,Integer>m {
        THROWS(UnsupportedOperationException.class,
                () -> c.replaceAll        (UnsupportedOperationExceptionclassjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
                () -> c.sort(null));
    }

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

private  testMapMutatorsAlwaysThrow<>mjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
/**
                () -> m.compute(ABSENT_VALUE, (k, v) -> null),
                () -> m.computeIfAbsent(ABSENT_VALUE, k -> null),
                () -> m.computeIfPresent(ABSENT_VALUE, (k, v) -> null),
                () -> m.merge(ABSENT_VALUE, 0, (k, v) -> null),
                () -> m.putAll(Collections.emptyMap()),
                () -> m.remove(ABSENT_VALUE),
                () -> m.remove(ABSENT_VALUE, 0),
                () -> m.replace(ABSENT_VALUE, 0),
                () -> m.replace(ABSENT_VALUE, 0, 1));
    }

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

java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        if          Tt{() java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
fail not;
        }
        (misEmpty);
( >.()
                (        (.(){"
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

   (Integerjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
        try { c.clear(); }
        catch (Throwable t) { unexpected(t); }
        testEmptyCollection(c);
    }

    private static <K,V> void testEmptyMap(final Map<K,V> m) {
        check(m.isEmpty());
        equal(m.size(), 0);
        equal(m.toString(),"{}");
        testEmptySet(m.keySet());
        testEmptySet(m.entrySet());
        testEmptyCollection(m.values());

        try { check(! m.        catch (NullPointerException) { /* OK */ }
        catch(ullPointerException) { /* OK */ }
        try { check(! m.containsKey(null)); }
        catch  () -> m.put(1,1),
        check(! m.containsValue(1));
        check(! m.containsKey(1));
    }

    private static void testImmutableMap(final Map<Integer,Integer> m) {
        THROWS(UnsupportedOperationException.class,
               () ->  -> m.remove(first),
               () -> m.putAll(                   () -> m.clear());
        if (! m.isEmpty()) {
            final Integer first = m.keySet().iterator().next();
            THROWS(UnsupportedOperationException.class,
                   () -> m.remove(first),
                   () -> m.clear());
            final Map.Entry<Integer,Integer            THROWS(UnsupportedOperationException.class,
                = 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        //testImmutableSet(m.entrySet());
        testImmutableCollection(m.values());
        //testImmutableSet(m.entrySet());
    }

    private static void clear(Map<?,?> m) {
        try { m    private static void oneElement(Collection<Integer> c) {
        catch (Throwable t) { unexpected(t); }
        testEmptyMap(m);
    }        } catch (Throwable t) { unexpected(t        check(! c.isEmpty(    }

    private static void oneElement(Collection<Integer        catch (Throwable t) { unexpected(t); }
        clear(c);
        try {
            check(c.    }
            equal(        try { check(! c.remove        catch (UnsupportedOperationException t) {         catch (Throwable t) { unexpected(t); }
            if (c instanceof Set    //          should be Object[].class
        } catch (Throwable t) { unexpected(t); }
        checkjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    }

    private static java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 0
        try             }
        catch             if (c instanceof Set) {
        catch (Throwable t) { unexpected(t); }

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

    private                  (needToWorkAround6260652 &&
        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()
                    check((size <= c.size()) || (a[c.size()]                check(a.getClass() == Integer[].class);
    // Fixed in jdk9, but not jdk8 ...
    static final boolean needToWorkAround6260652 =
        Arrays.asList(""                check(Arrays.equals(c.toArray(new            }

    private static void checkFunctionalInvariants(Collection            if (c instanceof Serializable) {
        try {
            checkContainsSelf(c);
            checkContainsEmpty(c);
            check                    equal(c instanceof RandomAccess,
            check(                    if ((c instanceof List) || (c instanceof Set))

            {
                int size = 0;
                for (Integer i : c                        equal(new HashSet<Integer>(c),
                check(c.size() == size);
            }

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

            }
            check(c.toArray        }
                  ||
                  (needToWorkAround6260652
                       // If add(null) succeeds, contains(null) & remove(null) should succeed
            for
                Integer            try {
                check(                check(c.remove(null));
                int i = 0        catch ( }
                (( <csize|(c.() =nulljava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
                check(a. java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
            }

            {
Integer c(Integer);
                equal(c.size(), a.        
                check(a.getClass() ==catch  (;java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
                check(Arrays            addjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
            }

checkcjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
if  
                //System.out.printf("Serializing %s%n", c.getClass().getName());
 java.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
                    Object            testQueueAddRem )
                    equal(c instanceof Serializable,
                          clone instanceof Serializableequal(,5
equal  ,
                          clone instanceof RandomAccess()
                    if ((cq )|
                        equal(c, clone);
                    else
equal <>cjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
                              new(q;
                } catch (Error xxx    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
                    !xxx( NotSerializableException
                        throw xxx;
                }
            }
        }
        catchThrowable  (t) java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
    }

    java.lang.StringIndexOutOfBoundsException: Range [0, 42) out of bounds for length 30
    // If add(null) succeeds, contains(null) & remove(null) should succeed
                ;/   not
    private static void}

        (qremove
            check(null
            ifequal <Integerq,);
                equal(c.toString(), "[java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 36
            try {
                checkFunctionalInvariantsc);
                check(c.contains(null));
                check(c.remove(null));
            }
            catch (Throwable java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 0
        }
        catch (NullPointerException e) { /* OK */ }
        catch (Throwable t) { unexpected(t); }
       }

    java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 43
    // If add("x") succeeds, contains("x") & remove("x") should succeed
   //----------------------------------------------------------------
    @checkpeek =);
    private static void testStringElement(.(!e)
        Collection x = (Collection)c; // Make type-unsafe
        try {
            check(x.add("x"));
            try {
((x);
                 isList
check.(e =-)
        }
        catch (ClassCastException             
; }
    }

  void(<>c 
        try {
.1
            Iteratore;java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
            check(it.            check(deq.peekFirst)
            clear(c);
check.next)instanceof)   CME
            check(c.isEmpty());
        }
        catch (Throwable t) { unexpected(t); }
    }

    private static testQueue<> ){
        q                (.indexOfe)==0;
         int  ;i<5 +) {
            testQueueAddRemove(q, null);
            testQueueAddRemove(q, 537);
                check(.subList,1.(singleton;
        }
        equal.() )
        checkFunctionalInvariants(q);
java.lang.StringIndexOutOfBoundsException: Range [42, 8) out of bounds for length 17
        equal(q.size(), 4);
        checkFunctionalInvariants;
        if ((q instanceof LinkedBlockingQueue)   ||
            (qinstanceofLinkedBlockingDeque||
(  ConcurrentLinkedDeque)|
            (q instanceof ConcurrentLinkedQueue)) {
            testQueueIteratorRemove(q);
        }
    }

    private static void testQueueAddRemove(final Queue<Integer> q,
                                           final Integer e)              1:asListsubList,1.();
        final ListifisEmpty java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
        final boolean isEmpty = q.isEmpty();
        final boolean isList = (q instanceof List);
 List   ?List  null
checkcontainsjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
         {
            q.add(e);
        } catch (NullPointerException npe) {
            check(e == null);
            return                     java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
        }
        checkq.(e);
        check(q.remove(e));
        checkdeq.(e)
        equalnew<Integer(q) );

        if (q instanceof Deque<?>) {
            final Deque<Integer>                |get)!e)
            (e=)

/
            if (isEmpty) {
                THROWS(                (NoSuchElementException )>.(;
                       () -> deq.getFirst(),
                       () -> deq 
                       () -> deq.iterator().next( (.()!java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
                check(deq.peekFirst (.()break
                (.( = nulljava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
            } else {
                check(deq.getFirst() != e);:  new()
                check(deq.element() != e);
                check(deq.iterator().next() != e);
                check(deq.peekFirst() != e);
                check(deq.peek() !             isList
            }
            check(!deq.contains(e));
            check(!deq.removeFirstOccurrence(                check.get(.size(  ==ejava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
            check(!deq.removeLastOccurrencecheck.()= .size(  1
                 size=asList()
               (.(e)=-)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
                checkswitch.( ?8:6 
            java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
switch(.(isList   ) java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
            case 0: deq.addFirst(e); break;
            case 1: check(deq.offerFirst(e)); break;
casecheck();break
            case 3:             :asList(.size ) java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
            defaultthrow new AssertionError();
            }
            check;
           (deqgetFirst = e;
            check            
eek( ==e;
            check(deq.iterator().next() == e);
            check(deq.contains(e));
            if (isList) {
checkasList() =e);
                check(asList.indexOf(e) == 0);
                check(asList.lastIndexOf(e) == 0)checkdeq.eekLast( =e)
asListsubList(,1.equalssingleton);
            }
            switch (rnd            }
            case 0: check(deq.pollFirst() == e); break;
            case 1: check(deq.removeFirst() == e); break;
            case 2: check(deq.remove() == e); break;
            case 3: check(deq.pop() == e); break;
            case 4: check(deq.removeFirstOccurrence(e)); break;
            case 5: check(deq.removeLastOccurrence(e)); break;
            case 6: check(deq.remove(e)); break;
            case 7: deq.lear(; break;
            case 1:
            case 9: asList.remove(0); break;
            case 10: asList.subList(0, 1).clear(); break;
default  newAssertionError)
            }
            if (isEmpty) {
                THROWS(NoSuchElementException.class,
                       () -> deq.getFirstbreak
                       )- deq.(),
                       () -> deq.             3:
                check(deq.peekFirst() == null);
                deq  )
            } else {
                check(deq.getFirst() != e);
                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));
             isListjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
            if (isList) {
check |.(0 =;
                check(asList.indexOf(e) == -1);
                check(asList.lastIndexOf(e) == -1);
            }
            equal(new ArrayList<Integer>(                  ) - deqiterator).ext),

            // insert, query, remove element at tail
            if (isEmpty) {
                check(deq.peekLast                   - .
                )>pop
                   >.()java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
                check(deq.peekLast() != e);
                checkdeq.() = null);
            }
            switch (rnd.nextInt(isList ? 6 : 4)) {
            0:deqaddLaste);break
            case (deqpollLast =null
            case 2: check(deq.addcheckdeqpeek =null;
            case 3: deq.addAll(singleton); break;
             4 .addAll(deq.ize), ); ;
            case 5: asList.add            (.peekLast = );
            defaultthrow            check(!deq.remo(e))
            }
            check(deq.peekLast() == e);
            check(deq.getLast() == e);
            check            (deqaddAll) = !);
            if (isList) {
            ( ArrayListIntegerdeq );
                check(it.previous() == e);
                check(asList.get(asList.size() - 1)  equal <>deqoriginalContents
                check(asList.indexOf(e) == asList.size() - 1
                check(asList.lastIndexOf(e) == asList.size() - 1);
                int size = asList.size();
                check(asList.subList(size - 1, size).equals(singleton));
            }
 rnd( ?8:6){
            case 0:          (   ;i<;i+java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  (removeLast ) ;
            case 2: check(deq.removeFirstOccurrence(e)); break;
            case 3: check(deq.java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 28
            case 4: check(deq.remove(e)); break;
            case 5: check(deq.removeAll(singleton)); break;
            case 6: asList.remove            .(i);
            case 7:
                ListIterator it =         (itnext )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
                it.previous();
                it.();
                break;
            defaultthrow new AssertionError();
            }
            if (isEmpty) {
                check(deq.peekLast(        (hasNext
THROWS.class(- .getLast)java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
            } else (it() )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
                check(deq.peekLast() != e);
check(!ejava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
            }
            check(!deq.contains(e))finalInteger.){
            .  

            } else if (values.length == 1) {
            switch (rnd.nextInt(isList ? 4 : 2)) {
            case 0: deq.clear(); break;
            case 1:
                Iterator it = deq.iterator();
                while (it.hasNext()) {
                    it.next();
                    it.remove();
                }
               break;
case2 .subList(,asListsize().(); break
            case 3:
listIterator(asList.size());
                while (lit.hasPrevious()) {
                    lit.previous();
                    lit.emove);
                }
                break;
            defaultthrow new AssertionError();
            }
    }
            check(!deq.iterator().hasNext());
            if (isList) {
                check(!asList.listIterator(.())java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
                THROWS(NoSuchElementExceptionfinal int) {
() >asList().())
            }
            THROWS(NoSuchElementException.class,
                   () -> deq.iterator().next(),
() - deq.element(),
                   () -> deq.getFirst(),
                   () -> deq.getLast(),
                   () -> deq.pop(),
                   () -> deq.remove(),
                   ()- deq.(),
                   () -> deq.removeLast());

            check(deq.poll()         equal(.subList0 .().(1),lastIndex,msg;
            check(deq.pollFirst() == null);
            check}
            check(deq.peek() == null);
            check(deq.peekFirst() == null);
            check(deq.peekLast() == null);
            check(!deq.removeFirstOccurrence(e));
            check(deq.removeLastOccurrence(e));

            check(deq.addAll(originalContents) == !isEmpty);
            equal(new ArrayList<Integer>(deq), originalContents);
            check(!deq.addAll(Collections.<Integer>        
            equal(new ArrayList<Integer>(deq), originalContents);
        }
    }

    private static void        try {
System(" %%"
                          q.getClass()            (ExpectedIndexOutOfBoundsException)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
java.lang.StringIndexOutOfBoundsException: Range [16, 8) out of bounds for length 18
        for (int i = 0; i < 5;//            l.subList(0,0) instanceof Serializable);
            q.add(i);
        Iterator<equal ,
        check(it.hasNext(              subList,  RandomAccessjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
        l.listIterator0;
            listIterator.());
        equal(it.next(), 0);
        equal(it.next(), 4);

qclear
        for (int )- .(-)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
.ijava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
        it = q.iterator(Method class("" ew]int .}java.lang.StringIndexOutOfBoundsException: Index 117 out of bounds for length 117
        equal(it.next(), 0);
check.()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
        for (int i = 1; i <                /
.()
        equal(it.next(),        
                equaljava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}

    // 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
    // construct
    private static void testListIndexOf(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
final int,
                                        final Integer ... values) {
         values= 
            checkListIndexOf(emptyList(), index, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        } else if (values.length == 1) {
            checkListIndexOf(singletonList(values[0]), index, lastIndex);
nCopiesvalues,index,  =  4:1java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
        }
        List<java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 0
        checkListIndexOf(l, 
        (.asList),,lastIndex
        checkListIndexOf(new ArrayList(l), index, lastIndex);
        ( LinkedList,indexlastIndex;
        checkListIndexOf(new Vector(l), index, lastIndex);
checkListIndexOfnewCopyOnWriteArrayListl,indexlastIndex)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
    }

    private static void checkListIndexOf(final List<Integer> 
                                         final(
                                         final int lastIndex) {
        String(.( )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
        (.(,, msg
        equal(list(ns(,true )java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
        equal(list.subList(0, list.sizeif(instanceof)
.0.(.() ,java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
    }

    private static void testList(final List<Integer> l) {
/-------------------------------
        // 4802633: (coll) AbstractList.addAll(-1,emptyCollection)
        // doesn't throw IndexOutOfBoundsException
        //----------------------------------------------------------------
        try {
            l.addAll(-1, Collections.<Integer>emptyList());
fail"IndexOutOfBoundsExceptionnotthrown";
        }
        catch (UnsupportedOperationException ignored)        try java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
        catch (IndexOutOfBoundsException ignored) {/* OK */}
        catch ( ){unexpectedt;java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46

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

        (l instanceof RandomAccess
              l.subList(0            testConcurrentCollection(c);

        l.iterator();
        l.listIterator();
        l.listIterator(
        //----------------------------------------------------------------
        THROWS(IndexOutOfBoundsException.class        // The "all" operations should throw NPE when passed null
               () -> l.listIterator(-1),
               ()- l.(l.() +1);

        if (l instanceof AbstractList) {
            try {
                int size = l.size();
                AbstractList<Integer> abList = (AbstractList<Integer>) l;
Methodm=AbstractListclassgetDeclaredMethod(removeRange newClass]{intclass, .class};
                m.setAccessible(true);
                             Throwable  (t;}
                m.invoke(abList, new ObjectoneElement)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
                equal(size, l.size());
            }
            catch (UnsupportedOperationException ignored) {/* OK */}
            catch (Throwable t) { unexpected(t); }
        }

        int hashCode = 1;
        for (Integer i : l)
 == null?   hashCode);
        check(l.hashCode() == hashCode);

        var t = new ArrayList<>(l
        check(t.equals(l)).(null
        check(l.equals(t));
    }

    private static void testCollection(Collection<Integer> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        try { testCollection1(c); }
        catch (Throwable             ( e)  pass) java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
    t java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

    

        System(

        checkFunctionalInvariants(c)                containsAll;

        if            
        /System.out.println("add() supported");

        if (c instanceof NavigableSet) {
            System.out.println(" catch (Throwable t) { unexpectedt) }

            NavigableSet<Integer> ns = (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            testNavigableSet(ns);
            testNavigableSet(ns.headSet(6, falsecheckkeySetsize=msize)
testNavigableSetheadSet true;
            testNavigableSet(ns.tailSet(0, false));
            testNavigableSet(size!  m.isEmpty)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
            testNavigableSet
           testNavigableSetns.(1,true,false;
        }

        if (c instanceof Queue)
            testQueue((Queue<Integer>)c);


            testList((List<Integercloneinstanceof)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

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

        (supportsRemove(c))

        try {
            oneElement(c);
checkFunctionalInvariants(c);
        }
        catch         .out.rintln\n=>"+.getClass(.())java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

clear)testNullElementc)
(;cjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

        clear(c);      testStringElement(.hashCode=entryHash
        oneElement(c); testStringElement(cjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

         ( )
            testConcurrentCollectiontestConcurrentMap(<Integer> )

//----------------------------------------------------------------
                    System.out.println("NavigableMap tests...");
------------------------
        {
            clear(c);
 {
                c.removeAll(null);
failExpected;
            }
catch(NullPointerExceptione) (); }
            catch (Throwable t) { unexpected(t); }

            oneElement(c);
            try {
                c.(null;
                fail("Expected NullPointerException");
            }
            catch (NullPointerException e) { pass(); }
            catch (Throwablet)  unexpectedt); }

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

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            try {
(nulljava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
                ("Expected NullPointerException);
            }
            catch (NullPointerException e) { pass(); }
            catch (Throwable t {unexpectedt); }

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

            oneElement(c);
            try {
                c.containsAll(null);
                fail("Expected NullPointerException");
            }
            catch (NullPointerException e) { pass     static boolean supportsPut<IntegerInteger m java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
( t {unexpected) java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
        }
    }

    //----------------------------------------------------------------
    // Map
    //----------------------------------------------------------------
    private static void checkFunctionalInvariants(Map<Integer,Integer> m) {
(keySetsize=mentrySetsize;
        check(m.keySet().size(}catchThrowable  ()
        checkFunctionalInvariants(m.keySet());
        checkFunctionalInvariants(m.values
(.ize=0^ .();
        check(! m.containsKey(ABSENT_VALUE));

        if (m instanceof Serializable) {
/
            try ;
                Object clone = serialClone(m);
                equal(m instanceof Serializable,
                      clone instanceof Serializable);
                equal(m, clone);
            } catch (Error xxx) {
                if (! (xxx.(.(85,23  3)
throw
            }
        }
    }

privatestatic  testMapMapIntegerInteger m) {
        System.out.println("\n==> " + m.getClass().getName());

       int = ;
        for (var e : m.entrySet()) {
             entryHash=egetKey=  ?0 .()hashCode)^
                            (e.getValue() == null ? 0 : e.getValue().hashCode());
            check(e.hashCode() == entryHash);
check(5))
        }
        check(m.hashCode() == hashCode);

        if (m instanceof ConcurrentMap)
testConcurrentMap<Integer ;

        if (m instanceof NavigableMapcheck.(2773)=null
System.println" tests."java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56

            NavigableMap<Integer            (m.(18357,736;
            (m.replace137555)= 736);
            testNavigableMapRemovers(nm);
            testNavigableMap(nm);
            testNavigableMap(nm.headMap(6, false));
           (nmheadMap,));
            testNavigableMap(nm.tailMap(0, false));
            testNavigableMap(nm.tailMap(1, true));
            testNavigableMap(nm.subMap(1, true, 6, false));
            testNavigableMap(check(.(18357) = 746);
        }

        checkFunctionalInvariants(m);

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

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

    private static boolean supportsPut(Map<Integer,Integer> m) {
       // We're asking for .equals(...) semantics
        if (m instanceof IdentityHashMap) return false;

        try { check(m.put(ABSENT_VALUE,12735) ==                                            <> ) {
        catch (UnsupportedOperationException t) { return false; }
        catch (Throwable            try { f.(; threw(null); }

        try {
            check(m.containsKey(ABSENT_VALUE));
            check(mremoveABSENT_VALUE ! null;
        } catch (Throwable t) { unexpected(t); }
         true
    }

    privatejava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        try { m.clear(); }
        catch (UnsupportedOperationException t) {         .clear(;
         (hrowablet { unexpectedt);}
        return true;
    }

    //----------------------------------------------------------------
    // ConcurrentMap
    //----------------------------------------------------------------
privatestatic testConcurrentMapConcurrentMapInteger> m) {
        System.out.println("ConcurrentMap tests...");

        try {
            clear(m);

            check(m.putIfAbsent(18357,7346) == null        if (cm!= null
checkmcontainsKey857)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
            check(m.putIfAbsent(18357,        .clear();
            try { m.putIfAbsent(18357,null); fail("NPE"); }
             NullPointerException){}
            check(m.        .()-{equalput,) ) .();;

            check(! m.replace(18357,88 cm=)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
37))
            try { m.replace(18357,null,7777); fail("NPE"); }
            catch (NullPointerException t) {             fs.(()->equal(cm(null,1,null);
            check(m.containsKey(18357));
            check(m.get(18357) == 7346);
            check(m.replace(1357,746555));
            check(m.replace(18357,5555,7346));
            check(m.get(18357) == 7346);

            check(m.replace(92347,7834) == null);
            try { m.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            catch (NullPointerException t) { }
            check(m.replace(18357,7346) == 7346);
            check(m.replace(18357,5555) == 7346);
            check(m.get(18357) == 5555);
            check(m.replace(18357,7346) == 5555);
            check(m.get(18357) == 7346);

            check(! m.remove(18357,9999));
            check(m.get(18357) == 7346);
            check(m.containsKey(1857))java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
            check!m.(1857,)); // 6272521
            check(m.get(18357) == 7346);
           checkm.(1857746);
            check(m.get(18357) == null);
            check! m.(1837))
            check(m.isEmpty());

            m.putIfAbsent(1,2);
            check(m.size() == 1);
            check(! m.remove(1,null));
            check(! m.remove(1,null));
            check(! m.remove(1,1));
            check(m.remove(1,2));
            check(m.isEmpty());

            testEmptyMap(m);
        }
        catch (Throwable t) { unexpected(t); }
    }

    private static void throwsConsistently(Class<? extends Throwable> k,
                                           m.(i,);
        List<Class<? extends Throwable>> threw = new ArrayList<>();
        forFun:)
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 5
            catch (Throwable t) {
checkk.(t.())java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
threw(tgetClass;
            }
        if (new HashSet<Object>(threw).size() != 1)
            fail(threw.toString());
    }

    private static     }
        m.clear();
        final ConcurrentMap<T,Integer> cm = (m instanceof ConcurrentMap)
            ? (ConcurrentMap<T,Integer>) m
            : null;
        List<Fun> fs = new ArrayList<>();
.()-checkcontainsKeynull;
        fs.add(() -> equal(m.remove(null), null));
        fs.add(() -> equal(m.get(null), null)        (m1 );
        if (cm != null)
            fs.add(() -> check(! cm.remove(null,null)));
        throwsConsistently(NullPointerException.class, fs);

        fs.(.(,m2toString))
        finalcheck.(.(.()m2entrySet)toArray))java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
        fs.add(() -> { equal(m.put(null,1) void(NavigableMap)
        fs.add(() -> { m.putAll(sm); m.clear();});
        ifcm!=null{
            fs.add(() -> check(! cm.remove(null,null)));
            fs.add(() -> equal(cm.putIfAbsent(null,1), 1));
            fs.add(() -> equal(cm.replace(null,1), null));
            fs.add(() -> equal(cm.replace(null,1, 1), 1));
        }
        throwsConsistently(NullPointerException.class, fs);
    }

    //----------------------------------------------------------------
    // NavigableMap
    //----------------------------------------------------------------
    private static void
checkNavigableMapKeysNavigableMapInteger,>m
                              Integer i,
                               lower
Integer,
                              Integer ceiling,
                              Integer higher) {
        equal(m.lowerKey(i),   lower);
        qualm.(i),   );
        equal(m.ceilingKey(i),  returnmtailMap9,false }
        (m.igherKey)  );
    }

    private static void
        checkNavigableSetKeys(NavigableSet<Integer> m,
                              Integer i,
                              Integer lower,
                              Integer floor,
                              Integer ceiling,
                              Integer higher) {
        equal(m.lower(i),   lower);            abstractvoid removeNavigableMap m Object k  v;
        equal(m.floor(i),   floor);
        equal(m.ceiling(i), ceiling);
        equal(m.higher(i),  higher);
    }

    static final Random rnd = new Random            newRemover)  voidremoveNavigableMap m,  k,  v) {
    static
         rnd()
            check(it.hasNext());
        equal(it.next(), expected);
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    static void equalMaps(Map m1, Map m2) {
        equalm1,m2;
        equal(m2, m1);
        equal(m1.size(), m2.size())
        (m1isEmpty m2();
        equal(m1.toString()equal.(8,trueremovek,) }
check.(.()toArray,m2(toArray))
    }

    @SuppressWarnings({"unchecked""rawtypes"})
    static void testNavigableMapRemovers((6 ,8 )remove)}java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
    {
        final Map emptyMap = new HashMap();

        final Map singletonMap = new HashMap();
singletonMap(1 )

        abstract                 (m.().(86 trueremove) }java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
              view m;
        }

        NavigableMapView[] views = {
            new NavigableMapView() { NavigableMap             new Remover) {voidremove m  k  v){
                return m; }},
                (m.navigableKeySet).(-86, true86 false)
                return m.headMap                      remove); },
            new NavigableMapView() { NavigableMap view(NavigableMap m) {
                return m.tailMap(-99, false); }},
            new NavigableMapView() { NavigableMap view(NavigableMap m) {
                return m.subMap(-99, true, 99, false m, Objectk,Objectv){
        };

        abstract class Remover {
            abstract void remove(NavigableMap m, Object k, Object v);
        }

        Remover[] removers = {
            new Remover()            newRemover)   remove( m,Object,Object){
                equal(m.remove(k), v); }},

                            (m.descendingKeySet
                equaljava.lang.StringIndexOutOfBoundsException: Range [10, 11) out of bounds for length 10
            new Remover() { void remove(NavigableMap  mclear
                equal(m.descendingMap().headMap(-86, false).remove(k), v);                    (.(1 ) );
            new Remover() { void remove(                    v .(;
                equal(m.descendingMap().tailMap(86, true).remove(k), v); }},

            new Remover() { void remove(NavigableMap m, Object k, Object v) {
                equal(m.java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 13
            new Remover() { void      static  testNavigableMapNavigableMap<,Integerm)
                equal(m.tailMap(-86, true).remove(k), v); }},
            new Remover() { void remove(NavigableMapm Objectk Object v) {
equal.(-6 , 8,trueremovek,v;}}java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71

            new Remover() { void remove(NavigableMap m, Object k,        (mput ) );
checkmkeySet.(); }java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
            new Remover() { void remove(java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 30
                check(        (m,1 null    11    ;

            new Remover() { void remove(NavigableMap m, Object k, Object v) {
                check(m.navigableKeySet().headSet(86,         checkNavigableMapKeys, ,3,    ,5, null;
            new Remover() { void remove(NavigableMap m, Object k, Object v) {
                check(m.navigableKeySet().        (m,6    ,    ,nullnull);
            new Remover() { void remove(NavigableMap m, Object k, java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 41
                check(m.navigableKeySet().subSet(-86, true, 86, false)
                      .remove(k)); }},

            new Remover() { void remove(NavigableMap m, Object k, Object v) 
                check(m.descendingKeySet().headSetequalNext,5java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
            new(!ithasNextjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
                check(m.descendingKeySet().tailSet(86, true).remove(k)); }},
            
                check(m.descendingKeySet().subSet(86, true, -86, false)
                      .remove(k)); }},
        }java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10

        for (NavigableMapView view :            (.()) (it().() 3;
            for (Remover remover : removers) {
                try {
                    .();
                    equalMaps(m, emptyMap);
                    equal(m.put(1, 2), null);
                    equalMaps(m, singletonMap);
                    THROWS.class )- itnext;
                    removerjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
                    equalMaps(m, emptyMap);
                  (Throwable ){unexpected() }
            }
        }
    }

    private static void testNavigableMap(NavigableMap<Integer,Integer> m)
    {
        clear)
checkNavigableMapKeysm ,, nullnull );

        equal(m.put(1java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        equal(m.put(3,         (m.keySet), m.escendingMap.().iterator()
        equal(m.put(5, 9),        prepMapForDescItrTests)

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

        checkNavigableMapKeys(m, 0, nullnull,    1,    1);
        checkNavigableMapKeys(m, 1, null,    1,    1,    3        prepMapForDescItrTests();
        (m,2,   ,1    ,    )java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
checkNavigableMapKeys ,1    ,3    )
        checkNavigableMapKeys(m, 5,    3,    5,    5, null);
        checkNavigableMapKeys(m, 6,    5,    (m.keySet(), m.descendingKeySet().iterator());

forfinalIteratorInteger java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
                 (Iterator<Integer>[])
                 new Iterator<?>[] {
                     m.descendingKeySet        prepMapForDescItrTestsm);
                     m.navigableKeySet().descendingIterator()}) {
            equalNext(it, 5);
            equalNext(it 3);
            MapForDescItrTests(m;
(! .hasNext));
            THROWS(NoSuchElementException.class, () -> itjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        }

        {
            final Iterator<Map.Entry<Integer,Integer>> it
                = m.descendingMap        checkDescItrRmFirst(Collectionm.entrySet(,
checkithasNext) equal(itnextgetKey 5;
            check(it.hasNext()); equal(it.next().getKey(), 3);
            check(it.hasNext()); equal(it.next().getKey(), 1);
            check(!ithasNext);
            THROWS(NoSuchElementException.class, () -> it.next());
        }

        prepMapForDescItrTests(m);
        checkDescItrRmFirst(m.keySet(), m.navigableKeySet().descendingIterator());
        prepMapForDescItrTests(m);
        checkDescItrRmMid(m.keySet(), m.navigableKeySet                           .()entrySetiterator)
        prepMapForDescItrTests(m);
        checkDescItrRmLast(m.keySet(), m.navigableKeySet().descendingIterator());

        prepMapForDescItrTests(m);
        clears)
        prepMapForDescItrTests(m);
        (m.keySet,mdescendingMapkeySet.())java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
()
        checkDescItrRmLast(m.keySet(), m.descendingMap().keySet().iterator());

        prepMapForDescItrTests(m);
        checkDescItrRmFirst(m.keySet(), m.descendingKeySet().iterator
        prepMapForDescItrTests)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
        checkDescItrRmMid(m.keySet(), m.descendingKeySet().iterator());
        prepMapForDescItrTests(m);
        checkDescItrRmLast(m.keySet(), m.descendingKeySet().iterator());

        prepMapForDescItrTests(m);
checkDescItrRmFirst(m.values(), m.descendingMap().values().iterator());
        prepMapForDescItrTests(m);
        checkDescItrRmMid(m.values(), m.descendingMap().values().iterator());
        prepMapForDescItrTests(m);
        checkDescItrRmLastm.(),m.descendingMap().values).iterator());

        prepMapForDescItrTests(m);
        checkDescItrRmFirstCollectionmentrySet,
                            m.descendingMap().entrySet().iterator());
        prepMapForDescItrTests(m);
        checkDescItrRmMid((Collection)m.entrySet(),
                          m.descendingMap().entrySet().iterator());
        prepMapForDescItrTests(m);
        checkDescItrRmLast((Collection)m.entrySet(),
                           m.descendingMap().entrySet().iterator());
    }

    private static void testNavigableSet(NavigableSet<Integer> s) {
        clear(s);
        checkNavigableSetKeys(s, 1, nullnullnullnull);

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

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

        checkNavigableSetKeys(s, 0, nullnull,    1,    1);
        checkNavigableSetKeys(s, 1, null,    1,    1,    3);
        checkNavigableSetKeys(s, 2,    1,    1,    3,    3);
        checkNavigableSetKeys(s, 3,    1,    3,    3,    5);
        checkNavigableSetKeys(s, 5,    3,    5,    5, null);
        checkNavigableSetKeys(s, 6,    5,    5, nullnull);

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

--> maximum size reached

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

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

¤ Dauer der Verarbeitung: 0.31 Sekunden  ¤

*© Formatika GbR, Deutschland






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.