示例#1
0
        /****************************************************************
        *                                                 main
        ****************************************************************/
        static void Main(string[] args)
        {
            int    T;
            string strData = "";
            string logfile = "";

            Utils.logger mylog;
            StreamWriter wr = null;

            logfile = args[0];
            if (logfile != "null")
            {
                wr = new StreamWriter(logfile);
            }
            else
            {
                wr = null;
            }
            // create logger
            mylog = new Utils.logger(wr);
            // check parameters
            if (args.Length == 0)
            {
                strData = string.Format("parameters: logfile (null or name)tests len1 len2 str1 str2[len1 len2 str1 str2]");
                mylog.Log(strData);
                return;
            }

            if ((args.Length - 2) % 4 != 0)
            {
                strData = string.Format("number of arguments of cases, must be a multiple of 4");
                mylog.Log(strData);
                mylog.close();
                return;
            }
            if (!Int32.TryParse(args[1], out T))
            {
                strData = string.Format("tests number is wrong");
                mylog.Log(strData);
                mylog.close();
                return;
            }
            if ((T < 1) || (T > Utils.Constants.Tmax))
            {
                strData = string.Format("number of test cases must be in range 1-{0}", Utils.Constants.Tmax);
                mylog.Log(strData);
                mylog.close();
                return;
            }

            Test.OneTest test;
            // execute all tests
            for (int i = 0; i < T; i++)
            {
                List <string> arg = new List <string>()
                {
                    args[i * 4 + 2], args[i * 4 + 3], args[i * 4 + 4], args[i * 4 + 5]
                };
                test = new Test.OneTest(i, arg, mylog);
                if (test.check())
                {
                    if (!test.findCommon())
                    {
                        strData = string.Format("Test: {0} failed\n", i + 1);
                    }
                    else
                    {
                        strData = string.Format("Test: {0} passed\n", i + 1);
                    }
                    mylog.Log(strData);
                }
            }
            mylog.close();
        }         //main
示例#2
0
            public bool check()
            {
                // take environment variables : debug level and log file name
                Int32.TryParse(Environment.GetEnvironmentVariable("DOTNETDEBUG", EnvironmentVariableTarget.User), out level);
                if (level >= 3)
                {
                    strData = string.Format("Enter: {0}", System.Reflection.MethodBase.GetCurrentMethod().Name);
                    mylog.Log(strData);
                    return(false);
                }
                strData = string.Format("TEST={4} parameters : {0} {1} {2} {3}",
                                        args[0], args[1], args[2], args[3], ind + 1);
                mylog.Log(strData);
                // check and set properly the test parameters
                if (!Int32.TryParse(args[0], out N) || !Int32.TryParse(args[1], out M))
                {
                    strData = string.Format("String length is incorrect");
                    mylog.Log(strData);
                    return(false);
                }

                return(true);
            }