- 
                Notifications
    You must be signed in to change notification settings 
- Fork 45
Add summary tests for ListWrapperReturnsVoidExample #444
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
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            130 changes: 130 additions & 0 deletions
          
          130 
        
  ...t-summary-tests/src/test/kotlin/examples/collections/SummaryListWrapperReturnsVoidTest.kt
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| package examples.collections | ||
|  | ||
| import examples.SummaryTestCaseGeneratorTest | ||
| import org.junit.jupiter.api.Test | ||
| import org.utbot.examples.DoNotCalculate | ||
| import org.utbot.examples.collections.ListWrapperReturnsVoidExample | ||
| import org.utbot.framework.plugin.api.MockStrategyApi | ||
|  | ||
| /** | ||
| * Tests verify that the previously discovered bug is not reproducible anymore. | ||
| * | ||
| * To get more details, see [issue-437](https://github.com/UnitTestBot/UTBotJava/issues/437) | ||
| */ | ||
| class SummaryListWrapperReturnsVoidTest : SummaryTestCaseGeneratorTest( | ||
| ListWrapperReturnsVoidExample::class, | ||
| ) { | ||
| @Test | ||
| fun testRunForEach() { | ||
| val summary1 = "Test throws NullPointerException in: list.forEach(o -> {\n" + | ||
| " if (o == null)\n" + | ||
| " i[0]++;\n" + | ||
| "});" | ||
| val summary2 = "Test returns from: return i[0];" | ||
| val summary3 = "Test returns from: return i[0];" | ||
| val summary4 = "Test returns from: return i[0];" | ||
|  | ||
| val methodName1 = "testRunForEach_ThrowNullPointerException" | ||
| val methodName2 = "testRunForEach_Return0OfI" | ||
| val methodName3 = "testRunForEach_Return0OfI_1" | ||
| val methodName4 = "testRunForEach_Return0OfI_2" | ||
|  | ||
| val displayName1 = "list.forEach(o -> { if (o == null) i[0]++ }) : True -> ThrowNullPointerException" | ||
| val displayName2 = "-> return i[0]" | ||
| val displayName3 = "-> return i[0]" | ||
| val displayName4 = "-> return i[0]" | ||
|  | ||
| val summaryKeys = listOf( | ||
| summary1, | ||
| summary2, | ||
| summary3, | ||
| summary4 | ||
| ) | ||
|  | ||
| val displayNames = listOf( | ||
| displayName1, | ||
| displayName2, | ||
| displayName3, | ||
| displayName4 | ||
| ) | ||
|  | ||
| val methodNames = listOf( | ||
| methodName1, | ||
| methodName2, | ||
| methodName3, | ||
| methodName4 | ||
| ) | ||
|  | ||
| val method = ListWrapperReturnsVoidExample::runForEach | ||
| val mockStrategy = MockStrategyApi.NO_MOCKS | ||
| val coverage = DoNotCalculate | ||
|  | ||
| check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) | ||
| } | ||
|  | ||
| @Test | ||
| fun testSumPositiveForEach() { | ||
| val summary1 = "Test throws NullPointerException in: list.forEach(i -> {\n" + | ||
| " if (i > 0) {\n" + | ||
| " sum[0] += i;\n" + | ||
| " }\n" + | ||
| "});" | ||
| val summary2 = "Test invokes: List::forEach once\n" + | ||
| "throws NullPointerException in: list.forEach(i -> {\n" + | ||
| " if (i > 0) {\n" + | ||
| " sum[0] += i;\n" + | ||
| " }\n" + | ||
| "});" | ||
| val summary3 = "Test executes conditions:\n" + | ||
| " (sum[0] == 0): True\n" + | ||
| "returns from: return 0;" | ||
| val summary4 = "Test executes conditions:\n" + | ||
| " (sum[0] == 0): True\n" + | ||
| "returns from: return 0;" | ||
| val summary5 = "Test executes conditions:\n" + | ||
| " (sum[0] == 0): False\n" + | ||
| "returns from: return sum[0];" | ||
|  | ||
| val methodName1 = "testSumPositiveForEach_ThrowNullPointerException" | ||
| val methodName2 = "testSumPositiveForEach_ListForEach" | ||
| val methodName3 = "testSumPositiveForEach_0OfSumEqualsZero" | ||
| val methodName4 = "testSumPositiveForEach_0OfSumEqualsZero_1" | ||
| val methodName5 = "testSumPositiveForEach_0OfSumNotEqualsZero" | ||
|  | ||
| val displayName1 = "list.forEach(i -> { if (i > 0) { sum[0] += i } }) : True -> ThrowNullPointerException" | ||
| val displayName2 = "list.forEach(i -> { if (i > 0) { sum[0] += i } }) : True -> ThrowNullPointerException" | ||
| val displayName3 = "sum[0] == 0 : True -> return 0" | ||
| val displayName4 = "sum[0] == 0 : True -> return 0" | ||
| val displayName5 = "sum[0] == 0 : False -> return sum[0]" | ||
|  | ||
| 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 method = ListWrapperReturnsVoidExample::sumPositiveForEach | ||
| val mockStrategy = MockStrategyApi.NO_MOCKS | ||
| val coverage = DoNotCalculate | ||
|  | ||
| check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) | ||
| } | ||
| } | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.