internal static void RunBasic(string[] args, TextWriter stdOut, TextReader input = null, TextWriter output = null) { if(args.Length != 2) { stdOut.WriteLine("Argument Error"); return; } try { if(input == null) input = new StreamReader(args[0]); if(output == null) output = new StreamWriter(args[1]); Sheet main = new Sheet(); main.ParseStream(input); main.EvaluateDocumentBasic(); main.WriteDocument(output); } catch(IOException) { FileErrorWriter(stdOut); return; } catch(UnauthorizedAccessException) { FileErrorWriter(stdOut); return; } catch(ArgumentException) { FileErrorWriter(stdOut); return; } catch(System.Security.SecurityException) { FileErrorWriter(stdOut); return; } finally { if(input != null) input.Close(); if(output != null) output.Close(); } }
public void ParseWrite_Codex() { string codexString = "[] 3 =B1*A2" + Environment.NewLine + "19 =C1+C2 42" + Environment.NewLine + "auto" + Environment.NewLine + "=B2/A1 =A1-B4 =C2+A4" + Environment.NewLine + "=chyba =A1+autobus" + Environment.NewLine; var input = new StringReader(codexString); var output = new StringWriter(); Sheet main = new Sheet(); main.ParseStream(input); main.WriteDocument(output); Assert.AreEqual(codexString, output.ToString()); input.Close(); output.Close(); }
public void ParseWrite_Mail2() { var input = new StreamReader(Program.SLNPath + @"codex\PrikladPrednostERRORorCYCLE_prohozene.in"); var output = new StringWriter(); Sheet main = new Sheet(); main.ParseStream(input); main.WriteDocument(output); Assert_Stream_File_Are_Equals(output, Program.SLNPath + @"codex\PrikladPrednostERRORorCYCLE_prohozene.in"); input.Close(); output.Close(); }