mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 19:31:16 +01:00
Refactored TabLineFactory into ProblemFactory. (#7)
* Refactored TabLineFactory into ProblemFactory. As part of https://github.com/processing/processing4/pull/1, refactored TabLineFactory into ProblemFactory, merging tests in the process. * Fix imports on https://github.com/sampottinger/processing4/pull/7.
This commit is contained in:
committed by
GitHub
parent
0febfce456
commit
2b05da132a
@@ -18,6 +18,7 @@ public class ProblemFactoryTest {
|
||||
private PdePreprocessIssue pdePreprocessIssue;
|
||||
private List<Integer> tabStarts;
|
||||
private Editor editor;
|
||||
private List<Integer> starts;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -29,6 +30,11 @@ public class ProblemFactoryTest {
|
||||
editor = Mockito.mock(Editor.class);
|
||||
Mockito.when(editor.getLineStartOffset(3)).thenReturn(10);
|
||||
Mockito.when(editor.getLineStopOffset(3)).thenReturn(12);
|
||||
|
||||
starts = new ArrayList<>();
|
||||
starts.add(0);
|
||||
starts.add(5);
|
||||
starts.add(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,4 +55,31 @@ public class ProblemFactoryTest {
|
||||
Assert.assertEquals("test", problem.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void getTabStart() {
|
||||
Assert.assertEquals(0, ProblemFactory.getTab(starts, 0).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddleFrontEdge() {
|
||||
Assert.assertEquals(1, ProblemFactory.getTab(starts, 5).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddle() {
|
||||
TabLine tabLine = ProblemFactory.getTab(starts, 7);
|
||||
Assert.assertEquals(1, tabLine.getTab());
|
||||
Assert.assertEquals(2, tabLine.getLineInTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddleBackEdge() {
|
||||
Assert.assertEquals(2, ProblemFactory.getTab(starts, 10).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabEnd() {
|
||||
Assert.assertEquals(2, ProblemFactory.getTab(starts, 15).getTab());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package processing.mode.java.pdex.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TabLineFactoryTest {
|
||||
|
||||
private List<Integer> starts;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
starts = new ArrayList<>();
|
||||
starts.add(0);
|
||||
starts.add(5);
|
||||
starts.add(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabStart() {
|
||||
Assert.assertEquals(0, TabLineFactory.getTab(starts, 0).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddleFrontEdge() {
|
||||
Assert.assertEquals(1, TabLineFactory.getTab(starts, 5).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddle() {
|
||||
TabLine tabLine = TabLineFactory.getTab(starts, 7);
|
||||
Assert.assertEquals(1, tabLine.getTab());
|
||||
Assert.assertEquals(2, tabLine.getLineInTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddleBackEdge() {
|
||||
Assert.assertEquals(2, TabLineFactory.getTab(starts, 10).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabEnd() {
|
||||
Assert.assertEquals(2, TabLineFactory.getTab(starts, 15).getTab());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user