Skip to content

Fix switch summary content & add extra summary test#1779

Merged
EgorkaKulikov merged 1 commit intomainfrom
andrey-t/switch_summary_fixes
Feb 9, 2023
Merged

Fix switch summary content & add extra summary test#1779
EgorkaKulikov merged 1 commit intomainfrom
andrey-t/switch_summary_fixes

Conversation

@sofurihafe
Copy link
Copy Markdown
Member

@sofurihafe sofurihafe commented Feb 8, 2023

Description

This PR fixes missing arguments in summary texts and unmatched display names.
Also, there was an incorrect summary test (SummaryIntMathPowTest.kt) which was fixed as well.

Fixes #756

How to test

Automated tests

utbot-samples.

Manual tests

Generate a test for the following method:

public int symbolToInt(char c) {
    switch (c) {
        case 'I': return 1;
        case 'V': return 5;
        case 'X': return 10;
        case 'L': return 50;
        case 'C': return 100;
        case 'D': return 500;
        case 'M': return 1000;
        default: throw new IllegalArgumentException("Unrecognized symbol: " + c);
    }
}

As the result, correct summaries and display names will be generated:

    /**
     * @utbot.classUnderTest {@link Switch}
     * @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#symbolToInt(char)}
     * @utbot.activatesSwitch {@code case 'C'}
     * @utbot.returnsFrom {@code return 100;}
     */
    @Test
    @DisplayName("symbolToInt: switch(c) case: 'C' -> return 100")
    public void testSymbolToInt_Return100() {
        Switch switch1 = new Switch();
        
        int actual = switch1.symbolToInt('C');
        
        assertEquals(100, actual);
    }
    
    /**
     * @utbot.classUnderTest {@link Switch}
     * @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#symbolToInt(char)}
     * @utbot.activatesSwitch {@code case 'V'}
     * @utbot.returnsFrom {@code return 5;}
     */
    @Test
    @DisplayName("symbolToInt: switch(c) case: 'V' -> return 5")
    public void testSymbolToInt_Return5() {
        Switch switch1 = new Switch();
        
        int actual = switch1.symbolToInt('V');
        
        assertEquals(5, actual);
    }

@sofurihafe sofurihafe added comp-codegen Issue is related to code generator comp-summaries Something related to the method names, code comments and display names generation ctg-bug-fix PR is fixing a bug labels Feb 8, 2023
@sofurihafe sofurihafe force-pushed the andrey-t/switch_summary_fixes branch 4 times, most recently from 3d98556 to 9f0fa52 Compare February 8, 2023 17:42
@sofurihafe sofurihafe force-pushed the andrey-t/switch_summary_fixes branch from 9f0fa52 to 3ca9e45 Compare February 8, 2023 17:58
@EgorkaKulikov EgorkaKulikov merged commit a2dcd6e into main Feb 9, 2023
@EgorkaKulikov EgorkaKulikov deleted the andrey-t/switch_summary_fixes branch February 9, 2023 07:28
@alisevych alisevych added this to the 2023.03 Release milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-codegen Issue is related to code generator comp-summaries Something related to the method names, code comments and display names generation ctg-bug-fix PR is fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong descriptions are generated for switch cases

3 participants