Skip to content

Added the wrapper for static methods of java.util.List #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.utbot.engine.overrides.collections;

import org.utbot.api.annotation.UtClassMock;

import java.util.Collection;

@UtClassMock(target = java.util.List.class, internalUsage = true)
public interface List<E> extends java.util.List<E> {
static <E> java.util.List<E> of() {
return new UtArrayList<>();
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1) {
return new UtArrayList<>((E[]) new Object[]{e1});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2) {
return new UtArrayList<>((E[]) new Object[]{e1, e2});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6, e7});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6, e7, e8});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6, e7, e8, e9});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6, e7, e8, e9, e10});
}

@SafeVarargs
@SuppressWarnings("varargs")
static <E> java.util.List<E> of(E... elements) {
return new UtArrayList<>(elements);
}

static <E> java.util.List<E> copyOf(Collection<? extends E> collection) {
return new UtArrayList<>(collection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public UtArrayList(Collection<? extends E> c) {
addAll(c);
}

public UtArrayList(E[] data) {
visit(this);
int length = data.length;
elementData = new RangeModifiableUnlimitedArray<>();
elementData.setRange(0, data, 0, length);
elementData.end = length;
}

/**
* Precondition check is called only once by object,
* if it was passed as parameter to method under test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.utbot.engine.overrides.collections.UtHashSet
import org.utbot.engine.overrides.collections.UtLinkedList
import org.utbot.engine.overrides.UtOverrideMock
import org.utbot.engine.overrides.collections.Collection
import org.utbot.engine.overrides.collections.List
import org.utbot.engine.overrides.collections.UtGenericStorage
import org.utbot.engine.overrides.collections.UtOptional
import org.utbot.engine.overrides.collections.UtOptionalDouble
Expand Down Expand Up @@ -133,6 +134,7 @@ private val classesToLoad = arrayOf(
UtStringBuffer::class,
Stream::class,
Collection::class,
List::class,
UtStream::class,
UtStream.UtStreamIterator::class
)