Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Implemented wrappers for primitive streams
  • Loading branch information
Damtev committed Sep 2, 2022
commit ca82c97d6857f7cfb75d9333aef803209c6e1dbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.utbot.engine.overrides.stream;

import org.utbot.api.annotation.UtClassMock;

import java.util.function.DoubleSupplier;
import java.util.function.DoubleUnaryOperator;
import java.util.stream.BaseStream;

import static org.utbot.engine.overrides.UtOverrideMock.executeConcretely;

@UtClassMock(target = java.util.stream.DoubleStream.class, internalUsage = true)
public interface DoubleStream extends BaseStream<Double, java.util.stream.DoubleStream> {
static java.util.stream.DoubleStream empty() {
return new UtDoubleStream();
}

static java.util.stream.DoubleStream of(double t) {
Double[] data = new Double[]{t};

return new UtDoubleStream(data, 1);
}

static java.util.stream.DoubleStream of(double... values) {
int size = values.length;
Double[] data = new Double[size];
for (int i = 0; i < size; i++) {
data[i] = values[i];
}

return new UtDoubleStream(data, size);
}

@SuppressWarnings("unused")
static java.util.stream.DoubleStream generate(DoubleSupplier s) {
// as "generate" method produces an infinite stream, we cannot analyze it symbolically
executeConcretely();
return null;
}

@SuppressWarnings("unused")
static java.util.stream.DoubleStream iterate(final double seed, final DoubleUnaryOperator f) {
// as "iterate" method produces an infinite stream, we cannot analyze it symbolically
executeConcretely();
return null;
}

@SuppressWarnings("unused")
static java.util.stream.DoubleStream concat(java.util.stream.DoubleStream a, java.util.stream.DoubleStream b) {
// as provided streams might be infinite, we cannot analyze this method symbolically
executeConcretely();
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.utbot.engine.overrides.stream;

import org.utbot.api.annotation.UtClassMock;

import java.util.function.IntSupplier;
import java.util.function.IntUnaryOperator;
import java.util.stream.BaseStream;

import static org.utbot.engine.overrides.UtOverrideMock.executeConcretely;
@UtClassMock(target = java.util.stream.IntStream.class, internalUsage = true)
public interface IntStream extends BaseStream<Integer, java.util.stream.IntStream> {
static java.util.stream.IntStream empty() {
return new UtIntStream();
}

static java.util.stream.IntStream of(int t) {
Integer[] data = new Integer[]{t};

return new UtIntStream(data, 1);
}

static java.util.stream.IntStream of(int... values) {
int size = values.length;
Integer[] data = new Integer[size];
for (int i = 0; i < size; i++) {
data[i] = values[i];
}

return new UtIntStream(data, size);
}

@SuppressWarnings("unused")
static java.util.stream.IntStream generate(IntSupplier s) {
// as "generate" method produces an infinite stream, we cannot analyze it symbolically
executeConcretely();
return null;
}

static java.util.stream.IntStream range(int startInclusive, int endExclusive) {
int size = endExclusive - startInclusive;
Integer[] data = new Integer[size];
for (int i = startInclusive; i < endExclusive; i++) {
data[i - startInclusive] = i;
}

return new UtIntStream(data, size);
}

@SuppressWarnings("unused")
static java.util.stream.IntStream rangeClosed(int startInclusive, int endInclusive) {
return range(startInclusive, endInclusive + 1);
}

@SuppressWarnings("unused")
static java.util.stream.IntStream iterate(final int seed, final IntUnaryOperator f) {
// as "iterate" method produces an infinite stream, we cannot analyze it symbolically
executeConcretely();
return null;
}

@SuppressWarnings("unused")
static java.util.stream.IntStream concat(java.util.stream.IntStream a, java.util.stream.IntStream b) {
// as provided streams might be infinite, we cannot analyze this method symbolically
executeConcretely();
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.utbot.engine.overrides.stream;

import org.utbot.api.annotation.UtClassMock;
import org.utbot.api.mock.UtMock;

import java.util.function.LongSupplier;
import java.util.function.LongUnaryOperator;
import java.util.stream.BaseStream;

import static org.utbot.engine.overrides.UtOverrideMock.executeConcretely;

@UtClassMock(target = java.util.stream.LongStream.class, internalUsage = true)
public interface LongStream extends BaseStream<Long, java.util.stream.LongStream> {
static java.util.stream.LongStream empty() {
return new UtLongStream();
}

static java.util.stream.LongStream of(long t) {
Long[] data = new Long[]{t};

return new UtLongStream(data, 1);
}

static java.util.stream.LongStream of(long... values) {
int size = values.length;
Long[] data = new Long[size];
for (int i = 0; i < size; i++) {
data[i] = values[i];
}

return new UtLongStream(data, size);
}

@SuppressWarnings("unused")
static java.util.stream.LongStream generate(LongSupplier s) {
// as "generate" method produces an infinite stream, we cannot analyze it symbolically
executeConcretely();
return null;
}

static java.util.stream.LongStream range(long startInclusive, long endExclusive) {
int start = (int) startInclusive;
int end = (int) endExclusive;

// check that borders fit in int range
UtMock.assumeOrExecuteConcretely(start == startInclusive);
UtMock.assumeOrExecuteConcretely(end == endExclusive);

int size = end - start;

Long[] data = new Long[size];
for (int i = start; i < end; i++) {
data[i - start] = (long) i;
}

return new UtLongStream(data, size);
}

@SuppressWarnings("unused")
static java.util.stream.LongStream rangeClosed(long startInclusive, long endInclusive) {
return range(startInclusive, endInclusive + 1);
}

@SuppressWarnings("unused")
static java.util.stream.LongStream iterate(final long seed, final LongUnaryOperator f) {
// as "iterate" method produces an infinite stream, we cannot analyze it symbolically
executeConcretely();
return null;
}

@SuppressWarnings("unused")
static java.util.stream.LongStream concat(java.util.stream.LongStream a, java.util.stream.LongStream b) {
// as provided streams might be infinite, we cannot analyze this method symbolically
executeConcretely();
return null;
}
}
Loading