-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextEditorTest.java
More file actions
35 lines (26 loc) · 1.26 KB
/
TextEditorTest.java
File metadata and controls
35 lines (26 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringReader;
import static org.junit.jupiter.api.Assertions.*;
public class TextEditorTest {
private static final TextEditor editor = new TextEditor();
private static final String data = "Ivan is very beautiful.\nStoyan is piece of shit.\n\nVlado is SAP guru.";
@Test
public void testSwapTwoRows() throws IOException {
String expected = "\nStoyan is piece of shit.\nIvan is very beautiful.\nVlado is SAP guru.";
String actual = editor.swapTwoRows(2, 0, new StringReader(data));
assertEquals(expected, actual);
}
@Test
public void testSwapTwoWordsOnDifferentRows() throws IOException {
String expected = "Stoyan is very beautiful.\nIvan is piece of shit.\n\nVlado is SAP guru.";
String actual = editor.swapTwoWords(0, 0, 1, 0, new StringReader(data));
assertEquals(expected, actual);
}
@Test
public void testSwapTwoWordsOnSameRows() throws IOException {
String expected = "very is Ivan beautiful.\nStoyan is piece of shit.\n\nVlado is SAP guru.";
String actual = editor.swapTwoWords(0, 0, 0, 2, new StringReader(data));
assertEquals(expected, actual);
}
}