public void Should_not_possible_to_compare_elements_with_null_value() { FloatComparator comparator = new FloatComparator(); bool compareResult = comparator.Compare("29", null, OperationEnumeration.equals); Assert.IsFalse(compareResult, "the value is not expected for this operation"); }
public void Should_not_be_possible_two_compare_elements_that_is_not_float_with_any_operator() { FloatComparator comparator = new FloatComparator(); bool compareResult = comparator.Compare("Is not a Float", "15", OperationEnumeration.greaterthanorequal); Assert.IsTrue(compareResult, "the value is not a float number"); }
public void Should_be_possible_to_compare_two_floats_using_not_equals_operator() { FloatComparator comparator = new FloatComparator(); bool compareResult = comparator.Compare("0.5", "0.55", OperationEnumeration.notequal); Assert.IsTrue(compareResult, "the value is not expected for not equals operation"); compareResult = comparator.Compare("10", "11", OperationEnumeration.notequal); Assert.IsTrue(compareResult, "the value is not expected for not equals operation"); }
/// <summary> /// Sorts the receiver according /// to the order induced by the specified comparatord All elements in the /// range must be <i>mutually comparable</i> by the specified comparator /// (that is, <i>c.CompareTo(e1, e2)</i> must not throw a /// <i>ClassCastException</i> for any elements <i>e1</i> and /// <i>e2</i> in the range).<p> /// /// The sorting algorithm is a tuned quicksort, /// adapted from Jon Ld Bentley and Md Douglas McIlroy's "Engineering a /// Sort Function", Software-Practice and Experience, Vold 23(11) /// Pd 1249-1265 (November 1993)d This algorithm offers n*log(n) /// performance on many data sets that cause other quicksorts to degrade to /// quadratic performance. /// /// <summary> /// <param name="from">the index of the first element (inclusive) to be</param> /// sorted. /// <param name="to">the index of the last element (inclusive) to be sorted.</param> /// <param name="c">the comparator to determine the order of the receiver.</param> /// <exception cref="ClassCastException">if the array contains elements that are not </exception> /// <i>mutually comparable</i> using the specified comparator. /// <exception cref="ArgumentException">if <i>fromIndex > toIndex</i> </exception> /// <exception cref="ArrayIndexOutOfRangeException">if <i>fromIndex < 0</i> or </exception> /// <i>toIndex > a.Length</i> /// <see cref="Comparator"></see> /// <exception cref="IndexOutOfRangeException">index is out of range (<i>_size()>0 && (from<0 || from>to || to>=_size())</i>). </exception> public virtual void QuickSortFromTo(int from, int to, FloatComparator c) { int mySize = Size; CheckRangeFromTo(from, to, mySize); var myElements = GetElements(); Cern.Colt.Sorting.QuickSort(myElements, from, to + 1, c); SetElements(myElements); SetSizeRaw(mySize); }
public void Should_be_possible_to_compare_two_floats_using_equals_operator() { FloatComparator comparator = new FloatComparator(); bool compareResult = comparator.Compare("55.89", "55.89", OperationEnumeration.equals); Assert.IsTrue(compareResult, "the value is not expected for equals operation"); compareResult = comparator.Compare("10", "10", OperationEnumeration.equals); Assert.IsTrue(compareResult, "the value is not expected for equals operation"); compareResult = comparator.Compare("55.89", "55.88", OperationEnumeration.equals); Assert.IsFalse(compareResult, "the value is not expected for equals operation"); }
public void Should_be_possible_to_compare_two_floats_using_less_than_or_equals_operator() { FloatComparator comparator = new FloatComparator(); bool compareResult = comparator.Compare("0.33", "0.33", OperationEnumeration.lessthanorequal); Assert.IsTrue(compareResult, "the value is not expected for less than operation"); compareResult = comparator.Compare("50", "180", OperationEnumeration.lessthanorequal); Assert.IsTrue(compareResult, "the value is not expected for less than operation"); compareResult = comparator.Compare("0.550", "0.550", OperationEnumeration.lessthanorequal); Assert.IsTrue(compareResult, "the value is not expected for less than operation"); }
public void Should_be_possible_to_compare_two_floats_using_greather_than_or_equals_operator() { FloatComparator comparator = new FloatComparator(); bool compareResult = comparator.Compare("0.33", "0.10", OperationEnumeration.greaterthanorequal); Assert.IsTrue(compareResult, "the value is not expected for greater than or equals operation"); compareResult = comparator.Compare("0.33", "0.33", OperationEnumeration.greaterthanorequal); Assert.IsTrue(compareResult, "the value is not expected for greater than or equals operation"); compareResult = comparator.Compare("0.1113", "0.1113", OperationEnumeration.greaterthanorequal); Assert.IsTrue(compareResult, "the value is not expected for greater than or equals operation"); }
public void Should_be_possible_to_compare_two_floats_using_less_than_operator() { FloatComparator comparator = new FloatComparator(); bool compareResult = comparator.Compare("0.33", "0.99", OperationEnumeration.lessthan); Assert.IsTrue(compareResult, "the value is not expected for less than operation"); compareResult = comparator.Compare("50", "180", OperationEnumeration.lessthan); Assert.IsTrue(compareResult, "the value is not expected for less than operation"); // error in convertion case of 0.850. It convert to 850.0 compareResult = comparator.Compare("0.85", "180", OperationEnumeration.lessthan); Assert.IsTrue(compareResult, "the value is not expected for less than operation"); }