Added tests for string division expecting exceptions

This commit is contained in:
Leonetienne
2022-02-27 15:55:47 +01:00
parent 5ff48cb710
commit a0a77f51fe
2 changed files with 25 additions and 6 deletions

View File

@@ -4,6 +4,7 @@
#include <vector>
#include <time.h>
#include <sstream>
#include <stdexcept>
// Tests that basic division (base10) is working, with oracle values
TEST_CASE(__FILE__"/Base10", "[StringDivision]")
@@ -130,3 +131,19 @@ TEST_CASE(__FILE__"/BaseFuckingBig", "[StringDivision]")
REQUIRE(res.second == 555);
}
}
// Tests that a division by zero exception is thrown when appropriate
TEST_CASE(__FILE__"/DivisionByZero", "[StringDivision]")
{
REQUIRE_THROWS_AS(
GeneralUtility::StringDivision("699", 0)
, std::overflow_error);
}
// Tests that a logic error is thrown when the supplied set is empty
TEST_CASE(__FILE__"/NoSetSupplied", "[StringDivision]")
{
REQUIRE_THROWS_AS(
GeneralUtility::StringDivision("699", 5, "")
, std::logic_error);
}