| 26 | } |
| 27 | |
| 28 | TEST(OptionalTest, sanity) { |
| 29 | { |
| 30 | butil::optional<int> empty; |
| 31 | ASSERT_FALSE(empty); |
| 32 | } |
| 33 | |
| 34 | { |
| 35 | butil::optional<int> empty{}; |
| 36 | ASSERT_FALSE(empty); |
| 37 | } |
| 38 | |
| 39 | { |
| 40 | butil::optional<int> empty = empty_optional(); |
| 41 | ASSERT_FALSE(empty); |
| 42 | } |
| 43 | |
| 44 | { |
| 45 | butil::optional<int> non_empty(42); |
| 46 | ASSERT_TRUE(non_empty); |
| 47 | ASSERT_TRUE(non_empty.has_value()); |
| 48 | ASSERT_EQ(*non_empty, 42); |
| 49 | } |
| 50 | |
| 51 | butil::optional<std::string> opt_string = "abc"; |
| 52 | ASSERT_TRUE(opt_string); |
| 53 | ASSERT_EQ(*opt_string, "abc"); |
| 54 | } |
| 55 | |
| 56 | TEST(OptionalTest, nullopt) { |
| 57 | butil::optional<int> empty(butil::nullopt); |
nothing calls this directly
no test coverage detected