2 * Sixth - System for data storage, computation, exploration and interaction.
3 * Author: Svjatoslav Agejenko.
4 * This project is released under Creative Commons Zero (CC0) license.
8 package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
10 import org.junit.Test;
12 import static org.junit.Assert.assertEquals;
14 public class TextLineTest {
17 public void testAddIdent() {
18 TextLine textLine = new TextLine("test");
20 assertEquals(" test", textLine.toString());
22 textLine = new TextLine();
24 assertEquals("", textLine.toString());
28 public void testCutFromBeginning() {
29 TextLine textLine = new TextLine("test");
30 textLine.cutFromBeginning(2);
31 assertEquals("st", textLine.toString());
33 textLine = new TextLine("test");
34 textLine.cutFromBeginning(4);
35 assertEquals("", textLine.toString());
37 textLine = new TextLine("test");
38 textLine.cutFromBeginning(5);
39 assertEquals("", textLine.toString());
41 textLine = new TextLine("test");
42 textLine.cutFromBeginning(100);
43 assertEquals("", textLine.toString());
47 public void testCutSubString() {
48 TextLine textLine = new TextLine("test");
49 assertEquals("es", textLine.cutSubString(1, 3));
50 assertEquals("tt", textLine.toString());
52 textLine = new TextLine("test");
53 assertEquals("st ", textLine.cutSubString(2, 5));
54 assertEquals("te", textLine.toString());
58 public void testGetCharForLocation() {
59 final TextLine textLine = new TextLine("test");
60 assertEquals('s', textLine.getCharForLocation(2));
61 assertEquals('t', textLine.getCharForLocation(3));
62 assertEquals(' ', textLine.getCharForLocation(4));
66 public void testGetIdent() {
67 final TextLine textLine = new TextLine(" test");
68 assertEquals(3, textLine.getIdent());
72 public void testGetLength() {
73 final TextLine textLine = new TextLine("test");
74 assertEquals(4, textLine.getLength());
78 public void testInsertCharacter() {
79 TextLine textLine = new TextLine("test");
80 textLine.insertCharacter(1, 'o');
81 assertEquals("toest", textLine.toString());
83 textLine = new TextLine("test");
84 textLine.insertCharacter(5, 'o');
85 assertEquals("test o", textLine.toString());
90 public void testIsEmpty() {
91 TextLine textLine = new TextLine("");
92 assertEquals(true, textLine.isEmpty());
94 textLine = new TextLine(" ");
95 assertEquals(true, textLine.isEmpty());
97 textLine = new TextLine("l");
98 assertEquals(false, textLine.isEmpty());
102 public void testRemoveCharacter() {
103 TextLine textLine = new TextLine("test");
104 textLine.removeCharacter(0);
105 assertEquals("est", textLine.toString());
107 textLine = new TextLine("test");
108 textLine.removeCharacter(3);
109 assertEquals("tes", textLine.toString());
111 textLine = new TextLine("test");
112 textLine.removeCharacter(4);
113 assertEquals("test", textLine.toString());