================
@@ -160,3 +161,48 @@ TEST(FormatEntity, LookupAllEntriesInTree) {
         << "Formatting " << testString << " did not succeed";
   }
 }
+
+TEST(FormatEntity, ScopeAlt) {
+  StreamString stream;
+  FormatEntity::Entry format;
+  Status status = FormatEntity::Parse("{${frame.pc}|foo}", format);
+  ASSERT_TRUE(status.Success()) << status.AsCString();
+
+  FormatEntity::Format(format, stream, nullptr, nullptr, nullptr, nullptr,
+                       false, false);
+  EXPECT_EQ(stream.GetString(), "foo");
+}
+
+TEST(FormatEntity, EscapedPipeInScope) {
+  StreamString stream;
+  FormatEntity::Entry format;
+  Status status = FormatEntity::Parse("{foo\\|bar}", format);
+  ASSERT_TRUE(status.Success()) << status.AsCString();
+
+  FormatEntity::Format(format, stream, nullptr, nullptr, nullptr, nullptr,
+                       false, false);
+  EXPECT_EQ(stream.GetString(), "foo|bar");
+}
+
+TEST(FormatEntity, PipeOutsideScope) {
+  StreamString stream;
+  FormatEntity::Entry format;
+  Status status = FormatEntity::Parse("foo|bar", format);
+  ASSERT_TRUE(status.Success()) << status.AsCString();
+
+  FormatEntity::Format(format, stream, nullptr, nullptr, nullptr, nullptr,
+                       false, false);
+  EXPECT_EQ(stream.GetString(), "foo|bar");
+}
+
+TEST(FormatEntity, ScopeAltMultiple) {
+  StreamString stream;
+  FormatEntity::Entry format;
+  Status status =
+      FormatEntity::Parse("{${frame.pc}|${function.name}|foo}", format);
+  ASSERT_TRUE(status.Success()) << status.AsCString();
+
+  FormatEntity::Format(format, stream, nullptr, nullptr, nullptr, nullptr,
+                       false, false);
+  EXPECT_EQ(stream.GetString(), "foo");
+}
----------------
Michael137 wrote:

Could we also test the following?
1. Nested scopes (e.g., `{ ${foo} | { ${bar} | ${baz} } }`)? Not sure that's a 
thing or not, but seems like it should work?
2. Pipes between scopes: `{ ${foo} } | { ${bar} }`
3. Empty format between pipes: `{ ${foo} || ${bar} }`

https://github.com/llvm/llvm-project/pull/137751
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to