MCPcopy Create free account
hub / github.com/alibaba/async_simple / TEST_F

Function TEST_F

async_simple/test/TryTest.cpp:60–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58} // namespace
59
60TEST_F(TryTest, testSimpleProcess) {
61 Try<int> v0(1);
62 ASSERT_EQ(1, v0.value());
63
64 Try<int> v1 = 1;
65 ASSERT_EQ(1, v1.value());
66
67 Try<int> v2 = std::move(v0);
68 ASSERT_EQ(1, v2.value());
69
70 Try<int> v3(std::move(v1));
71 ASSERT_TRUE(v3.available());
72 ASSERT_FALSE(v3.hasError());
73 ASSERT_EQ(1, v3.value());
74
75 Try<int> v4;
76 ASSERT_FALSE(v4.available());
77
78 bool hasException = false;
79 Try<int> ve;
80 try {
81 throw "abcdefg";
82 } catch (...) {
83 ve = std::current_exception();
84 }
85
86 ASSERT_TRUE(ve.available());
87 ASSERT_TRUE(ve.hasError());
88
89 try {
90 ve.value();
91 } catch (...) {
92 hasException = true;
93 }
94 ASSERT_TRUE(hasException);
95
96 Try<int> emptyV;
97 ASSERT_FALSE(emptyV.available());
98 emptyV = 100;
99 ASSERT_TRUE(emptyV.available());
100 ASSERT_FALSE(emptyV.hasError());
101 ASSERT_EQ(100, emptyV.value());
102}
103
104TEST_F(TryTest, testClass) {
105 int state0 = 0;

Callers

nothing calls this directly

Calls 5

DummyClass · 0.70
valueMethod · 0.45
availableMethod · 0.45
hasErrorMethod · 0.45
setExceptionMethod · 0.45

Tested by

no test coverage detected