File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 77// ===----------------------------------------------------------------------===//
88
99#include " LLDBUtils.h"
10+ #include " lldb/API/SBError.h"
1011#include " lldb/API/SBStructuredData.h"
12+ #include " llvm/Support/Error.h"
1113#include " gtest/gtest.h"
1214
1315using namespace llvm ;
@@ -44,3 +46,20 @@ TEST(LLDBUtilsTest, GetStringValue) {
4446 result = GetStringValue (empty_data);
4547 EXPECT_EQ (result, " " );
4648}
49+
50+ TEST (LLDBUtilsTest, ToError) {
51+ // Test with a successful SBError.
52+ SBError success_error;
53+ ASSERT_TRUE (success_error.Success ());
54+ llvm::Error llvm_error = ToError (success_error);
55+ EXPECT_FALSE (llvm_error);
56+
57+ // Test with a failing SBError.
58+ SBError fail_error;
59+ fail_error.SetErrorString (" Test error message" );
60+ ASSERT_TRUE (fail_error.Fail ());
61+ llvm_error = ToError (fail_error);
62+
63+ std::string error_message = toString (std::move (llvm_error));
64+ EXPECT_EQ (error_message, " Test error message" );
65+ }
You can’t perform that action at this time.
0 commit comments