mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Add unit tests to test rem(x, 0) and mod(x, 0)
This commit is contained in:
parent
0a69348b00
commit
ca802d86af
1 changed files with 23 additions and 1 deletions
|
@ -10,7 +10,7 @@ using namespace CalcEngine;
|
||||||
using namespace CalcEngine::RationalMath;
|
using namespace CalcEngine::RationalMath;
|
||||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||||
|
|
||||||
namespace RationalTests
|
namespace CalculatorManagerTest
|
||||||
{
|
{
|
||||||
TEST_CLASS(RationalTest)
|
TEST_CLASS(RationalTest)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,10 @@ namespace RationalTests
|
||||||
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"-8113");
|
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"-8113");
|
||||||
res = Mod(Rational(-643), Rational(-8756));
|
res = Mod(Rational(-643), Rational(-8756));
|
||||||
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"-643");
|
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"-643");
|
||||||
|
|
||||||
|
//Test with Zero
|
||||||
|
res = Mod(Rational(343654332), Rational(0));
|
||||||
|
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"343654332");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD(RemainderTest)
|
TEST_METHOD(RemainderTest)
|
||||||
|
@ -71,6 +75,24 @@ namespace RationalTests
|
||||||
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"643");
|
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"643");
|
||||||
res = Rational(-643) % Rational(-8756);
|
res = Rational(-643) % Rational(-8756);
|
||||||
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"-643");
|
VERIFY_ARE_EQUAL(res.ToString(10, FMT_FLOAT, 128), L"-643");
|
||||||
|
|
||||||
|
//Test with Zero
|
||||||
|
try
|
||||||
|
{
|
||||||
|
res = Rational(343654332) % Rational(0);
|
||||||
|
Assert::Fail();
|
||||||
|
}
|
||||||
|
catch (uint32_t t)
|
||||||
|
{
|
||||||
|
if (t != CALC_E_INDEFINITE)
|
||||||
|
{
|
||||||
|
Assert::Fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
Assert::Fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue