Skip to content

Commit

Permalink
Removed redundant withoutConcrete
Browse files Browse the repository at this point in the history
  • Loading branch information
Damtev committed Oct 28, 2022
1 parent 5b47b3b commit 53411ad
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import org.utbot.examples.mock.MockRandomExamples
import kotlin.reflect.full.functions
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.utbot.testcheckers.withConcrete

internal class CodegenExampleTest : UtValueTestCaseChecker(testClass = CodegenExample::class) {
@Test
fun firstExampleTest() {
withConcrete(useConcreteExecution = false) {
checkAllCombinations(
CodegenExample::firstExample,
)
}
checkAllCombinations(
CodegenExample::firstExample,
)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,41 +86,35 @@ internal class MapsPart1Test : UtValueTestCaseChecker(

@Test
fun testMapPutAndGet() {
withConcrete(useConcreteExecution = false) {
check(
Maps::mapPutAndGet,
eq(1),
{ r -> r == 3 }
)
}
check(
Maps::mapPutAndGet,
eq(1),
{ r -> r == 3 }
)
}

@Test
fun testPutInMapFromParameters() {
withConcrete(useConcreteExecution = false) {
check(
Maps::putInMapFromParameters,
ignoreExecutionsNumber,
{ values, _ -> values == null },
{ values, r -> 1 in values.keys && r == 3 },
{ values, r -> 1 !in values.keys && r == 3 },
)
}
check(
Maps::putInMapFromParameters,
ignoreExecutionsNumber,
{ values, _ -> values == null },
{ values, r -> 1 in values.keys && r == 3 },
{ values, r -> 1 !in values.keys && r == 3 },
)
}

// This test doesn't check anything specific, but the code from MUT
// caused errors with NPE as results while debugging `testPutInMapFromParameters`.
@Test
fun testContainsKeyAndPuts() {
withConcrete(useConcreteExecution = false) {
check(
Maps::containsKeyAndPuts,
ignoreExecutionsNumber,
{ values, _ -> values == null },
{ values, r -> 1 !in values.keys && r == 3 },
coverage = FullWithAssumptions(assumeCallsNumber = 2)
)
}
check(
Maps::containsKeyAndPuts,
ignoreExecutionsNumber,
{ values, _ -> values == null },
{ values, r -> 1 !in values.keys && r == 3 },
coverage = FullWithAssumptions(assumeCallsNumber = 2)
)
}

@Test
Expand Down Expand Up @@ -354,22 +348,18 @@ internal class MapsPart1Test : UtValueTestCaseChecker(

@Test
fun testCreateMapWithString() {
withConcrete(useConcreteExecution = false) {
check(
Maps::createMapWithString,
eq(1),
{ r -> r!!.isEmpty() }
)
}
check(
Maps::createMapWithString,
eq(1),
{ r -> r!!.isEmpty() }
)
}
@Test
fun testCreateMapWithEnum() {
withConcrete(useConcreteExecution = false) {
check(
Maps::createMapWithEnum,
eq(1),
{ r -> r != null && r.size == 2 && r[Maps.WorkDays.Monday] == 112 && r[Maps.WorkDays.Friday] == 567 }
)
}
check(
Maps::createMapWithEnum,
eq(1),
{ r -> r != null && r.size == 2 && r[Maps.WorkDays.Monday] == 112 && r[Maps.WorkDays.Friday] == 567 }
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import org.utbot.tests.infrastructure.ignoreExecutionsNumber
class ClassWithEnumTest : UtValueTestCaseChecker(testClass = ClassWithEnum::class) {
@Test
fun testOrdinal() {
withConcrete(useConcreteExecution = false) {
checkAllCombinations(ClassWithEnum::useOrdinal)
}
checkAllCombinations(ClassWithEnum::useOrdinal)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.utbot.tests.infrastructure.isException
import org.utbot.framework.plugin.api.CodegenLanguage
import org.junit.jupiter.api.Test
import org.utbot.testcheckers.eq
import org.utbot.testcheckers.withConcrete
import org.utbot.tests.infrastructure.CodeGeneration

internal class ExceptionExamplesTest : UtValueTestCaseChecker(
Expand Down Expand Up @@ -112,16 +111,14 @@ internal class ExceptionExamplesTest : UtValueTestCaseChecker(
*/
@Test
fun testCatchExceptionAfterOtherPossibleException() {
withConcrete(useConcreteExecution = false) {
checkWithException(
ExceptionExamples::catchExceptionAfterOtherPossibleException,
eq(3),
{ i, r -> i == -1 && r.isException<ArithmeticException>() },
{ i, r -> i == 0 && r.getOrThrow() == 2 },
{ i, r -> r.getOrThrow() == 1 },
coverage = atLeast(100)
)
}
checkWithException(
ExceptionExamples::catchExceptionAfterOtherPossibleException,
eq(3),
{ i, r -> i == -1 && r.isException<ArithmeticException>() },
{ i, r -> i == 0 && r.getOrThrow() == 2 },
{ i, r -> r.getOrThrow() == 1 },
coverage = atLeast(100)
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.utbot.tests.infrastructure.ignoreExecutionsNumber
import org.utbot.tests.infrastructure.isException
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.testcheckers.eq
import org.utbot.testcheckers.withConcrete
import org.utbot.tests.infrastructure.AtLeast
import org.utbot.tests.infrastructure.CodeGeneration
import java.util.Optional
Expand All @@ -31,28 +30,24 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
) {
@Test
fun testReturningStreamExample() {
withConcrete(useConcreteExecution = false) {
check(
BaseStreamExample::returningStreamExample,
eq(2),
// NOTE: the order of the matchers is important because Stream could be used only once
{ c, r -> c.isNotEmpty() && c == r!!.toList() },
{ c, r -> c.isEmpty() && c == r!!.toList() },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}
check(
BaseStreamExample::returningStreamExample,
eq(2),
// NOTE: the order of the matchers is important because Stream could be used only once
{ c, r -> c.isNotEmpty() && c == r!!.toList() },
{ c, r -> c.isEmpty() && c == r!!.toList() },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
fun testReturningStreamAsParameterExample() {
withConcrete(useConcreteExecution = false) {
check(
BaseStreamExample::returningStreamAsParameterExample,
eq(1),
{ s, r -> s != null && s.toList() == r!!.toList() },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}
check(
BaseStreamExample::returningStreamAsParameterExample,
eq(1),
{ s, r -> s != null && s.toList() == r!!.toList() },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
Expand Down Expand Up @@ -389,16 +384,14 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(

@Test
fun testStreamOfExample() {
withConcrete(useConcreteExecution = false) {
check(
BaseStreamExample::streamOfExample,
ignoreExecutionsNumber,
// NOTE: the order of the matchers is important because Stream could be used only once
{ c, r -> c.isNotEmpty() && c.contentEquals(r!!.toArray()) },
{ c, r -> c.isEmpty() && Stream.empty<Int>().toArray().contentEquals(r!!.toArray()) },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}
check(
BaseStreamExample::streamOfExample,
ignoreExecutionsNumber,
// NOTE: the order of the matchers is important because Stream could be used only once
{ c, r -> c.isNotEmpty() && c.contentEquals(r!!.toArray()) },
{ c, r -> c.isEmpty() && Stream.empty<Int>().toArray().contentEquals(r!!.toArray()) },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.testcheckers.eq
import org.utbot.testcheckers.withPathSelectorStepsLimit
import org.utbot.testcheckers.withConcrete
import org.utbot.tests.infrastructure.*
import java.util.OptionalDouble
import java.util.stream.DoubleStream
Expand Down Expand Up @@ -35,14 +34,12 @@ class DoubleStreamExampleTest : UtValueTestCaseChecker(

@Test
fun testReturningStreamAsParameterExample() {
withConcrete(useConcreteExecution = false) {
check(
DoubleStreamExample::returningStreamAsParameterExample,
eq(1),
{ s, r -> s != null && s.toList() == r!!.toList() },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}
check(
DoubleStreamExample::returningStreamAsParameterExample,
eq(1),
{ s, r -> s != null && s.toList() == r!!.toList() },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
Expand Down Expand Up @@ -325,41 +322,39 @@ class DoubleStreamExampleTest : UtValueTestCaseChecker(

@Test
fun testSummaryStatisticsExample() {
withConcrete(useConcreteExecution = false) {
check(
DoubleStreamExample::summaryStatisticsExample,
ignoreExecutionsNumber,
{ c, r ->
val sum = r!!.sum
val count = r.count
val min = r.min
val max = r.max
check(
DoubleStreamExample::summaryStatisticsExample,
ignoreExecutionsNumber,
{ c, r ->
val sum = r!!.sum
val count = r.count
val min = r.min
val max = r.max

val allStatisticsAreCorrect = sum == 0.0 &&
count == 0L &&
min == Double.POSITIVE_INFINITY &&
max == Double.NEGATIVE_INFINITY
val allStatisticsAreCorrect = sum == 0.0 &&
count == 0L &&
min == Double.POSITIVE_INFINITY &&
max == Double.NEGATIVE_INFINITY

c.isEmpty() && allStatisticsAreCorrect
},
{ c, r ->
val sum = r!!.sum
val count = r.count
val min = r.min
val max = r.max
c.isEmpty() && allStatisticsAreCorrect
},
{ c, r ->
val sum = r!!.sum
val count = r.count
val min = r.min
val max = r.max

val doubles = c.doubles()
val doubles = c.doubles()

val allStatisticsAreCorrect = sum == doubles.sum() &&
count == doubles.size.toLong() &&
min == doubles.minOrNull() &&
max == doubles.maxOrNull()
val allStatisticsAreCorrect = sum == doubles.sum() &&
count == doubles.size.toLong() &&
min == doubles.minOrNull() &&
max == doubles.maxOrNull()

c.isNotEmpty() && allStatisticsAreCorrect
},
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}
c.isNotEmpty() && allStatisticsAreCorrect
},
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
Expand Down Expand Up @@ -486,16 +481,14 @@ class DoubleStreamExampleTest : UtValueTestCaseChecker(

@Test
fun testStreamOfExample() {
withConcrete(useConcreteExecution = false) {
check(
DoubleStreamExample::streamOfExample,
ignoreExecutionsNumber,
// NOTE: the order of the matchers is important because Stream could be used only once
{ c, r -> c.isNotEmpty() && c.contentEquals(r!!.toArray()) },
{ c, r -> c.isEmpty() && DoubleStream.empty().toArray().contentEquals(r!!.toArray()) },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}
check(
DoubleStreamExample::streamOfExample,
ignoreExecutionsNumber,
// NOTE: the order of the matchers is important because Stream could be used only once
{ c, r -> c.isNotEmpty() && c.contentEquals(r!!.toArray()) },
{ c, r -> c.isEmpty() && DoubleStream.empty().toArray().contentEquals(r!!.toArray()) },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
Expand Down
Loading

0 comments on commit 53411ad

Please sign in to comment.