public void TestMoveLineDownAscending() { string value = "\n" + "a\n" + "cd\n" + "fgh\n" + "jklm"; // first line int index = 0; Assert.AreEqual(value.IndexOf('a'), CStringUtils.MoveLineDown(value, index)); // second line index = value.IndexOf('a'); Assert.AreEqual(value.IndexOf('c'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('a') + 1; Assert.AreEqual(value.IndexOf('d'), CStringUtils.MoveLineDown(value, index)); // third line index = value.IndexOf('c'); Assert.AreEqual(value.IndexOf('f'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('d'); Assert.AreEqual(value.IndexOf('g'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('d') + 1; Assert.AreEqual(value.IndexOf('h'), CStringUtils.MoveLineDown(value, index)); // fourth line index = value.IndexOf('f'); Assert.AreEqual(value.IndexOf('j'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('g'); Assert.AreEqual(value.IndexOf('k'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('h'); Assert.AreEqual(value.IndexOf('l'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('h') + 1; Assert.AreEqual(value.IndexOf('m'), CStringUtils.MoveLineDown(value, index)); // fifth line index = value.IndexOf('j'); Assert.AreEqual(index, CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('k'); Assert.AreEqual(index, CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('l'); Assert.AreEqual(index, CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('m'); Assert.AreEqual(index, CStringUtils.MoveLineDown(value, index)); }
public void TestMoveLineDownEmpty() { string value = "\n" + "\n" + ""; // first line Assert.AreEqual(1, CStringUtils.MoveLineDown(value, 0)); // second line Assert.AreEqual(2, CStringUtils.MoveLineDown(value, 1)); // third line Assert.AreEqual(2, CStringUtils.MoveLineDown(value, 2)); }
public void TestMoveLineDownDescending() { string value = "abcd\n" + "fgh\n" + "jk\n" + "m\n" + "\n" + ""; // first line int index = value.IndexOf('a'); Assert.AreEqual(value.IndexOf('f'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('b'); Assert.AreEqual(value.IndexOf('g'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('c'); Assert.AreEqual(value.IndexOf('h'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('d'); Assert.AreEqual(value.IndexOf('h') + 1, CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('d') + 1; Assert.AreEqual(value.IndexOf('h') + 1, CStringUtils.MoveLineDown(value, index)); // second line index = value.IndexOf('f'); Assert.AreEqual(value.IndexOf('j'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('g'); Assert.AreEqual(value.IndexOf('k'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('h'); Assert.AreEqual(value.IndexOf('k') + 1, CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('h') + 1; Assert.AreEqual(value.IndexOf('k') + 1, CStringUtils.MoveLineDown(value, index)); // third line index = value.IndexOf('j'); Assert.AreEqual(value.IndexOf('m'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('k'); Assert.AreEqual(value.IndexOf('m') + 1, CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('k') + 1; Assert.AreEqual(value.IndexOf('m') + 1, CStringUtils.MoveLineDown(value, index)); // fourth line index = value.IndexOf('m'); Assert.AreEqual(value.LastIndexOf('\n'), CStringUtils.MoveLineDown(value, index)); index = value.IndexOf('m') + 1; Assert.AreEqual(value.LastIndexOf('\n'), CStringUtils.MoveLineDown(value, index)); // fifth line index = value.LastIndexOf('\n'); Assert.AreEqual(value.LastIndexOf('\n') + 1, CStringUtils.MoveLineDown(value, index)); index = value.LastIndexOf('\n') + 1; Assert.AreEqual(value.LastIndexOf('\n') + 1, CStringUtils.MoveLineDown(value, index)); }