Skip to content

Commit

Permalink
Added tests for CoreMask transformations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimi1010 committed Jan 23, 2025
1 parent e5cf5fb commit 5076d29
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Tests/Common++Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ add_executable(
Tests/LoggerTests.cpp
Tests/LRUListTests.cpp
Tests/MacAddressTests.cpp
Tests/PointerVectorTests.cpp)
Tests/PointerVectorTests.cpp
Tests/SystemUtilsTests.cpp)

target_link_libraries(
Common++Test
Expand Down
47 changes: 47 additions & 0 deletions Tests/Common++Test/Tests/SystemUtilsTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>

#include "SystemUtils.h"

namespace pcpp
{

TEST(CoreMaskTest, CreateCoreMaskFromCoreIdsMethod)
{
const std::vector<int> coreIds{ 0, 1, 2, 3 };
CoreMask mask = createCoreMaskFromCoreIds(coreIds);

EXPECT_EQ(mask, 0x0F);
};

TEST(CoreMaskTest, CreateCoreMaskFromCoreVectorMethod)
{

const std::vector<SystemCore> cores{
SystemCores::Core0,
SystemCores::Core1,
SystemCores::Core2,
SystemCores::Core3,
};

CoreMask mask = createCoreMaskFromCoreVector(cores);

EXPECT_EQ(mask, 0x0F);
};

TEST(CoreMaskTest, CreateCoreVectorFromCoreMaskMethod)
{
const CoreMask mask = 0x0F;
const std::vector<SystemCore> expectedCores = {
SystemCores::Core0,
SystemCores::Core1,
SystemCores::Core2,
SystemCores::Core3,
};
std::vector<SystemCore> cores;

createCoreVectorFromCoreMask(mask, cores);

EXPECT_EQ(cores, expectedCores);
};
} // namespace pcpp

0 comments on commit 5076d29

Please sign in to comment.