blob: 6b4a26f2b27b46d599efad0e9848ff88dc29c57d [file] [log] [blame]
William A. Kennington III9a70f4e2021-05-01 17:16:57 -07001#include <gtest/gtest.h>
2#include <stdplus/exception.hpp>
3
4namespace stdplus
5{
6namespace exception
7{
8
9TEST(Exception, IgnoreNoError)
10{
11 ignore([] {})();
12 ignore([]() mutable { throw std::runtime_error("Boom"); })();
13 EXPECT_EQ(int(), ignore([]() -> int { throw 1; })());
14 auto x = std::make_unique<int>(1);
15 auto y = std::make_unique<int>(2);
16 auto z = std::make_unique<int>(3);
17 EXPECT_EQ(3, ignore([x = std::move(x)](auto&& v) { return *v + *x; })(y));
18 EXPECT_EQ(5, ignore([z = std::move(z)](auto v) { return *v + *z; })(
19 std::move(y)));
20}
21
22} // namespace exception
23} // namespace stdplus