aboutsummaryrefslogtreecommitdiff
path: root/lldb/unittests/Interpreter/TestCommandObjectExpression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/unittests/Interpreter/TestCommandObjectExpression.cpp')
-rw-r--r--lldb/unittests/Interpreter/TestCommandObjectExpression.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/lldb/unittests/Interpreter/TestCommandObjectExpression.cpp b/lldb/unittests/Interpreter/TestCommandObjectExpression.cpp
new file mode 100644
index 0000000..b0cf22d
--- /dev/null
+++ b/lldb/unittests/Interpreter/TestCommandObjectExpression.cpp
@@ -0,0 +1,34 @@
+#include "lldb/Expression/DiagnosticManager.h"
+#include "lldb/Utility/StreamString.h"
+#include "gtest/gtest.h"
+
+namespace lldb_private {
+std::string RenderDiagnosticDetails(Stream &stream,
+ std::optional<uint16_t> offset_in_command,
+ bool multiline,
+ llvm::ArrayRef<DiagnosticDetail> details);
+}
+
+using namespace lldb_private;
+using namespace lldb;
+using llvm::StringRef;
+namespace {
+class ErrorDisplayTest : public ::testing::Test {};
+} // namespace
+
+static std::string Render(std::vector<DiagnosticDetail> details) {
+ StreamString stream;
+ RenderDiagnosticDetails(stream, 0, true, details);
+ return stream.GetData();
+}
+
+TEST_F(ErrorDisplayTest, RenderStatus) {
+ DiagnosticDetail::SourceLocation inline_loc;
+ inline_loc.in_user_input = true;
+ {
+ std::string result =
+ Render({DiagnosticDetail{inline_loc, eSeverityError, "foo", ""}});
+ ASSERT_TRUE(StringRef(result).contains("error:"));
+ ASSERT_TRUE(StringRef(result).contains("foo"));
+ }
+}