Skip to content

Commit

Permalink
Bugfix for #1803: [Externalize Strings] IndexOutOfBoundsException.
Browse files Browse the repository at this point in the history
  • Loading branch information
nettozahler committed Dec 2, 2024
1 parent bf9e330 commit 2dd8b6d
Showing 1 changed file with 68 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,84 +37,78 @@ public class NLSHintStripQuotesTest {
@Rule
public Java15ProjectTestSetup pts15= new Java15ProjectTestSetup();

private IJavaProject javaProject;
private IJavaProject javaProject15;
private IJavaProject javaProject;
private IJavaProject javaProject15;

@Before

@Before
public void setUp() throws Exception {
javaProject= pts.getProject();
javaProject15= pts15.getProject();
}
javaProject= pts.getProject();
javaProject15= pts15.getProject();
}

@After
@After
public void tearDown() throws Exception {
JavaProjectHelper.clear(javaProject, pts.getDefaultClasspath());
JavaProjectHelper.clear(javaProject15, pts15.getDefaultClasspath());
}

@Test
public void test01() throws Exception {
String x= "\"abc\n\"";
String y= NLSHint.stripQuotes(x, javaProject.getJavaProject());
String expected= "abc\n";
assertEquals(expected, y);
}

@Test
public void test02() throws Exception {
String x= "\"\"\"abc\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject.getJavaProject());
String expected= "\"\"abc\n\"\"";
assertEquals(expected, y);
}

@Test
public void test03() throws Exception {
String x="\"\"\"\nabc\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc\ndef\n";
assertEquals(expected, y);
}

@Test
public void test04() throws Exception {
String x="\"\"\" \nabc\\s\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc \ndef\n";
assertEquals(expected, y);
}

@Test
public void test05() throws Exception {
String x="\"\"\" \n abc\\s\n def\n \"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc \ndef\n";
assertEquals(expected, y);
}

@Test
public void test06() throws Exception {
String x="\"\"\" \nabc \\s\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc \ndef\n";
assertEquals(expected, y);
}

@Test
public void test07() throws Exception {
String x="\"\"\" \nabc \\\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc def\n";
assertEquals(expected, y);
}

@Test
public void test08() throws Exception {
String x="\"\"\" \n abc\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= " abc\ndef\n";
assertEquals(expected, y);
}
JavaProjectHelper.clear(javaProject, pts.getDefaultClasspath());
JavaProjectHelper.clear(javaProject15, pts15.getDefaultClasspath());
}

@Test
public void test01() throws Exception {
String x= "\"abc\n\"";
String y= NLSHint.stripQuotes(x, javaProject.getJavaProject());
String expected= "abc\n";
assertEquals(expected, y);
}
@Test
public void test02() throws Exception {
String x= "\"\"\"abc\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject.getJavaProject());
String expected= "\"\"abc\n\"\"";
assertEquals(expected, y);
}
@Test
public void test03() throws Exception {
String x="\"\"\"\nabc\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc\ndef\n";
assertEquals(expected, y);
}
@Test
public void test04() throws Exception {
String x="\"\"\" \nabc\\s\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc \ndef\n";
assertEquals(expected, y);
}
@Test
public void test05() throws Exception {
String x="\"\"\" \n abc\\s\n def\n \"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc \ndef\n";
assertEquals(expected, y);
}
@Test
public void test06() throws Exception {
String x="\"\"\" \nabc \\s\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc \ndef\n";
assertEquals(expected, y);
}
@Test
public void test07() throws Exception {
String x="\"\"\" \nabc \\\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= "abc def\n";
assertEquals(expected, y);
}
@Test
public void test08() throws Exception {
String x="\"\"\" \n abc\ndef\n\"\"\"";
String y= NLSHint.stripQuotes(x, javaProject15.getJavaProject());
String expected= " abc\ndef\n";
assertEquals(expected, y);
}

@Test
public void test09() throws Exception {
Expand Down

0 comments on commit 2dd8b6d

Please sign in to comment.