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 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " LLDBUtils.h"
10
+ #include " lldb/API/SBError.h"
10
11
#include " lldb/API/SBStructuredData.h"
12
+ #include " llvm/Support/Error.h"
11
13
#include " gtest/gtest.h"
12
14
13
15
using namespace llvm ;
@@ -44,3 +46,20 @@ TEST(LLDBUtilsTest, GetStringValue) {
44
46
result = GetStringValue (empty_data);
45
47
EXPECT_EQ (result, " " );
46
48
}
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