Skip to content
Merged
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
Restored SummaryCycleTest.kt
  • Loading branch information
amandelpie committed Jul 4, 2022
commit 1ba59c242133d185c76a98f0e9a4ab01e28024a0
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest(
val methodName5 = "testInnerReturnCallCompare_ALessThanB"
val methodName6 = "testInnerReturnCallCompare_AGreaterOrEqualB"

val displayName1 = "b < 0 : True -> return a" // TODO: the same display names for many tests with different test names
val displayName1 =
"b < 0 : True -> return a" // TODO: the same display names for many tests with different test names
val displayName2 = "a > b : True -> return b"
val displayName3 = "b == 10 : True -> return c"
val displayName4 = "a < 0 : False -> return a"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,128 @@ import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Tag
import org.utbot.examples.controlflow.Cycles
import org.junit.jupiter.api.Test
@Disabled
import org.utbot.examples.DoNotCalculate
import org.utbot.examples.algorithms.ReturnExample
import org.utbot.framework.plugin.api.MockStrategyApi

class SummaryCycleTest : SummaryTestCaseGeneratorTest(
Cycles::class,
) {

val summaryLoopInsideLoop1 = "<pre>\n" +
"Test iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" +
" inside this loop, the test executes conditions:\n" +
" {@code (i < 0): True}\n" +
"returns from: {@code return 2;}\n" +
"</pre>"
val summaryLoopInsideLoop2 = "<pre>\n" +
"Test does not iterate {@code for(int i = x - 5; i < x; i++)}, {@code for(int j = i; j < x + i; j++)}, returns from: {@code return -1;}\n" +
"</pre>"
val summaryLoopInsideLoop3 = "<pre>\n" +
"Test iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" +
" inside this loop, the test executes conditions:\n" +
" {@code (i < 0): False}\n" +
"iterates the loop {@code for(int j = i; j < x + i; j++)} once,\n" +
" inside this loop, the test executes conditions:\n" +
" {@code (j == 7): True}\n" +
"returns from: {@code return 1;}\n" +
"</pre>"
val summaryLoopInsideLoop4 = "<pre>\n" +
"Test iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" +
" inside this loop, the test executes conditions:\n" +
" {@code (i < 0): False}\n" +
"iterates the loop {@code for(int j = i; j < x + i; j++)} twice,\n" +
" inside this loop, the test executes conditions:\n" +
" {@code (j == 7): False}\n" +
" {@code (j == 7): True}\n" +
"returns from: {@code return 1;}\n" +
"</pre>"
val summaryLoopInsideLoop5 = "<pre>\n" +
"Test iterates the loop {@code for(int i = x - 5; i < x; i++)} 5 times."

@Test
fun testLoopInsideLoop() {
checkOneArgument(
Cycles::loopInsideLoop,
summaryKeys = listOf(
summaryLoopInsideLoop1,
summaryLoopInsideLoop2,
summaryLoopInsideLoop3,
summaryLoopInsideLoop4,
summaryLoopInsideLoop5
),
displayNames = listOf(
"i < 0 : True -> return 2",
"-> return -1",
"i < 0 : False -> return 1",
"j == 7 : False -> return 1",
"-> return -1"
)
val summary1 = "Test iterates the loop for(int i = x - 5; i < x; i++) once,\n" +
" inside this loop, the test executes conditions:\n" +
" (i < 0): True\n" +
"returns from: return 2;"
val summary2 = "Test does not iterate for(int i = x - 5; i < x; i++), for(int j = i; j < x + i; j++), returns from: return -1;\n" // TODO: should it be formatted from the new string?
val summary3 = "Test iterates the loop for(int i = x - 5; i < x; i++) once,\n" +
" inside this loop, the test executes conditions:\n" +
" (i < 0): False\n" +
"iterates the loop for(int j = i; j < x + i; j++) once,\n" +
" inside this loop, the test executes conditions:\n" +
" (j == 7): True\n" +
"returns from: return 1;"
val summary4 = "Test iterates the loop for(int i = x - 5; i < x; i++) once,\n" +
" inside this loop, the test executes conditions:\n" +
" (i < 0): False\n" +
"iterates the loop for(int j = i; j < x + i; j++) twice,\n" +
" inside this loop, the test executes conditions:\n" +
" (j == 7): False\n" +
" (j == 7): True\n" +
"returns from: return 1;"
val summary5 = "Test iterates the loop for(int i = x - 5; i < x; i++) 5 times. \n" +
"Test afterwards does not iterate for(int j = i; j < x + i; j++), returns from: return -1;\n" // TODO: should it be formatted with separation of code?

val methodName1 = "testLoopInsideLoop_ILessThanZero"
val methodName2 = "testLoopInsideLoop_ReturnNegative1"
val methodName3 = "testLoopInsideLoop_JEquals7"
val methodName4 = "testLoopInsideLoop_JNotEquals7"
val methodName5 = "testLoopInsideLoop_ReturnNegative1_1"


val displayName1 = "i < 0 : True -> return 2"
val displayName2 = "-> return -1" // TODO: add something before ->
val displayName3 = "i < 0 : False -> return 1"
val displayName4 = "j == 7 : False -> return 1"
val displayName5 = "-> return -1"


val summaryKeys = listOf(
summary1,
summary2,
summary3,
summary4,
summary5
)

val displayNames = listOf(
displayName1,
displayName2,
displayName3,
displayName4,
displayName5
)

val methodNames = listOf(
methodName1,
methodName2,
methodName3,
methodName4,
methodName5
)
}

val summaryStructureLoop1 = "<pre>\n" +
"Test does not iterate {@code for(int i = 0; i < x; i++)}, returns from: {@code return -1;}\n" +
"</pre>"
val summaryStructureLoop2 = "<pre>\n" +
"Test iterates the loop {@code for(int i = 0; i < x; i++)} once,\n" +
" inside this loop, the test executes conditions:\n" +
" {@code (i == 2): False}\n"
val summaryStructureLoop3 = "<pre>\n" +
"Test iterates the loop {@code for(int i = 0; i < x; i++)} 3 times,\n" +
" inside this loop, the test executes conditions:\n" +
" {@code (i == 2): True}\n" +
"returns from: {@code return 1;}\n" +
"</pre>"
val method = Cycles::loopInsideLoop
val mockStrategy = MockStrategyApi.NO_MOCKS
val coverage = DoNotCalculate

check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
}

@Test
fun testStructureLoop() {
checkOneArgument(
Cycles::structureLoop,
summaryKeys = listOf(
summaryStructureLoop1,
summaryStructureLoop2,
summaryStructureLoop3
),
displayNames = listOf(
"-> return -1",
"i == 2 : False -> return -1",
"i == 2 : True -> return 1"
)
val summary1 = "Test does not iterate for(int i = 0; i < x; i++), returns from: return -1;\n"
val summary2 = "Test iterates the loop for(int i = 0; i < x; i++) once,\n" +
" inside this loop, the test executes conditions:\n" +
" (i == 2): False\n" +
"Test further returns from: return -1;\n"
val summary3 = "Test iterates the loop for(int i = 0; i < x; i++) 3 times,\n" +
" inside this loop, the test executes conditions:\n" +
" (i == 2): True\n" +
"returns from: return 1;"

val methodName1 = "testStructureLoop_ReturnNegative1"
val methodName2 = "testStructureLoop_INotEquals2"
val methodName3 = "testStructureLoop_IEquals2"


val displayName1 = "-> return -1"
val displayName2 = "i == 2 : False -> return -1"
val displayName3 = "i == 2 : True -> return 1"


val summaryKeys = listOf(
summary1,
summary2,
summary3
)

val displayNames = listOf(
displayName1,
displayName2,
displayName3
)

val methodNames = listOf(
methodName1,
methodName2,
methodName3
)

val method = Cycles::structureLoop
val mockStrategy = MockStrategyApi.NO_MOCKS
val coverage = DoNotCalculate

check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
}

}