Skip to content

Commit 6f2bed7

Browse files
committed
Fixed failed tests
1 parent 681e0bf commit 6f2bed7

File tree

7 files changed

+45
-39
lines changed

7 files changed

+45
-39
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/examples/stream/DoubleStreamExampleTest.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class DoubleStreamExampleTest : UtValueTestCaseChecker(
175175
}
176176

177177
@Test
178-
@Disabled("TODO wrong returned value")
179178
fun testPeekExample() {
180179
checkThisAndStaticsAfter(
181180
DoubleStreamExample::peekExample,
@@ -186,25 +185,23 @@ class DoubleStreamExampleTest : UtValueTestCaseChecker(
186185
}
187186

188187
@Test
189-
@Disabled("TODO unable to find second branch, even after exceeding steps limit")
190188
fun testLimitExample() {
191189
check(
192190
DoubleStreamExample::limitExample,
193191
ignoreExecutionsNumber,
194-
{ c, r -> c.size <= 5 && c.doubles().contentEquals(r) },
195-
{ c, r -> c.size > 5 && c.take(5).doubles().contentEquals(r) },
192+
{ c, r -> c.size <= 2 && c.doubles().contentEquals(r) },
193+
{ c, r -> c.size > 2 && c.take(2).doubles().contentEquals(r) },
196194
coverage = FullWithAssumptions(assumeCallsNumber = 1)
197195
)
198196
}
199197

200198
@Test
201-
@Disabled("TODO unable to find second branch, even after exceeding steps limit")
202199
fun testSkipExample() {
203200
check(
204201
DoubleStreamExample::skipExample,
205202
ignoreExecutionsNumber,
206-
{ c, r -> c.size > 5 && c.drop(5).doubles().contentEquals(r) },
207-
{ c, r -> c.size <= 5 && r!!.isEmpty() },
203+
{ c, r -> c.size > 2 && c.drop(2).doubles().contentEquals(r) },
204+
{ c, r -> c.size <= 2 && r!!.isEmpty() },
208205
coverage = FullWithAssumptions(assumeCallsNumber = 1)
209206
)
210207
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/stream/IntStreamExampleTest.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,23 @@ class IntStreamExampleTest : UtValueTestCaseChecker(
184184
}
185185

186186
@Test
187-
@Disabled("TODO unable to find second branch, even after exceeding steps limit")
188187
fun testLimitExample() {
189188
check(
190189
IntStreamExample::limitExample,
191190
ignoreExecutionsNumber,
192-
{ c, r -> c.size <= 5 && c.ints().contentEquals(r) },
193-
{ c, r -> c.size > 5 && c.take(5).ints().contentEquals(r) },
191+
{ c, r -> c.size <= 2 && c.ints().contentEquals(r) },
192+
{ c, r -> c.size > 2 && c.take(2).ints().contentEquals(r) },
194193
coverage = FullWithAssumptions(assumeCallsNumber = 1)
195194
)
196195
}
197196

198197
@Test
199-
@Disabled("TODO unable to find second branch, even after exceeding steps limit")
200198
fun testSkipExample() {
201199
check(
202200
IntStreamExample::skipExample,
203201
ignoreExecutionsNumber,
204-
{ c, r -> c.size > 5 && c.drop(5).ints().contentEquals(r) },
205-
{ c, r -> c.size <= 5 && r!!.isEmpty() },
202+
{ c, r -> c.size > 2 && c.drop(2).ints().contentEquals(r) },
203+
{ c, r -> c.size <= 2 && r!!.isEmpty() },
206204
coverage = FullWithAssumptions(assumeCallsNumber = 1)
207205
)
208206
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/stream/LongStreamExampleTest.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,23 @@ class LongStreamExampleTest : UtValueTestCaseChecker(
184184
}
185185

186186
@Test
187-
@Disabled("TODO unable to find second branch, even after exceeding steps limit")
188187
fun testLimitExample() {
189188
check(
190189
LongStreamExample::limitExample,
191190
ignoreExecutionsNumber,
192-
{ c, r -> c.size <= 5 && c.longs().contentEquals(r) },
193-
{ c, r -> c.size > 5 && c.take(5).longs().contentEquals(r) },
191+
{ c, r -> c.size <= 2 && c.longs().contentEquals(r) },
192+
{ c, r -> c.size > 2 && c.take(2).longs().contentEquals(r) },
194193
coverage = FullWithAssumptions(assumeCallsNumber = 1)
195194
)
196195
}
197196

198197
@Test
199-
@Disabled("TODO unable to find second branch, even after exceeding steps limit")
200198
fun testSkipExample() {
201199
check(
202200
LongStreamExample::skipExample,
203201
ignoreExecutionsNumber,
204-
{ c, r -> c.size > 5 && c.drop(5).longs().contentEquals(r) },
205-
{ c, r -> c.size <= 5 && r!!.isEmpty() },
202+
{ c, r -> c.size > 2 && c.drop(2).longs().contentEquals(r) },
203+
{ c, r -> c.size <= 2 && r!!.isEmpty() },
206204
coverage = FullWithAssumptions(assumeCallsNumber = 1)
207205
)
208206
}

utbot-sample/src/main/java/org/utbot/examples/stream/BaseStreamExample.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,16 @@ int peekExample(List<Integer> list) {
173173
int beforeStaticValue = x;
174174

175175
final Consumer<Integer> action = value -> x += value;
176+
final Stream<Integer> stream = list.stream();
176177
if (list.contains(null)) {
177-
list.stream().peek(action);
178+
stream.peek(action);
178179
} else {
179-
list.stream().peek(action);
180+
stream.peek(action);
180181
}
181182

183+
// use terminal operation to force peek action
184+
stream.count();
185+
182186
return beforeStaticValue;
183187
}
184188

utbot-sample/src/main/java/org/utbot/examples/stream/DoubleStreamExample.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ int peekExample(List<Short> list) {
158158
doubles.peek(action);
159159
}
160160

161+
// use terminal operation to force peek action
162+
doubles.count();
163+
161164
return beforeStaticValue;
162165
}
163166

@@ -167,10 +170,10 @@ int peekExample(List<Short> list) {
167170
final ToDoubleFunction<Short> shortToDoubleFunction = value -> value == null ? 0 : value.doubleValue();
168171
final DoubleStream doubles = list.stream().mapToDouble(shortToDoubleFunction);
169172

170-
if (list.size() <= 5) {
171-
return doubles.limit(5).toArray();
173+
if (list.size() <= 2) {
174+
return doubles.limit(2).toArray();
172175
} else {
173-
return doubles.limit(5).toArray();
176+
return doubles.limit(2).toArray();
174177
}
175178
}
176179

@@ -180,10 +183,10 @@ int peekExample(List<Short> list) {
180183
final ToDoubleFunction<Short> shortToDoubleFunction = value -> value == null ? 0 : value.doubleValue();
181184
final DoubleStream doubles = list.stream().mapToDouble(shortToDoubleFunction);
182185

183-
if (list.size() <= 5) {
184-
return doubles.skip(5).toArray();
186+
if (list.size() <= 2) {
187+
return doubles.skip(2).toArray();
185188
} else {
186-
return doubles.skip(5).toArray();
189+
return doubles.skip(2).toArray();
187190
}
188191
}
189192

utbot-sample/src/main/java/org/utbot/examples/stream/IntStreamExample.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ int peekExample(List<Short> list) {
161161
ints.peek(action);
162162
}
163163

164+
// use terminal operation to force peek action
165+
ints.count();
166+
164167
return beforeStaticValue;
165168
}
166169

@@ -170,10 +173,10 @@ int[] limitExample(List<Short> list) {
170173
final ToIntFunction<Short> shortToIntFunction = value -> value == null ? 0 : value.intValue();
171174
final IntStream ints = list.stream().mapToInt(shortToIntFunction);
172175

173-
if (list.size() <= 5) {
174-
return ints.limit(5).toArray();
176+
if (list.size() <= 2) {
177+
return ints.limit(2).toArray();
175178
} else {
176-
return ints.limit(5).toArray();
179+
return ints.limit(2).toArray();
177180
}
178181
}
179182

@@ -183,10 +186,10 @@ int[] skipExample(List<Short> list) {
183186
final ToIntFunction<Short> shortToIntFunction = value -> value == null ? 0 : value.intValue();
184187
final IntStream ints = list.stream().mapToInt(shortToIntFunction);
185188

186-
if (list.size() <= 5) {
187-
return ints.skip(5).toArray();
189+
if (list.size() <= 2) {
190+
return ints.skip(2).toArray();
188191
} else {
189-
return ints.skip(5).toArray();
192+
return ints.skip(2).toArray();
190193
}
191194
}
192195

utbot-sample/src/main/java/org/utbot/examples/stream/LongStreamExample.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ int peekExample(List<Short> list) {
160160
longs.peek(action);
161161
}
162162

163+
// use terminal operation to force peek action
164+
longs.count();
165+
163166
return beforeStaticValue;
164167
}
165168

@@ -169,10 +172,10 @@ long[] limitExample(List<Short> list) {
169172
final ToLongFunction<Short> shortToLongFunction = value -> value == null ? 0 : value.longValue();
170173
final LongStream longs = list.stream().mapToLong(shortToLongFunction);
171174

172-
if (list.size() <= 5) {
173-
return longs.limit(5).toArray();
175+
if (list.size() <= 2) {
176+
return longs.limit(2).toArray();
174177
} else {
175-
return longs.limit(5).toArray();
178+
return longs.limit(2).toArray();
176179
}
177180
}
178181

@@ -182,10 +185,10 @@ long[] skipExample(List<Short> list) {
182185
final ToLongFunction<Short> shortToLongFunction = value -> value == null ? 0 : value.longValue();
183186
final LongStream longs = list.stream().mapToLong(shortToLongFunction);
184187

185-
if (list.size() <= 5) {
186-
return longs.skip(5).toArray();
188+
if (list.size() <= 2) {
189+
return longs.skip(2).toArray();
187190
} else {
188-
return longs.skip(5).toArray();
191+
return longs.skip(2).toArray();
189192
}
190193
}
191194

0 commit comments

Comments
 (0)