static void Test_LineHeadIndexFromCharIndex() { TextBuffer text; SplitArray <int> lhi; MakeTestData(out text, out lhi); int i = 0; for ( ; i < 32; i++) { TestUtl.AssertEquals(0, LineLogic.GetLineHeadIndexFromCharIndex(text, lhi, i)); } for ( ; i < 33; i++) { TestUtl.AssertEquals(32, LineLogic.GetLineHeadIndexFromCharIndex(text, lhi, i)); } for ( ; i < 37; i++) { TestUtl.AssertEquals(33, LineLogic.GetLineHeadIndexFromCharIndex(text, lhi, i)); } for ( ; i < 38; i++) { TestUtl.AssertEquals(37, LineLogic.GetLineHeadIndexFromCharIndex(text, lhi, i)); } for ( ; i < 52; i++) { TestUtl.AssertEquals(38, LineLogic.GetLineHeadIndexFromCharIndex(text, lhi, i)); } for ( ; i < 53; i++) { TestUtl.AssertEquals(52, LineLogic.GetLineHeadIndexFromCharIndex(text, lhi, i)); } for ( ; i <= 71; i++) { TestUtl.AssertEquals(53, LineLogic.GetLineHeadIndexFromCharIndex(text, lhi, i)); } try{ LineLogic.GetLineHeadIndexFromCharIndex(text, lhi, i); TestUtl.Fail("exception must be thrown here."); } catch (Exception ex) { TestUtl.AssertType <AssertException>(ex); } }