Beispiel #1
0
        public void Calculate_cursor_position_from_index()
        {
            /*
             *   01234
             * 0 ab_cd
             * 1 efg
             * 2 hijkl
             * 3 mn op
             * 4 qrst
             */
            var sut      = new LineEditor("ab cd efg hijklmn op qrst", 5);
            var position = sut.GetSoftPosition(0); // before "a"

            Assert.AreEqual((0, 0), position);

            position = sut.GetSoftPosition(4); // before "d"
            Assert.AreEqual((0, 4), position);

            position = sut.GetSoftPosition(5); // after "d"
            Assert.AreEqual((0, 5), position);

            position = sut.GetSoftPosition(6); // before "e"
            Assert.AreEqual((1, 0), position);

            position = sut.GetSoftPosition(18); // before "o"
            Assert.AreEqual((3, 3), position);

            position = sut.GetSoftPosition(99); // far after "t"
            Assert.AreEqual((4, 4), position);
        }