polybar-dwm/tests/unit_tests/utils/memory.cpp

24 lines
499 B
C++
Raw Normal View History

#include "common/test.hpp"
2016-10-24 23:47:00 +00:00
#include "utils/memory.hpp"
using namespace polybar;
2016-10-24 23:47:00 +00: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-24 23:47:00 +00:00
TEST(Memory, countof) {
mytype A[3]{{}, {}, {}};
mytype B[8]{{}, {}, {}, {}, {}, {}, {}, {}};
2016-10-24 23:47:00 +00:00
EXPECT_EQ(memory_util::countof(A), size_t{3});
EXPECT_EQ(memory_util::countof(B), size_t{8});
2016-10-24 23:47:00 +00:00
}