private static void Main() { //var layout = ObjectLayoutInspector.TypeLayout.GetLayout(typeof(GCodeField)); //System.Console.WriteLine(layout); return; //var log10 = (int) Math.Log10(9234); var aaaaaa = new decimal(lo: 10456, mid: 0, hi: 0, isNegative: false, scale: 4) - 1; System.Console.WriteLine(aaaaaa); var aaaa = decimal.Add(1230M, aaaaaa); System.Console.WriteLine(aaaa); //var field = GCodeField.TryParse("X2147483647.2147483647".AsSpan(), out _, new GCodeParsingSettings()); //GCodeField.TryParse("X-10.20") return; using var stream = new FileStream( path: "sample.gcode", FileMode.Open, FileAccess.Read, FileShare.Read); var charArray = "aaaaaasdsdsd".ToCharArray(); using var stringReader = new StringReader("aaaaaaaaaa\r"); using var lineByLine = new LineByLineStreamReader(stringReader); //stream, Encoding.ASCII); while (lineByLine.ReadNextLine(out var line)) { System.Console.WriteLine(line.ToString()); System.Console.WriteLine("========="); } }
public void ReadLines() { var random = new Random(); var builder = new StringBuilder(); var addedLines = new List <string>(); for (var line = random.Next(0, 100); line >= 0; line--) { var newLine = PossibleLines[random.Next(0, PossibleLines.Length)]; var newBreak = PossibleLineBreaks[random.Next(0, PossibleLineBreaks.Length)]; if (newLine == "" && newBreak == "\n") { continue; // to avoid confusion with \r\n } builder.Append(newLine).Append(newBreak); addedLines.Add(newLine); } if (random.Next(0, 100) % 2 == 0) { var lastLine = PossibleLines[random.Next(0, PossibleLines.Length)]; builder.Append(lastLine); addedLines.Add(lastLine); } else { addedLines.Add(string.Empty); } using var stringReader = new StringReader(builder.ToString()); using var reader = new LineByLineStreamReader(stringReader); var index = 0; while (reader.ReadNextLine(out var span)) { var contents = span.ToString(); Assert.That(contents, Is.EqualTo(addedLines[index])); index++; Console.WriteLine(contents); } Assert.AreEqual(addedLines.Count, index); }