unittest start
This commit is contained in:
parent
bc87732585
commit
fa8bd24551
8 changed files with 105 additions and 99 deletions
|
|
@ -1,6 +1,7 @@
|
|||
//Tóth Dániel Mátyás | IFPQYY | V1
|
||||
#include "pch.h"
|
||||
#include "CppUnitTest.h"
|
||||
#include <cmydate.h>
|
||||
#include <cmydateexception.h>
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
|
|
@ -10,8 +11,86 @@ namespace UnitTest1
|
|||
{
|
||||
public:
|
||||
|
||||
TEST_METHOD(TestMethod1)
|
||||
|
||||
TEST_METHOD(ValidDate)
|
||||
{
|
||||
CMyDate date;
|
||||
Assert::AreEqual(true, date.IsValid(1980, 4, 23));
|
||||
Assert::AreEqual(true, date.IsValid(1970, 1, 31));
|
||||
Assert::AreEqual(true, date.IsValid(1970, 2, 28));
|
||||
Assert::AreEqual(true, date.IsValid(1970, 9, 30));
|
||||
Assert::AreEqual(true, date.IsValid(1972, 2, 29));
|
||||
}
|
||||
|
||||
TEST_METHOD(InvalidDates)
|
||||
{
|
||||
CMyDate date;
|
||||
|
||||
try
|
||||
{
|
||||
date.IsValid(1969, 1, 1);
|
||||
Assert::IsTrue(false);
|
||||
}
|
||||
catch (const CMyDateException &e)
|
||||
{
|
||||
Assert::AreEqual(CMyDateException::ErrMinYear, e.what());
|
||||
}
|
||||
try
|
||||
{
|
||||
date = CMyDate(1970, 0, 1);
|
||||
}
|
||||
catch (CMyDateException e)
|
||||
{
|
||||
Assert::AreEqual(CMyDateException::ErrMinMonth, e.what());
|
||||
}
|
||||
try
|
||||
{
|
||||
date = CMyDate(1970, 13, 1);
|
||||
}
|
||||
catch (CMyDateException e)
|
||||
{
|
||||
Assert::AreEqual(CMyDateException::ErrMaxMonth, e.what());
|
||||
}
|
||||
try
|
||||
{
|
||||
date = CMyDate(1970, 1, 0);
|
||||
}
|
||||
catch (CMyDateException e)
|
||||
{
|
||||
Assert::AreEqual(CMyDateException::ErrMinDay, e.what());
|
||||
}
|
||||
try
|
||||
{
|
||||
date = CMyDate(1970, 1, 32);
|
||||
}
|
||||
catch (CMyDateException e)
|
||||
{
|
||||
Assert::AreEqual(CMyDateException::ErrMaxDay, e.what());
|
||||
}
|
||||
try
|
||||
{
|
||||
date = CMyDate(1970, 9, 31);
|
||||
}
|
||||
catch (CMyDateException e)
|
||||
{
|
||||
Assert::AreEqual(CMyDateException::ErrMaxDay, e.what());
|
||||
}
|
||||
try
|
||||
{
|
||||
date = CMyDate(1970, 4, 29);
|
||||
}
|
||||
catch (CMyDateException e)
|
||||
{
|
||||
Assert::AreEqual(CMyDateException::ErrMaxDay, e.what());
|
||||
}
|
||||
try
|
||||
{
|
||||
date = CMyDate(2000, 4, 29);
|
||||
}
|
||||
catch (CMyDateException e)
|
||||
{
|
||||
Assert::AreEqual(CMyDateException::ErrMaxDay, e.what());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue