Example #1
0
    public virtual bool runTest()
    {
        int iCountErrors    = 0;
        int iCountTestcases = 0;

        Console.Out.Write(strName);
        Console.Out.Write(": ");
        Console.Out.Write(strTest);
        Console.Out.WriteLine(" runTest started...");
        String strFromStrStr = null;
        String strAlphabets  = "abcdefghijklmnopqrstuvwxyz";
        String strDigits     = "0123456789";

        do
        {
            IntlStrings intl        = new IntlStrings();
            String      testString  = intl.GetString(12, true, true);
            String      testString2 = intl.GetString(3, true, true);
            Console.Out.WriteLine("[] Construct a string from two strings");
            try
            {
                strFromStrStr = testString + testString2;
                if (strFromStrStr == null)
                {
                    Console.WriteLine(strTest + "E_101");
                    Console.WriteLine(strTest + "Failed to construct valid string");
                    ++iCountErrors;
                    break;
                }
                if (strFromStrStr.Equals(testString + testString2) != true)
                {
                    String strInfo = strTest + " error: ";
                    strInfo = strInfo + "Expected string<" + strAlphabets + strDigits + ">\n";
                    strInfo = strInfo + "Returned character <" + strFromStrStr + ">";
                    Console.WriteLine(strTest + "E_202");
                    Console.WriteLine(strTest + strInfo);
                    ++iCountErrors;
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(strTest + "E_303");
                Console.WriteLine(strTest + "Unexpected Exception: " + ex.ToString());
                ++iCountErrors;
                break;
            }
            strFromStrStr = strAlphabets + strDigits;
        }while (false);
        Console.Error.Write(strName);
        Console.Error.Write(": ");
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #2
0
    public virtual bool runTest
        ()
    {
        int nErrorBits = 0;
        int n2         = 0;

        System.String swrString2 = null;
        IntlStrings   intl       = new IntlStrings();

        swrString2 = "";
        if (swrString2.Length != 0x0)
        {
            nErrorBits = nErrorBits | 0x1;
        }
        swrString2 = intl.GetString(6, true, true);
        if (swrString2.Length != 6)
        {
            nErrorBits = nErrorBits | 0x2;
        }
        if (swrString2.Length != 6)
        {
            nErrorBits = nErrorBits | 0x4;
        }
        System.Console.Error.WriteLine(nErrorBits);
        if (nErrorBits == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #3
0
    public virtual bool runTest
        ()
    {
        int nErrorBits = 0;

        System.String swrString2 = null;
        System.String swrString4 = null;
        IntlStrings   intl       = new IntlStrings();

        swrString2 = intl.GetString(50, false, true);
        swrString4 = swrString2.ToLower();
        Console.WriteLine(swrString4);
        foreach (Char c in swrString4)
        {
            if (Char.GetUnicodeCategory(c) == UnicodeCategory.UppercaseLetter)
            {
                nErrorBits = nErrorBits | 0x1;
            }
        }
        System.Console.Error.WriteLine(nErrorBits);
        if (nErrorBits == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public virtual bool runTest
        ()
    {
        System.Console.Error.WriteLine("String.Equals: Co1100E runTest running:");
        int nErrorBits = 0;

        System.String swrString1 = null;
        System.String swrString2 = null;
        System.String swrString3 = null;
        System.String swrString4 = null;
        System.String swrString5 = null;
        System.String swrString6 = null;
        swrString2 = "nOpqrs";
        swrString3 = "nopqrs";
        swrString4 = "Dill Guv Dill Guv Dill";
        swrString5 = "Dill Guv Dill Guv Dill Guv Dill";
        swrString6 = "Y2";
        swrString1 = swrString2;
        if (String.Equals(swrString1, swrString2) != true)
        {
            nErrorBits = nErrorBits | 0x1;
        }
        IntlStrings intl = new IntlStrings();
        String      str1 = intl.GetString(20, false, true);
        String      str2 = str1;

        if (String.Equals(str1, str2) != true)
        {
            nErrorBits = nErrorBits | 0x20;
        }
        if (String.Equals(swrString1, swrString3) != false)
        {
            nErrorBits = nErrorBits | 0x2;
        }
        swrString1 = swrString4;
        if (String.Equals(swrString1, swrString5) != false)
        {
            nErrorBits = nErrorBits | 0x4;
        }
        if (String.Equals(swrString1, swrString6) != false)
        {
            nErrorBits = nErrorBits | 0x8;
        }
        swrString1 = swrString5;
        if (String.Equals(swrString1, swrString4) != false)
        {
            nErrorBits = nErrorBits | 0x10;
        }
        System.Console.Error.Write("String.Equals: Co1100E nErrorBits==");
        System.Console.Error.WriteLine(nErrorBits);
        if (nErrorBits == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
 private Boolean runTest(double timeInterval, int repetitions)
 {
     try
     {
         String emptyString = "";
         emptyString = emptyString.Replace('r', 't');
         IntlStrings intl           = new IntlStrings();
         String      testingString  = intl.GetString(7, true, true);
         String      copyTestString = testingString;
         Char        charVar        = testingString[4];
         testingString = testingString.Replace(testingString[4], 'h');
         testString(copyTestString, testingString, copyTestString[4], 'h', "Rep_cc-1");
         testString("Yehia", "Ye7ia", 'h', '7', "Rep_cc00");
         iCountTestcases++;
         testString("Redmond", "Redmond", 'x', 'd', "Rep_cc01");
         testString("Redmond", "Redmond", 'd', 'd', "Rep_cc02");
         iCountTestcases++;
         iCountTestcases++;
         testString("Redmond", "redmond", 'R', 'r', "Rep_cc03");
         testString("Redmond", "Redmond", 'r', 'c', "Rep_cc04");
         testString("Redmond", "Re mon ", 'd', ' ', "Rep_cc05");
         iCountTestcases++;
         testString("Reddod", "Rexxox", 'd', 'x', "Rep_cc06");
         testString("Redmo", "Rexmo", 'd', 'x', "Rep_cc07");
         iCountTestcases++;
         testString("Null", "N" + '\u0000' + "ll", 'u', '\u0000', "Rep_cc08");
         testString("In", "I" + '\uFFFF', 'n', '\uFFFF', "Rep_cc09");
         testString(" ", " ", ' ', ' ', "Rep_cc10");
         testString("  ", "aa", ' ', 'a', "Rep_cc11");
         testString("Seattle", "Sea" + '\n' + '\n' + "le", 't', '\n', "Rep_cc12");
         testString("Seattle", "Sea" + '\r' + '\r' + "le", 't', '\r', "Rep_cc13");
         testString("Seattle", "Sea" + '\t' + '\t' + "le", 't', '\t', "Rep_cc14");
         testString("Seattle", "Sea" + '\\' + '\\' + "le", 't', '\\', "Rep_cc15");
         testString("Seattle", "Sea" + '\a' + '\a' + "le", 't', '\a', "Rep_cc16");
         testString("Seattle", "Sea" + '\0' + '\0' + "le", 't', '\0', "Rep_cc17");
         for (int index = 0; index < repetitions; index++)
         {
             Console.WriteLine("Finished " + index + " repetition(s)");
             randomTest(timeInterval);
         }
     }
     catch (Exception ex)
     {
         ++iCountErrors;
         String strInfo = "Unexpected Exception: (runTest)";
         strInfo = strInfo + ex.ToString();
         Console.Error.WriteLine(strName + " " + strTest + " " + strPath);
         Console.Error.WriteLine(strInfo);
     }
     Console.WriteLine("FINAL TEST RESULT:" + strName + " " + strTest + " " + strPath);
     if (iCountErrors == 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #6
0
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        String strValue        = String.Empty;

        try
        {
            strLoc = "Loc_299cu";
            iCountTestcases++;
            if (!String.Concat(null, null).Equals(String.Empty))
            {
                iCountErrors++;
                printerr("Error_2029s! String.Empty not returned as expected");
            }
            strLoc = "Loc_109xh";
            iCountTestcases++;
            if (!String.Concat("Hello", "World").Equals("HelloWorld"))
            {
                iCountErrors++;
                printerr("Error_209sj! Expected==HelloWorld");
            }
            IntlStrings intl = new IntlStrings();
            String      str1 = intl.GetString(3, true, true);
            String      str2 = intl.GetString(5, true, true);
            if (!String.Concat(str1, str2).Equals(String.Concat(str1, str2, null)))
            {
                iCountErrors++;
                printerr("Error_209sj! Expected==HelloWorld");
            }
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #7
0
    public virtual bool runTest()
    {
        Console.Out.WriteLine("String\\Co3041ToString. runTest() started.");
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String str1            = null;

        iCountTestcases++;
        IntlStrings intl = new IntlStrings();

        str1 = intl.GetString(17, false, true);
        if (!(str1.ToString().Equals(str1)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_498o (Co3041ToString.)");
        }
        iCountTestcases++;
        str1 = "4874378828457y34";
        if (!(str1.ToString().Equals(str1)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_433r (Co3041ToString.)");
        }
        iCountTestcases++;
        str1 = "#$%@#$%@*#_@_!__!_!($#%JWE(@JA)(*#@$";
        if (!(str1.ToString().Equals(str1)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_879u (Co3041ToString.)");
        }
        iCountTestcases++;
        str1 = "\0";
        if (!(str1.ToString().Equals(str1)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_899 (Co3041ToString.)");
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #8
0
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        String strValue        = String.Empty;

        try
        {
            String str1;
            Object obj1;
            strLoc = "Loc_299cu";
            obj1   = null;
            iCountTestcases++;
            if (String.Concat(obj1) != String.Empty)
            {
                iCountErrors++;
                printerr("Error_2029s! String.Empty not returned as expected");
            }
            IntlStrings intl = new IntlStrings();
            str1 = intl.GetString(20, false, true);
            iCountTestcases++;
            if (!String.Concat(str1).Equals((object)str1))
            {
                iCountErrors++;
                printerr("Error_209sj! got value==" + String.Concat(str1));
            }
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public virtual bool runTest
        ()
    {
        System.Console.Error.WriteLine("String.EndsWith: Co1150EW runTest starting...");
        int nErrorBits = 0;

        System.String swrString2 = null;
        swrString2 = "nOpqRs";
        if (swrString2.EndsWith("qRs") != true)
        {
            nErrorBits = nErrorBits | 0x1;
        }
        if (swrString2.EndsWith("qrs") != false)
        {
            nErrorBits = nErrorBits | 0x2;
        }
        if (swrString2.EndsWith("nOp") != false)
        {
            nErrorBits = nErrorBits | 0x4;
        }
        Char[]      swrString3 = new Char[8];
        IntlStrings intl       = new IntlStrings();

        swrString2 = intl.GetString(10, true, true);
        swrString2.CopyTo(2, swrString3, 0, swrString2.Length - 2);
        String swrString4 = new String(swrString3);

        if (swrString2.EndsWith(swrString4) != true)
        {
            nErrorBits = nErrorBits | 0x1;
        }
        System.Console.Error.WriteLine(nErrorBits);
        if (nErrorBits == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        String strValue        = String.Empty;

        try
        {
            String        str1, str2;
            StringBuilder sb1, sb2;
            strLoc = "Loc_299nu";
            str1   = null;
            str2   = null;
            iCountTestcases++;
            if ((object)str1 != (object)str2)
            {
                iCountErrors++;
                printerr("Error_229a! References of two null strings are not equal");
            }
            strLoc = "Loc_299em";
            str1   = String.Empty;
            str2   = String.Empty;
            iCountTestcases++;
            if ((object)str1 != (object)str2)
            {
                iCountErrors++;
                printerr("Error_229b! References of two strings assigned with .Empty() directly are not equal");
            }
            strLoc = "Loc_230ema";
            sb2    = new StringBuilder().Append(String.Empty);
            str2   = sb2.ToString();
            iCountTestcases++;
            if ((object)str1 == (object)str2)
            {
                iCountErrors++;
                printerr("Error_230a! References of a built string with value String.Empty() and a string literal of .Empty() are equal");
            }
            IntlStrings intl = new IntlStrings();
            sb2  = new StringBuilder().Append(intl.GetString(18, false, true));
            str2 = sb2.ToString();
            iCountTestcases++;
            if ((object)str1 == (object)str2)
            {
                iCountErrors++;
                printerr("Error_23ekk2");
            }
            str1   = String.Empty;
            str2   = String.Empty;
            strLoc = "Loc_230emb";
            sb2    = new StringBuilder().Append(String.Empty);
            str2   = String.Intern(sb2.ToString());
            iCountTestcases++;
            if ((object)str1 != (object)str2)
            {
                iCountErrors++;
                printerr("Error_230b! References of an interned .Empty() string and string literal .Empty() are not equal");
            }
            strLoc = "Loc_231loa";
            sb1    = new StringBuilder().Append("a").Append("b").Append("c").Append("d").Append("e").Append("f").Append("g").Append("h").Append("i").Append("j").Append("k").Append("l").Append("m").Append("n").Append("o").Append("p").Append("q").Append("r").Append("s").Append("t").Append("u").Append("v").Append("w").Append("x").Append("y").Append("z").Append("aa").Append("bb").Append("cc").Append("dd").Append("ee").Append("ff").Append("gg").Append("hh").Append("ii").Append("jj").Append("kk").Append("ll").Append("mm").Append("nn").Append("oo").Append("pp").Append("qq").Append("rr").Append("ss").Append("tt").Append("uu").Append("vv").Append("ww").Append("xx").Append("yy").Append("zz");
            str1   = sb1.ToString();
            str2   = "abcdefghijklmnopqrstuvwxyzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz";
            iCountTestcases++;
            if ((object)str1 == (object)str2)
            {
                iCountErrors++;
                printerr("Error_231a! References of a literal long string and a built long string are equal");
            }
            strLoc = "Loc_231lob";
            str1   = String.Intern(sb1.ToString());
            iCountTestcases++;
            if ((object)str1 != (object)str2)
            {
                iCountErrors++;
                printerr("Error_231b! References of a literal long string and an interned built long string are not equal");
            }
            strLoc = "Loc_232syma";
            sb1    = new StringBuilder().Append("abc").Append("`").Append("-").Append("=").Append("[").Append("]").Append(";").Append("'").Append(",").Append(".").Append("/").Append("~").Append("!").Append("@").Append("#").Append("$").Append("%").Append("^").Append("&").Append("*").Append("(").Append(")").Append("_").Append("+").Append("{").Append("}").Append("|").Append(":").Append("<").Append(">").Append("?");
            str1   = sb1.ToString();
            str2   = "abc`-=[];',./~!@#$%^&*()_+{}|:<>?";
            iCountTestcases++;
            if ((object)str1 == (object)str2)
            {
                iCountErrors++;
                printerr("Error_232a! References of a literal string having symbols and a built string having symbols are equal");
            }
            strLoc = "Loc_232symb";
            str1   = String.Intern(sb1.ToString());
            iCountTestcases++;
            if ((object)str1 != (object)str2)
            {
                iCountErrors++;
                printerr("Error_232b! References of a literal string having symbols and an interned built string having symbols are not equal");
            }
            strLoc = "Loc_233numa";
            sb1    = new StringBuilder().Append("xyz").Append("1").Append("2").Append("3").Append("4").Append("5").Append("6").Append("7").Append("8").Append("9").Append("0");
            str1   = sb1.ToString();
            str2   = "xyz1234567890";
            iCountTestcases++;
            if ((object)str1 == (object)str2)
            {
                iCountErrors++;
                printerr("Error_233a! References of a literal string having alphanumerics and a built string having alphanumerics are equal");
            }
            strLoc = "Loc_233numb";
            str1   = String.Intern(sb1.ToString());
            iCountTestcases++;
            if ((object)str1 != (object)str2)
            {
                iCountErrors++;
                printerr("Error_233b! References of a literal string having alphanumerics and an interned built string having alphanumerics are not equal");
            }
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #11
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int            iCountErrors    = 0;
        int            iCountTestcases = 0;
        IntlStrings    intl;
        String         strLoc = "Loc_000oo";
        ListDictionary ld;

        string [] values =
        {
            "",
            " ",
            "a",
            "aa",
            "tExt",
            "     spAces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        string [] keys =
        {
            "zero",
            "one",
            " ",
            "",
            "aa",
            "1",
            System.DateTime.Today.ToString(),
            "$%^#",
            Int32.MaxValue.ToString(),
            "     spaces",
            "2222222222222222222222222"
        };
        Array       arr;
        ICollection vs;
        int         ind;

        try
        {
            intl = new IntlStrings();
            Console.WriteLine("--- create dictionary ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            ld = new ListDictionary();
            Console.WriteLine("1. get Values for empty dictionary");
            iCountTestcases++;
            if (ld.Count > 0)
            {
                ld.Clear();
            }
            if (ld.Values.Count != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001, returned Values.Count = {0}", ld.Values.Count);
            }
            Console.WriteLine("2. get Values on filled dictionary");
            strLoc = "Loc_002oo";
            int len = values.Length;
            iCountTestcases++;
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, count is {0} instead of {1}", ld.Count, len);
            }
            vs = ld.Values;
            if (vs.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, returned Values.Count = {0}", vs.Count);
            }
            arr = Array.CreateInstance(typeof(Object), len);
            vs.CopyTo(arr, 0);
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                ind = Array.IndexOf(arr, values[i]);
                if (ind < 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002b_{0}, Values doesn't contain \"{1}\" value. Search result: {2}", i, values[i], ind);
                }
            }
            Console.WriteLine("3. get Values on dictionary with different_in_casing_only keys ");
            strLoc = "Loc_003oo";
            iCountTestcases++;
            ld.Clear();
            string intlStr = intl.GetString(MAX_LEN, true, true, true);
            ld.Add("keykey", intlStr);
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            ld.Add("keyKey", intlStr);
            if (ld.Count != len + 2)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003a, count is {0} instead of {1}", ld.Count, len + 2);
            }
            iCountTestcases++;
            vs = ld.Values;
            if (vs.Count != ld.Count)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003b, returned Values.Count = {0}", vs.Count);
            }
            arr = Array.CreateInstance(typeof(Object), len + 2);
            vs.CopyTo(arr, 0);
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                ind = Array.IndexOf(arr, values[i]);
                if (ind < 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003c_{0}, Values doesn't contain \"{1}\" value", i, values[i]);
                }
            }
            iCountTestcases++;
            ind = Array.IndexOf(arr, intlStr);
            if (ind < 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003c, Values doesn't contain {0} value", intlStr);
            }
            Console.WriteLine("4. get Values for dictionary with intl strings");
            strLoc = "Loc_004oo";
            string [] intlValues = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);
            }
            if (ld.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0004a, count is {0} instead of {1}", ld.Count, len);
            }
            vs = ld.Values;
            if (vs.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0004b, returned Values.Count = {0}", vs.Count);
            }
            arr = Array.CreateInstance(typeof(Object), len);
            vs.CopyTo(arr, 0);
            for (int i = 0; i < arr.Length; i++)
            {
                iCountTestcases++;
                ind = Array.IndexOf(arr, intlValues[i]);
                if (ind < 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004c_{0}, Values doesn't contain \"{1}\" value", i, intlValues[i]);
                }
            }
            Console.WriteLine("5. Change dictinary");
            strLoc = "Loc_005oo";
            iCountTestcases++;
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005a, count is {0} instead of {1}", ld.Count, len);
            }
            vs = ld.Values;
            if (vs.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005a, returned Values.Count = {0}", vs.Count);
            }
            Console.WriteLine("     - remove element from the dictionary");
            ld.Remove(keys[0]);
            if (ld.Count != len - 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005b, didn't remove element");
            }
            if (vs.Count != len - 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005c, Values were not updated after removal");
            }
            iCountTestcases++;
            arr = Array.CreateInstance(typeof(Object), ld.Count);
            vs.CopyTo(arr, 0);
            ind = Array.IndexOf(arr, values[0]);
            if (ind >= 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005d, Values still contains removed value " + ind);
            }
            Console.WriteLine("     - add element to the dictionary");
            ld.Add(keys[0], "new item");
            if (ld.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005e, didn't add element");
            }
            if (vs.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005f, Values were not updated after addition");
            }
            iCountTestcases++;
            arr = Array.CreateInstance(typeof(Object), ld.Count);
            vs.CopyTo(arr, 0);
            ind = Array.IndexOf(arr, "new item");
            if (ind < 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005g, Values doesn't contain added value ");
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Example #12
0
 public Boolean runTest(double timeInterval, int repetitions)
 {
     try
     {
         try {
             String trialStr = "asdf";
             trialStr = trialStr.Replace(null, null);
             iCountErrors++;
             Console.WriteLine("Error_num701:  Should have thrown.");
         }
         catch (System.ArgumentNullException) {
         }
         try {
             IntlStrings intl     = new IntlStrings();
             String      trialStr = intl.GetString(18, false, true);
             trialStr = trialStr.Replace(null, "s");
             iCountErrors++;
             Console.WriteLine("Error_nuz801:  Should have thrown.");
         }
         catch (System.ArgumentNullException) {
         }
         try {
             String trialStr = "asdf";
             trialStr = trialStr.Replace(null, "s");
             iCountErrors++;
             Console.WriteLine("Error_nuz801:  Should have thrown.");
         }
         catch (System.ArgumentNullException) {
         }
         testString("asdf", "adf", "s", null, "Rep_ss200");
         testString("Yehia", "Ye7ia", "h", "7", "Rep_ss00");
         testString("Redmond", "Redmond", "x", "d", "Rep_ss01");
         testString("Redmond", "Redmond", "d", "d", "Rep02");
         testString("Redmond", "redmond", "R", "r", "Rep_ss03");
         testString("Redmond", "Redmond", "r", "c", "Rep_ss04");
         iCountTestcases++;
         testString("Redmond", "Re mon ", "d", " ", "Rep_ss05");
         iCountTestcases++;
         testString("Reddod", "Rexxox", "d", "x", "Rep_ss06");
         iCountTestcases++;
         testString("Redmo", "Rexmo", "d", "x", "Rep_ss07");
         iCountTestcases++;
         testString("Null", "N" + '\u0000' + "ll", "u", "\u0000", "Rep_ss08");
         iCountTestcases++;
         testString("In", "I" + '\uFFFF', "n", "\uFFFF", "Rep_ss09");
         iCountTestcases++;
         testString(" ", " ", " ", " ", "Rep_ss10");
         iCountTestcases++;
         testString("  ", "aa", " ", "a", "Rep_ss11");
         testString("Seattle", "Sea\\n\\nle", "t", "\\n", "Rep_ss12");
         iCountTestcases++;
         testString("Seattle", "Sea\\r\\rle", "t", "\\r", "Rep_ss13");
         testString("Seattle", "Sea\\t\\tle", "t", "\\t", "Rep_ss14");
         testString("Seattle", "S\\attl\\", "e", "\\", "Rep_ss15");
         testString("Seattle", "Sea\\a\\ale", "t", "\\a", "Rep_ss16");
         testString("Seattle", "Sea\\0\\0le", "t", "\\0", "Rep_ss17");
         testString("", "", "f", "s", "Rep_ss18");
         testString("asdf", "asdss", "f", "ss", "Rep_ss19");
         testString("asdf", "asdf", "ss", "f", "Rep_ss20");
         testString(" ", "asdf", " ", "asdf", "Rep_ss21");
         testString("as ", "ax ", "s", "x", "Rep_ss22");
         testString("  ", "  ", "x", "a", "Rep_ss23");
         testString("ss", "ssss", "s", "ss", "Rep_ss24");
         testString("sdsd", "", "sd", "", "Rep_ss25");
         testString("   ", "a ", "  ", "a", "Rep_ss26");
         testString("sf", "sc", "f", "c", "Rep_ss25");
         testString("sfff", "scc", "fff", "cc", "Rep_ss25");
         String point = "  ";
         String other = point;
         testString(point, other, " ", " ", "Rep_ss27");
         testString("asdf", "asdf", "dfgg", "vb", "Rep_ss28");
         for (int index = 0; index < repetitions; index++)
         {
             Console.WriteLine("Finished " + index + " repetition(s)");
             randomTest(timeInterval);
         }
     }
     catch (Exception ex)
     {
         ++iCountErrors;
         String strInfo = "Unexpected Exception: (runTest)";
         strInfo = strInfo + ex.ToString();
         Console.Error.WriteLine(strName + " " + strTest + " " + strPath);
         Console.Error.WriteLine(strInfo);
     }
     Console.WriteLine("FINAL TEST RESULT:" + strName + " " + strTest + " " + strPath);
     if (iCountErrors == 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #13
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int            iCountErrors    = 0;
        int            iCountTestcases = 0;
        IntlStrings    intl;
        String         strLoc = "Loc_000oo";
        ListDictionary ld;

        string [] values =
        {
            "",
            " ",
            "a",
            "aA",
            "text",
            "     SPaces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        string [] keys =
        {
            "zero",
            "oNe",
            " ",
            "",
            "aa",
            "1",
            System.DateTime.Today.ToString(),
            "$%^#",
            Int32.MaxValue.ToString(),
            "     spaces",
            "2222222222222222222222222"
        };
        Array destination;
        int   cnt = 0;

        try
        {
            intl = new IntlStrings();
            Console.WriteLine("--- create dictionary ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            ld = new ListDictionary();
            Console.WriteLine("1. Copy empty dictionary into empty array");
            iCountTestcases++;
            destination = Array.CreateInstance(typeof(Object), 0);
            Console.WriteLine(" destination Length = " + destination.Length);
            Console.WriteLine("     - CopyTo(arr, -1)");
            try
            {
                ld.CopyTo(destination, -1);
                iCountErrors++;
                Console.WriteLine("Err_0001a, no exception");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_001b, unexpected exception: {0}", e.ToString());
            }
            iCountTestcases++;
            Console.WriteLine("     - CopyTo(arr, 0)");
            try
            {
                ld.CopyTo(destination, 0);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_001c, unexpected exception: {0}", e.ToString());
            }
            iCountTestcases++;
            Console.WriteLine("     - CopyTo(arr, 1)");
            try
            {
                ld.CopyTo(destination, 1);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(" Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_001d, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("2. Copy empty dictionary into non-empty array");
            iCountTestcases++;
            destination = Array.CreateInstance(typeof(Object), values.Length);
            for (int i = 0; i < values.Length; i++)
            {
                destination.SetValue(values[i], i);
            }
            ld.CopyTo(destination, 0);
            if (destination.Length != values.Length)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, altered array after copying empty dictionary");
            }
            if (destination.Length == values.Length)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    iCountTestcases++;
                    if (String.Compare(destination.GetValue(i).ToString(), values[i], false) != 0)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_0002_{0}b, altered item {0} after copying empty dictionary", i);
                    }
                }
            }
            Console.WriteLine("3. add simple strings and CopyTo(Array, 0)");
            strLoc = "Loc_003oo";
            iCountTestcases++;
            cnt = ld.Count;
            int len = values.Length;
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003a, count is {0} instead of {1}", ld.Count, values.Length);
            }
            destination = Array.CreateInstance(typeof(Object), len);
            ld.CopyTo(destination, 0);
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (String.Compare(ld[keys[i]].ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), ld[keys[i]]);
                }
                iCountTestcases++;
                if (String.Compare(keys[i], ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), keys[i]);
                }
            }
            Console.WriteLine("4. add simple strings and CopyTo(Array, {0})", values.Length);
            ld.Clear();
            strLoc = "Loc_004oo";
            iCountTestcases++;
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0004a, count is {0} instead of {1}", ld.Count, values.Length);
            }
            destination = Array.CreateInstance(typeof(Object), len * 2);
            ld.CopyTo(destination, len);
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (String.Compare(ld[keys[i]].ToString(), ((DictionaryEntry)destination.GetValue(i + len)).Value.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Value, ld[keys[i]]);
                }
                iCountTestcases++;
                if (String.Compare(keys[i], ((DictionaryEntry)destination.GetValue(i + len)).Key.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Key, keys[i]);
                }
            }
            Console.WriteLine("5. add intl strings and CopyTo(Array, 0)");
            strLoc = "Loc_005oo";
            iCountTestcases++;
            string [] intlValues = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            Boolean caseInsensitive = false;
            for (int i = 0; i < len * 2; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                {
                    caseInsensitive = true;
                }
            }
            iCountTestcases++;
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);
            }
            if (ld.Count != (len))
            {
                iCountErrors++;
                Console.WriteLine("Err_0005a, count is {0} instead of {1}", ld.Count, len);
            }
            destination = Array.CreateInstance(typeof(Object), len);
            ld.CopyTo(destination, 0);
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (String.Compare(ld[intlValues[i + len]].ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value, ld[intlValues[i + len]]);
                }
                iCountTestcases++;
                if (String.Compare(intlValues[i + len], ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key, intlValues[i + len]);
                }
            }
            Console.WriteLine("6. add intl strings and CopyTo(Array, {0})", len);
            strLoc      = "Loc_006oo";
            destination = Array.CreateInstance(typeof(Object), len * 2);
            ld.CopyTo(destination, len);
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (String.Compare(ld[intlValues[i + len]].ToString(), ((DictionaryEntry)destination.GetValue(i + len)).Value.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0006_{0}a, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Value, ld[intlValues[i + len]]);
                }
                iCountTestcases++;
                if (String.Compare(intlValues[i + len], ((DictionaryEntry)destination.GetValue(i + len)).Key.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0006_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Key, intlValues[i + len]);
                }
            }
            Console.WriteLine("7. case sensitivity");
            strLoc = "Loc_007oo";
            string [] intlValuesLower = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                intlValues[i] = intlValues[i].ToUpper();
            }
            for (int i = 0; i < len * 2; i++)
            {
                intlValuesLower[i] = intlValues[i].ToLower();
            }
            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);
            }
            destination = Array.CreateInstance(typeof(Object), len);
            ld.CopyTo(destination, 0);
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (String.Compare(ld[intlValues[i + len]].ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0006_{0}a, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value, ld[intlValues[i + len]]);
                }
                iCountTestcases++;
                if (!caseInsensitive && Array.IndexOf(intlValuesLower, ((DictionaryEntry)destination.GetValue(i)).Value.ToString()) > -1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0006_{0}b, copied lowercase string");
                }
                iCountTestcases++;
                if (String.Compare(intlValues[i + len], ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0006_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key, intlValues[i + len]);
                }
                iCountTestcases++;
                if (!caseInsensitive && Array.IndexOf(intlValuesLower, ((DictionaryEntry)destination.GetValue(i)).Key.ToString()) > -1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0006_{0}d, copied lowercase key");
                }
            }
            Console.WriteLine("8. CopyTo(null, int)");
            strLoc = "Loc_008oo";
            iCountTestcases++;
            destination = null;
            try
            {
                ld.CopyTo(destination, 0);
                iCountErrors++;
                Console.WriteLine("Err_0008a: no exception ");
            }
            catch (ArgumentNullException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0008b, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("9. CopyTo(Array, -1)");
            strLoc = "Loc_009oo";
            iCountTestcases++;
            cnt         = ld.Count;
            destination = Array.CreateInstance(typeof(Object), 2);
            try
            {
                ld.CopyTo(destination, -1);
                iCountErrors++;
                Console.WriteLine("Err_0009b: no exception ");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0009c, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("10. CopyTo(Array, upperBound+1)");
            strLoc = "Loc_0010oo";
            iCountTestcases++;
            if (ld.Count < 1)
            {
                ld.Clear();
                for (int i = 0; i < len; i++)
                {
                    ld.Add(keys[i], values[i]);
                }
            }
            destination = Array.CreateInstance(typeof(Object), len);
            try
            {
                ld.CopyTo(destination, len);
                iCountErrors++;
                Console.WriteLine("Err_0010b: no exception ");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0010c, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("11. CopyTo(Array, upperBound+2)");
            strLoc = "Loc_010oo";
            iCountTestcases++;
            try
            {
                ld.CopyTo(destination, len + 1);
                iCountErrors++;
                Console.WriteLine("Err_0011b: no exception ");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0011c, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("12. CopyTo(Array, not_enough_space)");
            strLoc = "Loc_012oo";
            iCountTestcases++;
            try
            {
                ld.CopyTo(destination, len / 2);
                iCountErrors++;
                Console.WriteLine("Err_0012a: no exception ");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0012b, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("13. CopyTo(multidim_Array, 0)");
            strLoc = "Loc_013oo";
            iCountTestcases++;
            Array dest = Array.CreateInstance(typeof(string), len, len);
            try
            {
                ld.CopyTo(dest, 0);
                iCountErrors++;
                Console.WriteLine("Err_0013a: no exception ");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0013b, unexpected exception: {0}", e.ToString());
            }

            Console.WriteLine("15. copy empty LD: CopyTo(Array, upperBound+1)");
            strLoc = "Loc_0015oo";
            iCountTestcases++;
            ld.Clear();
            destination = Array.CreateInstance(typeof(Object), len);
            try
            {
                ld.CopyTo(destination, len);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0015a, unexpected exception: {0}", e.ToString());
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        String strValue        = String.Empty;

        try
        {
            char   ch = 'a';
            String str1 = String.Empty, str2 = String.Empty;
            int[]  iArrInvalidValues = new Int32[] { -1, -2, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000, Int32.MinValue };
            int[]  iArrLargeValues   = new Int32[] { Int32.MaxValue, Int32.MaxValue - 1, Int32.MaxValue / 2, Int32.MaxValue / 10, Int32.MaxValue / 100 };
            int[]  iArrValidValues   = new Int32[] { 10000, 100000, Int32.MaxValue / 100, Int32.MaxValue / 1000 };
            iCountTestcases++;
            String strNewString = String.Empty;
            for (int iLoop = 0; iLoop < iArrInvalidValues.Length; iLoop++)
            {
                try
                {
                    strNewString = new String('a', iArrInvalidValues[iLoop]);
                    iCountErrors++;
                } catch (ArgumentException) {
                } catch (Exception ex)
                {
                    Console.Error.WriteLine("Error_2222!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
                if (strNewString != String.Empty)
                {
                    iCountErrors++;
                    Console.Error.WriteLine("Error_3333!!!! Incorrect string content.... Expected...{0},  Actual...{1}", String.Empty, strNewString);
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrLargeValues.Length; iLoop++)
            {
                try
                {
                    strNewString = new String('a', iArrLargeValues[iLoop]);
                    if (strNewString.Length != iArrLargeValues[iLoop])
                    {
                        iCountErrors++;
                        Console.Error.WriteLine("Error_5555!!!! Incorrect string length.... Expected...{0},  Actual...{1}", iArrLargeValues[iLoop], strNewString.Length);
                    }
                } catch (OutOfMemoryException) {
                } catch (Exception ex)
                {
                    Console.Error.WriteLine("Error_4444!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrValidValues.Length; iLoop++)
            {
                try
                {
                    strNewString = new String('a', iArrValidValues[iLoop]);
                    if (strNewString.Length != iArrValidValues[iLoop])
                    {
                        iCountErrors++;
                        Console.Error.WriteLine("Error_6666!!!! Incorrect string length.... Expected...{0},  Actual...{1}", iArrValidValues[iLoop], strNewString.Length);
                    }
                } catch (Exception ex) {
                    Console.Error.WriteLine("Error_7777!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            strLoc = "Loc_498hv";
            iCountTestcases++;
            ch   = ' ';
            str2 = new String(ch, 4);
            if (!str2.Equals("    "))
            {
                iCountErrors++;
                printerr("Error_498ch! incorrect string returned for null argument==" + str2);
            }
            strLoc = "Loc_498hv.2";
            iCountTestcases++;
            ch   = '\0';
            str2 = new String(ch, 4);
            if (!str2.Equals("\0\0\0\0"))
            {
                iCountErrors++;
                printerr("Error_498ch.2! incorrect string returned for null argument==" + str2);
                printinfo("str2 is good == " + str2 + " is good");
            }
            strLoc = "Loc_982hc";
            iCountTestcases++;
            ch   = 'k';
            str2 = new String(ch, 3);
            if (!str2.Equals("kkk"))
            {
                iCountErrors++;
                printerr("Error_49hcx! incorrect string constructed==" + str2);
            }
            IntlStrings intl = new IntlStrings();
            str2 = intl.GetString(1, true, true);
            String testString = new String(str2[0], 3);
            str2 = String.Concat(str2[0], str2[0], str2[0]);
            if (!str2.Equals(testString))
            {
                iCountErrors++;
            }
            strLoc = "Loc_9fhc1";
            ch     = '\t';
            str2   = new String(ch, 2);
            iCountTestcases++;
            if (!str2.Equals("\t\t"))
            {
                iCountErrors++;
                printerr("Error_89hfd! incorrect string constructed==" + str2);
            }
            strLoc = "Loc_93286.2";
            iCountTestcases++;
            try {
                str2 = new String('a', -1);
                iCountErrors++;
                printerr("Error_209xu.2! Expected ArgExc instead Returned string ==" + str2);
            }
            catch (ArgumentOutOfRangeException) {
            }
            strLoc = "Loc_93286.3";
            iCountTestcases++;
            try {
                str2 = new String('a', 1000);
                if (str2.Length != 1000)
                {
                    iCountErrors++;
                    printerr("Error_209xu.3! String length mismatch; Expected: " + 1000 + "; Returned: " + str2.Length);
                }
            }
            catch (Exception exc) {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + " : Error Err_777yyy!  strLoc==" + strLoc + ", unexpected exc==" + exc.ToString());
            }
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #15
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int              iCountErrors    = 0;
        int              iCountTestcases = 0;
        IntlStrings      intl;
        String           strLoc = "Loc_000oo";
        StringCollection sc;

        string [] values =
        {
            "",
            " ",
            "a",
            "aa",
            "text",
            "     spaces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        int cnt = 0;

        try
        {
            intl = new IntlStrings();
            Console.WriteLine("--- create collection ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            sc = new StringCollection();
            Console.WriteLine("1. Remove() from empty collection");
            for (int i = 0; i < values.Length; i++)
            {
                iCountTestcases++;
                sc.Remove(values[i]);
                if (sc.Count != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0001_{0}, Remove changed Count for empty collection", i);
                }
            }
            Console.WriteLine("2. add simple strings and test Remove()");
            strLoc = "Loc_002oo";
            iCountTestcases++;
            sc.Clear();
            sc.AddRange(values);
            if (sc.Count != values.Length)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, count is {0} instead of {1}", sc.Count, values.Length);
            }
            for (int i = 0; i < values.Length; i++)
            {
                iCountTestcases++;
                if (!sc.Contains(values[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}b, doesn't contain {0} item", i);
                }
                cnt = sc.Count;
                iCountTestcases++;
                sc.Remove(values[i]);
                if (sc.Count != cnt - 1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}c, didn't remove anything", i);
                }
                if (sc.Contains(values[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}d, removed wrong item", i);
                }
            }
            Console.WriteLine("3. add intl strings and test Remove()");
            strLoc = "Loc_003oo";
            string [] intlValues = new string [values.Length];
            for (int i = 0; i < values.Length; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            int     len             = values.Length;
            Boolean caseInsensitive = false;
            for (int i = 0; i < len; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                {
                    caseInsensitive = true;
                }
            }
            iCountTestcases++;
            sc.Clear();
            sc.AddRange(intlValues);
            if (sc.Count != intlValues.Length)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003a, count is {0} instead of {1}", sc.Count, intlValues.Length);
            }
            for (int i = 0; i < intlValues.Length; i++)
            {
                iCountTestcases++;
                if (!sc.Contains(intlValues[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}b, doesn't contain {0} item", i);
                }
                cnt = sc.Count;
                iCountTestcases++;
                sc.Remove(intlValues[i]);
                if (sc.Count != cnt - 1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}c, didn't remove anything", i);
                }
                if (sc.Contains(intlValues[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}d, removed wrong item", i);
                }
            }
            Console.WriteLine("4. duplicate strings ");
            strLoc = "Loc_004oo";
            iCountTestcases++;
            sc.Clear();
            string intlStr = intlValues[0];
            sc.Add(intlStr);
            sc.AddRange(values);
            sc.AddRange(intlValues);
            cnt = values.Length + 1 + intlValues.Length;
            if (sc.Count != cnt)
            {
                iCountErrors++;
                Console.WriteLine("Err_0004a, count is {1} instead of {2}", sc.Count, cnt);
            }
            iCountTestcases++;
            if (sc.IndexOf(intlStr) != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0004b, IndexOf returned {0} instead of {1}", sc.IndexOf(intlStr), 0);
            }
            iCountTestcases++;
            sc.Remove(intlStr);
            if (!sc.Contains(intlStr))
            {
                iCountErrors++;
                Console.WriteLine("Err_0004c, removed both duplicates");
            }
            if (sc.IndexOf(intlStr) != values.Length)
            {
                iCountErrors++;
                Console.WriteLine("Err_0004d, IndexOf returned {0} instead of {1}", sc.IndexOf(intlStr), values.Length);
            }
            for (int i = 0; i < values.Length; i++)
            {
                if (sc.IndexOf(values[i]) != i)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004e_{0}, IndexOf {0} item returned {1} ", i, sc.IndexOf(values[i]));
                }
                if (sc.IndexOf(intlValues[i]) != i + values.Length)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004f_{0}, IndexOf {1} item returned {2} ", i, i + values.Length, sc.IndexOf(intlValues[i]));
                }
            }
            Console.WriteLine("5. Case sensitivity");
            strLoc = "Loc_005oo";
            iCountTestcases++;
            sc.Clear();
            sc.Add(intlStr.ToUpper());
            sc.AddRange(values);
            sc.Add(intlStr.ToLower());
            cnt = values.Length + 2;
            if (sc.Count != cnt)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005a, count is {1} instead of {2} ", sc.Count, cnt);
            }
            intlStr = intlStr.ToLower();
            iCountTestcases++;
            Console.WriteLine(" - remove lowercase");
            cnt = sc.Count;
            sc.Remove(intlStr);
            if (sc.Count != cnt - 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005b, didn't remove anything");
            }
            if (!caseInsensitive && sc.Contains(intlStr))
            {
                iCountErrors++;
                Console.WriteLine("Err_0005c, didn't remove lowercase ");
            }
            if (!sc.Contains(intlValues[0].ToUpper()))
            {
                iCountErrors++;
                Console.WriteLine("Err_0005d, removed uppercase ");
            }
            Console.WriteLine("6. Remove() non-existing item");
            strLoc = "Loc_006oo";
            iCountTestcases++;
            sc.Clear();
            sc.AddRange(values);
            cnt = values.Length;
            if (sc.Count != cnt)
            {
                iCountErrors++;
                Console.WriteLine("Err_0006a, count is {1} instead of {2} ", sc.Count, cnt);
            }
            intlStr = "Hello";
            iCountTestcases++;
            cnt = sc.Count;
            sc.Remove(intlStr);
            if (sc.Count != cnt)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005b, removed something");
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Example #16
0
    public virtual bool runTest()
    {
        Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int         iCountErrors    = 0;
        int         iCountTestcases = 0;
        String      strLoc          = "Loc_000oo";
        String      strBaseLoc      = "";
        IntlStrings intl            = new IntlStrings();
        String      tempString      = intl.GetString(4, true, true);
        String      str1;

        Char[]   chArr;
        Char[]   chResultArr1 = {};
        Char[]   chResultArr2 = { tempString[0], tempString[1], tempString[2], tempString[3] };
        Char[]   chResultArr3 = { 'a', 'k', 'k', 'a', ' ', 'b', 'a', 'k', 'k', 'a' };
        Char[]   chResultArr4 = { '\\', '\\' };
        Char[]   chResultArr5 = { 'M', 'I', 'C', 'R', 'O', 'S', 'O', 'F', 'T' };
        Char[]   chResultArr6 = { 'C', 'O', 'M', '+' };
        Char[]   chResultArr7 = { '1', '2', '3', '4', '5' };
        Char[]   chResultArr8 = { ']', '[' };
        String[] strTestArray = { "",
                                  tempString,
                                  "akka bakka",
                                  "\\\\",
                                  "MICROSOFT",
                                  "COM+",
                                  "12345",
                                  "][" };
        try {
LABEL_860_GENERAL:
            do
            {
                strBaseLoc = "Loc_1000uq_";
                chArr      = strTestArray[0].ToCharArray();
                iCountTestcases++;
                if (chArr.Length != chResultArr1.Length)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + "Err_983cd");
                }
                iCountTestcases++;
                for (int ii = 0; ii < chResultArr1.Length; ii++)
                {
                    strLoc = strBaseLoc + ii.ToString();
                    if (chArr[ii] != chResultArr1[ii])
                    {
                        iCountErrors++;
                        Console.WriteLine(s_strTFAbbrev + "Err_598uq");
                    }
                }
                strBaseLoc = "Loc_1100fd_";
                chArr      = strTestArray[1].ToCharArray();
                iCountTestcases++;
                if (chArr.Length != chResultArr2.Length)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + "Err_930oo");
                }
                iCountTestcases++;
                for (int ii = 0; ii < chResultArr2.Length; ii++)
                {
                    strLoc = strBaseLoc + ii.ToString();
                    if (chArr[ii] != chResultArr2[ii])
                    {
                        iCountErrors++;
                        Console.WriteLine(s_strTFAbbrev + "Err_803ii");
                    }
                }
                strBaseLoc = "Loc_1200ds_";
                chArr      = strTestArray[2].ToCharArray();
                iCountTestcases++;
                if (chArr.Length != chResultArr3.Length)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + "Err_932oo");
                }
                iCountTestcases++;
                for (int ii = 0; ii < chResultArr3.Length; ii++)
                {
                    strLoc = strBaseLoc + ii.ToString();
                    if (chArr[ii] != chResultArr3[ii])
                    {
                        iCountErrors++;
                        Console.WriteLine(s_strTFAbbrev + "Err_348uw");
                    }
                }
                strBaseLoc = "Loc_1300re_";
                chArr      = strTestArray[3].ToCharArray();
                iCountTestcases++;
                if (chArr.Length != chResultArr4.Length)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + "Err_934oo");
                }
                iCountTestcases++;
                for (int ii = 0; ii < chResultArr4.Length; ii++)
                {
                    strLoc = strBaseLoc + ii.ToString();
                    if (chArr[ii] != chResultArr4[ii])
                    {
                        iCountErrors++;
                        Console.WriteLine(s_strTFAbbrev + "Err_903ww! ii==" + ii + ", chArr[ii]==" + chArr[ii] + ", chResultArr[ii]=" + chResultArr4[ii]);
                    }
                }
                strBaseLoc = "Loc_1400er_";
                chArr      = strTestArray[4].ToCharArray();
                iCountTestcases++;
                if (chArr.Length != chResultArr5.Length)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + "Err_936oo");
                }
                iCountTestcases++;
                for (int ii = 0; ii < chResultArr5.Length; ii++)
                {
                    strLoc = strBaseLoc + ii.ToString();
                    if (chArr[ii] != chResultArr5[ii])
                    {
                        iCountErrors++;
                        Console.WriteLine(s_strTFAbbrev + "Err_349cs");
                    }
                }
                strBaseLoc = "Loc_1500ei_";
                chArr      = strTestArray[5].ToCharArray();
                iCountTestcases++;
                if (chArr.Length != chResultArr6.Length)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + "Err_940oo");
                }
                iCountTestcases++;
                for (int ii = 0; ii < chResultArr6.Length; ii++)
                {
                    strLoc = strBaseLoc + ii.ToString();
                    if (chArr[ii] != chResultArr6[ii])
                    {
                        iCountErrors++;
                        Console.WriteLine(s_strTFAbbrev + "Err_490op");
                    }
                }
                strBaseLoc = "Loc_1600du_";
                chArr      = strTestArray[6].ToCharArray();
                iCountTestcases++;
                if (chArr.Length != chResultArr7.Length)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + "Err_945oo");
                }
                iCountTestcases++;
                for (int ii = 0; ii < chResultArr7.Length; ii++)
                {
                    strLoc = strBaseLoc + ii.ToString();
                    if (chArr[ii] != chResultArr7[ii])
                    {
                        iCountErrors++;
                        Console.WriteLine(s_strTFAbbrev + "Err_893ao");
                    }
                }
                strBaseLoc = "Loc_1700uf_";
                chArr      = strTestArray[7].ToCharArray();
                iCountTestcases++;
                if (chArr.Length != chResultArr8.Length)
                {
                    iCountErrors++;
                    Console.WriteLine(s_strTFAbbrev + "Err_950oo");
                }
                iCountTestcases++;
                for (int ii = 0; ii < chResultArr8.Length; ii++)
                {
                    strLoc = strBaseLoc + ii.ToString();
                    if (chArr[ii] != chResultArr8[ii])
                    {
                        iCountErrors++;
                        Console.WriteLine(s_strTFAbbrev + "Err_4398u");
                    }
                }
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general);
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public Boolean runTest()
    {
        int    iCountErrors    = 0;
        int    iCountTestcases = 1;
        String strLoc          = "123_er";
        String strInfo         = null;

        Console.Out.Write(strName);
        Console.Out.Write(": ");
        Console.Out.Write(strPath + strTest);
        Console.Out.WriteLine(" runTest started...");
        String      strAlphabetsLower = "abcdefghijklmnopqrstuvwxyz";
        String      strAlphabetsUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String      str1 = null;
        String      str2 = null;
        CultureInfo ciCultInfo;
        CompareInfo ciCompInfo;
        Int32       iAnswer;
        Thread      tCurrentThread;

        try
        {
            tCurrentThread = Thread.CurrentThread;
            ciCultInfo     = tCurrentThread.CurrentCulture;
            ciCompInfo     = ciCultInfo.CompareInfo;
            iAnswer        = ciCompInfo.Compare("a", "-", CompareOptions.StringSort);
            if (iAnswer != 1)
            {
                ++iCountErrors;
                Console.WriteLine("Error_pim750:  (" + iAnswer.ToString() + ") .StringSort bad, a -to- -");
            }
            iAnswer = ciCompInfo.Compare("a", "-a", CompareOptions.StringSort);
            if (iAnswer != 1)
            {
                ++iCountErrors;
                Console.WriteLine("Error_pim761:  (" + iAnswer.ToString() + ") .StringSort bad, a -to- -a");
            }
            iAnswer = ciCompInfo.Compare("a", "-");
            if (iAnswer != 1)
            {
                ++iCountErrors;
                Console.WriteLine("Error_ran346:  (" + iAnswer.ToString() + ") bad, a -to- -");
            }
            iAnswer = ciCompInfo.Compare("a", "-a");
            if (iAnswer != -1)
            {
                ++iCountErrors;
                Console.WriteLine("Error_ran337:  (" + iAnswer.ToString() + ")  bad, a -to- -a");
            }
            iAnswer = ciCompInfo.Compare("coop", "co-op");
            if (iAnswer != -1)
            {
                ++iCountErrors;
                Console.WriteLine("Error_ran328:  (" + iAnswer.ToString() + ") bad, coop -to- co-op");
            }
            do
            {
                str1 = strAlphabetsLower;
                if (String.Compare(str1, strAlphabetsLower) != 0)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_738ke";
                    Console.WriteLine(strTest + strInfo);
                }
                IntlStrings intl       = new IntlStrings();
                String      intlString = intl.GetString(10, false, true);
                str1 = intlString;
                if (String.Compare(str1, intlString) != 0)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_738ke";
                    Console.WriteLine(strTest + strInfo);
                }
                str2 = strAlphabetsLower;
                if (String.Compare(str2, strAlphabetsLower) != 0)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_390nb";
                    Console.WriteLine(strTest + strInfo);
                }
                str2 = strAlphabetsLower;
                Console.WriteLine("Info_wat481:  a -to- A == " + String.Compare("a", "A"));
                if (String.Compare(str2, strAlphabetsUpper, false, CultureInfo.InvariantCulture) >= 0)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_023Sd   , str1==" + str2 + " , str2==" + strAlphabetsUpper;
                    Console.WriteLine(strTest + strInfo);
                }
                str2 = strAlphabetsUpper;
                if (String.Compare(str2, strAlphabetsLower, false, CultureInfo.InvariantCulture) <= 0)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_033pw";
                    Console.WriteLine(strTest + strInfo);
                }
                str1 = strAlphabetsUpper;
                str2 = null;
                if (String.Compare(str1, str2) != 1)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_053jh";
                    Console.WriteLine(strTest + strInfo);
                }
                str1 = null;
                str2 = strAlphabetsLower;
                if (String.Compare(str1, str2) != -1)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_304_jk";
                    Console.WriteLine(strTest + strInfo);
                }
                str1 = null;
                str2 = null;
                if (String.Compare(str1, str2) != 0)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_982ww";
                    Console.WriteLine(strTest + strInfo);
                }
            } while (false);
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.Error.WriteLine("POINTTOBREAK: Error Err_103! strLoc==" + strLoc + " ,exc_general==" + exc_general);
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #18
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int              iCountErrors    = 0;
        int              iCountTestcases = 0;
        IntlStrings      intl;
        String           strLoc = "Loc_000oo";
        HybridDictionary hd;
        const int        BIG_LENGTH = 100;

        string [] valuesShort =
        {
            "",
            " ",
            "$%^#",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        string [] keysShort =
        {
            Int32.MaxValue.ToString(),
            " ",
            System.DateTime.Today.ToString(),
            "",
            "$%^#"
        };
        string [] valuesLong = new string[BIG_LENGTH];
        string [] keysLong   = new string[BIG_LENGTH];
        int       cnt        = 0;

        try
        {
            intl = new IntlStrings();
            for (int i = 0; i < BIG_LENGTH; i++)
            {
                valuesLong[i] = "Item" + i;
                keysLong[i]   = "keY" + i;
            }
            Console.WriteLine("--- create dictionary ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            hd = new HybridDictionary();
            Console.WriteLine("1. Contains() on empty dictionary");
            iCountTestcases++;
            Console.WriteLine("     - Contains(null)");
            try
            {
                hd.Contains(null);
                iCountErrors++;
                Console.WriteLine("Err_0001a, ArgumentNullException expected");
            }
            //
            catch (System.ArgumentNullException e)
            {
                Console.WriteLine("expected exception: {0}", e.ToString());
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001b, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("     - Contains(some_object)");
            if (hd.Contains("some_string"))
            {
                iCountErrors++;
                Console.WriteLine("Err_0001c, empty dictionary contains some_object");
            }
            Console.WriteLine("2. add few simple strings and check Contains()");
            strLoc = "Loc_002oo";
            iCountTestcases++;
            cnt = hd.Count;
            int len = valuesShort.Length;
            for (int i = 0; i < len; i++)
            {
                hd.Add(keysShort[i], valuesShort[i]);
            }
            if (hd.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, count is {0} instead of {1}", hd.Count, valuesShort.Length);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(keysShort[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}b, doesn't contain \"{1}\"", i, keysShort[i]);
                }
            }
            Console.WriteLine(" .. increase number of elements");
            cnt = hd.Count;
            len = valuesLong.Length;
            for (int i = 0; i < len; i++)
            {
                hd.Add(keysLong[i], valuesLong[i]);
            }
            if (hd.Count != len + cnt)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002c, count is {0} instead of {1}", hd.Count, len + cnt);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(keysLong[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}d, doesn't contain \"{1}\"", i, keysLong[i]);
                }
            }
            for (int i = 0; i < valuesShort.Length; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(keysShort[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}e, doesn't contain \"{1}\"", i, keysShort[i]);
                }
            }
            Console.WriteLine("3. add intl strings check Contains()");
            strLoc = "Loc_003oo";
            iCountTestcases++;
            string [] intlValues = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            iCountTestcases++;
            hd.Clear();
            for (int i = 0; i < len; i++)
            {
                hd.Add(intlValues[i + len], intlValues[i]);
            }
            if (hd.Count != (len))
            {
                iCountErrors++;
                Console.WriteLine("Err_0003a, count is {0} instead of {1}", hd.Count, len);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(intlValues[i + len]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, doesn't contain \"{1}\"", i, intlValues[i + len]);
                }
            }
            Console.WriteLine("4. case sensitivity");
            strLoc = "Loc_004oo";
            hd.Clear();
            len = valuesLong.Length;
            for (int i = 0; i < len; i++)
            {
                hd.Add(keysLong[i], valuesLong[i]);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(keysLong[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}a, doesn't contain added uppercase \"{1}\"", i, keysLong[i]);
                }
                iCountTestcases++;
                if (hd.Contains(keysLong[i].ToUpper()))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}a, contains uppercase \"{1}\" - should not", i, keysLong[i].ToUpper());
                }
            }
            Console.WriteLine("5. similar_but_different_in_casing keys and Contains()");
            strLoc = "Loc_005oo";
            iCountTestcases++;
            hd.Clear();
            string [] ks = { "Key", "kEy", "keY" };
            len = ks.Length;
            for (int i = 0; i < len; i++)
            {
                hd.Add(ks[i], "Value" + i);
            }
            if (hd.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005a, count is {0} instead of {1}", hd.Count, len);
            }
            iCountTestcases++;
            if (hd.Contains("Value0"))
            {
                iCountErrors++;
                Console.WriteLine("Err_0005b, returned true when should not");
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(ks[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005c_{0}, returned false when true expected", i);
                }
            }
            Console.WriteLine(" .. increase number of elements");
            cnt = hd.Count;
            len = valuesLong.Length;
            for (int i = 0; i < len; i++)
            {
                hd.Add(keysLong[i], valuesLong[i]);
            }
            if (hd.Count != len + cnt)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005d, count is {0} instead of {1}", hd.Count, len + cnt);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(keysLong[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}e, doesn't contain \"{1}\"", i, keysLong[i]);
                }
            }
            for (int i = 0; i < ks.Length; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(ks[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}f, doesn't contain \"{1}\"", i, ks[i]);
                }
            }
            Console.WriteLine("6. Contains(null) for filled dictionary");
            strLoc = "Loc_006oo";
            iCountTestcases++;
            len = valuesShort.Length;
            hd.Clear();
            for (int i = 0; i < len; i++)
            {
                hd.Add(keysShort[i], valuesShort[i]);
            }
            try
            {
                hd.Contains(null);
                iCountErrors++;
                Console.WriteLine("Err_0006a, no exception");
            }
            catch (ArgumentNullException ex)
            {
                Console.WriteLine("  Expected exception: {0}", ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0006b, unexpected exception: {0}", e.ToString());
            }
            Console.WriteLine("7. Contains() for case-insensitive comparer dictionary");
            hd     = new HybridDictionary(true);
            strLoc = "Loc_007oo";
            iCountTestcases++;
            hd.Clear();
            len = ks.Length;
            hd.Add(ks[0], "Value0");
            for (int i = 1; i < len; i++)
            {
                try
                {
                    hd.Add(ks[i], "Value" + i);
                    iCountErrors++;
                    Console.WriteLine("Err_0007a_{0}, no exception", i);
                }
                catch (ArgumentException e)
                {
                    Console.WriteLine("_{0}, Expected exception: {1}", i, e.Message);
                }
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0007b_{0}, unexpected exception: {1}", i, ex.ToString());
                }
            }
            if (hd.Count != 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0007c, count is {0} instead of {1}", hd.Count, 1);
            }
            iCountTestcases++;
            if (hd.Contains("Value0"))
            {
                iCountErrors++;
                Console.WriteLine("Err_0007d, returned true when should not");
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(ks[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0007e_{0}, returned false when true expected", i);
                }
            }
            iCountTestcases++;
            if (!hd.Contains("KEY"))
            {
                iCountErrors++;
                Console.WriteLine("Err_0007f, returned false non-existing-cased key");
            }
            Console.WriteLine("9. Contains() and few SpecialStructs_not_overriding_Equals");
            hd     = new HybridDictionary();
            strLoc = "Loc_009oo";
            iCountTestcases++;
            Co8686_SpecialStruct s = new Co8686_SpecialStruct();
            s.Num = 1;
            s.Wrd = "one";
            Co8686_SpecialStruct s1 = new Co8686_SpecialStruct();
            s.Num = 1;
            s.Wrd = "one";
            hd.Add(s, "first");
            hd.Add(s1, "second");
            if (hd.Count != 2)
            {
                iCountErrors++;
                Console.WriteLine("Err_0009a, count is {0} instead of {1}", hd.Count, 2);
            }
            iCountTestcases++;
            if (!hd.Contains(s))
            {
                iCountErrors++;
                Console.WriteLine("Err_0009b, returned false when true expected");
            }
            iCountTestcases++;
            if (!hd.Contains(s1))
            {
                iCountErrors++;
                Console.WriteLine("Err_0009c, returned false when true expected");
            }
            Console.WriteLine("10. Contains() and many SpecialStructs_not_overriding_Equals");
            int num = 40;
            hd     = new HybridDictionary();
            strLoc = "Loc_010oo";
            iCountTestcases++;
            Co8686_SpecialStruct [] ss = new Co8686_SpecialStruct[num];
            for (int i = 0; i < num; i++)
            {
                ss[i]     = new Co8686_SpecialStruct();
                ss[i].Num = i;
                ss[i].Wrd = "value" + i;
                hd.Add(ss[i], "item" + i);
            }
            if (hd.Count != num)
            {
                iCountErrors++;
                Console.WriteLine("Err_0010a, count is {0} instead of {1}", hd.Count, num);
            }
            for (int i = 0; i < num; i++)
            {
                iCountTestcases++;
                if (!hd.Contains(ss[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0010b_{0}, returned false when true expected", i);
                }
            }
            iCountTestcases++;
            s     = new Co8686_SpecialStruct();
            s.Num = 1;
            s.Wrd = "value1";
            if (hd.Contains(s))
            {
                iCountErrors++;
                Console.WriteLine("Err_0010c, returned true when false expected");
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Example #19
0
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        String strValue        = String.Empty;

        try
        {
            String      str1;
            Char[]      chArr;
            int         iResult           = 0;
            int[]       iArrInvalidValues = new Int32[] { -1, -2, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000, Int32.MinValue };
            int[]       iArrLargeValues   = new Int32[] { Int32.MaxValue, Int32.MaxValue - 1, Int32.MaxValue / 2, Int32.MaxValue / 10, Int32.MaxValue / 100 };
            int[]       iArrValidValues   = new Int32[] { 10000, 5000, 1000, 0 };
            IntlStrings intl       = new IntlStrings();
            String      intlString = intl.GetString(20, true, true);
            Char[]      chrArr     = intlString.ToCharArray();
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrInvalidValues.Length; iLoop++)
            {
                try
                {
                    intlString.CopyTo(iArrInvalidValues[iLoop], chrArr, 5, 5);
                    iCountErrors++;
                    Console.Error.WriteLine("Error_0000!!!! Expected exception not occured");
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.Error.WriteLine("Error_2222!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrInvalidValues.Length; iLoop++)
            {
                try
                {
                    intlString.CopyTo(5, chrArr, iArrInvalidValues[iLoop], 5);
                    iCountErrors++;
                    Console.Error.WriteLine("Error_4444!!!! Expected exception not occured");
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.Error.WriteLine("Error_5555!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrInvalidValues.Length; iLoop++)
            {
                try
                {
                    intlString.CopyTo(5, chrArr, 5, iArrInvalidValues[iLoop]);
                    iCountErrors++;
                    Console.Error.WriteLine("Error_7777!!!! Expected exception not occured");
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.Error.WriteLine("Error_8888!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrLargeValues.Length; iLoop++)
            {
                try
                {
                    intlString.CopyTo(iArrLargeValues[iLoop], chrArr, 5, 5);
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.Error.WriteLine("Error_2134!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrLargeValues.Length; iLoop++)
            {
                try
                {
                    intlString.CopyTo(5, chrArr, iArrLargeValues[iLoop], 5);
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.Error.WriteLine("Error_8787!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrLargeValues.Length; iLoop++)
            {
                try
                {
                    intlString.CopyTo(5, chrArr, 5, iArrLargeValues[iLoop]);
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.Error.WriteLine("Error_43433!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            intlString = intl.GetString(100000, true, true);
            str1       = intlString;
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrValidValues.Length; iLoop++)
            {
                try
                {
                    chrArr = new Char[iArrValidValues[iLoop]];
                    intlString.CopyTo(iLoop * 100, chrArr, 0, iArrValidValues[iLoop]);
                    if (iResult != 0)
                    {
                        iCountErrors++;
                        Console.Error.WriteLine("Error_8787!!!! CopyTo returned incorrect value.... Expected...{0},  Actual...{1}", 0, iResult);
                    }
                } catch (Exception ex) {
                    Console.Error.WriteLine("Error_4564!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            strLoc = "Loc_0939v";
            str1   = String.Empty;
            iCountTestcases++;
            try {
                str1.CopyTo(0, null, 0, 0);
                iCountErrors++;
                printerr("Error_1908c! ArgumentNullException expected");
            } catch (ArgumentNullException aExc) {
                Console.WriteLine("Info_18f84! Caught Expected Exception , exc==" + aExc.Message);
            } catch (Exception exc) {
                iCountErrors++;
                printerr("Error_0129x! ArgumentNullException expected, got exc==" + exc.ToString());
            }
            strLoc = "Loc_09ucd";
            str1   = String.Empty;
            chArr  = new Char[0];
            iCountTestcases++;
            try {
                str1.CopyTo(-1, chArr, 0, 0);
                iCountErrors++;
                printerr("Error_109uc! ArgumentOutOfRangeException expected");
            } catch (ArgumentOutOfRangeException aExc) {
                Console.WriteLine("Info_109fa! Caught expected exception , exc==" + aExc.Message);
            } catch (Exception exc) {
                iCountErrors++;
                printerr("Error_1098u! ArgumentOutOfRangeException expected, got exc==" + exc.ToString());
            }
            strLoc = "Loc_09f8v";
            str1   = String.Empty;
            chArr  = new Char[0];
            iCountTestcases++;
            try {
                str1.CopyTo(1, chArr, 0, 0);
                iCountErrors++;
                printerr("Error_1908v! ArgumentOutOfRangeException expected");
            } catch (ArgumentOutOfRangeException aExc) {
                Console.WriteLine("Info_09t95! Caught expected exception , exc==" + aExc.Message);
            } catch (Exception exc) {
                iCountErrors++;
                printerr("Error_228ch! ArgumentOutOfRangeException expected, got exc==" + exc.ToString());
            }
            strLoc = "Loc_98yt5";
            str1   = "Hello";
            chArr  = new Char[0];
            iCountTestcases++;
            try {
                str1.CopyTo(3, chArr, -1, 1);
                iCountErrors++;
                printerr("Error_498gb! ArgumentOutOfRangeException expected");
            } catch (ArgumentOutOfRangeException aExc) {
                Console.WriteLine("Info_298vh! Caught expected exception , exc==" + aExc.Message);
            } catch (Exception exc) {
                iCountErrors++;
                printerr("Error_20g9f! ArgumentOutOfRangeException expected, got exc==" + exc.ToString());
            }
            strLoc = "Loc_2998c";
            str1   = "Hello";
            chArr  = new Char[0];
            iCountTestcases++;
            try {
                str1.CopyTo(2, chArr, 0, 1);
                iCountErrors++;
                printerr("Error_28gh8! ArgumentOutOfRangeException expected");
            } catch (ArgumentOutOfRangeException aExc) {
                Console.WriteLine("Info_298gb! Caught expected excpetion , exc==" + aExc.Message);
            } catch (Exception exc) {
                iCountErrors++;
                printerr("Error_298hb! ArgumentOutOfRangeException expected, got exc==" + exc.ToString());
            }
            strLoc = "Loc_209uc";
            str1   = "HelloWorld";
            chArr  = new Char[2];
            str1.CopyTo(4, chArr, 0, 2);
            iCountTestcases++;
            if (chArr[0] != 'i' && chArr[1] != 'W')
            {
                iCountErrors++;
                printerr("Error_287fv! Incorrect chars in array [0]==" + chArr[0].ToString() + " , [1]==" + chArr[1].ToString());
            }
            intl  = new IntlStrings();
            str1  = intl.GetString(8, true, true);
            chArr = new Char[2];
            str1.CopyTo(0, chArr, 0, 2);
            iCountTestcases++;
            if (chArr[0] != str1[0] && chArr[1] != str1[1])
            {
                iCountErrors++;
                printerr("Error_287fv! Incorrect chars in array [0]==" + chArr[0].ToString() + " , [1]==" + chArr[1].ToString());
            }
            strLoc = "Loc_298hg";
            str1   = "HelloWorld";
            chArr  = new Char[15];
            str1.CopyTo(4, chArr, 5, 2);
            iCountTestcases++;
            if (chArr[5] != 'i' && chArr[6] != 'W')
            {
                iCountErrors++;
                printerr("Error_7yg73! Incorrect chars in array [5]==" + chArr[5].ToString() + " , [6]==" + chArr.ToString());
            }
            strLoc = "Loc_298hg";
            str1   = "Bug";
            chArr  = new Char[3];
            str1.CopyTo(0, chArr, 0, 3);
            iCountTestcases++;
            if (chArr[0] != 'B' && chArr[1] != 'u' && chArr[2] != 'g')
            {
                iCountErrors++;
                printerr("Error_27ggb! Incorrect chars in array");
            }
            str1  = "Bug";
            chArr = new Char[7];
            str1.CopyTo(0, chArr, 2, 3);
            iCountTestcases++;
            if (chArr[2] != 'B' && chArr[3] != 'u' && chArr[4] != 'g')
            {
                iCountErrors++;
                printerr("Error_958vh! Incorrect chars in array");
            }
            strLoc = "Loc_27hgt";
            str1   = "Bug";
            chArr  = new Char[10];
            iCountTestcases++;
            try {
                str1.CopyTo(2, chArr, 3, 2);
                Console.WriteLine(chArr[2]);
                iCountErrors++;
                printerr("Error_2gh88! ArgumentOutOfRangeException expected");
            } catch (ArgumentOutOfRangeException aExc) {
                Console.WriteLine("Info_498gh! Caught expected Exception, exc==" + aExc.Message);
            } catch (Exception exc) {
                iCountErrors++;
                printerr("Error_209u9! ArgumentException expected , got exc==" + exc.ToString());
            }
            str1  = "Bug";
            chArr = new Char[4];
            iCountTestcases++;
            try {
                str1.CopyTo(1, chArr, 3, 3);
                iCountErrors++;
                printerr("Error_29hvg! ArgumentException expected");
            } catch (ArgumentException aExc) {
                Console.WriteLine("Info_287gb! Caught expected Exception, exc==" + aExc.Message);
            } catch (Exception exc) {
                iCountErrors++;
                printerr("Error_298g8! ArgumentException expected, got exc==" + exc.ToString());
            }
            StringBuilder sb1 = new StringBuilder("");
            for (int i = 0; i < 100000; i++)
            {
                sb1.Append('o');
            }
            str1 = sb1.ToString();
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #20
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int              iCountErrors    = 0;
        int              iCountTestcases = 0;
        IntlStrings      intl;
        String           strLoc = "Loc_000oo";
        StringCollection sc;

        string [] values =
        {
            "",
            " ",
            "a",
            "aa",
            "text",
            "     spaces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        int cnt = 0;

        try
        {
            intl = new IntlStrings();
            Console.WriteLine("--- create collection ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            sc = new StringCollection();
            Console.WriteLine("1. add simple strings");
            iCountTestcases++;
            cnt = sc.Count;
            sc.AddRange(values);
            if (sc.Count != values.Length)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001, count is {0} instead of {1}", sc.Count, values.Length);
            }
            Console.WriteLine("2. verify that collection contains all added items");
            strLoc = "Loc_002oo";
            for (int i = 0; i < values.Length; i++)
            {
                iCountTestcases++;
                if (!sc.Contains(values[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}, collection doesn't contain new item", i);
                }
            }
            Console.WriteLine("3. add intl strings");
            string [] intlValues = new string [values.Length];
            for (int i = 0; i < values.Length; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            strLoc = "Loc_003oo";
            cnt    = sc.Count;
            Console.WriteLine(" initial number of items: " + cnt);
            iCountTestcases++;
            sc.AddRange(intlValues);
            if (sc.Count != (cnt + intlValues.Length))
            {
                iCountErrors++;
                Console.WriteLine("Err_0003, count is {0} instead of {1}", sc.Count, cnt + intlValues.Length);
            }
            Console.WriteLine("4. verify that collection contains all added items");
            strLoc = "Loc_004oo";
            for (int i = 0; i < intlValues.Length; i++)
            {
                iCountTestcases++;
                iCountTestcases++;
                if (!sc.Contains(intlValues[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}, collection doesn't contain new item", i);
                }
            }
            Console.WriteLine("5. add empty range");
            strLoc = "Loc_005oo";
            iCountTestcases++;
            cnt = sc.Count;
            string [] empty = {};
            sc.AddRange(empty);
            if (sc.Count != cnt)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005, count is {0} instead of {1}", sc.Count, cnt);
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Example #21
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int            iCountErrors    = 0;
        int            iCountTestcases = 0;
        IntlStrings    intl;
        String         strLoc = "Loc_000oo";
        ListDictionary ld;

        string [] values =
        {
            "",
            " ",
            "a",
            "aA",
            "text",
            "     SPaces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        string [] keys =
        {
            "zero",
            "oNe",
            " ",
            "",
            "aa",
            "1",
            System.DateTime.Today.ToString(),
            "$%^#",
            Int32.MaxValue.ToString(),
            "     spaces",
            "2222222222222222222222222"
        };
        int cnt = 0;

        try
        {
            intl = new IntlStrings();
            Console.WriteLine("--- create dictionary ---");
            strLoc = "Loc_001_oo";
            iCountTestcases++;
            ld  = new ListDictionary();
            cnt = ld.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001_, count is {0} instead of {1} after default ctor", ld.Count, 0);
            }
            Console.WriteLine("1. call Clear() on empty dictionary");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            ld.Clear();
            cnt = ld.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001a, count is {0} instead of {1} after Clear()", ld.Count, 0);
            }
            iCountTestcases++;
            cnt = ld.Keys.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001b, Keys.Count is {0} instead of {1} after Clear()", cnt, 0);
            }
            iCountTestcases++;
            cnt = ld.Values.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001c, Values.Count is {0} instead of {1} after Clear()", cnt, 0);
            }
            Console.WriteLine("2. add simple strings and Clear()");
            strLoc = "Loc_002oo";
            iCountTestcases++;
            cnt = ld.Count;
            for (int i = 0; i < values.Length; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != values.Length)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, count is {0} instead of {1}", ld.Count, values.Length);
            }
            iCountTestcases++;
            ld.Clear();
            cnt = ld.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002b, count is {0} instead of {1} after Clear()", ld.Count, 0);
            }
            iCountTestcases++;
            cnt = ld.Keys.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002c, Keys.Count is {0} instead of {1} after Clear()", cnt, 0);
            }
            iCountTestcases++;
            cnt = ld.Values.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002d, Values.Count is {0} instead of {1} after Clear()", cnt, 0);
            }
            Console.WriteLine("3. add intl strings and Clear()");
            strLoc = "Loc_003oo";
            int       len        = values.Length;
            string [] intlValues = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            cnt = ld.Count;
            iCountTestcases++;
            for (int i = 0; i < len; i++)
            {
                ld.Add(intlValues[i + len], intlValues[i]);
            }
            if (ld.Count != (cnt + len))
            {
                iCountErrors++;
                Console.WriteLine("Err_0003a, count is {0} instead of {1}", ld.Count, cnt + len);
            }
            iCountTestcases++;
            ld.Clear();
            cnt = ld.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003b, count is {0} instead of {1} after Clear()", ld.Count, 0);
            }
            iCountTestcases++;
            cnt = ld.Keys.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003c, Keys.Count is {0} instead of {1} after Clear()", cnt, 0);
            }
            iCountTestcases++;
            cnt = ld.Values.Count;
            if (cnt != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0003d, Values.Count is {0} instead of {1} after Clear()", cnt, 0);
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Example #22
0
    public unsafe bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        String strValue        = String.Empty;

        try
        {
            sbyte *chptr = null, baseptr = null;
            String str1 = String.Empty, str2 = String.Empty;
            strLoc = "Loc_498hv";
            try {
                iCountTestcases++;
                str2 = new String(chptr);
                if (!str2.Equals(String.Empty))
                {
                    iCountErrors++;
                    printerr("Error_498ch! incorrect string returned for null argument==" + str2);
                }
            } catch (Exception e) { Console.WriteLine(e.ToString()); };
            strLoc = "Loc_982hc";
            iCountTestcases++;
            try {
                iCountTestcases++;
                IntlStrings intl       = new IntlStrings();
                String      testString = intl.GetString(1, true, true);
                fixed(char *charptr = testString)
                {
                    str2 = new  String(charptr);
                }
                if (str2 != testString)
                {
                    iCountErrors++;
                    printerr("Error_49hcx! incorrect string constructed==" + str2);
                }
            } catch (Exception e) { Console.WriteLine("WRONG"); }
            try {
                strLoc = "Loc_9fhc1";
                *chptr = (sbyte)'\t';
                str2 = new String(chptr);
                iCountTestcases++;
                if (str2[0] != '\t')
                {
                    iCountErrors++;
                    printerr("Error_89hfd! incorrect string constructed==" + str2);
                }
            } catch (Exception e) { Console.WriteLine(e.ToString()); }
            try {
                strLoc = "Loc_9fh56";
                iCountTestcases++;
                sbyte *p = stackalloc sbyte[10];
                for (int i = 0; i < 10; i++)
                {
                    p[i]  = (sbyte)(i + (int)'0');
                    str1 += ((sbyte)i);
                }
                strLoc = "Loc_93286";
                iCountTestcases++;
                str2   = new String(p);
                strLoc = "Loc_93287";
                if (!str2.Equals(str1))
                {
                    iCountErrors++;
                    printerr("Error_209xu! Expected==" + str1 + "\nIncorrect string==" + str2);
                    printinfo("str2.Length == " + str2.Length);
                }
            }
            catch (Exception e) { Console.WriteLine(e.ToString()); }
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public Boolean runTest()
    {
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        Int32  i2      = -123;
        String strLoc  = "123_er";
        String strInfo = null;

        Console.Out.Write(strName);
        Console.Out.Write(": ");
        Console.Out.Write(strPath + strTest);
        Console.Out.WriteLine(" runTest started...");
        String strAlphabetsLower = "abcdefghijklmnopqrstuvwxyz";
        String strAlphabetsUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String str1 = null;
        String str2 = null;

        try
        {
            do
            {
                IntlStrings intl       = new IntlStrings();
                String      intlString = intl.GetString(10, false, true);
                str1 = intlString;
                if (str1.CompareTo(intlString) != 0)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_738ke";
                    Console.WriteLine(strTest + strInfo);
                }
                str1 = strAlphabetsLower;
                ++iCountTestcases;
                if (str1.CompareTo(strAlphabetsLower) != 0)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_738ke";
                    Console.WriteLine(strTest + strInfo);
                }
                strLoc = "reb8312";
                str1   = strAlphabetsLower;
                ++iCountTestcases;
                if (str1.CompareTo(strAlphabetsUpper) >= 0 && CultureInfo.CurrentCulture.LCID != 0x41F)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_023Sd";
                    Console.WriteLine(strTest + strInfo);
                }
                strLoc = "reb8313";
                str1   = strAlphabetsUpper;
                ++iCountTestcases;
                if (str1.CompareTo(strAlphabetsLower) <= 0 && CultureInfo.CurrentCulture.LCID != 0x41F)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_033pw";
                    Console.WriteLine(strTest + strInfo);
                }
                strLoc = "reb8314";
                str1   = strAlphabetsUpper;
                str2   = null;
                ++iCountTestcases;
                if (str1.CompareTo(str2) != 1)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_053jh";
                    Console.WriteLine(strTest + strInfo);
                }
                strLoc = "reb8315";
                str1   = null;
                str2   = strAlphabetsLower;
                ++iCountTestcases;
                try
                {
                    i2 = str1.CompareTo(str2);
                    ++iCountErrors;
                    Console.WriteLine("Error_reb2155: Expected NullRefExc!");
                }
                catch (NullReferenceException)
                {}
                strLoc = "Loc_837hd";
                str1   = "0";
                str2   = "{";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_371eh! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_192hw";
                str1   = "z";
                str2   = "{";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_732qu! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_128yr";
                str1   = "A";
                str2   = "*";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_347hw! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_834yw";
                str1   = "0";
                str2   = "$";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_289nk! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_372hu";
                str1   = "0";
                str2   = "5";
                iCountTestcases++;
                if (str1.CompareTo(str2) >= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_793rh! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_373hu";
                str1   = "5";
                str2   = "0";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_794rh! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_373hu";
                str1   = "5";
                str2   = "0";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_794rh! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_373hu";
                str1   = "A";
                str2   = "a";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_894rh! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_481hu";
                str1   = "A";
                str2   = "B";
                iCountTestcases++;
                if (str1.CompareTo(str2) >= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_933jw! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_473hu";
                str1   = "a";
                str2   = "A";
                iCountTestcases++;
                if (str1.CompareTo(str2) >= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_812ks! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_751hu";
                str1   = "B";
                str2   = "A";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_941jd! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_573hu";
                str1   = "}";
                str2   = "<";
                iCountTestcases++;
                if (str1.CompareTo(str2) >= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_094rh! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_673hu";
                str1   = "<";
                str2   = "{";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_099uh! , result==" + str1.CompareTo(str2));
                }
                strLoc = "Loc_683hu";
                str1   = "A";
                str2   = "0";
                iCountTestcases++;
                if (str1.CompareTo(str2) <= 0)
                {
                    iCountErrors++;
                    Console.WriteLine(strTest + "Err_134eh! , result==" + str1.CompareTo(str2));
                }
            } while (false);
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.Error.WriteLine("POINTTOBREAK: Error Err_103! strLoc==" + strLoc + " ,exc_general==" + exc_general);
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public virtual bool runTest()
    {
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "123_er";

        Console.Out.Write(s_strClassMethod);
        Console.Out.Write(": ");
        Console.Out.Write(s_strTFPath + s_strTFName);
        Console.Out.Write(": ");
        Console.Out.Write(s_strDtTmVer);
        Console.Out.WriteLine(" runTest started...");
        String str1;
        String str2;
        int    iPosition;

        try
        {
            int         iResult           = 0;
            int[]       iArrInvalidValues = new Int32[] { -1, -2, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000, Int32.MinValue };
            int[]       iArrLargeValues   = new Int32[] { Int32.MaxValue, Int32.MaxValue - 1, Int32.MaxValue / 2, Int32.MaxValue / 10, Int32.MaxValue / 100, 100000, 10000, 1000, 100, 21 };
            int[]       iArrValidValues   = new Int32[] { 100000, 99999, 50000, 10000, 1000, 200, 500, 100, 10, 3 };
            IntlStrings intl       = new IntlStrings();
            String      intlString = intl.GetString(20, true, true);
            str1 = intlString.Substring(10, 2);
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrInvalidValues.Length; iLoop++)
            {
                try
                {
                    iResult = intlString.LastIndexOf(str1, iArrInvalidValues[iLoop], 5);
                    iCountErrors++;
                    Console.WriteLine("Error_0000!!! Expected exception not occured...");
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.WriteLine("Error_1111!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrInvalidValues.Length; iLoop++)
            {
                try
                {
                    iResult = intlString.LastIndexOf(str1, 5, iArrInvalidValues[iLoop]);
                    iCountErrors++;
                    Console.WriteLine("Error_2222!!! Expected exception not occured...");
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.WriteLine("Error_3333!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrLargeValues.Length; iLoop++)
            {
                try
                {
                    iResult = intlString.LastIndexOf(str1, iArrLargeValues[iLoop], 5);
                    iCountErrors++;
                    Console.WriteLine("Error_4444!!! Expected exception not occured...");
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.WriteLine("Error_5555!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            for (int iLoop = 0; iLoop < iArrLargeValues.Length; iLoop++)
            {
                try
                {
                    iResult = intlString.LastIndexOf(str1, 5, iArrLargeValues[iLoop]);
                    iCountErrors++;
                    Console.WriteLine("Error_6666!!! Expected exception not occured...");
                } catch (ArgumentOutOfRangeException) {
                } catch (Exception ex)
                {
                    Console.WriteLine("Error_7777!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            iCountTestcases++;
            intlString = intl.GetString(100002, true, true);
            str1       = intlString.Substring(0, 2);
            for (int iLoop = 0; iLoop < iArrValidValues.Length; iLoop++)
            {
                try
                {
                    iResult = intlString.LastIndexOf(str1, iArrValidValues[iLoop] - 1, iArrValidValues[iLoop]);
                    if (iResult == -1)
                    {
                        iCountErrors++;
                        Console.WriteLine("Error_8888!!!! Incorrect LastIndexOf value.... Actual...{0}", iResult);
                    }
                } catch (Exception ex) {
                    Console.WriteLine("Error_9999!!! Unexpected exception " + ex.ToString());
                    iCountErrors++;
                }
            }
            str1      = "Good Will Hunting is Good";
            str2      = "Good";
            iPosition = str1.LastIndexOf(str2, str1.Length, str1.Length + 1);
            ++iCountTestcases;
            if (iPosition != 21)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_320ye!  iPosition==" + iPosition);
            }
            try {
                intl = new IntlStrings();
                String myIntlString  = intl.GetString(5, true, true);
                String myIntlString2 = intl.GetString(13, true, true);
                myIntlString = String.Concat(myIntlString2, myIntlString);
                myIntlString = String.Concat(myIntlString, myIntlString2);
                Console.WriteLine(myIntlString.Length);
                Console.WriteLine(myIntlString + "$" + myIntlString2);
                if (myIntlString.LastIndexOf(myIntlString2, myIntlString.Length - 2, myIntlString.Length - 1) != 0)
                {
                    Console.WriteLine(myIntlString.LastIndexOf(myIntlString2, 0, 0));
                    ++iCountErrors;
                }
            } catch (Exception e) { ++iCountErrors;  Console.WriteLine("hi" + e.ToString()); }
            str1      = "Good Will Hunting is Good";
            str2      = "Good";
            iPosition = str1.LastIndexOf(str2, str1.Length - 2, str1.Length - 1);
            if (iPosition != 0)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_826se!  iPosition==" + iPosition);
            }
            str1      = "Good Will Hunting is Good";
            str2      = "Good";
            iPosition = str1.LastIndexOf(str2, str1.Length - 2, str1.Length - 2);
            if (iPosition != -1)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_026qm!  iPosition==" + iPosition);
            }
            str1      = "Good Will Hunting is Good";
            str2      = "gOOD";
            iPosition = str1.LastIndexOf(str2, str1.Length - 1, str1.Length);
            if (iPosition != -1)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_672xe!  iPosition==" + iPosition);
            }
            str1      = "Good Will Hunting is Good";
            str2      = String.Empty;
            iPosition = str1.LastIndexOf(str2, str1.Length - 1, str1.Length);
            if (iPosition != str1.Length - 1)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_539dr!  iPosition==" + iPosition);
            }
            str1      = String.Empty;
            str2      = String.Empty;
            iPosition = str1.LastIndexOf(str2, 0, 0);
            if (iPosition != 0)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_873se!  iPosition==" + iPosition);
            }
            str1      = "Good Will Hunting is Good";
            iPosition = str1.LastIndexOf(str1, str1.Length, str1.Length + 1);
            if (iPosition != 0)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_835xe!  iPosition==" + iPosition);
            }
            str1      = "Good Will Hunting is Good";
            iPosition = str1.LastIndexOf(str1, str1.Length, str1.Length);
            if (iPosition != -1)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_382dr!  iPosition==" + iPosition);
            }
            str1      = "Good Will Hunting is Good";
            str2      = "Good";
            iPosition = str1.LastIndexOf(str2, str1.Length, str1.Length - 21);
            if (iPosition != -1)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_357ze!  iPosition==" + iPosition);
            }
            str1      = "Good Will Hunting is Good";
            str2      = "Good";
            iPosition = str1.LastIndexOf(str2, 0, 1);
            if (iPosition != -1)
            {
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_571sw!  iPosition==" + iPosition);
            }
            str1 = "Good Will Hunting is Good";
            str2 = null;
            try
            {
                iPosition = str1.LastIndexOf(str2, str1.Length - 1, str1.Length);
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_835xr!  iPosition==" + iPosition);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                ++iCountErrors;
                Console.Error.WriteLine("POINTTOBREAK: Error E_972qr!  , Wrong Exception thrown == " + ex);
            }
            str1 = "Good Will Hunting is Good";
            str2 = "Good";
            try
            {
                iPosition = str1.LastIndexOf(str2, -1, -1);
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_753xr!  iPosition==" + iPosition);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                ++iCountErrors;
                Console.Error.WriteLine("POINTTOBREAK: Error E_904cr!  , Wrong Exception thrown == " + ex);
            }
            str1 = "Good Will Hunting is Good";
            str2 = "Good";
            try
            {
                iPosition = str1.LastIndexOf(str2, str1.Length + 1, str1.Length + 2);
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_844gf!  iPosition==" + iPosition);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                ++iCountErrors;
                Console.Error.WriteLine("POINTTOBREAK: Error E_853xr!  , Wrong Exception thrown == " + ex);
            }
            str1 = "Good Will Hunting is Good";
            str2 = "Good";
            try
            {
                iPosition = str1.LastIndexOf(str2, str1.Length, str1.Length + 2);
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_862sa!  iPosition==" + iPosition);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                ++iCountErrors;
                Console.Error.WriteLine("POINTTOBREAK: Error E_975se!  , Wrong Exception thrown == " + ex);
            }
            str1 = "Good Will Hunting is Good";
            str2 = "Good";
            try
            {
                iPosition = str1.LastIndexOf(str2, str1.Length + 1, str1.Length + 2);
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_864aq!  iPosition==" + iPosition);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                ++iCountErrors;
                Console.Error.WriteLine("POINTTOBREAK: Error E_162sw!  , Wrong Exception thrown == " + ex);
            }
            str1 = "Good Will Hunting is Good";
            str2 = "Good";
            try
            {
                iPosition = str1.LastIndexOf(str2, 0, str1.Length + 1);
                ++iCountErrors;
                Console.WriteLine(s_strTFAbbrev + "Err_926dt!  iPosition==" + iPosition);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                ++iCountErrors;
                Console.Error.WriteLine("POINTTOBREAK: Error E_108dw!  , Wrong Exception thrown == " + ex);
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + "Error Err_8888yyy!  strLoc==" + strLoc + " ,exc_general==" + exc_general);
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #25
0
    public Boolean runTest()
    {
        Console.Out.WriteLine("String\\Co3038TrimEnd_ChArr. runTest() started.");
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String str1            = null;
        String str2            = null;
        String str3            = null;
        String str4            = null;

        char[] cArr  = null;
        char[] cArr1 = new Char[] { 'E', 'F', 'g', 'h' };
        char[] cArr2 = new Char[] { 'E', 'F', 'G', 'H' };
        char[] cArr3 = new Char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
        char[] cArr4 = new Char[] { 'a', 'b' };
        char[] cArr5 = new Char[] { '#', '$', '%', '@', '!', '*', '?' };
        char[] cArr6 = new Char[] {};
        str1 = "  GeneMi  ";
        str2 = "  GeneMi";
        str3 = str1.TrimEnd(cArr6);
        str4 = str1.TrimEnd(null);
        iCountTestcases++;
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find Error_zer703 (Co3038TrimEnd_ChArr)");
        }
        iCountTestcases++;
        if (!(str3.Equals(str4)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find Error_zen603 (Co3038TrimEnd_ChArr)");
        }
        str1 = "abcdefg     ";
        str2 = "abcdefg";
        str3 = str1.TrimEnd(cArr);
        iCountTestcases++;
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_92si (Co3038TrimEnd_ChArr.)");
        }
        str1 = "abcde     e                     ";
        str2 = "abcde     e";
        str3 = str1.TrimEnd(cArr);
        iCountTestcases++;
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_982q (Co3038TrimEnd_ChArr.)");
        }
        IntlStrings intl = new IntlStrings();

        str1 = intl.GetString(8, false, true).TrimEnd();
        str2 = str1;
        str1 = String.Concat(str1, "           \n\n\n\t\t\t\t\t\t\t\r\r\r\r\r\n\n\t\t\t   ");
        str3 = str1.TrimEnd(cArr);
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_3228i (Co3038TrimEnd_ChArr.)");
        }
        str1 = "abcdefgh           \n\n\n\t\t\t\t\t\t\t\r\r\r\r\r\n\n\t\t\t   ";
        str2 = "abcdefgh";
        str3 = str1.TrimEnd(cArr);
        iCountTestcases++;
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_828i (Co3038TrimEnd_ChArr.)");
        }
        str1 = "ABCDEEEEEEFGH";
        str2 = "ABCD";
        str3 = str1.TrimEnd(cArr1);
        iCountTestcases++;
        if (!(str3.Equals(str1)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_280u (Co3038TrimEnd_ChArr.)");
        }
        str3 = str1.TrimEnd(cArr2);
        iCountTestcases++;
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_32ww (Co3038TrimEnd_ChArr.)");
        }
        str1 = "ABCDEFGH";
        str2 = "";
        str3 = str1.TrimEnd(cArr3);
        iCountTestcases++;
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_72as (Co3038TrimEnd_ChArr.)");
        }
        str1 = "ababbababbbababcababbabbabbaba";
        str2 = "ababbababbbababc";
        str3 = str1.TrimEnd(cArr4);
        iCountTestcases++;
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_438t (Co3038TrimEnd_ChArr.)");
        }
        str1 = "!!!!!!!!?((@#$?%*%@!!??";
        str2 = "!!!!!!!!?((";
        str3 = str1.TrimEnd(cArr5);
        iCountTestcases++;
        if (!(str3.Equals(str2)))
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_279j (CB3038TrimTail.)");
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #26
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int              iCountErrors    = 0;
        int              iCountTestcases = 0;
        IntlStrings      intl;
        String           strLoc = "Loc_000oo";
        StringDictionary sd;
        string           ind;

        string [] values =
        {
            "",
            " ",
            "a",
            "aa",
            "text",
            "     spaces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        string [] keys =
        {
            "zero",
            "one",
            " ",
            "",
            "aa",
            "1",
            System.DateTime.Today.ToString(),
            "$%^#",
            Int32.MaxValue.ToString(),
            "     spaces",
            "2222222222222222222222222"
        };
        int cnt = 0;

        try
        {
            intl = new IntlStrings();
            Console.WriteLine("--- create dictionary ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            sd = new StringDictionary();
            Console.WriteLine("1. Check for empty dictionary");
            for (int i = 0; i < values.Length; i++)
            {
                iCountTestcases++;
                if (sd.ContainsKey(keys[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0001_{0}, returned true for empty dictionary", i);
                }
            }
            Console.WriteLine("2. add simple strings and verify ContainsKey()");
            strLoc = "Loc_002oo";
            iCountTestcases++;
            cnt = values.Length;
            for (int i = 0; i < cnt; i++)
            {
                sd.Add(keys[i], values[i]);
            }
            if (sd.Count != cnt)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, cnt);
            }
            for (int i = 0; i < cnt; i++)
            {
                iCountTestcases++;
                if (!sd.ContainsValue(values[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}b, collection doesn't contain value \"{1}\"", i, values[i]);
                }
                iCountTestcases++;
                if (!sd.ContainsKey(keys[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}c, collection doesn't contain key \"{1}\"", i, keys[i]);
                }
            }
            Console.WriteLine("3. add intl strings and verify ContainsKey()");
            strLoc = "Loc_003oo";
            int       len        = values.Length;
            string [] intlValues = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            Boolean caseInsensitive = false;
            for (int i = 0; i < len * 2; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                {
                    caseInsensitive = true;
                }
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                cnt = sd.Count;
                sd.Add(intlValues[i + len], intlValues[i]);
                if (sd.Count != cnt + 1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}a, count is {1} instead of {2}", i, sd.Count, cnt + 1);
                }
                iCountTestcases++;
                if (!sd.ContainsValue(intlValues[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, collection doesn't contain value of new item", i);
                }
                iCountTestcases++;
                if (!sd.ContainsKey(intlValues[i + len]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}c, collection doesn't contain key of new item", i);
                }
                ind = intlValues[i + len];
                iCountTestcases++;
                if (String.Compare(sd[ind], intlValues[i], false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sd[ind], intlValues[i]);
                }
            }
            Console.WriteLine("4. add null string with non-null key and verify ContainsKey()");
            strLoc = "Loc_004oo";
            iCountTestcases++;
            cnt = sd.Count;
            string k = "keykey";
            sd.Add(k, null);
            if (sd.Count != cnt + 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0004a, count is {1} instead of {2}", sd.Count, cnt + 1);
            }
            iCountTestcases++;
            if (!sd.ContainsKey(k))
            {
                iCountErrors++;
                Console.WriteLine("Err_0004b, dictionary doesn't contain new key");
            }
            Console.WriteLine("5. Case sensitivity");
            strLoc = "Loc_005oo";
            iCountTestcases++;
            sd.Clear();
            if (sd.Count != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005, count is {1} instead of {2} after Clear()", sd.Count, 0);
            }
            string [] intlValuesLower = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                intlValues[i] = intlValues[i].ToUpper();
            }
            for (int i = 0; i < len * 2; i++)
            {
                intlValuesLower[i] = intlValues[i].ToLower();
            }
            sd.Clear();
            Console.WriteLine(" initial number of items: " + sd.Count);
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                cnt = sd.Count;
                sd.Add(intlValues[i + len], intlValues[i]);
                if (sd.Count != cnt + 1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}a, count is {1} instead of {2}", i, sd.Count, cnt + 1);
                }
                iCountTestcases++;
                if (!sd.ContainsValue(intlValues[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}b, collection doesn't contain value of new item", i);
                }
                iCountTestcases++;
                if (!sd.ContainsKey(intlValues[i + len]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}c, collection doesn't contain key of new item", i);
                }
                iCountTestcases++;
                if (!caseInsensitive && sd.ContainsValue(intlValuesLower[i]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}d, collection contains lowercase value of new item", i);
                }
                iCountTestcases++;
                if (!sd.ContainsKey(intlValuesLower[i + len]))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}e, collection doesn't contain lowercase key of new item", i);
                }
            }
            Console.WriteLine("6. ContainsKey (null) ");
            Console.WriteLine(" initial number of items: " + sd.Count);
            strLoc = "Loc_006oo";
            iCountTestcases++;
            try
            {
                sd.ContainsKey(null);
                iCountErrors++;
                Console.WriteLine("Err_0006a, no exception");
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine("  expected exception: " + ex.Message);
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0006b, unexpected exception: " + e.ToString());
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
    public virtual bool runTest()
    {
        Console.Out.WriteLine("String\\Co3042GetHashCode. runTest() started.");
        int         iCountErrors    = 0;
        int         iCountTestcases = 0;
        String      str1            = null;
        String      str2            = null;
        IntlStrings intl            = new IntlStrings();

        str1 = intl.GetString(12, false, true);
        str2 = str1;
        if (str1.GetHashCode() != str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_498o (Co3042GetHashCode.)");
        }
        iCountTestcases++;
        str1 = "sdfjlksjdfhsdf ;flks ;lldk fas";
        str2 = "sdfjlksjdfhsdf ;flks ;lldk fas";
        if (str1.GetHashCode() != str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_498o (Co3042GetHashCode.)");
        }
        iCountTestcases++;
        str1 = "4874378828457y34";
        str2 = "4874378828457y34";
        if (str1.GetHashCode() != str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_433r (Co3042GetHashCode.)");
        }
        iCountTestcases++;
        str1 = "#$%@#$%@*#_@_!__!_!($#%JWE(@JA)(*#@$";
        str2 = "#$%@#$%@*#_@_!__!_!($#%JWE(@JA)(*#@$";
        if (str1.GetHashCode() != str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_879u (Co3042GetHashCode.)");
        }
        iCountTestcases++;
        str1 = "\0";
        str2 = "\0";
        if (str1.GetHashCode() != str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_899q (Co3042GetHashCode.)");
        }
        str1 = "\n\n\n\n\n\n\n\r\r\r\r\t\t\t\t\tuuuu\t\t\t\t\r\r\r\n%%%%%%%%^heyhw";
        str2 = "\n\n\n\n\n\n\n\r\r\r\r\t\t\t\t\tuuuu\t\t\t\t\r\r\r\n%%%%%%%%^heyhw";
        iCountTestcases++;
        if (str1.GetHashCode() != str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_888q (Co3042GetHashCode.)");
        }
        str1 = "\n\n\n\n\r\r\r\rt";
        str2 = "\n\n\n\n\r\r\r\r\t";
        iCountTestcases++;
        if (str1.GetHashCode() == str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_999p (Co3042GetHashCode.)");
        }
        str1 = "t";
        str2 = "T";
        iCountTestcases++;
        if (str1.GetHashCode() == str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_999r (Co3042GetHashCode.)");
        }
        str1 = "\0";
        str2 = "0";
        iCountTestcases++;
        if (str1.GetHashCode() == str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_111q (Co3042GetHashCode.)");
        }
        str1 = "111111111111111111111111111111111111111111111111111111111111111";
        str2 = "111111111111111111111111111111111111111111111111111111111111112";
        iCountTestcases++;
        if (str1.GetHashCode() == str2.GetHashCode())
        {
            iCountErrors++;
            Console.Error.WriteLine("POINTTOBREAK: find E_666a (Co3042GetHashCode.)");
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public virtual bool runTest()
    {
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "123_er";
        String strInfo         = null;

        Console.Out.Write(strName);
        Console.Out.Write(": ");
        Console.Out.Write(strPath + strTest);
        Console.Out.WriteLine(" runTest started...");
        String str1 = "Dill Guv Dill Guv Dill";
        String str2 = null;

        try
        {
LABEL_860_GENERAL:
            do
            {
                IntlStrings intl = new IntlStrings();
                String      str5 = intl.GetString(8, true, true);
                String      str6 = intl.GetString(3, true, true);
                str6 = String.Concat(str5, str6);
                if (str6.StartsWith(str5) == false)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_208bt";
                    Console.WriteLine(strTest + strInfo);
                }
                ++iCountTestcases;
                str2 = "Dill ";
                if (str1.StartsWith(str2) == false)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_738ke";
                    Console.WriteLine(strTest + strInfo);
                }
                str2 = "DILL ";
                if (str1.StartsWith(str2) == true)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_532dh";
                    Console.WriteLine(strTest + strInfo);
                }
                str2 = " ";
                if (str1.StartsWith(str2) == true)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_053kd";
                    Console.WriteLine(strTest + strInfo);
                }
                strLoc = "E_620pf";
                str2   = String.Empty;
                if (str1.StartsWith(str2) == false)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_260is";
                    Console.WriteLine(strTest + strInfo);
                }
                str2 = null;
                try
                {
                    str1.StartsWith(str2);
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_304_jk";
                    strInfo += ", Exception not thrown";
                    Console.WriteLine(strTest + strInfo);
                }
                catch (ArgumentException ex)
                {
                }
                catch (Exception ex)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo  = "FAiL. E_278pw";
                    strInfo += ", Wrong Exception thrown == " + ex.ToString();
                    Console.WriteLine(strTest + strInfo);
                }
                str2 = " ";
                str1 = null;
                try
                {
                    str1.StartsWith(str2);
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_935ep ";
                    strInfo += ", Exception not thrown";
                    Console.WriteLine(strTest + strInfo);
                }
                catch (NullReferenceException ex)
                {
                }
                catch (Exception ex)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo  = "FAiL. E_267mo";
                    strInfo += ", Wrong Exception thrown == " + ex.ToString();
                    Console.WriteLine(strTest + strInfo);
                }
            } while (false);
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.Error.WriteLine("POINTTOBREAK: Error Err_103! strLoc==" + strLoc + " ,exc_general==" + exc_general);
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public virtual bool runTest()
    {
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "123_er";
        String strInfo         = null;

        Console.Out.Write(strName);
        Console.Out.Write(": ");
        Console.Out.Write(strPath + strTest);
        Console.Out.WriteLine(" runTest started...");
        String str1 = "Dill Guv Dill Guv Dill";
        Char   ch1  = '\0';

        try
        {
LABEL_860_GENERAL:
            do
            {
                IntlStrings intl       = new IntlStrings();
                String      swrString2 = intl.GetString(4, true, true);
                String      swrString3 = intl.GetString(1, true, true);
                String      swrString4 = String.Concat(swrString2, swrString3);
                swrString4 = String.Concat(swrString4, swrString2);
                swrString4 = String.Concat(swrString4, swrString3);
                swrString4 = String.Concat(swrString4, swrString2);
                int n2 = swrString4.LastIndexOf(swrString3[0]);
                if (n2 < 4)
                {
                    ++iCountErrors;
                }
                ch1 = 'G';
                ++iCountTestcases;
                if (str1.LastIndexOf(ch1) != 14)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_362gg";
                    Console.WriteLine(strTest + strInfo);
                }
                ch1 = 'g';
                if (str1.LastIndexOf(ch1) != -1)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_672pf";
                    Console.WriteLine(strTest + strInfo);
                }
                ch1 = 'X';
                if (str1.LastIndexOf(ch1) != -1)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_738ke";
                    Console.WriteLine(strTest + strInfo);
                }
                ch1 = '\0';
                if (str1.LastIndexOf(ch1) != -1)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_839pl ";
                    Console.WriteLine(strTest + strInfo);
                }
                str1 = null;
                ch1  = 'G';
                try
                {
                    str1.LastIndexOf(ch1);
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo += "FAiL. E_304_jk";
                    strInfo += ", Exception not thrown";
                    Console.WriteLine(strTest + strInfo);
                }
                catch (NullReferenceException ex)
                {
                }
                catch (Exception ex)
                {
                    ++iCountErrors;
                    strInfo  = strTest + " error: ";
                    strInfo  = "FAiL. E_278pw";
                    strInfo += ", Wrong Exception thrown == " + ex.ToString();
                    Console.WriteLine(strTest + strInfo);
                }
            } while (false);
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.Error.WriteLine("POINTTOBREAK: Error Err_103! strLoc==" + strLoc + " ,exc_general==" + exc_general);
        }
        if (iCountErrors == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #30
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int                 iCountErrors    = 0;
        int                 iCountTestcases = 0;
        IntlStrings         intl;
        String              strLoc = "Loc_000oo";
        NameValueCollection nvc;

        string [] vls;
        string [] values =
        {
            "",
            " ",
            "a",
            "aA",
            "text",
            "     SPaces",
            "1",
            "$%^#",
            "2222222222222222222222222",
            System.DateTime.Today.ToString(),
            Int32.MaxValue.ToString()
        };
        string [] keys =
        {
            "zero",
            "oNe",
            " ",
            "",
            "aa",
            "1",
            System.DateTime.Today.ToString(),
            "$%^#",
            Int32.MaxValue.ToString(),
            "     spaces",
            "2222222222222222222222222"
        };
        int cnt = 0;

        try
        {
            intl = new IntlStrings();
            Console.WriteLine("--- create collection ---");
            strLoc = "Loc_001oo";
            iCountTestcases++;
            nvc = new NameValueCollection();
            Console.WriteLine("1. GetValues() on empty collection");
            iCountTestcases++;
            Console.WriteLine("     - GetValues(null)");
            if (nvc.GetValues(null) != null)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001a, returned non-null");
            }
            Console.WriteLine("     - GetValues(some_string)");
            if (nvc.GetValues("some_string") != null)
            {
                iCountErrors++;
                Console.WriteLine("Err_0001b, returned non-null");
            }
            Console.WriteLine("2. add simple strings access them via GetValues(string)");
            strLoc = "Loc_002oo";
            iCountTestcases++;
            cnt = nvc.Count;
            int len = values.Length;
            for (int i = 0; i < len; i++)
            {
                nvc.Add(keys[i], values[i]);
            }
            if (nvc.Count != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0002a, count is {0} instead of {1}", nvc.Count, values.Length);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                vls = nvc.GetValues(keys[i]);
                if (vls.Length != 1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}b, returned number of strings {1} instead of 1", i, vls.Length);
                }
                iCountTestcases++;
                if (String.Compare(vls[0], values[i], false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}c, returned: \"{1}\", expected \"{2}\"", i, vls[0], values[i]);
                }
            }
            Console.WriteLine("3. add intl strings GetValues()");
            strLoc = "Loc_003oo";
            iCountTestcases++;
            string [] intlValues = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetString(MAX_LEN, true, true, true);
                while (Array.IndexOf(intlValues, val) != -1)
                {
                    val = intl.GetString(MAX_LEN, true, true, true);
                }
                intlValues[i] = val;
            }
            Boolean caseInsensitive = false;
            for (int i = 0; i < len * 2; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                {
                    caseInsensitive = true;
                }
            }
            iCountTestcases++;
            nvc.Clear();
            for (int i = 0; i < len; i++)
            {
                nvc.Add(intlValues[i + len], intlValues[i]);
            }
            if (nvc.Count != (len))
            {
                iCountErrors++;
                Console.WriteLine("Err_0003a, count is {0} instead of {1}", nvc.Count, len);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                vls = nvc.GetValues(intlValues[i + len]);
                if (vls.Length != 1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, returned number of strings {1} instead of 1", i, vls.Length);
                }
                iCountTestcases++;
                if (String.Compare(vls[0], intlValues[i], false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}c, returned \"{1}\" instead of \"{2}\"", i, vls[0], intlValues[i]);
                }
            }
            Console.WriteLine("4. case sensitivity");
            strLoc = "Loc_004oo";
            string [] intlValuesLower = new string [len * 2];
            for (int i = 0; i < len * 2; i++)
            {
                intlValues[i] = intlValues[i].ToUpper();
            }
            for (int i = 0; i < len * 2; i++)
            {
                intlValuesLower[i] = intlValues[i].ToLower();
            }
            nvc.Clear();
            for (int i = 0; i < len; i++)
            {
                nvc.Add(intlValues[i + len], intlValues[i]);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                vls = nvc.GetValues(intlValues[i + len]);
                if (vls.Length != 1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}a, returned number of strings {1} instead of 1", i, vls.Length);
                }
                iCountTestcases++;
                if (String.Compare(vls[0], intlValues[i], false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}b, returned \"{1}\" instead of \"{2}\"", i, vls[0], intlValues[i]);
                }
                iCountTestcases++;
                vls = nvc.GetValues(intlValuesLower[i + len]);
                if (vls.Length != 1)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}c, returned number of strings {1} instead of 1", i, vls.Length);
                }
                iCountTestcases++;
                if (String.Compare(vls[0], intlValues[i], false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}d, returned \"{1}\" instead of \"{2}\"", i, vls[0], intlValues[i]);
                }
                iCountTestcases++;
                if (!caseInsensitive && String.Compare(vls[0], intlValuesLower[i], false) == 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0004_{0}a, returned lowercase when added uppercase", i);
                }
            }
            Console.WriteLine("5. multiple items with same key and GetValues()");
            strLoc = "Loc_005oo";
            iCountTestcases++;
            nvc.Clear();
            len = values.Length;
            string k    = "keykey";
            string k1   = "hm1";
            string exp  = "";
            string exp1 = "";
            for (int i = 0; i < len; i++)
            {
                nvc.Add(k, "Value" + i);
                nvc.Add(k1, "iTem" + i);
                if (i < len - 1)
                {
                    exp  += "Value" + i + ",";
                    exp1 += "iTem" + i + ",";
                }
                else
                {
                    exp  += "Value" + i;
                    exp1 += "iTem" + i;
                }
            }
            if (nvc.Count != 2)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005a, count is {0} instead of {1}", nvc.Count, 2);
            }
            iCountTestcases++;
            vls = nvc.GetValues(k);
            if (vls.Length != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005b, returned number of strings {0} instead of {1}", vls.Length, len);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (String.Compare(vls[i], "Value" + i, false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}b, returned \"{1}\" instead of \"{2}\"", i, vls[i], "Value" + i);
                }
            }
            iCountTestcases++;
            vls = nvc.GetValues(k1);
            if (vls.Length != len)
            {
                iCountErrors++;
                Console.WriteLine("Err_0005c, returned number of strings {0} instead of {1}", vls.Length, len);
            }
            for (int i = 0; i < len; i++)
            {
                iCountTestcases++;
                if (String.Compare(vls[i], "iTem" + i, false) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0005_{0}d, returned \"{1}\" instead of \"{2}\"", i, vls[i], "iTem" + i);
                }
            }
            Console.WriteLine("6. GetValues(null) when there is item with null key");
            strLoc = "Loc_006oo";
            iCountTestcases++;
            cnt = nvc.Count;
            nvc.Add(null, "nullValue");
            iCountTestcases++;
            vls = nvc.GetValues(null);
            if (vls.Length != 1)
            {
                iCountErrors++;
                Console.WriteLine("Err_0006a, returned number of strings {0} instead of {1}", vls.Length, 1);
            }
            if (String.Compare(vls[0], "nullValue", false) != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_0006: returned \"{}\" instead of \"{}\"", vls[0], "nullValue");
            }
            Console.WriteLine("7. GetValues(null) when no such key");
            strLoc = "Loc_07oo";
            iCountTestcases++;
            nvc.Clear();
            for (int i = 0; i < len; i++)
            {
                nvc.Add(keys[i], values[i]);
            }
            try
            {
                vls = nvc.GetValues(null);
                if (vls != null)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0007a: returned non-null ");
                }
            }
            catch (Exception e)
            {
                iCountErrors++;
                Console.WriteLine("Err_0007b, unexpected exception: {0}", e.ToString());
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_general!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString());
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("Pass.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("Fail!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }