public static void TestCtor_CultureInfo_Compare(object a, object b, int expected)
        {
            var cultureNames = new string[]
            {
                "cs-CZ","da-DK","de-DE","el-GR","en-US",
                "es-ES","fi-FI","fr-FR","hu-HU","it-IT",
                "ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
                "pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
                "zh-CN","zh-HK","zh-TW"
            };

            foreach (string cultureName in cultureNames)
            {
                CultureInfo culture;
                try
                {
                    culture = new CultureInfo(cultureName);
                }
                catch (CultureNotFoundException)
                {
                    continue;
                }

                var comparer = new CaseInsensitiveComparer(culture);
                Assert.Equal(expected, Helpers.NormalizeCompare(comparer.Compare(a, b)));
            }
        }
Beispiel #2
0
 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
     String strLoc = "Loc_000oo";
     String strValue = String.Empty;
     int iCountErrors = 0;
     int iCountTestcases = 0;
     CaseInsensitiveComparer comparer;		
     try
     {
         strLoc = "Loc_384sdg";
         iCountTestcases++;
         comparer = new CaseInsensitiveComparer();
         if(comparer.Compare("hello", "HELLO")!=0)
         {
             iCountErrors++;
             Console.WriteLine( "Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "HELLO"));
         }
         if(comparer.Compare("hello", "hello")!=0)
         {
             iCountErrors++;
             Console.WriteLine( "Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "hello"));
         }
         if(comparer.Compare("hello", "mello")==0)
         {
             iCountErrors++;
             Console.WriteLine( "Err_3846tdfsg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "mello"));
         }
         iCountTestcases++;
         if(comparer.Compare(5, 5)!=0)
         {
             iCountErrors++;
             Console.WriteLine( "Err_347tsfg! wrong value returned");
         }
         if(comparer.Compare(5, 10)==0)
         {
             iCountErrors++;
             Console.WriteLine( "Err_973425sdg! wrong value returned");
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
         return true;
     }
     else
     {
         Console.WriteLine("FAiL! "+s_strTFName+" ,inCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
Beispiel #3
0
 public new bool Equals(object x, object y)
 {
     if (myComparer.Compare(x, y) == 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public int Compare(DuplicateItemViewModel x, DuplicateItemViewModel y)
 {
     if (x.GroupId == y.GroupId)
     {
         if (x.IsGroupHeader && y.IsGroupHeader)
         {
             return(0);
         }
         if (x.IsGroupHeader)
         {
             return(-1);
         }
         if (y.IsGroupHeader)
         {
             return(1);
         }
         return(caseiComp.Compare(x.Path, y.Path));
     }
     return(caseiComp.Compare(x.GroupId, y.GroupId));
 }
Beispiel #5
0
        /**************************************************************************/

        public int Compare(object x, object y)
        {
            int          compareResult;
            int          returncompareResult = 0;
            ListViewItem listviewX, listviewY;

            object [] ObjectPair;
            string    ColumnName;

            listviewX = ( ListViewItem )x;
            listviewY = ( ListViewItem )y;

            if (
                (this.ColumnToSort > listviewX.SubItems.Count) ||
                (this.ColumnToSort > listviewY.SubItems.Count))
            {
                return(returncompareResult);
            }

            ColumnName = listviewX.ListView.Columns[this.ColumnToSort].Text;

            if (Regex.IsMatch(ColumnName, @"\s+Date"))
            {
                ObjectPair = DetermineValueTypeDate(
                    listviewX.SubItems[this.ColumnToSort].Text,
                    listviewY.SubItems[this.ColumnToSort].Text
                    );
            }
            else
            {
                ObjectPair = DetermineValueType(
                    listviewX.SubItems[this.ColumnToSort].Text,
                    listviewY.SubItems[this.ColumnToSort].Text
                    );
            }

            compareResult = ObjectCompare.Compare(ObjectPair[0], ObjectPair[1]);

            if (this.OrderOfSort == SortOrder.Ascending)
            {
                returncompareResult = compareResult;
            }
            else
            if (this.OrderOfSort == SortOrder.Descending)
            {
                returncompareResult = -compareResult;
            }
            else
            {
                returncompareResult = 0;
            }

            return(returncompareResult);
        }
Beispiel #6
0
        public int Compare(string x, string y)
        {
            // Parse the extension from the file name.
            xExt = x.Substring(x.LastIndexOf(".") + 1);
            yExt = y.Substring(y.LastIndexOf(".") + 1);

            // Compare the file extensions.
            int vExt = caseiComp.Compare(xExt, yExt);

            if (vExt != 0)
            {
                return(vExt);
            }
            else
            {
                // The extension is the same,
                // so compare the filenames.
                return(caseiComp.Compare(x, y));
            }
        }
Beispiel #7
0
        // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
        int IComparer <IRecord> .Compare(IRecord x, IRecord y)
        {
            widget r1 = x as widget;
            widget r2 = y as widget;

            // record 1 pos

            int r1_x;
            int r1_y;

            if (r1.buttonPos.Size == 0)
            {
                r1_x = slotX;
            }
            else
            {
                r1_x = r1.buttonPos[0];
            }

            if (r1.buttonPos.Size < 2)
            {
                r1_y = slotY;
            }
            else
            {
                r1_y = r1.buttonPos[1];
            }

            // record 2 pos

            int r2_x;
            int r2_y;

            if (r2.buttonPos.Size == 0)
            {
                r2_x = slotX;
            }
            else
            {
                r2_x = r2.buttonPos[0];
            }

            if (r2.buttonPos.Size < 2)
            {
                r2_y = slotY;
            }
            else
            {
                r2_y = r2.buttonPos[1];
            }

            return(cic.Compare(get_slot(r1_x, r1_y),
                               get_slot(r1_x, r1_y)));
        }
Beispiel #8
0
    // This method is inherited from the IComparer interface.
    // It compares the two objects passed using a case
    // insensitive comparison.
    //
    // x: First object to be compared
    // y: Second object to be compared
    //
    // The result of the comparison. "0" if equal,
    // negative if 'x' is less than 'y' and
    // positive if 'x' is greater than 'y'
    public int Compare(object x, object y)
    {
        int          compareResult;
        ListViewItem listviewX, listviewY;

        // Cast the objects to be compared to ListViewItem objects
        listviewX = (ListViewItem)x;
        listviewY = (ListViewItem)y;
        // Determine whether the type being compared is a date type.
        try
        {
            // Parse the two objects passed as a parameter as a DateTime.
            DateTime firstDate  = DateTime.Parse(listviewX.SubItems[ColumnToSort].Text);
            DateTime secondDate = DateTime.Parse(listviewY.SubItems[ColumnToSort].Text);
            // Compare the two dates.
            compareResult = DateTime.Compare(firstDate, secondDate);
        }
        // If neither compared object has a valid date format,
        // perform a Case Insensitive Sort
        catch
        {
            try
            {
                int num1 = int.Parse(listviewX.SubItems[ColumnToSort].Text);
                int num2 = int.Parse(listviewY.SubItems[ColumnToSort].Text);
                // Compare the two dates.
                compareResult = num1.CompareTo(num2);
            }
            catch
            {
                // Case Insensitive Compare
                compareResult = ObjectCompare.Compare(
                    listviewX.SubItems[ColumnToSort].Text,
                    listviewY.SubItems[ColumnToSort].Text
                    );
            }
        }
        // Calculate correct return value based on object comparison
        if (OrderOfSort == SortOrder.Ascending)
        {
            // Ascending sort is selected, return normal result of compare operation
            return(compareResult);
        }
        else if (OrderOfSort == SortOrder.Descending)
        {
            // Descending sort is selected, return negative result of compare operation
            return(-compareResult);
        }
        else
        {
            // Return '0' to indicate they are equal
            return(0);
        }
    }
Beispiel #9
0
    /// <summary>
    /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
    /// </summary>
    /// <param name="x">First object to be compared</param>
    /// <param name="y">Second object to be compared</param>
    /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
    public int Compare(object x, object y)
    {
        int compareResult;

        // if sorting is suspended, return 0 on the compares
        if (SuspendSort)
        {
            return(0);
        }

        // Cast the objects to be compared to ListViewItem objects
        string stringX = ((ListViewItem)x).SubItems[ColumnToSort].Text;
        string stringY = ((ListViewItem)y).SubItems[ColumnToSort].Text;

        // Compare the two items either by number or text
        if (stringX.Replace(".", "").All(char.IsDigit) && stringY.Replace(".", "").All(char.IsDigit))
        {
            compareResult = ObjectCompare.Compare(extendChannelSubchannel(stringX), extendChannelSubchannel(stringY));
        }
        else
        {
            compareResult = ObjectCompare.Compare(stringX, stringY);
        }

        // Calculate correct return value based on object comparison
        if (OrderOfSort == SortOrder.Ascending)
        {
            // Ascending sort is selected, return normal result of compare operation
            return(compareResult);
        }
        else if (OrderOfSort == SortOrder.Descending)
        {
            // Descending sort is selected, return negative result of compare operation
            return(-compareResult);
        }
        else
        {
            // Return '0' to indicate they are equal
            return(0);
        }
    }
Beispiel #10
0
        public int Compare(object x, object y)
        {
            int          compareResult;
            ListViewItem listviewX, listviewY;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;
            int tempCount  = -1;
            int tempCount2 = -1;

            Int32.TryParse(listviewX.SubItems[SortColumn].Text, out tempCount);
            Int32.TryParse(listviewY.SubItems[SortColumn].Text, out tempCount2);
            if (tempCount > 0)
            {
                if (tempCount2 > -1)//в столбце числа а не строки, их надо в int перевести чтобы сортировка не по первой букве цифры была
                {
                    compareResult = ObjectCompare.Compare(Convert.ToInt32(listviewX.SubItems[SortColumn].Text), Convert.ToInt32(listviewY.SubItems[SortColumn].Text));
                }
                else
                {
                    compareResult = ObjectCompare.Compare(listviewX.SubItems[SortColumn].Text, listviewY.SubItems[SortColumn].Text);
                }
            }
            else
            {
                compareResult = ObjectCompare.Compare(listviewX.SubItems[SortColumn].Text, listviewY.SubItems[SortColumn].Text);
            }
            if (Order == SortOrder.Ascending) // Calculate correct return value based on object comparison
            {
                return(compareResult);        // Ascending sort is selected, return normal result of compare operation
            }
            else if (Order == SortOrder.Descending)
            {
                return(-compareResult);// Descending sort is selected, return negative result of compare operation
            }
            else
            {
                return(0);// Return '0' to indicate they are equal
            }
        }
Beispiel #11
0
        // The comparison function - the raison d'etre of this class
        public int Compare(object x, object y)
        {
            string sx = x.ToString();
            string sy = y.ToString();

            char[] acx = sx.ToCharArray();
            char[] acy = sy.ToCharArray();

            int l = sx.Length;

            if (sy.Length < l)
            {
                l = sy.Length;
            }

            // Ensure No Surname people go at top of list
            if (acx[0] == ',' && acy[0] != ',')
            {
                return(-1);
            }
            if (acx[0] != ',' && acy[0] == ',')
            {
                return(1);
            }

            for (int i = 0; i < l; ++i)
            {
                int ix = Alphabet.IndexOf(Char.ToUpper(acx[i]));
                int iy = Alphabet.IndexOf(Char.ToUpper(acy[i]));
                if (iy == -1 || ix == -1)
                {
                    return(fComparer.Compare(x, y));
                }
                if (ix < iy)
                {
                    return(-1);
                }
                if (ix > iy)
                {
                    return(1);
                }
            }

            if (sx.Length == sy.Length)
            {
                return(0);
            }
            if (sx.Length < sy.Length)
            {
                return(-1);
            }
            return(1);
        }
Beispiel #12
0
            int IComparer.Compare(Object x, Object y)
            {
                int[] xArray = (int[])x;
                int[] yArray = (int[])y;

                var myComp = new CaseInsensitiveComparer();

                // X first -> Ascending, y first -> Descending
                var toReturn = myComp.Compare(xArray.Sum(), yArray.Sum());

                return(toReturn);
            }
Beispiel #13
0
            public int Compare(object x, object y)
            {
                int          compareResult;
                ListViewItem listviewX, listviewY;
                int          useColumn = ColumnToSort;

                // Switch to Raw column if using the Time column
                if (useColumn == 1)
                {
                    useColumn = 3;
                }

                listviewX = (ListViewItem)x;
                listviewY = (ListViewItem)y;

                if (useColumn == 0 || useColumn == 4)
                {
                    compareResult = ObjectCompare.Compare(listviewX.SubItems[useColumn].Text, listviewY.SubItems[useColumn].Text);
                }
                else
                {
                    Int64 v1, v2;
                    v1 = Int64.Parse(listviewX.SubItems[useColumn].Text);
                    v2 = Int64.Parse(listviewY.SubItems[useColumn].Text);

                    if (v1 < v2)
                    {
                        compareResult = -1;
                    }
                    else
                    if (v1 > v2)
                    {
                        compareResult = 1;
                    }
                    else
                    {
                        compareResult = 0;
                    }
                }

                if (OrderOfSort == SortOrder.Ascending)
                {
                    return(compareResult);
                }
                else if (OrderOfSort == SortOrder.Descending)
                {
                    return(-compareResult);
                }
                else
                {
                    return(0);
                }
            }
Beispiel #14
0
    /// <summary>
    /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
    /// </summary>
    /// <param name="x">First object to be compared</param>
    /// <param name="y">Second object to be compared</param>
    /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
    public int Compare(object x, object y)
    {
        int          compareResult;
        ListViewItem listviewX, listviewY;
        string       textX, textY;

        // Cast the objects to be compared to ListViewItem objects
        listviewX = (ListViewItem)x;
        listviewY = (ListViewItem)y;

        textX = listviewX.SubItems[ColumnToSort].Text.Replace(" Hz", "").Replace(" KB", "");
        textY = listviewY.SubItems[ColumnToSort].Text.Replace(" Hz", "").Replace(" KB", "");

        // Compare the two items
        if ((IVAUDToolBox.Utils.isNumeric(textX)) && (IVAUDToolBox.Utils.isNumeric(textY)))
        {
            compareResult = ObjectCompare.Compare(System.Convert.ToInt32(textX), System.Convert.ToInt32(textY));
        }
        else
        {
            compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
        }

        // Calculate correct return value based on object comparison
        if (OrderOfSort == SortOrder.Ascending)
        {
            // Ascending sort is selected, return normal result of compare operation
            return(compareResult);
        }
        else if (OrderOfSort == SortOrder.Descending)
        {
            // Descending sort is selected, return negative result of compare operation
            return(-compareResult);
        }
        else
        {
            // Return '0' to indicate they are equal
            return(0);
        }
    }
        /// <summary>
        /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
        /// </summary>
        /// <param name="x">First object to be compared</param>
        /// <param name="y">Second object to be compared</param>
        /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
        public int Compare(object x, object y)
        {
            int          compareResult;
            ListViewItem listviewX, listviewY;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;

            // Compare the two items

            //Hardcoded to sort certain columns as text and some as numerical

            if (TextSort)
            {
                compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
            }
            else
            {
                compareResult = ObjectCompare.Compare(float.Parse(listviewX.SubItems[ColumnToSort].Text, CultureInfo.CurrentCulture), float.Parse(listviewY.SubItems[ColumnToSort].Text, CultureInfo.CurrentCulture));
            }


            // Calculate correct return value based on object comparison
            if (OrderOfSort == SortOrder.Ascending)
            {
                // Ascending sort is selected, return normal result of compare operation
                return(compareResult);
            }
            else if (OrderOfSort == SortOrder.Descending)
            {
                // Descending sort is selected, return negative result of compare operation
                return(-compareResult);
            }
            else
            {
                // Return '0' to indicate they are equal
                return(0);
            }
        }
    /// <summary>
    /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
    /// </summary>
    /// <param name="x">First object to be compared</param>
    /// <param name="y">Second object to be compared</param>
    /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
    public int Compare(object x, object y)
    {
        int          compareResult;
        ListViewItem listviewX, listviewY;

        // Cast the objects to be compared to ListViewItem objects
        listviewX = (ListViewItem)x;
        listviewY = (ListViewItem)y;

        // Compare the two items
        if (ColumnToSort == 0) /* Index */
        {
            compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text.PadLeft(10, '0'), listviewY.SubItems[ColumnToSort].Text.PadLeft(10, '0'));
        }
        else if (ColumnToSort == 2 || ColumnToSort == 3 || ColumnToSort == 4 || ColumnToSort == 5)
        {
            compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Tag, listviewY.SubItems[ColumnToSort].Tag);
        }
        else
        {
            compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
        }

        // Calculate correct return value based on object comparison
        if (OrderOfSort == SortOrder.Ascending)
        {
            // Ascending sort is selected, return normal result of compare operation
            return(compareResult);
        }
        else if (OrderOfSort == SortOrder.Descending)
        {
            // Descending sort is selected, return negative result of compare operation
            return(-compareResult);
        }
        else
        {
            // Return '0' to indicate they are equal
            return(0);
        }
    }
Beispiel #17
0
        [Category("NotWorking")]          // bug #80076
        public void Default()
        {
            CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;

            try {
                Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");

                // CaseInsensitiveComparer.Default is initialized using
                // Thread.CurrentCulture
                CaseInsensitiveComparer cic = CaseInsensitiveComparer.Default;
                Assert.AreEqual(-1, cic.Compare("I", "i"), "#A1");
                Assert.AreEqual(0, cic.Compare("A", "a"), "#A2");

                // changing the current culture does not affect an already
                // initialized CaseInsensitiveComparer
                Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-BE");
                Assert.AreEqual(-1, cic.Compare("I", "i"), "#B1");
                Assert.AreEqual(0, cic.Compare("A", "a"), "#B2");

                // but it does affect new instances
                cic = CaseInsensitiveComparer.Default;
                Assert.AreEqual(0, cic.Compare("I", "i"), "#C1");
                Assert.AreEqual(0, cic.Compare("A", "a"), "#C2");
            } finally {
                // restore original culture
                Thread.CurrentThread.CurrentCulture = originalCulture;
            }
        }
Beispiel #18
0
        /// <summary>
        /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
        /// </summary>
        /// <param name="x">First object to be compared</param>
        /// <param name="y">Second object to be compared</param>
        /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
        public int Compare(object x, object y)
        {
            int          compareResult;
            ListViewItem listviewX, listviewY;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;

            // Compare the two items
            if (ColumnToSort == 0)
            {
                compareResult = ObjectCompare.Compare(int.Parse(listviewX.SubItems[ColumnToSort].Text), int.Parse(listviewY.SubItems[ColumnToSort].Text));
            }
            else if (ColumnToSort >= 4)
            {
                compareResult = ObjectCompare.Compare(int.Parse(listviewX.SubItems[ColumnToSort].Text.Substring(2), Globalization.NumberStyles.HexNumber), int.Parse(listviewY.SubItems[ColumnToSort].Text.Substring(2), Globalization.NumberStyles.HexNumber));
            }
            else
            {
                compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
            }

            // Calculate correct return value based on object comparison
            if (OrderOfSort == SortOrder.Ascending)
            {
                // Ascending sort is selected, return normal result of compare operation
                return(compareResult);
            }
            else if (OrderOfSort == SortOrder.Descending)
            {
                // Descending sort is selected, return negative result of compare operation
                return(-compareResult);
            }
            else
            {
                // Return '0' to indicate they are equal
                return(0);
            }
        }
        /// <summary>
        /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
        /// </summary>
        /// <param name="x">First object to be compared</param>
        /// <param name="y">Second object to be compared</param>
        /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
        public int Compare(object x, object y)
        {
            int          compareResult;
            ListViewItem listviewX, listviewY;
            DateTime     xDate;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;

            if (DateTime.TryParse(listviewX.SubItems[ColumnToSort].Text, out xDate))
            {
                DateTime yDate;

                DateTime.TryParse(listviewY.SubItems[ColumnToSort].Text, out yDate);
                compareResult = ObjectCompare.Compare(xDate, yDate);
            }
            else
            {
                // Compare the two items
                compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
            }

            // Calculate correct return value based on object comparison
            if (OrderOfSort == SortOrder.Ascending)
            {
                // Ascending sort is selected, return normal result of compare operation
                return(compareResult);
            }
            else if (OrderOfSort == SortOrder.Descending)
            {
                // Descending sort is selected, return negative result of compare operation
                return(-compareResult);
            }
            else
            {
                // Return '0' to indicate they are equal
                return(0);
            }
        }
Beispiel #20
0
        /// <summary>
        /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
        /// </summary>
        /// <param name="x">First object to be compared</param>
        /// <param name="y">Second object to be compared</param>
        /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
        public int Compare(object x, object y)
        {
            int          compareResult;
            ListViewItem listviewX, listviewY;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;

            if (decimal.TryParse(listviewX.SubItems[SortColumn].Text, out decimal dx) && decimal.TryParse(listviewY.SubItems[SortColumn].Text, out decimal dy))
            {
                //compare the 2 items as doubles
                compareResult = decimal.Compare(dx, dy);
            }
            else if (DateTime.TryParse(listviewX.SubItems[SortColumn].Text, out DateTime dtx) && DateTime.TryParse(listviewY.SubItems[SortColumn].Text, out DateTime dty))
            {
                //compare the 2 items as doubles
                compareResult = DateTime.Compare(dtx, dty);
            }
            // When one is a number and the other not, return -1 to have the numbers on top (or bottom)
            else if (decimal.TryParse(listviewX.SubItems[SortColumn].Text, out dx))
            {
                compareResult = -1;
            }
            // When one is a number and the other not, return 1 to have the numbers on top (or bottom)
            else if (decimal.TryParse(listviewY.SubItems[SortColumn].Text, out dy))
            {
                compareResult = 1;
            }
            else
            {
                // Compare the two items
                compareResult = ObjectCompare.Compare(listviewX.SubItems[SortColumn].Text, listviewY.SubItems[SortColumn].Text);
            }

            // Calculate correct return value based on object comparison
            if (Order == SortOrder.Ascending)
            {
                // Ascending sort is selected, return normal result of compare operation
                return(compareResult);
            }
            else if (Order == SortOrder.Descending)
            {
                // Descending sort is selected, return negative result of compare operation
                return(-compareResult);
            }
            else
            {
                // Return '0' to indicate they are equal
                return(0);
            }
        }
        public int Compare(object x, object y)
        {
            int          compareResults;
            double       dx, dy;
            ListViewItem listviewX, listviewY;

            listviewX = ( ListViewItem )x;
            listviewY = ( ListViewItem )y;

            if (IsAlphaNumeric && (compareResults = Helper.AlphaNumericSort(listviewX.SubItems [ColumnToSort].Text, listviewY.SubItems [ColumnToSort].Text)) != 0)
            {
                ;
            }
            else if (double.TryParse(listviewX.SubItems [ColumnToSort].Text, out dx) && double.TryParse(listviewY.SubItems [ColumnToSort].Text, out dy))
            {
                compareResults = ObjectCompare.Compare(dx, dy);
            }
            else if (Helper.ParseHMS(listviewX.SubItems [ColumnToSort].Text, out dx) && Helper.ParseHMS(listviewY.SubItems [ColumnToSort].Text, out dy))
            {
                compareResults = ObjectCompare.Compare(dx, dy);
            }
            else
            {
                compareResults = ObjectCompare.Compare(listviewX.SubItems [ColumnToSort].Text, listviewY.SubItems [ColumnToSort].Text);
            }

            if (OrderOfSort == SortOrder.Ascending)
            {
                return(compareResults);
            }
            else if (OrderOfSort == SortOrder.Descending)
            {
                return(-compareResults);
            }
            else
            {
                return(0);
            }
        }
Beispiel #22
0
        /// <summary>
        /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
        /// </summary>
        /// <param name="x">First object to be compared</param>
        /// <param name="y">Second object to be compared</param>
        /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
        public int Compare(object x, object y)
        {
            int          compareResult;
            ListViewItem listviewX, listviewY;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;
            // Compare the two items
            string s1 = listviewX.SubItems[ColumnToSort].Text;
            string s2 = listviewY.SubItems[ColumnToSort].Text;
            // check for a numeric column
            decimal n1, n2 = 0;

            if (Decimal.TryParse(s1, out n1) && Decimal.TryParse(s2, out n2))
            {
                compareResult = ObjectCompare.Compare(n1, n2);
            }
            else
            {
                compareResult = ObjectCompare.Compare(s1, s2);
            }
            // Calculate correct return value based on object comparison
            if (OrderOfSort == SortOrder.Ascending)
            {
                // Ascending sort is selected, return normal result of compare operation
                return(compareResult);
            }
            else if (OrderOfSort == SortOrder.Descending)
            {
                // Descending sort is selected, return negative result of compare operation
                return(-compareResult);
            }
            else
            {
                // Return '0' to indicate they are equal
                return(0);
            }
        }
Beispiel #23
0
        public ArchivedFile Search(string fileName)
        {
            CaseInsensitiveComparer caseInsensitiveComparer = CaseInsensitiveComparer.Default;

            for (int i = 0; i < m_Files.Length; i++)
            {
                if (caseInsensitiveComparer.Compare(m_Files[i].FileName, fileName) == 0)
                {
                    return(m_Files[i]);
                }
            }
            return(null);
        }
Beispiel #24
0
 private int CompareString(ListViewItem lviX, ListViewItem lviY)
 {
     try
     {
         int compareResult = objectCompare.Compare(lviX.SubItems[SortColumn].Text, lviY.SubItems[SortColumn].Text);
         return(compareResult);
     }
     catch (IndexOutOfRangeException ex)
     {
         Console.WriteLine(ex.Message);
         return(0);
     }
 }
Beispiel #25
0
        /// <summary>
        /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
        /// </summary>
        /// <param name="x">First object to be compared</param>
        /// <param name="y">Second object to be compared</param>
        /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
        public static int Compare(object x, object y, int sortColumn, SortOrder sortOrder)
        {
            ListViewItem listviewX, listviewY;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;

            string s1 = listviewX.SubItems[sortColumn].Text;
            string s2 = listviewY.SubItems[sortColumn].Text;

            int number;

            if (int.TryParse(s1, out number))
            {
                s1 = number.ToString("D10");
            }
            if (int.TryParse(s2, out number))
            {
                s2 = number.ToString("D10");
            }

            // Calculate correct return value based on object comparison
            if (sortOrder == SortOrder.Ascending)
            {
                // Ascending sort is selected, return normal result of compare operation
                return(ObjectCompare.Compare(s1, s2));
            }
            else if (sortOrder == SortOrder.Descending)
            {
                // Descending sort is selected, return negative result of compare operation
                return(-ObjectCompare.Compare(s1, s2));
            }
            else
            {
                // Return '0' to indicate they are equal
                return(0);
            }
        }
Beispiel #26
0
        public int Compare(object x, object y)
        {
            int compareResult;

            // Cast the objects to be compared to ListViewItem objects
            ListViewItem listviewX = (ListViewItem)x;
            ListViewItem listviewY = (ListViewItem)y;

            // Compare the two items
            string strX = listviewX.SubItems[_intColumnToSort].Text;
            string strY = listviewY.SubItems[_intColumnToSort].Text;

            if (_intColumnToSort == 0)
            {
                compareResult = DateTime.Compare(DateTime.Parse(strX), DateTime.Parse(strY));
            }
            else if (_intColumnToSort == 1)
            {
                compareResult = _objObjectCompare.Compare(Convert.ToInt32(strX.FastEscape(chrCurrencyTrim)), Convert.ToInt32(strY.FastEscape(chrCurrencyTrim)));
            }
            else
            {
                compareResult = _objObjectCompare.Compare(strX, strY);
            }

            // Calculate correct return value based on object comparison
            if (_objOrderOfSort == SortOrder.Ascending)
            {
                return(compareResult);
            }
            else if (_objOrderOfSort == SortOrder.Descending)
            {
                return(-compareResult);
            }
            else
            {
                return(0);
            }
        }
Beispiel #27
0
        public int Compare(string x, string y)
        {
            int i = cic.Compare(x, y);

            if (i == 0)
            {
                return(String.CompareOrdinal(x, y));
            }
            else
            {
                return(i);
            }
        }
Beispiel #28
0
        public int Compare(object a, object b)
        {
            int compareResult;
            //Convert the objects into listview items
            ListViewItem lviewItemA, lviewItemB;

            lviewItemA = (ListViewItem)a;
            lviewItemB = (ListViewItem)b;

            int numberA = 0, numberB = 0;

            //Check if both items are numbers
            if (int.TryParse(lviewItemA.SubItems[ColumnToSort].Text, out numberA) && int.TryParse(lviewItemB.SubItems[ColumnToSort].Text, out numberB))
            {
                //MessageBox.Show(numberA + " - " + numberB);
                if (numberA < numberB)
                {
                    compareResult = -1;
                }
                else if (numberA > numberB)
                {
                    compareResult = 1;
                }
                else
                {
                    compareResult = 0;
                }
            }
            //Else compare like they are strings
            else
            {
                //Now compare the items and get the integer result
                compareResult = ItemComparer.Compare(lviewItemA.SubItems[ColumnToSort].Text, lviewItemB.SubItems[ColumnToSort].Text);
            }
            //Now determine how the order mode affects the return result
            //Ascending - normal output
            if (SortMode == SortOrder.Ascending)
            {
                return(compareResult);
            }
            //Descending - flip output
            else if (SortMode == SortOrder.Descending)
            {
                return(-compareResult);
            }
            //None - return 0  which means equals - maintain order
            else
            {
                return(0);
            }
        }
Beispiel #29
0
            public int Compare(object x, object y)
            {
                if (_orderOfSort == SortOrder.None)
                {
                    return(0);
                }

                ListViewItem listviewX = (ListViewItem)x;
                ListViewItem listviewY = (ListViewItem)y;

                if (_columnPropertyMethod == null)
                {
                    PropertyInfo propInfo = listviewX.Tag.GetType().GetProperty(_bindings[_columnToSort]);
                    if (propInfo != null)
                    {
                        _columnPropertyMethod = propInfo.GetGetMethod();

                        _columnType = null;
                        if (_columnPropertyMethod != null)
                        {
                            _columnType = _columnPropertyMethod.ReturnType;
                        }
                    }
                }

                int compareResult;

                if (_columnType == typeof(DateTime))
                {
                    object dataX = GetData(listviewX);
                    object dataY = GetData(listviewY);
                    compareResult = ((DateTime)dataX).CompareTo(dataY);
                }
                else
                {
                    compareResult = _objectCompare.Compare(listviewX.SubItems[_columnToSort].Text, listviewY.SubItems[_columnToSort].Text);
                }

                if (_orderOfSort == SortOrder.Ascending)
                {
                    return(compareResult);
                }
                else if (_orderOfSort == SortOrder.Descending)
                {
                    return(-compareResult);
                }
                else
                {
                    return(0);
                }
            }
Beispiel #30
0
        /// <summary>
        /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
        /// </summary>
        /// <param name="x">First object to be compared</param>
        /// <param name="y">Second object to be compared</param>
        /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
        public int Compare(object x, object y)
        {
            int          compareResult;
            ListViewItem listviewX, listviewY;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;

            // Compare the two items
            string itemX;

            try
            {
                itemX = listviewX.SubItems[ColumnToSort].Text;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                itemX = " ";
            }
            string itemY;

            try
            {
                itemY = listviewY.SubItems[ColumnToSort].Text;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                itemY = " ";
            }
            compareResult = ObjectCompare.Compare(itemX, itemY);

            // Calculate correct return value based on object comparison
            if (OrderOfSort == SortOrder.Ascending)
            {
                // Ascending sort is selected, return normal result of compare operation
                return(compareResult);
            }
            else if (OrderOfSort == SortOrder.Descending)
            {
                // Descending sort is selected, return negative result of compare operation
                return(-compareResult);
            }
            else
            {
                // Return '0' to indicate they are equal
                return(0);
            }
        }
Beispiel #31
0
        public virtual int Compare(object x, object y)
        {
            try {
                bool   alreadyCompared = false;
                int    compareResult   = 0;
                string listViewVal_X   = (x as ListViewItem).SubItems[this.sortColumn].Text,
                       listViewVal_Y   = (y as ListViewItem).SubItems[this.sortColumn].Text;


                for (int i = 0; i < _intSorts.Length; i++)
                {
                    if (_intSorts[i] == sortColumn)
                    {
                        alreadyCompared = true;
                        int i1 = this.parseIntValue(listViewVal_X),
                            i2 = this.parseIntValue(listViewVal_Y);

                        compareResult = i1.CompareTo(i2);
                        break;
                    }
                }

                if (!alreadyCompared)
                {
                    DateTime dt1, dt2;
                    if (DateTime.TryParse(listViewVal_X, out dt1) && DateTime.TryParse(listViewVal_Y, out dt2))
                    {
                        compareResult = DateTime.Compare(dt1, dt2);
                    }
                    else
                    {
                        compareResult = ObjectCompare.Compare(listViewVal_X, listViewVal_Y);
                    }
                }

                if (sortOrder == SortOrder.Ascending)
                {
                    return(compareResult);
                }
                else if (sortOrder == SortOrder.Descending)
                {
                    return(-compareResult);
                }
                else
                {
                    return(0);
                }
            } catch (Exception) {
                return(0);
            }
        }
Beispiel #32
0
        /// <summary>
        /// This method is inherited from the IComparer interface.  It compares the two objects passed using a case insensitive comparison.
        /// </summary>
        /// <param name="x">First object to be compared</param>
        /// <param name="y">Second object to be compared</param>
        /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
        public int Compare(object x, object y)
        {
            int          compareResult;
            ListViewItem listviewX, listviewY;

            // Cast the objects to be compared to ListViewItem objects
            listviewX = (ListViewItem)x;
            listviewY = (ListViewItem)y;

            // Compare the two items
            if (ColumnType == null)
            {
                compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
            }
            else
            {
                compareResult = ObjectCompare.Compare(
                    System.Convert.ChangeType(listviewX.SubItems[ColumnToSort].Text, ColumnType),
                    System.Convert.ChangeType(listviewY.SubItems[ColumnToSort].Text, ColumnType));
            }

            // Calculate correct return value based on object comparison
            if (OrderOfSort == SortOrder.Ascending)
            {
                // Ascending sort is selected, return normal result of compare operation
                return(compareResult);
            }
            else if (OrderOfSort == SortOrder.Descending)
            {
                // Descending sort is selected, return negative result of compare operation
                return(-compareResult);
            }
            else
            {
                // Return '0' to indicate they are equal
                return(0);
            }
        }
    public bool runTest()
    {
        //////////// Global Variables used for all tests
        int iCountErrors = 0;
        int iCountTestcases = 0;

        CaseInsensitiveComparer comparer;

        try
        {
            /////////////////////////  START TESTS ////////////////////////////
            ///////////////////////////////////////////////////////////////////

            //[]vanilla - the ctor simply sets the CompareInfo to the current culture - CultureInfo.CurrentCulture.CompareInfo
            //There is no easy way to test this other than make sure that string comparison is case insensitive

            iCountTestcases++;
            iCountTestcases++;
            iCountTestcases++;

            var somePopularCultureNames = new string[] {
                        "cs-CZ","da-DK","de-DE","el-GR","en-US",
                        "es-ES","fi-FI","fr-FR","hu-HU","it-IT",
                        "ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
                        "pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
                        "zh-CN","zh-HK","zh-TW" };
            foreach (string cultureName in somePopularCultureNames)
            {
                CultureInfo culture = new CultureInfo(cultureName);
                if (culture == null)
                {
                    continue;
                }
                comparer = new CaseInsensitiveComparer(culture);

                if (comparer.Compare("hello", "HELLO") != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>, Culture: {2}", 0, comparer.Compare("hello", "HELLO"), culture.Name);
                }

                //same strings should work ok
                if (comparer.Compare("hello", "hello") != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>, Culture: {2}", 0, comparer.Compare("hello", "hello"), culture.Name);
                }

                //different strings should return false
                if (comparer.Compare("hello", "mello") == 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_3846tdfsg! wrong value returned. Expected - <{0}>, Returned - <{1}>, Culture: {2}", "non-zero", comparer.Compare("hello", "mello"), culture.Name);
                }

                // "tr-TR" = "Turkish (Turkey)"
                // Turkish has lower-case and upper-case version of the dotted "i", so the upper case of "i" (U+0069) isn't "I" (U+0049), but rather "İ" (U+0130).
                if (culture.Name != "tr-TR")
                {
                    if (comparer.Compare("file", "FILE") != 0)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_3846tdfsg! wrong value returned. Expected - <{0}>, Returned - <{1}>, Culture: {2}", 0, comparer.Compare("file", "FILE"), culture.Name);
                    }
                }
                else
                {
                    if (comparer.Compare("file", "FILE") == 0)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_3846tdfsg! wrong value returned. Expected - <{0}>, Returned - <{1}>, Culture: {2}", "non-zero", comparer.Compare("file", "FILE"), culture.Name);
                    }
                }

                //[]Other data types should work as is
                iCountTestcases++;
                if (comparer.Compare(5, 5) != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_347tsfg! wrong value returned");
                }

                if (comparer.Compare(5, 10) == 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_973425sdg! wrong value returned");
                }
            }

            //[]parm test
            iCountTestcases++;
            try
            {


                comparer = new CaseInsensitiveComparer(null);

                iCountErrors++;
                Console.WriteLine("Err_9745sdg! Exception not thrown");
            }
            catch (ArgumentNullException)
            {
            }
            catch (Exception ex)
            {
                iCountErrors++;
                Console.WriteLine("Err_9745sdg! Unexpected exception thrown, " + ex.GetType().Name);
            }
            ///////////////////////////////////////////////////////////////////
            /////////////////////////// END TESTS /////////////////////////////
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(" : Error Err_8888yyy!  exc_general==" + exc_general.ToString());
        }
        ////  Finish Diagnostics

        if (iCountErrors == 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    public bool runTest()
    {
        //////////// Global Variables used for all tests
        int iCountErrors = 0;
        int iCountTestcases = 0;

        CaseInsensitiveComparer comparer;
        String str1;
        String str2;

        try
        {
            /////////////////////////  START TESTS ////////////////////////////
            ///////////////////////////////////////////////////////////////////

            //[]vanilla - the ctor simply sets the CompareInfo to the current culture - CultureInfo.CurrentCulture.CompareInfo
            //There is no easy way to test this other than make sure that string comparison is case insensitive

            iCountTestcases++;

            comparer = new CaseInsensitiveComparer();

            if (comparer.Compare("hello", "HELLO") != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "HELLO"));
            }

            //same strings should work ok
            if (comparer.Compare("hello", "hello") != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "hello"));
            }

            //different strings should return false
            if (comparer.Compare("hello", "mello") == 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_3846tdfsg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "mello"));
            }


            //[]Other data types should work as is
            iCountTestcases++;
            if (comparer.Compare(5, 5) != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_347tsfg! wrong value returned");
            }

            if (comparer.Compare(5, 10) == 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_973425sdg! wrong value returned");
            }

            //[]we will consider nulls 
            iCountTestcases++;
            if (comparer.Compare(5, null) <= 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_83sdg! wrong value returned, " + comparer.Compare(5, null));
            }

            if (comparer.Compare(null, 5) >= 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_94375sdg! wrong value returned, " + comparer.Compare(null, 5));
            }

            if (comparer.Compare(null, null) != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_94375sdg! wrong value returned, " + comparer.Compare(null, null));
            }

            //[]we will consider nulls with Strings
            iCountTestcases++;
            str1 = "Hello";
            str2 = null;
            if (comparer.Compare(str1, str2) <= 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_948732dsg! wrong value returned, " + comparer.Compare(str1, str2));
            }

            str1 = null;
            str2 = "Hello";
            if (comparer.Compare(str1, str2) >= 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_948732dsg! wrong value returned, " + comparer.Compare(str1, str2));
            }

            str1 = null;
            str2 = null;
            if (comparer.Compare(str1, str2) != 0)
            {
                iCountErrors++;
                Console.WriteLine("Err_948732dsg! wrong value returned, " + comparer.Compare(str1, str2));
            }


            ///////////////////////////////////////////////////////////////////
            /////////////////////////// END TESTS /////////////////////////////
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine(" : Error Err_8888yyy! exc_general==" + exc_general.ToString());
        }
        ////  Finish Diagnostics

        if (iCountErrors == 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
 public static void Ctor_Empty_Compare(object a, object b, int expected)
 {
     CaseInsensitiveComparer comparer = new CaseInsensitiveComparer();
     Assert.Equal(expected, Math.Sign(comparer.Compare(a, b)));
 }
Beispiel #36
0
 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
     String strLoc = "Loc_000oo";
     String strValue = String.Empty;
     int iCountErrors = 0;
     int iCountTestcases = 0;
     CaseInsensitiveComparer comparer;
     CultureInfo[] cultures;
     try
     {
         strLoc = "Loc_384sdg";
         iCountTestcases++;
         iCountTestcases++;
         iCountTestcases++;
         cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
         for(int i=0; i<cultures.Length; i++)
         {
             comparer = new CaseInsensitiveComparer(cultures[i]);
             if(comparer.Compare("hello", "HELLO")!=0)
             {
                 iCountErrors++;
                 Console.WriteLine( "Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "HELLO"));
             }
             if(comparer.Compare("hello", "hello")!=0)
             {
                 iCountErrors++;
                 Console.WriteLine( "Err_93745sdg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "hello"));
             }
             if(comparer.Compare("hello", "mello")==0)
             {
                 iCountErrors++;
                 Console.WriteLine( "Err_3846tdfsg! wrong value returned. Expected - <{0}>, Returned - <{1}>", 0, comparer.Compare("hello", "mello"));
             }
             iCountTestcases++;
             if(comparer.Compare(5, 5)!=0)
             {
                 iCountErrors++;
                 Console.WriteLine( "Err_347tsfg! wrong value returned");
             }
             if(comparer.Compare(5, 10)==0)
             {
                 iCountErrors++;
                 Console.WriteLine( "Err_973425sdg! wrong value returned");
             }
         }
         strLoc = "Loc_dfyusg";
         iCountTestcases++;
         try
         {
             comparer = new CaseInsensitiveComparer(null);
             iCountErrors++;
             Console.WriteLine( "Err_9745sdg! Exception not thrown");
         }
         catch(ArgumentNullException)
         {
         }
         catch(Exception ex)
         {
             iCountErrors++;
             Console.WriteLine( "Err_9745sdg! Unexpected exception thrown, " + ex.GetType().Name);
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
         return true;
     }
     else
     {
         Console.WriteLine("FAiL! "+s_strTFName+" ,inCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
 public static void TestCtor_Empty_Compare(object a, object b, int expected)
 {
     CaseInsensitiveComparer comparer = new CaseInsensitiveComparer();
     Assert.Equal(expected, Helpers.NormalizeCompare(comparer.Compare(a, b)));
 }
        public static void TestCtor_CultureInfo_Compare_TurkishI()
        {
            var cultureNames = new string[]
            {
                "cs-CZ","da-DK","de-DE","el-GR","en-US",
                "es-ES","fi-FI","fr-FR","hu-HU","it-IT",
                "ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
                "pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
                "zh-CN","zh-HK","zh-TW"
            };

            foreach (string cultureName in cultureNames)
            {
                CultureInfo culture;
                try
                {
                    culture = new CultureInfo(cultureName);
                }
                catch (CultureNotFoundException)
                {
                    continue;
                }

                var comparer = new CaseInsensitiveComparer(culture);

                // Turkish has lower-case and upper-case version of the dotted "i", so the upper case of "i" (U+0069) isn't "I" (U+0049)
                // but rather "İ" (U+0130)
                if (culture.Name == "tr-TR")
                {
                    Assert.Equal(1, comparer.Compare("file", "FILE"));
                }
                else
                {
                    Assert.Equal(0, comparer.Compare("file", "FILE"));
                }
            }
        }