public static void CompareTo_And_ComparisonOperators(int first, int other, int expectedSign) { Rune a = new Rune(first); Rune b = new Rune(other); Assert.Equal(expectedSign, Math.Sign(a.CompareTo(b))); Assert.Equal(expectedSign < 0, a < b); Assert.Equal(expectedSign <= 0, a <= b); Assert.Equal(expectedSign > 0, a > b); Assert.Equal(expectedSign >= 0, a >= b); }
public static void Operators_And_CompareTo(uint scalarValueLeft, uint scalarValueRight) { Rune left = new Rune(scalarValueLeft); Rune right = new Rune(scalarValueRight); Assert.Equal(scalarValueLeft == scalarValueRight, left == right); Assert.Equal(scalarValueLeft != scalarValueRight, left != right); Assert.Equal(scalarValueLeft < scalarValueRight, left < right); Assert.Equal(scalarValueLeft <= scalarValueRight, left <= right); Assert.Equal(scalarValueLeft > scalarValueRight, left > right); Assert.Equal(scalarValueLeft >= scalarValueRight, left >= right); Assert.Equal(scalarValueLeft.CompareTo(scalarValueRight), left.CompareTo(right)); }
public static void NonGenericCompareTo_GivenNonRuneArgument_ThrowsArgumentException() { IComparable rune = new Rune(0); Assert.Throws <ArgumentException>(() => rune.CompareTo(0 /* int32 */)); }