Files
openide/plugins/coverage/testData/conditions/testSrc/SwitchesTest.java
Maksim Zuev 2c6d2d763e [coverage] IDEA-340739 Fix switch labels
* using labels from PSI requires order guaranties in bytecode

* only Java switch by string is guarantied to have the same order (as it has 2 switches in bytecode)

GitOrigin-RevId: 6c58cb503ff21beca5b14fa2e1a6c486c559cf4a
2024-01-10 20:18:22 +00:00

98 lines
2.8 KiB
Java

import junit.framework.TestCase;
public class SwitchesTest extends TestCase {
public void test() {
Switches switches = new Switches();
switches.singleBranchSwitch1(1);
switches.singleBranchSwitch2(2);
switches.defaultBranchSwitch(3);
switches.fullyCoveredSwitch(1);
switches.fullyCoveredSwitch(2);
switches.fullyCoveredSwitchWithDefault(1);
switches.fullyCoveredSwitchWithDefault(2);
switches.fullyCoveredSwitchWithDefault(3);
switches.fullyCoveredSwitchWithoutDefault(1);
switches.fullyCoveredSwitchWithoutDefault(2);
switches.fullyCoveredSwitchWithImplicitDefault(1);
switches.fullyCoveredSwitchWithImplicitDefault(2);
switches.fullyCoveredSwitchWithImplicitDefault(3);
switches.switchWithFallThrough(1);
switches.stringSwitch("A");
switches.fullStringSwitch("A");
switches.fullStringSwitch("B");
switches.fullStringSwitch("C");
switches.stringSwitchSameHashCode("Aa");
switches.stringSwitchSameHashCode("BB");
switches.stringSwitchSameHashCode("C");
switches.tableSwitch(4);
switches.tableSwitch(4);
switches.tableSwitch(4);
switches.tableSwitch(4);
switches.tableSwitch(3);
switches.tableSwitch(3);
switches.tableSwitch(3);
switches.tableSwitch(2);
switches.tableSwitch(2);
switches.tableSwitch(1);
}
public void testKotlin() {
KtSwitches switches = new KtSwitches();
switches.singleBranchSwitch1(1);
switches.singleBranchSwitch2(2);
switches.defaultBranchSwitch(3);
switches.fullyCoveredSwitch(1);
switches.fullyCoveredSwitch(2);
switches.fullyCoveredSwitchWithDefault(1);
switches.fullyCoveredSwitchWithDefault(2);
switches.fullyCoveredSwitchWithDefault(3);
switches.fullyCoveredSwitchWithoutDefault(1);
switches.fullyCoveredSwitchWithoutDefault(2);
switches.fullyCoveredSwitchWithImplicitDefault(1);
switches.fullyCoveredSwitchWithImplicitDefault(2);
switches.fullyCoveredSwitchWithImplicitDefault(3);
switches.fullyCoveredSwitchWithImplicitDefault(4);
switches.switchWithOnlyTwoBranchesTransformsIntoIf("A");
switches.stringSwitch("A");
switches.fullStringSwitch("A");
switches.fullStringSwitch("B");
switches.fullStringSwitch("C");
switches.fullStringSwitch("D");
switches.stringSwitchSameHashCode("Aa");
switches.stringSwitchSameHashCode("BB");
switches.stringSwitchSameHashCode("C");
switches.stringSwitchSameHashCode("D");
switches.stringSwitchSameHashCode("E");
switches.tableSwitch(4);
switches.tableSwitch(4);
switches.tableSwitch(4);
switches.tableSwitch(4);
switches.tableSwitch(3);
switches.tableSwitch(3);
switches.tableSwitch(3);
switches.tableSwitch(2);
switches.tableSwitch(2);
switches.tableSwitch(1);
}
}