Skip to content

Commit

Permalink
add missing number tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal committed Oct 16, 2023
1 parent d85b230 commit 806aae6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/modules/number/NumberTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ class NumberTest : public Test
public:
};

TEST_F(NumberTest, givenInvalidRangeArguments_shouldThrowInvalidArgument)
TEST_F(NumberTest, integer_givenInvalidRangeArguments_shouldThrowInvalidArgument)
{
ASSERT_THROW(Number::integer<int>(10, 2), std::invalid_argument);
}

TEST_F(NumberTest, givenRangeWithSameNumberSection_shouldGenerateThisNumber)
TEST_F(NumberTest, givenRangeWithSameNumbers_shouldGenerateThisNumber)
{
const int actualRandomNumber = Number::integer<int>(2, 2);

ASSERT_EQ(actualRandomNumber, 2);
}

TEST_F(NumberTest, givenValidRangeArguments_shouldGenerateNumberThatIsInGivenRange)
TEST_F(NumberTest, givenValidRange_shouldGenerateNumberWithinGivenRange)
{
const int actualRandomNumber = Number::integer<int>(2, 10);

Expand All @@ -40,6 +40,11 @@ TEST_F(NumberTest, givenSingleArgument_shouldCorrectlyResolveToTwoArgsOverload)
ASSERT_TRUE(randomNumber <= 10);
}

TEST_F(NumberTest, decimal_givenInvalidRangeArguments_shouldThrowInvalidArgument)
{
ASSERT_THROW(Number::decimal<float>(10.f, 2.f), std::invalid_argument);
}

TEST_F(NumberTest, givenValidRangeArguments_shouldGenerateDecimalNumberThatIsInGivenRange)
{
const std::floating_point auto actualRandomNumber = Number::decimal<float>(2.f, 10.f);
Expand All @@ -55,9 +60,9 @@ TEST_F(NumberTest, givenRangeWithSameNumberSection_shouldGenerateThisNumberForDe
ASSERT_EQ(actualRandomNumber, 2.f);
}

TEST_F(NumberTest, HexMethodTest)
TEST_F(NumberTest, shouldGenerateHexNumber)
{
std::string result = Number::hex();
auto result = Number::hex();
ASSERT_EQ(result.size(), 1);
ASSERT_TRUE(std::isxdigit(result[0]));

Expand Down

0 comments on commit 806aae6

Please sign in to comment.