Here is a test fixture demonstrating the problem:
[TestFixture]
public class DoubleTests
{
[Test]
[ExpectedException(typeof(OverflowException))]
public void MaxValue_ThrowsException_WhenParsing()
{
double readValue = double.Parse(double.MaxValue.ToString());
Assert.AreEqual(double.MaxValue, readValue);
}
[Test]
[ExpectedException(typeof(OverflowException))]
public void MinValue_ThrowsException_WhenParsing()
{
double readValue = double.Parse(double.MinValue.ToString());
Assert.AreEqual(double.MinValue, readValue);
}
[Test]
public void NanValue_ThrowsException_WhenParsing()
{
double readValue = double.Parse(double.NaN.ToString());
Assert.AreEqual(double.NaN, readValue);
}
}
No comments:
Post a Comment