static void Main(string[] args) { string logpath = "./log.txt"; string outpath = "./out.txt"; // string logpath = null; // string outpath = null; Cons = Console.Out; FileStream ostream0 = null; FileStream ostream1 = null; if (outpath != null) { try { ostream0 = new FileStream(outpath, FileMode.Create, FileAccess.Write); File = new StreamWriter(ostream0); Console.SetOut(File); } catch (Exception e) { Console.WriteLine("could not open '{0}'", outpath); Console.WriteLine(e.Message); return; } } if (logpath != null) { try { ostream1 = new FileStream(logpath, FileMode.Create, FileAccess.Write); Log = new StreamWriter(ostream1); } catch (Exception e) { Console.WriteLine("could not open '{0}'", logpath); Console.WriteLine(e.Message); return; } } for (int i, n, v = 0; v < 2; ++v) { for (i = I; i <= MAX_I; i *= 10) { RunTest(i, v == 0, "PrintSet", PrintSet); } for (i = I; i <= MAX_I / 20; i *= 2) { RunTest(i, v == 0, "PrintPairs", PrintPairs); } for (n = N; n <= MAX_N; ++n) { RunTest(n, v == 0, "PrintSubs", PrintSubs); } } Cons.WriteLine("test complete"); if (Log != null) { Log.Close(); } if (Cons != null) { Cons.Close(); } if (File != null) { File.Close(); } if (ostream0 != null) { ostream0.Close(); } if (ostream1 != null) { ostream1.Close(); } }