mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-18 18:30:30 +00:00
Add unittest for covering ErrorBuilder implicit cast and metaprogramming (#2882)
- update unittest of Error, cover the casting of ErrorBuilder. - add unittest of metaprogramming.h
This commit is contained in:
1 parent
e066e96464
commit
9eb040d1c0
3 files changed
+55
No files matched your search
@@ -97,5 +97,17 @@ TEST(ErrorTest, AssignOrReturnHasErrorInExpected) {
|
||||
EXPECT_EQ(result.error().message(), "error");
|
||||
}
|
||||
|
||||
TEST(ErrorTest, ErrorBuilderOperatorImplicitCast) {
|
||||
ErrorOr<int> result1 = ErrorBuilder() << "msg";
|
||||
ASSERT_FALSE(result1.ok());
|
||||
EXPECT_EQ(result1.error().message(), "msg");
|
||||
|
||||
auto result2 = static_cast<Error>(ErrorBuilder("TestFunc") << "msg");
|
||||
std::string result2_output;
|
||||
llvm::raw_string_ostream oss(result2_output);
|
||||
result2.Print(oss);
|
||||
EXPECT_EQ(oss.str(), "TestFunc: msg");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon::Testing
|
||||
Reference in new issue
Block a user