1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2025-02-24 15:58:22 -05:00
polybar/tests/unit_tests/utils/memory.cpp

24 lines
499 B
C++
Raw Normal View History

#include "common/test.hpp"
2016-10-25 01:47:00 +02:00
#include "utils/memory.hpp"
using namespace polybar;
2016-10-25 01:47:00 +02:00
struct mytype {
int x, y, z;
};
TEST(Memory, makeMallocPtr) {
auto ptr = memory_util::make_malloc_ptr<mytype>();
EXPECT_EQ(sizeof(mytype*), sizeof(ptr.get()));
ptr.reset();
EXPECT_EQ(nullptr, ptr.get());
}
2016-10-25 01:47:00 +02:00
TEST(Memory, countof) {
mytype A[3]{{}, {}, {}};
mytype B[8]{{}, {}, {}, {}, {}, {}, {}, {}};
2016-10-25 01:47:00 +02:00
EXPECT_EQ(memory_util::countof(A), size_t{3});
EXPECT_EQ(memory_util::countof(B), size_t{8});
2016-10-25 01:47:00 +02:00
}