internal static void Check(TestContext tc, string testname, int minwidth, int tabwidth, int padding, byte padchar, TabWriter.Formatting flags, ustring src, ustring expected) { var b = new Buffer(); b.Init(1000); var w = new TabWriter(); w.Init(b, minwidth, tabwidth, padding, padchar, flags); // write all at once var title = testname + " (written all at once)"; b.Clear(); Write(title, w, src); Verify(tc, title, w, b, src, expected); // write byte-by-byte title = testname + " (written byte-by-byte)"; b.Clear(); for (var i = 0; i < src.Length; i++) { Write(title, w, src.ToByteArray().Slice(i, i + 1).ToArray()); } Verify(tc, title, w, b, src, expected); // write using Fibonacci slice sizes title = testname + " (written in fibonacci slices)"; b.Clear(); for (var(i, d) = (0, 0); i < src.Length;)
internal static void Verify(TestContext tc, string testname, TabWriter w, Buffer b, ustring src, ustring expected) { w.Flush(); var res = b.ToUstring(); // DBG: tc.WriteLine($" expected = {expected.Slice()}"); tc.WriteLine($" found = {res.Slice()}"); Assert.AreEqual(expected, res, $"--- test: {testname}\n--- src:\n{src}\n--- found:\n{res}\n--- expected:\n{expected}\n"); }
internal static void Write(string testname, TabWriter w, ustring src) { w.WriteString(src); }