MCPcopy Create free account
hub / github.com/apache/brpc / TEST

Function TEST

test/optional_unittest.cpp:28–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28TEST(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
56TEST(OptionalTest, nullopt) {
57 butil::optional<int> empty(butil::nullopt);

Callers

nothing calls this directly

Calls 8

empty_optionalFunction · 0.85
make_optionalFunction · 0.85
has_valueMethod · 0.80
value_orMethod · 0.80
moveFunction · 0.50
swapFunction · 0.50
valueMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected