| William A. Kennington III | 9a70f4e | 2021-05-01 17:16:57 -0700 | [diff] [blame] | 1 | #include <stdplus/exception.hpp> | 
 | 2 |  | 
| Patrick Williams | d1984dd | 2023-05-10 16:12:44 -0500 | [diff] [blame] | 3 | #include <gtest/gtest.h> | 
 | 4 |  | 
| William A. Kennington III | 9a70f4e | 2021-05-01 17:16:57 -0700 | [diff] [blame] | 5 | namespace stdplus | 
 | 6 | { | 
 | 7 | namespace exception | 
 | 8 | { | 
 | 9 |  | 
 | 10 | TEST(Exception, IgnoreNoError) | 
 | 11 | { | 
 | 12 |     ignore([] {})(); | 
 | 13 |     ignore([]() mutable { throw std::runtime_error("Boom"); })(); | 
 | 14 |     EXPECT_EQ(int(), ignore([]() -> int { throw 1; })()); | 
 | 15 |     auto x = std::make_unique<int>(1); | 
 | 16 |     auto y = std::make_unique<int>(2); | 
 | 17 |     auto z = std::make_unique<int>(3); | 
 | 18 |     EXPECT_EQ(3, ignore([x = std::move(x)](auto&& v) { return *v + *x; })(y)); | 
| Patrick Williams | d8e0af5 | 2024-08-16 15:21:12 -0400 | [diff] [blame] | 19 |     EXPECT_EQ(5, ignore([z = std::move(z)](auto v) { | 
 | 20 |                   return *v + *z; | 
 | 21 |               })(std::move(y))); | 
| William A. Kennington III | 9a70f4e | 2021-05-01 17:16:57 -0700 | [diff] [blame] | 22 | } | 
 | 23 |  | 
| William A. Kennington III | eff9ab2 | 2021-06-10 01:48:14 -0700 | [diff] [blame] | 24 | TEST(Exception, IgnoreQuiet) | 
 | 25 | { | 
 | 26 |     ignoreQuiet([] {})(); | 
 | 27 |     ignoreQuiet([]() mutable { throw std::runtime_error("Boom"); })(); | 
 | 28 | } | 
 | 29 |  | 
| William A. Kennington III | 9a70f4e | 2021-05-01 17:16:57 -0700 | [diff] [blame] | 30 | } // namespace exception | 
 | 31 | } // namespace stdplus |