1 19 20 package org.netbeans.modules.tasklist.core; 21 22 import junit.framework.Test; 23 import org.netbeans.modules.tasklist.core.util.*; 24 import org.netbeans.junit.NbTestCase; 25 import org.netbeans.junit.NbTestSuite; 26 27 30 public class TextPositionsMapperTest extends NbTestCase { 31 public TextPositionsMapperTest(String name) { 32 super(name); 33 } 34 35 public static void main (String args []) { 36 junit.textui.TestRunner.run(TextPositionsMapperTest.class); 37 } 38 39 public static Test suite () { 40 return new NbTestSuite(TextPositionsMapperTest.class); 41 } 42 43 46 public void testPositions() { 47 TextPositionsMapper m = new TextPositionsMapper( 48 "\n" + 49 "This is the first line\n" + 50 "This is the second line\r\n" + 51 "This is the third line\n" + 52 "\r" + 53 "The fifth line"); 54 int[] pos = new int[2]; 55 56 m.findPosition(0, pos); 57 assertEquals(0, pos[0]); 58 assertEquals(0, pos[1]); 59 60 m.findPosition(1, pos); 61 assertEquals(1, pos[0]); 62 assertEquals(0, pos[1]); 63 64 m.findPosition(20, pos); 65 assertEquals(1, pos[0]); 66 assertEquals(19, pos[1]); 67 68 m.findPosition(24, pos); 69 assertEquals(2, pos[0]); 70 assertEquals(0, pos[1]); 71 72 m.findPosition(49, pos); 73 assertEquals(3, pos[0]); 74 assertEquals(0, pos[1]); 75 76 m.findPosition(73, pos); 77 assertEquals(5, pos[0]); 78 assertEquals(0, pos[1]); 79 } 80 } 81 | Popular Tags |