public void ReserveAllReservesAll() { ReservedIndexedCharList list = new ReservedIndexedCharList("ABC"); list.ReserveAll(new NullToken()); Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 0); }
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"); }
public void ReserveOneShouldShorten() { ReservedIndexedCharList list = new ReservedIndexedCharList("ABC"); list[1].ReservedBy = new NullToken(); Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 2); Assert.IsTrue(list.ToStringOnlyNoneReserved() == "AC"); }
public void ReserveFromStartAndStopCharWorksCorrectly() { ReservedIndexedCharList list = new ReservedIndexedCharList("A'B'C"); list.ReserveFromStartAndStopChar('\'', '\'', new NullToken()); Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 2); Assert.IsTrue(list.ToStringOnlyNoneReserved() == "AC"); }
public void RemoveWhiteSpace_Only_Keeps_None_WhiteSpace_Characters_In_List() { ReservedIndexedCharList list = new ReservedIndexedCharList(" A B\t C "); list.RemoveWhiteSpace(); Assert.IsTrue(list.ToString() == "ABC"); Assert.IsTrue(list[2].Position == 2); }
public void GetReservedRetunrsWhatTokenHasReserved() { ReservedIndexedCharList list = new ReservedIndexedCharList("ABC"); Token t = new NullToken(); list.Reserve(0, t); list.Reserve(2, t); Assert.IsTrue(list.ToStringOnlyNoneReserved().Length == 1); Assert.IsTrue(list.GetReserved(t) == "AC"); }
public TokenTree TokenizeFormula(string formula) { var list = new ReservedIndexedCharList(formula); ReserveStrings(list); list.RemoveWhiteSpace(); ReserveParanthesises(list); return CreateTokenTree(list); }
private void ReserveStrings(ReservedIndexedCharList list) { while (list.ToStringOnlyNoneReserved().Contains("'")) { list.ReserveFromStartAndStopChar('\'', '\'', new PathToken()); } while (list.ToStringOnlyNoneReserved().Contains("\"")) { list.ReserveFromStartAndStopChar('"', '"', new StringToken()); } }
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()); } }
public void ToStringShouldBeTheSame() { ReservedIndexedCharList list = new ReservedIndexedCharList("ABC"); Assert.IsTrue(list.ToString() == "ABC"); }
public void NothingShouldBeReserved() { ReservedIndexedCharList list = new ReservedIndexedCharList("ABC"); Assert.IsTrue(list.Chars.All(c => c.ReservedBy == null)); }
public void ListLentghShouldBeThree() { ReservedIndexedCharList list = new ReservedIndexedCharList("ABC"); Assert.IsTrue(list.Chars.Count == 3); }
private TokenTree CreateTokenTree(ReservedIndexedCharList list) { return null; }