public static void TestAll() { // convenience for readable testcases, WARNING: does not respect \t n stuff .... // argument TokLine is assumed to be empty Func <string [], TokLinePlanB <DTT>, DTT []> fillFromArgs = (args, TokLine) => { var L = new List <DTT>(); foreach (var s in args) { if (s.All(c => c == ' ')) { TokLine.AddWS(s.Length); } else { var dtt = new DTT { str = s }; TokLine.AddTok(dtt); L.Add(dtt); } } return(L.ToArray()); }; Func <IEnumerable <string>, int> sumLen = (strs) => strs.Select(s => s.Length).Sum(); var T1_arr = new [] { "foo", " " }; var T1_TokLine = new TokLinePlanB <DTT>(); var T1_DDT_arr = fillFromArgs(T1_arr, T1_TokLine); var T1_I_immediate_after_WS = sumLen(T1_arr); // ---- nail down edge case behaviour : ---- // [foo ] // _ | AC_tok() is foo D.Assert(T1_TokLine.CPosFromStringpos(T1_I_immediate_after_WS).conflated_clusterF_AC_tok() == T1_DDT_arr[0]); // [foo ] // _ | StringPos is the same as above -- never outside of serialzed stringlen ( CPosC creation implicitly clamps to special END node -> StringPos is derived from nodepointer ) D.Assert(T1_TokLine.CPosFromStringpos(T1_I_immediate_after_WS + 5).StringPos() == T1_I_immediate_after_WS); // [foo bar] // _ | AC_tok() is still foo in this case // -> corrolary of things like : // [.%foo.bar] [.%foo.] // _ _ | want AC_tok() to point to the second '.' // this behaviour was introduced for cases like : // [.%foo.%bar] // _ | where with this cursor pos one would want to AC on "foo"-token T1_TokLine.AddTok(new DTT { str = "bar" }); D.Assert(T1_TokLine.CPosFromStringpos(T1_I_immediate_after_WS).conflated_clusterF_AC_tok() == T1_DDT_arr[0]); Console.WriteLine("TokLinePlanB<> :: ok "); }
public CPosC(TokLinePlanB <Tok> line) { this.line = line; }
public bool isValid(TokLinePlanB <Tok> other_line) // mainly for unit tests n stuff { return(other_line == line && (N == line.Start || N.is_valid)); }