#include "util/function.hpp" #include #include TEST_CASE("normalize_lamda") { SUBCASE("Can return a function that returns a int") { const int number = 58; CHECK(normalize_lambda( [number]() { return number; })() == number); } SUBCASE("Can preserve object state") { class Book { public: Book() noexcept = default; void read_page() noexcept { _pages_read++; } [[nodiscard]] uint32_t pages_read() const noexcept { return _pages_read; } private: uint32_t _pages_read{0U}; }; auto book = Book(); book.read_page(); book.read_page(); book.read_page(); CHECK(normalize_lambda( [book]() { return book.pages_read(); })() == 3); } }