MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / TEST

Function TEST

oneflow/maybe/error_test.cpp:36–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34} // namespace oneflow
35
36TEST(StackedError, SimpleStackedError) {
37 StackedError<std::error_code, std::string_view> a(std::make_error_code(std::errc::timed_out));
38
39 ASSERT_EQ(a.Error(), std::errc::timed_out);
40 ASSERT_EQ(a.StackSize(), 0);
41
42 const auto& ec = a.Error();
43 ASSERT_DEATH(a.Abort(), // NOLINT(cppcoreguidelines-avoid-goto)
44 ec.category().name() + ":"s + std::to_string(ec.value()));
45
46 [&a] { a.PushStack(__FILE__, __LINE__, __PRETTY_FUNCTION__, "hello"); }();
47
48 struct SomeType {
49 explicit SomeType(decltype(a)& a) {
50 a.PushStack(__FILE__, __LINE__, __PRETTY_FUNCTION__, "hi");
51 }
52 } x(a);
53
54 ASSERT_EQ(a.StackSize(), 2);
55 ASSERT_DEATH(a.Abort(), // NOLINT(cppcoreguidelines-avoid-goto)
56 "(lambda|operator\\(\\)).*hello.*\n.*SomeType::SomeType.*hi");
57
58 ASSERT_EQ(a.StackElem(0).message, "hello");
59 ASSERT_EQ(a.StackElem(1).message, "hi");
60}
61
62TEST(StackedError, SimpleNoStackError) {
63 NoStackError<std::error_code> a(std::make_error_code(std::errc::address_in_use));

Callers

nothing calls this directly

Calls 8

to_stringFunction · 0.85
ErrorMethod · 0.45
StackSizeMethod · 0.45
AbortMethod · 0.45
nameMethod · 0.45
valueMethod · 0.45
PushStackMethod · 0.45
StackElemMethod · 0.45

Tested by

no test coverage detected