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
|
@ -88,7 +88,7 @@ int main(int argc, char** argv, char** envp) {
|
|||
|
||||
// Test matrices
|
||||
{
|
||||
Mat3x3 jeremy = Mat3x3::outputProjection({1920, 1080}, HYPRUTILS_TRANSFORM_FLIPPED_90);
|
||||
Mat3x3 jeremy = Mat3x3::outputProjection({1920, 1080}, HYPRUTILS_TRANSFORM_FLIPPED_90);
|
||||
Mat3x3 matrixBox = jeremy.projectBox(CBox{10, 10, 200, 200}, HYPRUTILS_TRANSFORM_NORMAL).translate({100, 100}).scale({1.25F, 1.5F}).transpose();
|
||||
|
||||
Mat3x3 expected = std::array<float, 9>{0, 0.46296296, 0, 0.3125, 0, 0, 19.84375, 36.055557, 1};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <hyprutils/memory/WeakPtr.hpp>
|
||||
#include "shared.hpp"
|
||||
#include <vector>
|
||||
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
|
@ -7,9 +8,10 @@ using namespace Hyprutils::Memory;
|
|||
#define WP CWeakPointer
|
||||
|
||||
int main(int argc, char** argv, char** envp) {
|
||||
SP<int> intPtr = makeShared<int>(10);
|
||||
SP<int> intPtr = makeShared<int>(10);
|
||||
SP<int> intPtr2 = makeShared<int>(1337);
|
||||
|
||||
int ret = 0;
|
||||
int ret = 0;
|
||||
|
||||
EXPECT(*intPtr, 10);
|
||||
EXPECT(intPtr.strongRef(), 1);
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Colors {
|
|||
|
||||
#define EXPECT(expr, val) \
|
||||
if (const auto RESULT = expr; RESULT != (val)) { \
|
||||
std::cout << Colors::RED << "Failed: " << Colors::RESET << #expr << ", expected " << val << " but got " << RESULT << "\n"; \
|
||||
std::cout << Colors::RED << "Failed: " << Colors::RESET << #expr << ", expected " << val << " but got " << RESULT << "\n"; \
|
||||
ret = 1; \
|
||||
} else { \
|
||||
std::cout << Colors::GREEN << "Passed " << Colors::RESET << #expr << ". Got " << val << "\n"; \
|
||||
|
|
|
@ -6,13 +6,11 @@ using namespace Hyprutils::Signal;
|
|||
using namespace Hyprutils::Memory;
|
||||
|
||||
int main(int argc, char** argv, char** envp) {
|
||||
int ret = 0;
|
||||
int ret = 0;
|
||||
|
||||
CSignal signal;
|
||||
int data = 0;
|
||||
auto listener = signal.registerListener([&] (std::any d) {
|
||||
data = 1;
|
||||
});
|
||||
int data = 0;
|
||||
auto listener = signal.registerListener([&](std::any d) { data = 1; });
|
||||
|
||||
signal.emit();
|
||||
|
||||
|
|
Loading…
Reference in a new issue