public void TestDecimalEdges_01() { for (byte scale = 0; scale < 29; scale++) { var l = new decimal(~0, ~0, ~0, false, scale); check(l); l = new decimal(~0, ~0, ~0, true, scale); check(l); } for (byte scale = 0; scale < 29; scale++) { var l = new decimal(unchecked ((int)0x99999999), unchecked ((int)0x99999999), 0x19999999, false, scale); check(l); l = new decimal(unchecked ((int)0x99999999), unchecked ((int)0x99999999), 0x19999999, true, scale); check(l); l = new decimal(unchecked ((int)0x99999998), unchecked ((int)0x99999999), 0x19999999, false, scale); check(l); l = new decimal(unchecked ((int)0x99999998), unchecked ((int)0x99999999), 0x19999999, true, scale); check(l); l = new decimal(unchecked ((int)0x9999999A), unchecked ((int)0x99999999), 0x19999999, false, scale); check(l); l = new decimal(unchecked ((int)0x9999999A), unchecked ((int)0x99999999), 0x19999999, true, scale); check(l); } for (int high = 0; high < 2; high++) { for (int mid = 0; mid < 2; mid++) { for (int p2 = 0; p2 < 32; p2++) { int low = 1 << p2; var l = new decimal(low, mid, high, false, 28); check(l); l = new decimal(low, mid, high, true, 28); check(l); } } } void check(decimal d) { Assert.False(ForDecimal.Related(LessThan, d).Any(Equal, d)); Assert.True(ForDecimal.Related(LessThanOrEqual, d).Any(Equal, d)); Assert.False(ForDecimal.Related(GreaterThan, d).Any(Equal, d)); Assert.True(ForDecimal.Related(GreaterThanOrEqual, d).Any(Equal, d)); } }
public void TestDecimalRelations_01() { Assert.Equal( "[-79228162514264337593543950335..-0.0000000000000000000000000001]", ForDecimal.Related(LessThan, 0.0m).ToString() ); Assert.Equal( "[-79228162514264337593543950335..0.0000000000000000000000000000]", ForDecimal.Related(LessThanOrEqual, 0.0m).ToString() ); Assert.Equal( "[0.0000000000000000000000000001..79228162514264337593543950335]", ForDecimal.Related(GreaterThan, 0.0m).ToString() ); Assert.Equal( "[0.0000000000000000000000000000..79228162514264337593543950335]", ForDecimal.Related(GreaterThanOrEqual, 0.0m).ToString() ); }