]> source.dussan.org Git - sonarqube.git/commitdiff
WIP: Add test
authorMartin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com>
Mon, 27 Nov 2023 16:04:14 +0000 (17:04 +0100)
committerGitHub <noreply@github.com>
Mon, 27 Nov 2023 16:04:14 +0000 (17:04 +0100)
sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java

index 4997a11dd555de71fb4da0890a61da17f0c80ee0..1f40ff3107cfb95672c8cebea1fdcb4985ebdb56 100644 (file)
@@ -67,4 +67,16 @@ public class DefaultSymbolTableTest {
     assertThat(referencesPerSymbol).hasSize(2);
   }
 
+  @Test
+  public void should_fail_on_reference_overlaps_declaration() {
+    DefaultSymbolTable symbolTableBuilder = new DefaultSymbolTable(mock(SensorStorage.class))
+      .onFile(INPUT_FILE);
+    symbolTableBuilder = symbolTableBuilder
+      .newSymbol(1, 0, 1, 10);
+    
+    assertThatThrownBy(() -> {
+      symbolTableBuilder.newReference(1, 0, 1, 10);
+    }).isInstanceOf(IllegalArgumentException.class)
+      .hasMessageMatching(".*");
+  }
 }