SPRNET-1490 extended support for IsZero to Byte and SByte, improved tests around IsZero, and fixed several poss. casting errors

This commit is contained in:
Steve Bohlen
2012-04-17 15:40:16 -04:00
parent 153a1bb909
commit 9ccfaeb3e2
2 changed files with 47 additions and 16 deletions

View File

@@ -65,20 +65,51 @@ namespace Spring.Util
}
[Test]
public void IsNumber()
public void IsNumber()
{
Assert.IsTrue(NumberUtils.IsNumber(10));
Assert.IsTrue(NumberUtils.IsNumber(10L));
Assert.IsTrue(NumberUtils.IsNumber((short) 10));
Assert.IsFalse(NumberUtils.IsNumber('e'));
Assert.IsFalse(NumberUtils.IsNumber(null));
Assert.IsTrue(NumberUtils.IsNumber(9.5D));
Assert.IsTrue(NumberUtils.IsNumber(9.5F));
Assert.IsFalse(NumberUtils.IsNumber(this));
Assert.IsFalse(NumberUtils.IsNumber(null));
Assert.IsFalse(NumberUtils.IsNumber(string.Empty));
Assert.IsTrue(NumberUtils.IsNumber(10));
Assert.IsTrue(NumberUtils.IsNumber(10L));
Assert.IsTrue(NumberUtils.IsNumber((short)10));
Assert.IsFalse(NumberUtils.IsNumber('e'));
Assert.IsFalse(NumberUtils.IsNumber(null));
Assert.IsTrue(NumberUtils.IsNumber(9.5D));
Assert.IsTrue(NumberUtils.IsNumber(9.5F));
Assert.IsFalse(NumberUtils.IsNumber(this));
Assert.IsFalse(NumberUtils.IsNumber(null));
Assert.IsFalse(NumberUtils.IsNumber(string.Empty));
}
[Test]
public void IsZero()
{
Assert.IsFalse(NumberUtils.IsZero((Int16)2));
Assert.IsTrue(NumberUtils.IsZero((Int16)0));
Assert.IsFalse(NumberUtils.IsZero((Int32)2));
Assert.IsTrue(NumberUtils.IsZero((Int32)0));
Assert.IsFalse(NumberUtils.IsZero((Int64)2));
Assert.IsTrue(NumberUtils.IsZero((Int64)0));
Assert.IsFalse(NumberUtils.IsZero((UInt16)2));
Assert.IsTrue(NumberUtils.IsZero((UInt16)0));
Assert.IsFalse(NumberUtils.IsZero((UInt32)2));
Assert.IsTrue(NumberUtils.IsZero((UInt32)0));
Assert.IsFalse(NumberUtils.IsZero((UInt64)2));
Assert.IsTrue(NumberUtils.IsZero((UInt64)0));
Assert.IsFalse(NumberUtils.IsZero((decimal)2));
Assert.IsTrue(NumberUtils.IsZero((decimal)0));
Assert.IsTrue(NumberUtils.IsZero((Byte?)0));
Assert.IsFalse(NumberUtils.IsZero((Byte)2));
Assert.IsTrue(NumberUtils.IsZero((SByte?)0));
Assert.IsFalse(NumberUtils.IsZero((SByte)2));
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void NegateNull()
@@ -90,7 +121,7 @@ namespace Spring.Util
[ExpectedException(typeof(ArgumentException))]
public void NegateString()
{
NumberUtils.Negate(null);
NumberUtils.Negate(string.Empty);
}
[Test]