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());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@
|
|||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>C:\Users\danit\Desktop\2026-27-cpp-homework\feladat4\feladat4;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
|
|
@ -142,7 +143,8 @@
|
|||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>C:\Users\danit\Desktop\2026-27-cpp-homework\feladat4\feladat4\x64\Debug;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>cmydate;cmydateexception;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue