mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 11:12:29 +00:00
feat: implement MD5 algorithm
This commit is contained in:
parent
d4ee19c6af
commit
bd5cc06b68
5 changed files with 330 additions and 6 deletions
|
|
@ -6,6 +6,24 @@ struct TestContainer
|
|||
uint32_t value[10];
|
||||
};
|
||||
|
||||
class TestClass
|
||||
{
|
||||
public:
|
||||
uint32_t* m_value = nullptr;
|
||||
|
||||
TestClass(uint32_t* value) {
|
||||
this->m_value = value;
|
||||
if (this->m_value) {
|
||||
*this->m_value = 1;
|
||||
}
|
||||
}
|
||||
~TestClass() {
|
||||
if (this->m_value) {
|
||||
*this->m_value = 2;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE("CDataAllocator::CDataAllocator", "[dataallocator]") {
|
||||
SECTION("constructs new data allocator") {
|
||||
CDataAllocator allocator(sizeof(TestContainer), 2);
|
||||
|
|
@ -23,6 +41,9 @@ TEST_CASE("CDataAllocator::GetData", "[dataallocator]") {
|
|||
REQUIRE(container2);
|
||||
REQUIRE(container3);
|
||||
REQUIRE(allocator.DataUsed() == 3);
|
||||
allocator.PutData(container, __FILE__, __LINE__);
|
||||
allocator.PutData(container2, __FILE__, __LINE__);
|
||||
allocator.PutData(container3, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,5 +56,20 @@ TEST_CASE("CDataAllocator::PutData", "[dataallocator]") {
|
|||
allocator.PutData(container, __FILE__, __LINE__);
|
||||
allocator.PutData(container3, __FILE__, __LINE__);
|
||||
REQUIRE(allocator.DataUsed() == 1);
|
||||
allocator.PutData(container2, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("CDataAllocator Class Handling", "[dataallocator]") {
|
||||
SECTION("test class creation/destruction") {
|
||||
CDataAllocator allocator(sizeof(TestClass), 2);
|
||||
uint32_t value = 0;
|
||||
|
||||
auto testClass = ALLOCATOR_NEW(allocator, TestClass, &value);
|
||||
REQUIRE(testClass->m_value == &value);
|
||||
REQUIRE(value == 1);
|
||||
|
||||
ALLOCATOR_DEL(allocator, testClass);
|
||||
REQUIRE(value == 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue