Fix whitespace (Checkstyle WhitespaceAround)
This commit is contained in:
parent
765f381bb1
commit
f4ecabd9ac
|
@ -59,6 +59,7 @@ limitations under the License.
|
||||||
<module name="RightCurly"/>
|
<module name="RightCurly"/>
|
||||||
<module name="GenericWhitespace"/>
|
<module name="GenericWhitespace"/>
|
||||||
<module name="WhitespaceAfter"/>
|
<module name="WhitespaceAfter"/>
|
||||||
|
<module name="WhitespaceAround"/>
|
||||||
<module name="NoWhitespaceBefore"/>
|
<module name="NoWhitespaceBefore"/>
|
||||||
<module name="Indentation">
|
<module name="Indentation">
|
||||||
<!-- Indentation style recommended by Oracle -->
|
<!-- Indentation style recommended by Oracle -->
|
||||||
|
|
|
@ -263,5 +263,8 @@ public class BagUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private BagUtils() {}
|
private BagUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,6 +370,8 @@ public class ClosureUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private ClosureUtils() {}
|
private ClosureUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2151,5 +2151,7 @@ public class CollectionUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private CollectionUtils() {}
|
private CollectionUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,6 +238,8 @@ public class ComparatorUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private ComparatorUtils() {}
|
private ComparatorUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,8 @@ public class FactoryUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private FactoryUtils() {}
|
private FactoryUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1438,6 +1438,8 @@ public class IteratorUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private IteratorUtils() {}
|
private IteratorUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -744,5 +744,8 @@ public class ListUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private ListUtils() {}
|
private ListUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,8 @@ public class MultiMapUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private MultiMapUtils() {}
|
private MultiMapUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,8 @@ public class MultiSetUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private MultiSetUtils() {}
|
private MultiSetUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,7 +380,7 @@ public class PredicateUtils {
|
||||||
* @throws NullPointerException if the predicate is null.
|
* @throws NullPointerException if the predicate is null.
|
||||||
* @see NullIsExceptionPredicate
|
* @see NullIsExceptionPredicate
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> nullIsExceptionPredicate(final Predicate<? super T> predicate){
|
public static <T> Predicate<T> nullIsExceptionPredicate(final Predicate<? super T> predicate) {
|
||||||
return NullIsExceptionPredicate.nullIsExceptionPredicate(predicate);
|
return NullIsExceptionPredicate.nullIsExceptionPredicate(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ public class PredicateUtils {
|
||||||
* @throws NullPointerException if the predicate is null.
|
* @throws NullPointerException if the predicate is null.
|
||||||
* @see NullIsFalsePredicate
|
* @see NullIsFalsePredicate
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> nullIsFalsePredicate(final Predicate<? super T> predicate){
|
public static <T> Predicate<T> nullIsFalsePredicate(final Predicate<? super T> predicate) {
|
||||||
return NullIsFalsePredicate.nullIsFalsePredicate(predicate);
|
return NullIsFalsePredicate.nullIsFalsePredicate(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ public class PredicateUtils {
|
||||||
* @throws NullPointerException if the predicate is null.
|
* @throws NullPointerException if the predicate is null.
|
||||||
* @see NullIsTruePredicate
|
* @see NullIsTruePredicate
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> nullIsTruePredicate(final Predicate<? super T> predicate){
|
public static <T> Predicate<T> nullIsTruePredicate(final Predicate<? super T> predicate) {
|
||||||
return NullIsTruePredicate.nullIsTruePredicate(predicate);
|
return NullIsTruePredicate.nullIsTruePredicate(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,8 +486,7 @@ public class PredicateUtils {
|
||||||
* @see TransformedPredicate
|
* @see TransformedPredicate
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> transformedPredicate(
|
public static <T> Predicate<T> transformedPredicate(final Transformer<? super T, ? extends T> transformer, final Predicate<? super T> predicate) {
|
||||||
final Transformer<? super T, ? extends T> transformer, final Predicate<? super T> predicate) {
|
|
||||||
return TransformedPredicate.transformedPredicate(transformer, predicate);
|
return TransformedPredicate.transformedPredicate(transformer, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,6 +520,8 @@ public class PredicateUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private PredicateUtils() {}
|
private PredicateUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,8 +113,7 @@ public class QueueUtils {
|
||||||
* @return a transformed queue backed by the given queue
|
* @return a transformed queue backed by the given queue
|
||||||
* @throws NullPointerException if the queue or transformer is null
|
* @throws NullPointerException if the queue or transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Queue<E> transformingQueue(final Queue<E> queue,
|
public static <E> Queue<E> transformingQueue(final Queue<E> queue, final Transformer<? super E, ? extends E> transformer) {
|
||||||
final Transformer<? super E, ? extends E> transformer) {
|
|
||||||
return TransformedQueue.transformingQueue(queue, transformer);
|
return TransformedQueue.transformingQueue(queue, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,5 +132,7 @@ public class QueueUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private QueueUtils() {}
|
private QueueUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -652,5 +652,8 @@ public class SetUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private SetUtils() {}
|
private SetUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,8 @@ public class SplitMapUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private SplitMapUtils() {}
|
private SplitMapUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,6 +480,8 @@ public class TransformerUtils {
|
||||||
/**
|
/**
|
||||||
* This class is not normally instantiated.
|
* This class is not normally instantiated.
|
||||||
*/
|
*/
|
||||||
private TransformerUtils() {}
|
private TransformerUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ public class TrieUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private TrieUtils() {}
|
private TrieUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1969,13 +1969,13 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
||||||
* @throws ClassNotFoundException if an object read from the stream can not be loaded
|
* @throws ClassNotFoundException if an object read from the stream can not be loaded
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // This will fail at runtime if the stream is incorrect
|
@SuppressWarnings("unchecked") // This will fail at runtime if the stream is incorrect
|
||||||
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException{
|
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||||
stream.defaultReadObject();
|
stream.defaultReadObject();
|
||||||
rootNode = new Node[2];
|
rootNode = new Node[2];
|
||||||
final int size = stream.readInt();
|
final int size = stream.readInt();
|
||||||
for (int i = 0; i < size; i++){
|
for (int i = 0; i < size; i++) {
|
||||||
final K k =(K) stream.readObject();
|
final K k = (K) stream.readObject();
|
||||||
final V v =(V) stream.readObject();
|
final V v = (V) stream.readObject();
|
||||||
put(k, v);
|
put(k, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2224,7 +2224,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
||||||
* @param stream the output stream
|
* @param stream the output stream
|
||||||
* @throws IOException if an error occurs while writing to the stream
|
* @throws IOException if an error occurs while writing to the stream
|
||||||
*/
|
*/
|
||||||
private void writeObject(final ObjectOutputStream stream) throws IOException{
|
private void writeObject(final ObjectOutputStream stream) throws IOException {
|
||||||
stream.defaultWriteObject();
|
stream.defaultWriteObject();
|
||||||
stream.writeInt(this.size());
|
stream.writeInt(this.size());
|
||||||
for (final Entry<K, V> entry : entrySet()) {
|
for (final Entry<K, V> entry : entrySet()) {
|
||||||
|
|
|
@ -166,7 +166,7 @@ public interface BloomFilter extends IndexProducer, BitMapProducer {
|
||||||
estimate = Math.round(eThis + eOther - eUnion);
|
estimate = Math.round(eThis + eOther - eUnion);
|
||||||
estimate = estimate < 0 ? 0 : estimate;
|
estimate = estimate < 0 ? 0 : estimate;
|
||||||
}
|
}
|
||||||
return estimate>Integer.MAX_VALUE?Integer.MAX_VALUE:(int) estimate;
|
return estimate > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) estimate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,6 +42,10 @@ final class IndexUtils {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not instantiate
|
/**
|
||||||
private IndexUtils() {}
|
* Don't instantiate.
|
||||||
|
*/
|
||||||
|
private IndexUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,10 @@ public class LayerManager<T extends BloomFilter> implements BloomFilterProducer
|
||||||
* A Cleanup that never removes anything.
|
* A Cleanup that never removes anything.
|
||||||
* @return A Consumer suitable for the LayerManager {@code cleanup} parameter.
|
* @return A Consumer suitable for the LayerManager {@code cleanup} parameter.
|
||||||
*/
|
*/
|
||||||
public static <T extends BloomFilter> Consumer<Deque<T>> noCleanup() {
|
public static <T extends BloomFilter> Consumer<Deque<T>> noCleanup() {
|
||||||
return x -> {};
|
return x -> {
|
||||||
|
// empty
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,7 +45,7 @@ import java.util.Comparator;
|
||||||
public class ComparableComparator<E extends Comparable<? super E>> implements Comparator<E>, Serializable {
|
public class ComparableComparator<E extends Comparable<? super E>> implements Comparator<E>, Serializable {
|
||||||
|
|
||||||
/** Serialization version. */
|
/** Serialization version. */
|
||||||
private static final long serialVersionUID=-291439688585137865L;
|
private static final long serialVersionUID = -291439688585137865L;
|
||||||
|
|
||||||
/** The singleton instance. */
|
/** The singleton instance. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
|
||||||
*
|
*
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
*/
|
*/
|
||||||
public Predicate<? super I> getPredicate(){
|
public Predicate<? super I> getPredicate() {
|
||||||
return iPredicate;
|
return iPredicate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public O transform(final I input) {
|
public O transform(final I input) {
|
||||||
if (iPredicate.evaluate(input)){
|
if (iPredicate.evaluate(input)) {
|
||||||
return iTrueTransformer.transform(input);
|
return iTrueTransformer.transform(input);
|
||||||
}
|
}
|
||||||
return iFalseTransformer.transform(input);
|
return iFalseTransformer.transform(input);
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
||||||
throw new IllegalArgumentException("The predicate and closure arrays must be the same size");
|
throw new IllegalArgumentException("The predicate and closure arrays must be the same size");
|
||||||
}
|
}
|
||||||
if (predicates.length == 0) {
|
if (predicates.length == 0) {
|
||||||
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>nopClosure(): defaultClosure);
|
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>nopClosure() : defaultClosure);
|
||||||
}
|
}
|
||||||
return new SwitchClosure<>(predicates, closures, defaultClosure);
|
return new SwitchClosure<>(predicates, closures, defaultClosure);
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ public class FilterListIterator<E> implements ListIterator<E> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
return nextIndex-1;
|
return nextIndex - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Not supported. */
|
/** Not supported. */
|
||||||
|
|
|
@ -492,10 +492,8 @@ public class LRUMap<K, V>
|
||||||
reuseEntry(entry, hashIndex, hashCode, key, value);
|
reuseEntry(entry, hashIndex, hashCode, key, value);
|
||||||
addEntry(entry, hashIndex);
|
addEntry(entry, hashIndex);
|
||||||
} catch (final NullPointerException ex) {
|
} catch (final NullPointerException ex) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("NPE, entry=" + entry + " entryIsHeader=" + (entry == header) + " key=" + key + " value=" + value + " size=" + size
|
||||||
"NPE, entry=" + entry + " entryIsHeader=" + (entry==header) +
|
+ " maxSize=" + maxSize + " This should not occur if your keys are immutable, and you have used synchronization properly.");
|
||||||
" key=" + key + " value=" + value + " size=" + size + " maxSize=" + maxSize +
|
|
||||||
" This should not occur if your keys are immutable, and you have used synchronization properly.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,11 +264,11 @@ public class SequencesComparator<T> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int delta = m - n;
|
final int delta = m - n;
|
||||||
final int sum = n + m;
|
final int sum = n + m;
|
||||||
final int offset = (sum % 2 == 0 ? sum : sum + 1) / 2;
|
final int offset = (sum % 2 == 0 ? sum : sum + 1) / 2;
|
||||||
vDown[1+offset] = start1;
|
vDown[1 + offset] = start1;
|
||||||
vUp[1+offset] = end1 + 1;
|
vUp[1 + offset] = end1 + 1;
|
||||||
|
|
||||||
for (int d = 0; d <= offset; ++d) {
|
for (int d = 0; d <= offset; ++d) {
|
||||||
// Down
|
// Down
|
||||||
|
@ -276,10 +276,10 @@ public class SequencesComparator<T> {
|
||||||
// First step
|
// First step
|
||||||
|
|
||||||
final int i = k + offset;
|
final int i = k + offset;
|
||||||
if (k == -d || k != d && vDown[i-1] < vDown[i+1]) {
|
if (k == -d || k != d && vDown[i - 1] < vDown[i + 1]) {
|
||||||
vDown[i] = vDown[i+1];
|
vDown[i] = vDown[i + 1];
|
||||||
} else {
|
} else {
|
||||||
vDown[i] = vDown[i-1] + 1;
|
vDown[i] = vDown[i - 1] + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = vDown[i];
|
int x = vDown[i];
|
||||||
|
@ -290,8 +290,8 @@ public class SequencesComparator<T> {
|
||||||
++y;
|
++y;
|
||||||
}
|
}
|
||||||
// Second step
|
// Second step
|
||||||
if (delta % 2 != 0 && delta - d <= k && k <= delta + d && vUp[i-delta] <= vDown[i]) { // NOPMD
|
if (delta % 2 != 0 && delta - d <= k && k <= delta + d && vUp[i - delta] <= vDown[i]) { // NOPMD
|
||||||
return buildSnake(vUp[i-delta], k + start1 - start2, end1, end2);
|
return buildSnake(vUp[i - delta], k + start1 - start2, end1, end2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,17 +299,15 @@ public class SequencesComparator<T> {
|
||||||
for (int k = delta - d; k <= delta + d; k += 2) {
|
for (int k = delta - d; k <= delta + d; k += 2) {
|
||||||
// First step
|
// First step
|
||||||
final int i = k + offset - delta;
|
final int i = k + offset - delta;
|
||||||
if (k == delta - d
|
if (k == delta - d || k != delta + d && vUp[i + 1] <= vUp[i - 1]) {
|
||||||
|| k != delta + d && vUp[i+1] <= vUp[i-1]) {
|
vUp[i] = vUp[i + 1] - 1;
|
||||||
vUp[i] = vUp[i+1] - 1;
|
|
||||||
} else {
|
} else {
|
||||||
vUp[i] = vUp[i-1];
|
vUp[i] = vUp[i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = vUp[i] - 1;
|
int x = vUp[i] - 1;
|
||||||
int y = x - start1 + start2 - k;
|
int y = x - start1 + start2 - k;
|
||||||
while (x >= start1 && y >= start2
|
while (x >= start1 && y >= start2 && equator.equate(sequence1.get(x), sequence2.get(y))) {
|
||||||
&& equator.equate(sequence1.get(x), sequence2.get(y))) {
|
|
||||||
vUp[i] = x--;
|
vUp[i] = x--;
|
||||||
y--;
|
y--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2061,11 +2061,11 @@ public abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K,
|
||||||
* Reads the content of the stream.
|
* Reads the content of the stream.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // This will fail at runtime if the stream is incorrect
|
@SuppressWarnings("unchecked") // This will fail at runtime if the stream is incorrect
|
||||||
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException{
|
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||||
stream.defaultReadObject();
|
stream.defaultReadObject();
|
||||||
root = new TrieEntry<>(null, null, -1);
|
root = new TrieEntry<>(null, null, -1);
|
||||||
final int size = stream.readInt();
|
final int size = stream.readInt();
|
||||||
for (int i = 0; i < size; i++){
|
for (int i = 0; i < size; i++) {
|
||||||
final K k = (K) stream.readObject();
|
final K k = (K) stream.readObject();
|
||||||
final V v = (V) stream.readObject();
|
final V v = (V) stream.readObject();
|
||||||
put(k, v);
|
put(k, v);
|
||||||
|
@ -2434,7 +2434,7 @@ public abstract class AbstractPatriciaTrie<K, V> extends AbstractBitwiseTrie<K,
|
||||||
/**
|
/**
|
||||||
* Writes the content to the stream for serialization.
|
* Writes the content to the stream for serialization.
|
||||||
*/
|
*/
|
||||||
private void writeObject(final ObjectOutputStream stream) throws IOException{
|
private void writeObject(final ObjectOutputStream stream) throws IOException {
|
||||||
stream.defaultWriteObject();
|
stream.defaultWriteObject();
|
||||||
stream.writeInt(this.size());
|
stream.writeInt(this.size());
|
||||||
for (final Entry<K, V> entry : entrySet()) {
|
for (final Entry<K, V> entry : entrySet()) {
|
||||||
|
|
|
@ -31,12 +31,10 @@ import org.junit.jupiter.api.Test;
|
||||||
/**
|
/**
|
||||||
* Tests base {@link java.util.LinkedList} methods and contracts.
|
* Tests base {@link java.util.LinkedList} methods and contracts.
|
||||||
* <p>
|
* <p>
|
||||||
* To use, simply extend this class, and implement
|
* To use, simply extend this class, and implement the {@link #makeObject()} method.
|
||||||
* the {@link #makeObject()} method.
|
|
||||||
* <p>
|
* <p>
|
||||||
* If your {@link LinkedList} fails one of these tests by design,
|
* If your {@link LinkedList} fails one of these tests by design, you may still use this base set of cases. Simply override the test case (method) your
|
||||||
* you may still use this base set of cases. Simply override the
|
* {@link List} fails.
|
||||||
* test case (method) your {@link List} fails.
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
|
|
||||||
|
@ -45,9 +43,9 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link #collection} field cast to a {@link LinkedList}.
|
* Returns the {@link #collection} field cast to a {@link LinkedList}.
|
||||||
*
|
*
|
||||||
* @return the collection field as a List
|
* @return the collection field as a List
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<T> getCollection() {
|
public LinkedList<T> getCollection() {
|
||||||
|
@ -55,16 +53,16 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link #confirmed} field cast to a {@link LinkedList}.
|
* Returns the {@link #confirmed} field cast to a {@link LinkedList}.
|
||||||
*
|
*
|
||||||
* @return the confirmed field as a List
|
* @return the confirmed field as a List
|
||||||
*/
|
*/
|
||||||
protected LinkedList<T> getConfirmedLinkedList() {
|
protected LinkedList<T> getConfirmedLinkedList() {
|
||||||
return (LinkedList<T>) getConfirmed();
|
return (LinkedList<T>) getConfirmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an empty {@link LinkedList}.
|
* Returns an empty {@link LinkedList}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<T> makeConfirmedCollection() {
|
public Collection<T> makeConfirmedCollection() {
|
||||||
|
@ -72,7 +70,7 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a full {@link LinkedList}.
|
* Returns a full {@link LinkedList}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<T> makeConfirmedFullCollection() {
|
public Collection<T> makeConfirmedFullCollection() {
|
||||||
|
@ -83,7 +81,7 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
public abstract LinkedList<T> makeObject();
|
public abstract LinkedList<T> makeObject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link LinkedList#addFirst(Object)}.
|
* Tests {@link LinkedList#addFirst(Object)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -105,7 +103,7 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link LinkedList#addLast(Object)}.
|
* Tests {@link LinkedList#addLast(Object)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -127,43 +125,39 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link LinkedList#getFirst()}.
|
* Tests {@link LinkedList#getFirst()}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLinkedListGetFirst() {
|
public void testLinkedListGetFirst() {
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
assertThrows(NoSuchElementException.class, () -> getCollection().getFirst(),
|
assertThrows(NoSuchElementException.class, () -> getCollection().getFirst(), "getFirst() should throw a NoSuchElementException for an empty list.");
|
||||||
"getFirst() should throw a NoSuchElementException for an empty list.");
|
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
final Object first = getCollection().getFirst();
|
final Object first = getCollection().getFirst();
|
||||||
final Object confirmedFirst = getConfirmedLinkedList().getFirst();
|
final Object confirmedFirst = getConfirmedLinkedList().getFirst();
|
||||||
assertEquals(confirmedFirst, first,
|
assertEquals(confirmedFirst, first, "Result returned by getFirst() was wrong.");
|
||||||
"Result returned by getFirst() was wrong.");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link LinkedList#getLast()}.
|
* Tests {@link LinkedList#getLast()}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLinkedListGetLast() {
|
public void testLinkedListGetLast() {
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
assertThrows(NoSuchElementException.class, () -> getCollection().getLast(),
|
assertThrows(NoSuchElementException.class, () -> getCollection().getLast(), "getLast() should throw a NoSuchElementException for an empty list.");
|
||||||
"getLast() should throw a NoSuchElementException for an empty list.");
|
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
final Object last = getCollection().getLast();
|
final Object last = getCollection().getLast();
|
||||||
final Object confirmedLast = getConfirmedLinkedList().getLast();
|
final Object confirmedLast = getConfirmedLinkedList().getLast();
|
||||||
assertEquals(confirmedLast, last,
|
assertEquals(confirmedLast, last, "Result returned by getLast() was wrong.");
|
||||||
"Result returned by getLast() was wrong.");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link LinkedList#removeFirst()}.
|
* Tests {@link LinkedList#removeFirst()}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLinkedListRemoveFirst() {
|
public void testLinkedListRemoveFirst() {
|
||||||
|
@ -179,13 +173,12 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
resetFull();
|
resetFull();
|
||||||
final Object first = getCollection().removeFirst();
|
final Object first = getCollection().removeFirst();
|
||||||
final Object confirmedFirst = getConfirmedLinkedList().removeFirst();
|
final Object confirmedFirst = getConfirmedLinkedList().removeFirst();
|
||||||
assertEquals(confirmedFirst, first,
|
assertEquals(confirmedFirst, first, "Result returned by removeFirst() was wrong.");
|
||||||
"Result returned by removeFirst() was wrong.");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link LinkedList#removeLast()}.
|
* Tests {@link LinkedList#removeLast()}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLinkedListRemoveLast() {
|
public void testLinkedListRemoveLast() {
|
||||||
|
@ -194,15 +187,13 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
assertThrows(NoSuchElementException.class, () -> getCollection().removeLast(),
|
assertThrows(NoSuchElementException.class, () -> getCollection().removeLast(), "removeLast() should throw a NoSuchElementException for an empty list.");
|
||||||
"removeLast() should throw a NoSuchElementException for an empty list.");
|
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
final Object last = getCollection().removeLast();
|
final Object last = getCollection().removeLast();
|
||||||
final Object confirmedLast = getConfirmedLinkedList().removeLast();
|
final Object confirmedLast = getConfirmedLinkedList().removeLast();
|
||||||
assertEquals(confirmedLast, last,
|
assertEquals(confirmedLast, last, "Result returned by removeLast() was wrong.");
|
||||||
"Result returned by removeLast() was wrong.");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,12 +280,12 @@ public class CollectionUtilsTest extends MockTestCase {
|
||||||
|
|
||||||
final Collection<String> strings = Arrays.asList("a", "b", "c");
|
final Collection<String> strings = Arrays.asList("a", "b", "c");
|
||||||
final StringBuilder result = new StringBuilder();
|
final StringBuilder result = new StringBuilder();
|
||||||
result.append(CollectionUtils.forAllButLastDo(strings, (Closure<String>) input -> result.append(input+";")));
|
result.append(CollectionUtils.forAllButLastDo(strings, (Closure<String>) input -> result.append(input + ";")));
|
||||||
assertEquals("a;b;c", result.toString());
|
assertEquals("a;b;c", result.toString());
|
||||||
|
|
||||||
final Collection<String> oneString = Arrays.asList("a");
|
final Collection<String> oneString = Arrays.asList("a");
|
||||||
final StringBuilder resultOne = new StringBuilder();
|
final StringBuilder resultOne = new StringBuilder();
|
||||||
resultOne.append(CollectionUtils.forAllButLastDo(oneString, (Closure<String>) input -> resultOne.append(input+";")));
|
resultOne.append(CollectionUtils.forAllButLastDo(oneString, (Closure<String>) input -> resultOne.append(input + ";")));
|
||||||
assertEquals("a", resultOne.toString());
|
assertEquals("a", resultOne.toString());
|
||||||
assertNull(CollectionUtils.forAllButLastDo(strings, (Closure<String>) null)); // do not remove cast
|
assertNull(CollectionUtils.forAllButLastDo(strings, (Closure<String>) null)); // do not remove cast
|
||||||
assertNull(CollectionUtils.forAllButLastDo((Collection<String>) null, (Closure<String>) null)); // do not remove cast
|
assertNull(CollectionUtils.forAllButLastDo((Collection<String>) null, (Closure<String>) null)); // do not remove cast
|
||||||
|
|
|
@ -247,7 +247,7 @@ public class MapUtilsTest {
|
||||||
final String INDENT = " ";
|
final String INDENT = " ";
|
||||||
|
|
||||||
final Map<Object, Object> map = new HashMap<>();
|
final Map<Object, Object> map = new HashMap<>();
|
||||||
final Map<Object, Object> map2= new HashMap<>();
|
final Map<Object, Object> map2 = new HashMap<>();
|
||||||
map.put(null, map2);
|
map.put(null, map2);
|
||||||
map2.put("2", "B");
|
map2.put("2", "B");
|
||||||
|
|
||||||
|
|
|
@ -76,5 +76,8 @@ public final class TestUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestUtils() {}
|
private TestUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getIterationBehaviour(){
|
protected int getIterationBehaviour() {
|
||||||
return AbstractBagTest.this.getIterationBehaviour();
|
return AbstractBagTest.this.getIterationBehaviour();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,7 @@ package org.apache.commons.collections4.bag;
|
||||||
import org.apache.commons.collections4.Bag;
|
import org.apache.commons.collections4.Bag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@link AbstractBagTest} for exercising the {@link SynchronizedBag}
|
* Extension of {@link AbstractBagTest} for exercising the {@link SynchronizedBag} implementation.
|
||||||
* implementation.
|
|
||||||
*/
|
*/
|
||||||
public class SynchronizedBagTest<T> extends AbstractBagTest<T> {
|
public class SynchronizedBagTest<T> extends AbstractBagTest<T> {
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ public class SynchronizedBagTest<T> extends AbstractBagTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getIterationBehaviour(){
|
protected int getIterationBehaviour() {
|
||||||
return UNORDERED;
|
return UNORDERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,9 @@ public abstract class AbstractOrderedBidiMapTest<K, V> extends AbstractBidiMapTe
|
||||||
if (!isAllowNullKey()) {
|
if (!isAllowNullKey()) {
|
||||||
try {
|
try {
|
||||||
assertNull(bidi.nextKey(null)); // this is allowed too
|
assertNull(bidi.nextKey(null)); // this is allowed too
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ignore) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertNull(bidi.nextKey(null));
|
assertNull(bidi.nextKey(null));
|
||||||
}
|
}
|
||||||
|
@ -182,7 +184,9 @@ public abstract class AbstractOrderedBidiMapTest<K, V> extends AbstractBidiMapTe
|
||||||
if (!isAllowNullKey()) {
|
if (!isAllowNullKey()) {
|
||||||
try {
|
try {
|
||||||
assertNull(bidi.previousKey(null)); // this is allowed too
|
assertNull(bidi.previousKey(null)); // this is allowed too
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ignore) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertNull(bidi.previousKey(null));
|
assertNull(bidi.previousKey(null));
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,9 @@ import org.junit.jupiter.api.Test;
|
||||||
@SuppressWarnings("boxing")
|
@SuppressWarnings("boxing")
|
||||||
public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<V>> extends AbstractSortedBidiMapTest<K, V> {
|
public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<V>> extends AbstractSortedBidiMapTest<K, V> {
|
||||||
|
|
||||||
private static final class IntegerComparator implements Comparator<Integer>, Serializable{
|
private static final class IntegerComparator implements Comparator<Integer>, Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Integer o1, final Integer o2) {
|
public int compare(final Integer o1, final Integer o2) {
|
||||||
return o1.compareTo(o2);
|
return o1.compareTo(o2);
|
||||||
|
|
|
@ -221,19 +221,17 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
|
||||||
BitMapProducer bitMapProducer = BitMapProducer.fromIndexProducer(new IncrementingHasher(1, 1).indices(getTestShape()),
|
BitMapProducer bitMapProducer = BitMapProducer.fromIndexProducer(new IncrementingHasher(1, 1).indices(getTestShape()),
|
||||||
getTestShape().getNumberOfBits());
|
getTestShape().getNumberOfBits());
|
||||||
assertTrue(bf2.contains(bitMapProducer), "BF2 Should contain this hasher");
|
assertTrue(bf2.contains(bitMapProducer), "BF2 Should contain this hasher");
|
||||||
bitMapProducer = BitMapProducer.fromIndexProducer(new IncrementingHasher(1, 3).indices(getTestShape()),
|
bitMapProducer = BitMapProducer.fromIndexProducer(new IncrementingHasher(1, 3).indices(getTestShape()), getTestShape().getNumberOfBits());
|
||||||
getTestShape().getNumberOfBits());
|
|
||||||
assertFalse(bf2.contains(bitMapProducer), "BF2 Should not contain this hasher");
|
assertFalse(bf2.contains(bitMapProducer), "BF2 Should not contain this hasher");
|
||||||
|
|
||||||
// Test different lengths
|
// Test different lengths
|
||||||
bf1 = createFilter(getTestShape(), TestingHashers.FROM1);
|
bf1 = createFilter(getTestShape(), TestingHashers.FROM1);
|
||||||
final BloomFilter bf3 = createFilter(Shape.fromKM(getTestShape().getNumberOfHashFunctions(), Long.SIZE - 1),
|
final BloomFilter bf3 = createFilter(Shape.fromKM(getTestShape().getNumberOfHashFunctions(), Long.SIZE - 1), TestingHashers.FROM1);
|
||||||
TestingHashers.FROM1);
|
|
||||||
assertTrue(bf1.contains(bf3));
|
assertTrue(bf1.contains(bf3));
|
||||||
assertTrue(bf3.contains(bf1));
|
assertTrue(bf3.contains(bf1));
|
||||||
|
|
||||||
final BloomFilter bf4 = TestingHashers.populateRange(createEmptyFilter(Shape.fromKM(getTestShape().getNumberOfHashFunctions(), Long.SIZE - 1)),
|
final BloomFilter bf4 = TestingHashers.populateRange(createEmptyFilter(Shape.fromKM(getTestShape().getNumberOfHashFunctions(), Long.SIZE - 1)), 1,
|
||||||
1, 11+getTestShape().getNumberOfHashFunctions());
|
11 + getTestShape().getNumberOfHashFunctions());
|
||||||
|
|
||||||
assertFalse(bf1.contains(bf4));
|
assertFalse(bf1.contains(bf4));
|
||||||
assertTrue(bf4.contains(bf1));
|
assertTrue(bf4.contains(bf1));
|
||||||
|
@ -253,7 +251,6 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void testEstimateIntersection() {
|
public final void testEstimateIntersection() {
|
||||||
|
|
||||||
final BloomFilter bf = createFilter(getTestShape(), TestingHashers.FROM1);
|
final BloomFilter bf = createFilter(getTestShape(), TestingHashers.FROM1);
|
||||||
final BloomFilter bf2 = TestingHashers.populateFromHashersFrom1AndFrom11(createEmptyFilter(getTestShape()));
|
final BloomFilter bf2 = TestingHashers.populateFromHashersFrom1AndFrom11(createEmptyFilter(getTestShape()));
|
||||||
|
|
||||||
|
@ -272,7 +269,7 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
|
||||||
|
|
||||||
final int midPoint = getTestShape().getNumberOfBits() / 2;
|
final int midPoint = getTestShape().getNumberOfBits() / 2;
|
||||||
final BloomFilter bf5 = TestingHashers.populateRange(createEmptyFilter(getTestShape()), 0, midPoint);
|
final BloomFilter bf5 = TestingHashers.populateRange(createEmptyFilter(getTestShape()), 0, midPoint);
|
||||||
final BloomFilter bf6 = TestingHashers.populateRange(createEmptyFilter(getTestShape()), midPoint+1, getTestShape().getNumberOfBits()-1);
|
final BloomFilter bf6 = TestingHashers.populateRange(createEmptyFilter(getTestShape()), midPoint + 1, getTestShape().getNumberOfBits() - 1);
|
||||||
assertThrows(IllegalArgumentException.class, () -> bf5.estimateIntersection(bf6));
|
assertThrows(IllegalArgumentException.class, () -> bf5.estimateIntersection(bf6));
|
||||||
|
|
||||||
// infinite with infinite
|
// infinite with infinite
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.collections4.bloomfilter;
|
package org.apache.commons.collections4.bloomfilter;
|
||||||
|
|
||||||
public class BloomFilterProducerFromBloomFilterArrayTest extends AbstractBloomFilterProducerTest{
|
public class BloomFilterProducerFromBloomFilterArrayTest extends AbstractBloomFilterProducerTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BloomFilterProducer createUnderTest(final BloomFilter... filters) {
|
protected BloomFilterProducer createUnderTest(final BloomFilter... filters) {
|
||||||
|
|
|
@ -16,14 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.collections4.bloomfilter;
|
package org.apache.commons.collections4.bloomfilter;
|
||||||
|
|
||||||
public class BloomFilterProducerFromLayeredBloomFilterTest extends AbstractBloomFilterProducerTest{
|
public class BloomFilterProducerFromLayeredBloomFilterTest extends AbstractBloomFilterProducerTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BloomFilterProducer createUnderTest(final BloomFilter... filters) {
|
protected BloomFilterProducer createUnderTest(final BloomFilter... filters) {
|
||||||
final Shape shape = filters[0].getShape();
|
final Shape shape = filters[0].getShape();
|
||||||
final LayerManager layerManager = LayerManager.builder().setSupplier( () -> new SimpleBloomFilter(shape) )
|
final LayerManager layerManager = LayerManager.builder().setSupplier(() -> new SimpleBloomFilter(shape))
|
||||||
.setExtendCheck( LayerManager.ExtendCheck.advanceOnPopulated())
|
.setExtendCheck(LayerManager.ExtendCheck.advanceOnPopulated()).setCleanup(LayerManager.Cleanup.noCleanup()).build();
|
||||||
.setCleanup(LayerManager.Cleanup.noCleanup()).build();
|
|
||||||
final LayeredBloomFilter underTest = new LayeredBloomFilter(shape, layerManager);
|
final LayeredBloomFilter underTest = new LayeredBloomFilter(shape, layerManager);
|
||||||
for (final BloomFilter bf : filters) {
|
for (final BloomFilter bf : filters) {
|
||||||
underTest.merge(bf);
|
underTest.merge(bf);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CountingPredicateTest {
|
||||||
final List<Pair<Integer, Integer>> result = new ArrayList<>();
|
final List<Pair<Integer, Integer>> result = new ArrayList<>();
|
||||||
expected.add(Pair.of(1, 3));
|
expected.add(Pair.of(1, 3));
|
||||||
|
|
||||||
CountingPredicate<Integer> cp = new CountingPredicate<>(ary, makeFunc((x, y) -> x!=null, result));
|
CountingPredicate<Integer> cp = new CountingPredicate<>(ary, makeFunc((x, y) -> x != null, result));
|
||||||
assertTrue(cp.test(Integer.valueOf(3)));
|
assertTrue(cp.test(Integer.valueOf(3)));
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
expected.add(Pair.of(2, null));
|
expected.add(Pair.of(2, null));
|
||||||
|
@ -64,16 +64,16 @@ public class CountingPredicateTest {
|
||||||
expected.add(Pair.of(1, null));
|
expected.add(Pair.of(1, null));
|
||||||
expected.add(Pair.of(2, null));
|
expected.add(Pair.of(2, null));
|
||||||
result.clear();
|
result.clear();
|
||||||
cp = new CountingPredicate<>(ary, makeFunc((x, y) -> x!=null, result));
|
cp = new CountingPredicate<>(ary, makeFunc((x, y) -> x != null, result));
|
||||||
assertTrue(cp.forEachRemaining());
|
assertTrue(cp.forEachRemaining());
|
||||||
assertEquals( expected, result);
|
assertEquals(expected, result);
|
||||||
|
|
||||||
// If a test fails then the result should be false and the rest of the list should
|
// If a test fails then the result should be false and the rest of the list should
|
||||||
// not be processed.
|
// not be processed.
|
||||||
expected.clear();
|
expected.clear();
|
||||||
expected.add(Pair.of(1, null));
|
expected.add(Pair.of(1, null));
|
||||||
result.clear();
|
result.clear();
|
||||||
cp = new CountingPredicate<>(ary, makeFunc((x, y) -> x == Integer.valueOf(1), result));
|
cp = new CountingPredicate<>(ary, makeFunc((x, y) -> x == Integer.valueOf(1), result));
|
||||||
assertFalse(cp.forEachRemaining());
|
assertFalse(cp.forEachRemaining());
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,11 @@ public class IndexProducerFromSparseBloomFilterTest extends AbstractIndexProduce
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getAsIndexArrayBehaviour() {
|
protected int getAsIndexArrayBehaviour() {
|
||||||
return DISTINCT |ORDERED;
|
return DISTINCT | ORDERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int[] getExpectedIndices() {
|
protected int[] getExpectedIndices() {
|
||||||
return new int[] {2, 4, 9, 11, 16, 18, 23, 25, 30, 32, 37, 39, 44, 46, 53, 60, 67};
|
return new int[] { 2, 4, 9, 11, 16, 18, 23, 25, 30, 32, 37, 39, 44, 46, 53, 60, 67 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class LayerManagerTest {
|
||||||
while (layerManager.getTarget().getShape().estimateN(layerManager.getTarget().cardinality()) < maxN) {
|
while (layerManager.getTarget().getShape().estimateN(layerManager.getTarget().cardinality()) < maxN) {
|
||||||
assertFalse(underTest.test(layerManager));
|
assertFalse(underTest.test(layerManager));
|
||||||
layerManager.getTarget().merge(new IncrementingHasher(hashStart, shape.getNumberOfHashFunctions()));
|
layerManager.getTarget().merge(new IncrementingHasher(hashStart, shape.getNumberOfHashFunctions()));
|
||||||
hashStart+=shape.getNumberOfHashFunctions();
|
hashStart += shape.getNumberOfHashFunctions();
|
||||||
}
|
}
|
||||||
assertTrue(underTest.test(layerManager));
|
assertTrue(underTest.test(layerManager));
|
||||||
assertThrows(IllegalArgumentException.class, () -> LayerManager.ExtendCheck.advanceOnSaturation(0));
|
assertThrows(IllegalArgumentException.class, () -> LayerManager.ExtendCheck.advanceOnSaturation(0));
|
||||||
|
|
|
@ -90,11 +90,14 @@ public class TestingHashers {
|
||||||
* Creates an EnhancedDoubleHasher hasher from 2 random longs.
|
* Creates an EnhancedDoubleHasher hasher from 2 random longs.
|
||||||
*/
|
*/
|
||||||
public static Hasher randomHasher() {
|
public static Hasher randomHasher() {
|
||||||
return new EnhancedDoubleHasher( ThreadLocalRandom.current().nextLong(), ThreadLocalRandom.current().nextLong() );
|
return new EnhancedDoubleHasher(ThreadLocalRandom.current().nextLong(), ThreadLocalRandom.current().nextLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not instantiate.
|
* Do not instantiate.
|
||||||
*/
|
*/
|
||||||
private TestingHashers() {}
|
private TestingHashers() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,7 +384,7 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
|
||||||
* @return the iteration behavior
|
* @return the iteration behavior
|
||||||
* @see #UNORDERED
|
* @see #UNORDERED
|
||||||
*/
|
*/
|
||||||
protected int getIterationBehaviour(){
|
protected int getIterationBehaviour() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,20 +137,19 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest<String> {
|
||||||
/** Shuffles the keys and asserts that the comparator sorts them back to
|
/** Shuffles the keys and asserts that the comparator sorts them back to
|
||||||
* their original order.
|
* their original order.
|
||||||
*/
|
*/
|
||||||
private void assertComparatorYieldsOrder(final String[] orderedObjects,
|
private void assertComparatorYieldsOrder(final String[] orderedObjects, final Comparator<String> comparator) {
|
||||||
final Comparator<String> comparator) {
|
|
||||||
final String[] keys = orderedObjects.clone();
|
final String[] keys = orderedObjects.clone();
|
||||||
|
|
||||||
// shuffle until the order changes. It's extremely rare that
|
// shuffle until the order changes. It's extremely rare that
|
||||||
// this requires more than one shuffle.
|
// this requires more than one shuffle.
|
||||||
|
|
||||||
boolean isInNewOrder = false;
|
boolean isInNewOrder = false;
|
||||||
final Random rand = new Random();
|
final Random rand = new Random();
|
||||||
while (keys.length > 1 && !isInNewOrder) {
|
while (keys.length > 1 && !isInNewOrder) {
|
||||||
// shuffle:
|
// shuffle:
|
||||||
for (int i = keys.length-1; i > 0; i--) {
|
for (int i = keys.length - 1; i > 0; i--) {
|
||||||
final String swap = keys[i];
|
final String swap = keys[i];
|
||||||
final int j = rand.nextInt(i+1);
|
final int j = rand.nextInt(i + 1);
|
||||||
keys[i] = keys[j];
|
keys[i] = keys[j];
|
||||||
keys[j] = swap;
|
keys[j] = swap;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +163,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest<String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The real test: sort and make sure they come out right.
|
// The real test: sort and make sure they come out right.
|
||||||
|
|
||||||
Arrays.sort(keys, comparator);
|
Arrays.sort(keys, comparator);
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,8 @@ public abstract class AbstractIteratorTest<E> extends AbstractObjectTest {
|
||||||
// check for UnsupportedOperationException if not supported
|
// check for UnsupportedOperationException if not supported
|
||||||
try {
|
try {
|
||||||
it.remove();
|
it.remove();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class NodeListIteratorTest extends AbstractIteratorTest<Node> {
|
||||||
public int getLength() {
|
public int getLength() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node item(final int index) {
|
public Node item(final int index) {
|
||||||
throw new IndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
|
@ -79,6 +80,7 @@ public class NodeListIteratorTest extends AbstractIteratorTest<Node> {
|
||||||
public int getLength() {
|
public int getLength() {
|
||||||
return nodes.length;
|
return nodes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node item(final int index) {
|
public Node item(final int index) {
|
||||||
return nodes[index];
|
return nodes[index];
|
||||||
|
@ -99,7 +101,7 @@ public class NodeListIteratorTest extends AbstractIteratorTest<Node> {
|
||||||
final Node node2 = createMock(Element.class);
|
final Node node2 = createMock(Element.class);
|
||||||
final Node node3 = createMock(Text.class);
|
final Node node3 = createMock(Text.class);
|
||||||
final Node node4 = createMock(Element.class);
|
final Node node4 = createMock(Element.class);
|
||||||
nodes = new Node[] {node1, node2, node3, node4};
|
nodes = new Node[] { node1, node2, node3, node4 };
|
||||||
|
|
||||||
replay(node1);
|
replay(node1);
|
||||||
replay(node2);
|
replay(node2);
|
||||||
|
@ -116,7 +118,7 @@ public class NodeListIteratorTest extends AbstractIteratorTest<Node> {
|
||||||
* tests the convenience Constructor with parameter type org.w3c.Node
|
* tests the convenience Constructor with parameter type org.w3c.Node
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyIteratorWithNodeConstructor(){
|
public void testEmptyIteratorWithNodeConstructor() {
|
||||||
createIteratorWithStandardConstr = false;
|
createIteratorWithStandardConstr = false;
|
||||||
testEmptyIterator();
|
testEmptyIterator();
|
||||||
}
|
}
|
||||||
|
@ -125,7 +127,7 @@ public class NodeListIteratorTest extends AbstractIteratorTest<Node> {
|
||||||
* tests the convenience Constructor with parameter type org.w3c.Node
|
* tests the convenience Constructor with parameter type org.w3c.Node
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFullIteratorWithNodeConstructor(){
|
public void testFullIteratorWithNodeConstructor() {
|
||||||
createIteratorWithStandardConstr = false;
|
createIteratorWithStandardConstr = false;
|
||||||
testFullIterator();
|
testFullIterator();
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class PermutationIteratorTest extends AbstractIteratorTest<List<Character
|
||||||
@SuppressWarnings("boxing") // OK in test code
|
@SuppressWarnings("boxing") // OK in test code
|
||||||
public void testPermutationResultSize() {
|
public void testPermutationResultSize() {
|
||||||
int factorial = 1;
|
int factorial = 1;
|
||||||
for (int i = 0; i < 8; i++, factorial*=i) {
|
for (int i = 0; i < 8; i++, factorial *= i) {
|
||||||
final List<Integer> list = new ArrayList<>();
|
final List<Integer> list = new ArrayList<>();
|
||||||
for (int j = 0; j < i; j++) {
|
for (int j = 0; j < i; j++) {
|
||||||
list.add(j);
|
list.add(j);
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class MultiKeyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object readResolve() {
|
private Object readResolve() {
|
||||||
hashCode=2; // simulate different hashCode after deserialization in another process
|
hashCode = 2; // simulate different hashCode after deserialization in another process
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,7 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
for (int i = 0; i < list.size; i++) {
|
for (int i = 0; i < list.size; i++) {
|
||||||
assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
|
assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
|
||||||
if (i < list.size - 1) {
|
if (i < list.size - 1) {
|
||||||
assertEquals(list.getNode(i + 1, false).previous,
|
assertEquals(list.getNode(i + 1, false).previous, list.getNode(i, false));
|
||||||
list.getNode(i, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +58,8 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
if (!isAddSupported()) {
|
if (!isAddSupported()) {
|
||||||
try {
|
try {
|
||||||
list.addFirst(null);
|
list.addFirst(null);
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addFirst((E) "value1");
|
list.addFirst((E) "value1");
|
||||||
|
@ -92,20 +92,16 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
final AbstractLinkedList<E> list = getCollection();
|
final AbstractLinkedList<E> list = getCollection();
|
||||||
// get marker
|
// get marker
|
||||||
assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
|
assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(0, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(0, false), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
list.addAll( Arrays.asList((E[]) new String[]{"value1", "value2"}));
|
|
||||||
checkNodes();
|
checkNodes();
|
||||||
list.addFirst((E) "value0");
|
list.addFirst((E) "value0");
|
||||||
checkNodes();
|
checkNodes();
|
||||||
list.removeNode(list.getNode(1, false));
|
list.removeNode(list.getNode(1, false));
|
||||||
checkNodes();
|
checkNodes();
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(2, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(2, false), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(-1, false), "Expecting IndexOutOfBoundsException.");
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(-1, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(3, true), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(3, true),
|
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -116,7 +112,8 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
try {
|
try {
|
||||||
list.removeFirst();
|
list.removeFirst();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
|
@ -141,7 +138,8 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
try {
|
try {
|
||||||
list.removeLast();
|
list.removeLast();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
|
|
|
@ -817,11 +817,13 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
|
||||||
resetFull();
|
resetFull();
|
||||||
try {
|
try {
|
||||||
getCollection().listIterator(-1);
|
getCollection().listIterator(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
resetFull();
|
resetFull();
|
||||||
try {
|
try {
|
||||||
getCollection().listIterator(getCollection().size() + 1);
|
getCollection().listIterator(getCollection().size() + 1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
resetFull();
|
resetFull();
|
||||||
for (int i = 0; i <= getConfirmed().size(); i++) {
|
for (int i = 0; i <= getConfirmed().size(); i++) {
|
||||||
forwardTest(getCollection().listIterator(i), i);
|
forwardTest(getCollection().listIterator(i), i);
|
||||||
|
|
|
@ -57,8 +57,7 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
for (int i = 0; i < list.size; i++) {
|
for (int i = 0; i < list.size; i++) {
|
||||||
assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
|
assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
|
||||||
if (i < list.size - 1) {
|
if (i < list.size - 1) {
|
||||||
assertEquals(list.getNode(i + 1, false).previous,
|
assertEquals(list.getNode(i + 1, false).previous, list.getNode(i, false));
|
||||||
list.getNode(i, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +90,8 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
if (!isAddSupported()) {
|
if (!isAddSupported()) {
|
||||||
try {
|
try {
|
||||||
list.addFirst(null);
|
list.addFirst(null);
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addFirst((E) "value1");
|
list.addFirst((E) "value1");
|
||||||
|
@ -124,20 +124,16 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
final AbstractLinkedListForJava21<E> list = getCollection();
|
final AbstractLinkedListForJava21<E> list = getCollection();
|
||||||
// get marker
|
// get marker
|
||||||
assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
|
assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(0, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(0, false), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
list.addAll( Arrays.asList((E[]) new String[]{"value1", "value2"}));
|
|
||||||
checkNodes();
|
checkNodes();
|
||||||
list.addFirst((E) "value0");
|
list.addFirst((E) "value0");
|
||||||
checkNodes();
|
checkNodes();
|
||||||
list.removeNode(list.getNode(1, false));
|
list.removeNode(list.getNode(1, false));
|
||||||
checkNodes();
|
checkNodes();
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(2, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(2, false), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(-1, false), "Expecting IndexOutOfBoundsException.");
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(-1, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(3, true), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(3, true),
|
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -148,7 +144,8 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
try {
|
try {
|
||||||
list.removeFirst();
|
list.removeFirst();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
|
@ -173,7 +170,8 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
try {
|
try {
|
||||||
list.removeLast();
|
list.removeLast();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -95,7 +95,7 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe
|
||||||
/**
|
/**
|
||||||
* JUnit constructor.
|
* JUnit constructor.
|
||||||
*
|
*
|
||||||
* @param testName the test name
|
* @param testName the test name
|
||||||
*/
|
*/
|
||||||
public AbstractOrderedMapTest(final String testName) {
|
public AbstractOrderedMapTest(final String testName) {
|
||||||
super(testName);
|
super(testName);
|
||||||
|
@ -114,8 +114,7 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The only confirmed collection we have that is ordered is the sorted one.
|
* The only confirmed collection we have that is ordered is the sorted one. Thus, sort the keys.
|
||||||
* Thus, sort the keys.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -186,7 +185,8 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe
|
||||||
if (!isAllowNullKey()) {
|
if (!isAllowNullKey()) {
|
||||||
try {
|
try {
|
||||||
assertNull(ordered.nextKey(null)); // this is allowed too
|
assertNull(ordered.nextKey(null)); // this is allowed too
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ex) {
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertNull(ordered.nextKey(null));
|
assertNull(ordered.nextKey(null));
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,8 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe
|
||||||
if (!isAllowNullKey()) {
|
if (!isAllowNullKey()) {
|
||||||
try {
|
try {
|
||||||
assertNull(ordered.previousKey(null)); // this is allowed too
|
assertNull(ordered.previousKey(null)); // this is allowed too
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ex) {
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertNull(ordered.previousKey(null));
|
assertNull(ordered.previousKey(null));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,22 +57,27 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
public boolean isNullSupported() {
|
public boolean isNullSupported() {
|
||||||
return LinkedMapTest.this.isAllowNullKey();
|
return LinkedMapTest.this.isAllowNullKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRemoveSupported() {
|
public boolean isRemoveSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSetSupported() {
|
public boolean isSetSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTestSerialization() {
|
public boolean isTestSerialization() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<K> makeFullCollection() {
|
public List<K> makeFullCollection() {
|
||||||
return LinkedMapTest.this.makeFullMap().asList();
|
return LinkedMapTest.this.makeFullMap().asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<K> makeObject() {
|
public List<K> makeObject() {
|
||||||
return LinkedMapTest.this.makeObject().asList();
|
return LinkedMapTest.this.makeObject().asList();
|
||||||
|
@ -129,19 +134,23 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
LinkedMap<K, V> lm = getMap();
|
LinkedMap<K, V> lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.get(0);
|
lm.get(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.get(-1);
|
lm.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lm = getMap();
|
lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.get(-1);
|
lm.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.get(lm.size());
|
lm.get(lm.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -155,19 +164,23 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
LinkedMap<K, V> lm = getMap();
|
LinkedMap<K, V> lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.getValue(0);
|
lm.getValue(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.getValue(-1);
|
lm.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lm = getMap();
|
lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.getValue(-1);
|
lm.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.getValue(lm.size());
|
lm.getValue(lm.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -263,19 +276,23 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
LinkedMap<K, V> lm = getMap();
|
LinkedMap<K, V> lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.remove(0);
|
lm.remove(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.remove(-1);
|
lm.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lm = getMap();
|
lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.remove(-1);
|
lm.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.remove(lm.size());
|
lm.remove(lm.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
final List<K> list = new ArrayList<>();
|
final List<K> list = new ArrayList<>();
|
||||||
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext();) {
|
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext();) {
|
||||||
|
|
|
@ -29,8 +29,7 @@ import org.apache.commons.collections4.list.AbstractListTest;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap}
|
* Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap} implementation.
|
||||||
* implementation.
|
|
||||||
*/
|
*/
|
||||||
public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
|
|
||||||
|
@ -54,22 +53,27 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
public boolean isNullSupported() {
|
public boolean isNullSupported() {
|
||||||
return ListOrderedMap2Test.this.isAllowNullKey();
|
return ListOrderedMap2Test.this.isAllowNullKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRemoveSupported() {
|
public boolean isRemoveSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSetSupported() {
|
public boolean isSetSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTestSerialization() {
|
public boolean isTestSerialization() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<K> makeFullCollection() {
|
public List<K> makeFullCollection() {
|
||||||
return ListOrderedMap2Test.this.makeFullMap().asList();
|
return ListOrderedMap2Test.this.makeFullMap().asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<K> makeObject() {
|
public List<K> makeObject() {
|
||||||
return ListOrderedMap2Test.this.makeObject().asList();
|
return ListOrderedMap2Test.this.makeObject().asList();
|
||||||
|
@ -116,19 +120,23 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.get(0);
|
lom.get(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.get(-1);
|
lom.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.get(-1);
|
lom.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.get(lom.size());
|
lom.get(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -142,19 +150,23 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.getValue(0);
|
lom.getValue(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.getValue(-1);
|
lom.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.getValue(-1);
|
lom.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.getValue(lom.size());
|
lom.getValue(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -197,19 +209,23 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.remove(0);
|
lom.remove(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.remove(-1);
|
lom.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.remove(-1);
|
lom.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.remove(lom.size());
|
lom.remove(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
final List<K> list = new ArrayList<>();
|
final List<K> list = new ArrayList<>();
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) {
|
||||||
|
|
|
@ -35,8 +35,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap}
|
* Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap} implementation.
|
||||||
* implementation.
|
|
||||||
*/
|
*/
|
||||||
public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
|
|
||||||
|
@ -175,7 +174,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCOLLECTIONS_474_nonNullValues () {
|
public void testCOLLECTIONS_474_nonNullValues() {
|
||||||
final Object key1 = new Object();
|
final Object key1 = new Object();
|
||||||
final Object key2 = new Object();
|
final Object key2 = new Object();
|
||||||
final HashMap<Object, Object> hmap = new HashMap<>();
|
final HashMap<Object, Object> hmap = new HashMap<>();
|
||||||
|
@ -190,7 +189,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCOLLECTIONS_474_nullValues () {
|
public void testCOLLECTIONS_474_nullValues() {
|
||||||
final Object key1 = new Object();
|
final Object key1 = new Object();
|
||||||
final Object key2 = new Object();
|
final Object key2 = new Object();
|
||||||
final HashMap<Object, Object> hmap = new HashMap<>();
|
final HashMap<Object, Object> hmap = new HashMap<>();
|
||||||
|
@ -210,19 +209,23 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.get(0);
|
lom.get(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.get(-1);
|
lom.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.get(-1);
|
lom.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.get(lom.size());
|
lom.get(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -236,19 +239,23 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.getValue(0);
|
lom.getValue(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.getValue(-1);
|
lom.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.getValue(-1);
|
lom.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.getValue(lom.size());
|
lom.getValue(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -285,8 +292,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
() -> assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(1, (K) "testInsert1", (V) "testInsert1v"),
|
() -> assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(1, (K) "testInsert1", (V) "testInsert1v"),
|
||||||
"should not be able to insert at pos 1 in empty Map"),
|
"should not be able to insert at pos 1 in empty Map"),
|
||||||
() -> assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(-1, (K) "testInsert-1", (V) "testInsert-1v"),
|
() -> assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(-1, (K) "testInsert-1", (V) "testInsert-1v"),
|
||||||
"should not be able to insert at pos -1 in empty Map")
|
"should not be able to insert at pos -1 in empty Map"));
|
||||||
);
|
|
||||||
|
|
||||||
// put where key doesn't exist
|
// put where key doesn't exist
|
||||||
lom.put(0, (K) "testInsert1", (V) "testInsert1v");
|
lom.put(0, (K) "testInsert1", (V) "testInsert1v");
|
||||||
|
@ -450,19 +456,23 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.remove(0);
|
lom.remove(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.remove(-1);
|
lom.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.remove(-1);
|
lom.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.remove(lom.size());
|
lom.remove(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
final List<K> list = new ArrayList<>();
|
final List<K> list = new ArrayList<>();
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) {
|
||||||
|
@ -484,19 +494,23 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.setValue(0, (V) StringUtils.EMPTY);
|
lom.setValue(0, (V) StringUtils.EMPTY);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.setValue(-1, (V) StringUtils.EMPTY);
|
lom.setValue(-1, (V) StringUtils.EMPTY);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.setValue(-1, (V) StringUtils.EMPTY);
|
lom.setValue(-1, (V) StringUtils.EMPTY);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.setValue(lom.size(), (V) StringUtils.EMPTY);
|
lom.setValue(lom.size(), (V) StringUtils.EMPTY);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < lom.size(); i++) {
|
for (int i = 0; i < lom.size(); i++) {
|
||||||
final V value = lom.getValue(i);
|
final V value = lom.getValue(i);
|
||||||
|
|
|
@ -1337,7 +1337,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToString(){
|
public void testToString() {
|
||||||
assumeTrue(isAddSupported());
|
assumeTrue(isAddSupported());
|
||||||
final MultiValuedMap<K, V> map = makeObject();
|
final MultiValuedMap<K, V> map = makeObject();
|
||||||
map.put((K) "A", (V) "X");
|
map.put((K) "A", (V) "X");
|
||||||
|
@ -1346,18 +1346,11 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
||||||
map.put((K) "B", (V) "U");
|
map.put((K) "B", (V) "U");
|
||||||
map.put((K) "B", (V) "V");
|
map.put((K) "B", (V) "V");
|
||||||
map.put((K) "B", (V) "W");
|
map.put((K) "B", (V) "W");
|
||||||
assertTrue(
|
assertTrue("{A=[X, Y, Z], B=[U, V, W]}".equals(map.toString()) || "{B=[U, V, W], A=[X, Y, Z]}".equals(map.toString()));
|
||||||
"{A=[X, Y, Z], B=[U, V, W]}".equals(map.toString()) ||
|
|
||||||
"{B=[U, V, W], A=[X, Y, Z]}".equals(map.toString())
|
|
||||||
);
|
|
||||||
|
|
||||||
final MultiValuedMap<K, V> originalNull = null;
|
final MultiValuedMap<K, V> originalNull = null;
|
||||||
assertThrows(NullPointerException.class, () -> map.putAll(originalNull),
|
assertThrows(NullPointerException.class, () -> map.putAll(originalNull), "expecting NullPointerException");
|
||||||
"expecting NullPointerException");
|
assertTrue("{A=[X, Y, Z], B=[U, V, W]}".equals(map.toString()) || "{B=[U, V, W], A=[X, Y, Z]}".equals(map.toString()));
|
||||||
assertTrue(
|
|
||||||
"{A=[X, Y, Z], B=[U, V, W]}".equals(map.toString()) ||
|
|
||||||
"{B=[U, V, W], A=[X, Y, Z]}".equals(map.toString())
|
|
||||||
);
|
|
||||||
|
|
||||||
map.remove("A");
|
map.remove("A");
|
||||||
map.remove("B");
|
map.remove("B");
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class ArrayListValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTrimToSize(){
|
public void testTrimToSize() {
|
||||||
final ArrayListValuedHashMap<K, V> listMap = new ArrayListValuedHashMap<>(4);
|
final ArrayListValuedHashMap<K, V> listMap = new ArrayListValuedHashMap<>(4);
|
||||||
|
|
||||||
assertEquals("{}", listMap.toString());
|
assertEquals("{}", listMap.toString());
|
||||||
|
@ -192,7 +192,7 @@ public class ArrayListValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValuesListIteratorMethods(){
|
public void testValuesListIteratorMethods() {
|
||||||
final ListValuedMap<K, V> listMap = makeObject();
|
final ListValuedMap<K, V> listMap = makeObject();
|
||||||
final List<V> listA = listMap.get((K) "A");
|
final List<V> listA = listMap.get((K) "A");
|
||||||
final List<V> list = Arrays.asList((V) "W", (V) "X", (V) "F", (V) "Q", (V) "Q", (V) "F");
|
final List<V> list = Arrays.asList((V) "W", (V) "X", (V) "F", (V) "Q", (V) "Q", (V) "F");
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class HashSetValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest<K
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHashSetValuedHashMap_2(){
|
public void testHashSetValuedHashMap_2() {
|
||||||
final Map<K, V> map = new HashMap<>();
|
final Map<K, V> map = new HashMap<>();
|
||||||
final SetValuedMap<K, V> map1;
|
final SetValuedMap<K, V> map1;
|
||||||
final SetValuedMap<K, V> map2;
|
final SetValuedMap<K, V> map2;
|
||||||
|
|
|
@ -178,20 +178,18 @@ public class SequencesComparatorTest {
|
||||||
|
|
||||||
final Random random = new Random(4564634237452342L);
|
final Random random = new Random(4564634237452342L);
|
||||||
|
|
||||||
for (int nbCom = 0; nbCom <= 40; nbCom+=5) {
|
for (int nbCom = 0; nbCom <= 40; nbCom += 5) {
|
||||||
sentenceAfter.clear();
|
sentenceAfter.clear();
|
||||||
sentenceAfter.addAll(sentenceBefore);
|
sentenceAfter.addAll(sentenceBefore);
|
||||||
for (int i = 0; i<nbCom; i++) {
|
for (int i = 0; i < nbCom; i++) {
|
||||||
if (random.nextInt(2) == 0) {
|
if (random.nextInt(2) == 0) {
|
||||||
sentenceAfter.add(random.nextInt(sentenceAfter.size() + 1),
|
sentenceAfter.add(random.nextInt(sentenceAfter.size() + 1), shadokAlph[random.nextInt(4)]);
|
||||||
shadokAlph[random.nextInt(4)]);
|
|
||||||
} else {
|
} else {
|
||||||
sentenceAfter.remove(random.nextInt(sentenceAfter.size()));
|
sentenceAfter.remove(random.nextInt(sentenceAfter.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final SequencesComparator<String> comparator =
|
final SequencesComparator<String> comparator = new SequencesComparator<>(sentenceBefore, sentenceAfter);
|
||||||
new SequencesComparator<>(sentenceBefore, sentenceAfter);
|
|
||||||
assertTrue(comparator.getScript().getModifications() <= nbCom);
|
assertTrue(comparator.getScript().getModifications() <= nbCom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +204,7 @@ public class SequencesComparatorTest {
|
||||||
"MEU"
|
"MEU"
|
||||||
};
|
};
|
||||||
List<List<String>> shadokSentences = new ArrayList<>();
|
List<List<String>> shadokSentences = new ArrayList<>();
|
||||||
for (int lg=0; lg<lgMax; ++lg) {
|
for (int lg = 0; lg < lgMax; ++lg) {
|
||||||
final List<List<String>> newTab = new ArrayList<>();
|
final List<List<String>> newTab = new ArrayList<>();
|
||||||
newTab.add(new ArrayList<>());
|
newTab.add(new ArrayList<>());
|
||||||
for (final String element : shadokAlph) {
|
for (final String element : shadokAlph) {
|
||||||
|
|
|
@ -57,8 +57,7 @@ public class TransformedSplitMapTest extends BulkTest {
|
||||||
NOPTransformer.<String>nopTransformer(),
|
NOPTransformer.<String>nopTransformer(),
|
||||||
NOPTransformer.<String>nopTransformer() );
|
NOPTransformer.<String>nopTransformer() );
|
||||||
|
|
||||||
final ObjectInputStream in =
|
final ObjectInputStream in = new ObjectInputStream(new FileInputStream(TEST_DATA_PATH + "/TransformedSplitMap.emptyCollection.version4.obj"));
|
||||||
new ObjectInputStream( new FileInputStream( TEST_DATA_PATH+"/TransformedSplitMap.emptyCollection.version4.obj" ) );
|
|
||||||
final Object readObject = in.readObject();
|
final Object readObject = in.readObject();
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
|
@ -78,14 +77,13 @@ public class TransformedSplitMapTest extends BulkTest {
|
||||||
map.put( "e", "f" );
|
map.put( "e", "f" );
|
||||||
map.put( "g", "h" );
|
map.put( "g", "h" );
|
||||||
|
|
||||||
final ObjectInputStream in =
|
final ObjectInputStream in = new ObjectInputStream(new FileInputStream(TEST_DATA_PATH + "TransformedSplitMap.fullCollection.version4.obj"));
|
||||||
new ObjectInputStream( new FileInputStream( TEST_DATA_PATH+"TransformedSplitMap.fullCollection.version4.obj" ) );
|
|
||||||
final Object readObject = in.readObject();
|
final Object readObject = in.readObject();
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
final TransformedSplitMap<?, ?, ?, ?> readMap = (TransformedSplitMap<?, ?, ?, ?>) readObject;
|
final TransformedSplitMap<?, ?, ?, ?> readMap = (TransformedSplitMap<?, ?, ?, ?>) readObject;
|
||||||
assertFalse(readMap.isEmpty(), "Map should not be empty");
|
assertFalse(readMap.isEmpty(), "Map should not be empty");
|
||||||
assertEquals( map.entrySet(), readMap.entrySet() );
|
assertEquals(map.entrySet(), readMap.entrySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue