init
This commit is contained in:
commit
67a2391619
37 changed files with 2388 additions and 0 deletions
156
feladat2/UnitTest1/UnitTest1.cpp
Normal file
156
feladat2/UnitTest1/UnitTest1.cpp
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
//Tóth Dániel Mátyás | IFPQYY | v2
|
||||
#include "pch.h"
|
||||
#include "CppUnitTest.h"
|
||||
#include "feladat2.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace UnitTest1
|
||||
{
|
||||
TEST_CLASS(UnitTest1)
|
||||
{
|
||||
public:
|
||||
|
||||
//Works weirdly, seems like the test methods are not isolated in themselves in this instance, will need to create and destroy in every
|
||||
//seperate test to guarantee they will work as intended. If only these were in classes instead of being global.....
|
||||
|
||||
TEST_METHOD(CreateTest1)
|
||||
{
|
||||
destroyfifo();
|
||||
Assert::AreEqual(OK, createfifo(10));
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(CreateTest2)
|
||||
{
|
||||
createfifo(10);
|
||||
Assert::AreEqual(NOK, createfifo(10));
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(DestroyTest1)
|
||||
{
|
||||
createfifo(10);
|
||||
Assert::AreEqual(OK, destroyfifo());
|
||||
}
|
||||
TEST_METHOD(DestroyTest2)
|
||||
{
|
||||
destroyfifo();
|
||||
Assert::AreEqual(NOK, destroyfifo());
|
||||
}
|
||||
|
||||
TEST_METHOD(PushTest1)
|
||||
{
|
||||
destroyfifo();
|
||||
createfifo(10);
|
||||
Assert::AreEqual(OK, push('c'));
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(PopTest1)
|
||||
{
|
||||
destroyfifo();
|
||||
createfifo(10);
|
||||
push('c');
|
||||
Assert::AreEqual('c', (char)pop());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(PopTest2)
|
||||
{
|
||||
destroyfifo();
|
||||
createfifo(10);
|
||||
Assert::AreEqual(NOK, pop());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(PopTest3)
|
||||
{
|
||||
destroyfifo();
|
||||
createfifo(10);
|
||||
push('c');
|
||||
Assert::AreEqual('c', (char)pop());
|
||||
Assert::AreEqual(NOK, pop());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(PeekTest1)
|
||||
{
|
||||
destroyfifo();
|
||||
createfifo(10);
|
||||
push('c');
|
||||
Assert::AreEqual('c', (char)peek());
|
||||
Assert::AreEqual('c', (char)peek());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(PeekTest2)
|
||||
{
|
||||
destroyfifo();
|
||||
createfifo(10);
|
||||
Assert::AreEqual(NOK, pop());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(FreespaceTest1)
|
||||
{
|
||||
destroyfifo();
|
||||
int s = 5;
|
||||
createfifo(s);
|
||||
for (int i = 0; i < s; i++)
|
||||
{
|
||||
push('t');
|
||||
}
|
||||
Assert::AreEqual(0, freespace());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(FreespaceTest2)
|
||||
{
|
||||
destroyfifo();
|
||||
int s = 5;
|
||||
createfifo(s);
|
||||
for (int i = 0; i < s-1; i++)
|
||||
{
|
||||
push('t');
|
||||
}
|
||||
Assert::AreEqual(1, freespace());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(CapacityTest1)
|
||||
{
|
||||
destroyfifo();
|
||||
int s = 5;
|
||||
createfifo(s);
|
||||
Assert::AreEqual(s, capacity());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(CapacityTest2)
|
||||
{
|
||||
destroyfifo();
|
||||
int s = 5;
|
||||
createfifo(s);
|
||||
push('c');
|
||||
Assert::AreEqual(s, capacity());
|
||||
destroyfifo();
|
||||
}
|
||||
|
||||
TEST_METHOD(ClearTest1)
|
||||
{
|
||||
destroyfifo();
|
||||
createfifo(10);
|
||||
push('c');
|
||||
Assert::AreEqual(OK, clearfifo());
|
||||
Assert::AreEqual(NOK, pop());
|
||||
Assert::AreEqual(NOK, peek());
|
||||
destroyfifo();
|
||||
}
|
||||
TEST_METHOD(ClearTest2)
|
||||
{
|
||||
destroyfifo();
|
||||
Assert::AreEqual(NOK, clearfifo());
|
||||
}
|
||||
TEST_METHOD(EnlargeTest)
|
||||
{
|
||||
destroyfifo();
|
||||
createfifo(2); //2
|
||||
push('c'); //1
|
||||
push('a'); //0
|
||||
push('d'); //doubles
|
||||
Assert::AreEqual(4, capacity());
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue