public void ReserveRangeReservesCorrect() { ReservedIndexedCharList list = new ReservedIndexedCharList("ABC"); list.ReserveRange(0, 1, new NullToken()); Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 1); Assert.IsTrue(list.ToStringOnlyNoneReserved() == "C"); }
private void ReserveParanthesises(ReservedIndexedCharList list) { string current = list.ToStringOnlyNoneReserved(); if (current.CountOf('(') != current.CountOf(')')) throw new BadFormulaExpression("Parentheses does not match"); int expressionCount = current.CountOf('('); int start = 0; int end = current.Length - 1; while(expressionCount-- > 0) { start = current.IndexOf('(', start); end = current.LastIndexOf(')', end); list.ReserveRange(start++, end--, new ExpressionToken()); } }