Skip to content

Commit

Permalink
Merge pull request nbuilder#28 from StanleyGoldman/generate_positive_…
Browse files Browse the repository at this point in the history
…float_bug

Generate positive float bug
  • Loading branch information
crmckenzie committed Feb 23, 2016
2 parents 2c5e82f + dcdcb42 commit e491dc6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
50 changes: 49 additions & 1 deletion Source/FizzWare.NBuilder.Tests/Unit/RandomGeneratorTests.cs
Expand Up @@ -33,36 +33,78 @@ public void ShouldBeAbleToGenerateInt16UsingNext()
randomGenerator.Next(short.MinValue, short.MaxValue);
}

[Test]
public void ShouldBeAbleToGeneratePositiveInt16UsingNext()
{
randomGenerator.Next((short)0, short.MaxValue);
}

[Test]
public void ShouldBeAbleToGenerateInt32UsingNext()
{
randomGenerator.Next(int.MinValue, int.MaxValue);
}

[Test]
public void ShouldBeAbleToGeneratePositiveInt32UsingNext()
{
randomGenerator.Next(0, int.MaxValue);
}

[Test]
public void ShouldBeAbleToGenerateInt64UsingNext()
{
randomGenerator.Next(long.MinValue, long.MaxValue);
}

[Test]
public void ShouldBeAbleToGeneratePositiveInt64UsingNext()
{
randomGenerator.Next(0, long.MaxValue);
}

[Test]
public void ShouldBeAbleToGenerateSingleUsingNext()
{
randomGenerator.Next(float.MinValue, float.MaxValue);
}

[Test]
public void ShouldBeAbleToGeneratePositiveSingleUsingNext()
{
randomGenerator.Next(0, Single.MaxValue);
}

[Test]
public void ShouldBeAbleToGenerateDoubleUsingNext()
{
randomGenerator.Next(double.MinValue, double.MaxValue);
}

[Test]
public void ShouldBeAbleToGeneratePositiveDoubleUsingNext()
{
randomGenerator.Next(0, double.MaxValue);
}

[Test]
public void ShouldBeAbleToGenerateDecimalUsingNext()
{
randomGenerator.Next(decimal.MinValue, decimal.MaxValue);
}

[Test]
public void ShouldBeAbleToGeneratePositiveDecimalUsingNext()
{
randomGenerator.Next(0, decimal.MaxValue);
}

[Test]
public void ShouldBeAbleToGeneratePositiveFloatUsingNext()
{
randomGenerator.Next(0, float.MaxValue);
}

[Test]
public void ShouldBeAbleToGenerateCharUsingNext()
{
Expand Down Expand Up @@ -150,7 +192,13 @@ public void ShouldBeAbleToGenerateInt64()
}

[Test]
public void ShouldBeAbleToGenerateSingle()
public void ShouldBeAbleToGenerateShort()
{
randomGenerator.Short();
}

[Test]
public void ShouldBeAbleToGenerateFloat()
{
randomGenerator.Float();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/FizzWare.NBuilder/Generators/RandomGenerator.cs
Expand Up @@ -49,7 +49,7 @@ public virtual long Next(long min, long max)

public virtual float Next(float min, float max)
{
return (float)Next((int)min, (int)max);
return (float)Next((double)min, (double)max);
}

public virtual double Next(double min, double max)
Expand Down

0 comments on commit e491dc6

Please sign in to comment.