Suppress 'Result of call ignored' when exception is expected in tests

GitOrigin-RevId: de4277b9eaf93b19d71c832f1649a53935f2c1f6
This commit is contained in:
Tagir Valeev
2024-06-25 18:06:51 +02:00
committed by intellij-monorepo-bot
parent 180c1fe1e9
commit 346ef0d213
2 changed files with 10 additions and 2 deletions

View File

@@ -5,8 +5,8 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Segment;
import com.intellij.openapi.util.UnfairTextRange;
import com.intellij.tools.ide.metrics.benchmark.PerformanceTestUtil;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.tools.ide.metrics.benchmark.PerformanceTestUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.concurrency.AppExecutorUtil;
@@ -59,6 +59,7 @@ public class ContainerUtilTest extends TestCase {
assertEquals(4, (int)l.get(3));
try {
//noinspection ResultOfMethodCallIgnored
l.get(-1);
fail();
}
@@ -66,6 +67,7 @@ public class ContainerUtilTest extends TestCase {
}
try {
//noinspection ResultOfMethodCallIgnored
l.get(4);
fail();
}
@@ -84,6 +86,7 @@ public class ContainerUtilTest extends TestCase {
try {
a1.clear();
//noinspection ResultOfMethodCallIgnored
l.get(3);
fail();
}

View File

@@ -20,12 +20,17 @@ public class TextRangeTest {
assertEquals("", new TextRange(2, 2).substring("abcd"));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void cutOut() {
assertEquals(new TextRange(1, 5), new TextRange(1, 5).cutOut(new TextRange(0, 4)));
assertEquals(new TextRange(2, 5), new TextRange(1, 5).cutOut(new TextRange(1, 4)));
assertEquals(new TextRange(1, 4), new TextRange(1, 5).cutOut(new TextRange(0, 3)));
assertEquals(new TextRange(3, 3), new TextRange(1, 5).cutOut(new TextRange(2, 2)));
}
@Test(expected = IllegalArgumentException.class)
public void cutOutExc() {
//noinspection ResultOfMethodCallIgnored
new TextRange(1, 5).cutOut(new TextRange(1, 10));
}