mirror of
https://github.com/hyprwm/hyprutils.git
synced 2024-12-22 09:39:49 +01:00
tests: enhance memory + format
This commit is contained in:
parent
db956287d3
commit
3f5293432b
4 changed files with 20 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
|||
#include <hyprutils/memory/WeakPtr.hpp>
|
||||
#include "shared.hpp"
|
||||
#include <vector>
|
||||
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
|
@ -8,6 +9,7 @@ using namespace Hyprutils::Memory;
|
|||
|
||||
int main(int argc, char** argv, char** envp) {
|
||||
SP<int> intPtr = makeShared<int>(10);
|
||||
SP<int> intPtr2 = makeShared<int>(1337);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
|
@ -21,7 +23,17 @@ int main(int argc, char** argv, char** envp) {
|
|||
EXPECT(*weak.get(), 10);
|
||||
EXPECT(weak.expired(), false);
|
||||
|
||||
intPtr = {};
|
||||
std::vector<SP<int>> sps;
|
||||
sps.push_back(intPtr);
|
||||
sps.emplace_back(intPtr);
|
||||
sps.push_back(intPtr2);
|
||||
sps.emplace_back(intPtr2);
|
||||
std::erase_if(sps, [intPtr](const auto& e) { return e == intPtr; });
|
||||
|
||||
intPtr.reset();
|
||||
|
||||
EXPECT(weak.impl_->ref(), 0);
|
||||
EXPECT(intPtr2.strongRef(), 3);
|
||||
|
||||
EXPECT(weak.expired(), true);
|
||||
|
||||
|
|
|
@ -10,9 +10,7 @@ int main(int argc, char** argv, char** envp) {
|
|||
|
||||
CSignal signal;
|
||||
int data = 0;
|
||||
auto listener = signal.registerListener([&] (std::any d) {
|
||||
data = 1;
|
||||
});
|
||||
auto listener = signal.registerListener([&](std::any d) { data = 1; });
|
||||
|
||||
signal.emit();
|
||||
|
||||
|
|
Loading…
Reference in a new issue