blob: 6b4a26f2b27b46d599efad0e9848ff88dc29c57d [file] [log] [blame]
#include <gtest/gtest.h>
#include <stdplus/exception.hpp>
namespace stdplus
{
namespace exception
{
TEST(Exception, IgnoreNoError)
{
ignore([] {})();
ignore([]() mutable { throw std::runtime_error("Boom"); })();
EXPECT_EQ(int(), ignore([]() -> int { throw 1; })());
auto x = std::make_unique<int>(1);
auto y = std::make_unique<int>(2);
auto z = std::make_unique<int>(3);
EXPECT_EQ(3, ignore([x = std::move(x)](auto&& v) { return *v + *x; })(y));
EXPECT_EQ(5, ignore([z = std::move(z)](auto v) { return *v + *z; })(
std::move(y)));
}
} // namespace exception
} // namespace stdplus