================ @@ -0,0 +1,118 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "support/Markdown.h" +#include "gtest/gtest.h" + +using namespace clang::doc::markdown; +using namespace llvm; + +namespace { + +/// Returns the text of the first TextNode child in the given inline list. +static llvm::StringRef firstChildText(const InlineList &L) { + return llvm::cast<TextNode>(L.front()).getText(); +} + +TEST(MarkdownNodeTest, TextNode) { + TextNode N("hello"); + EXPECT_EQ(N.getKind(), NodeKind::NK_Text); + EXPECT_EQ(N.getText(), "hello"); +} + +TEST(MarkdownNodeTest, FencedCodeNode) { + FencedCodeNode N("cpp", "int x = 0;\nint y = 1;"); + EXPECT_EQ(N.getKind(), NodeKind::NK_FencedCode); + EXPECT_EQ(N.getLang(), "cpp"); + llvm::SmallVector<llvm::StringRef> Lines; + N.getCode().split(Lines, '\n'); + EXPECT_EQ(Lines[0], "int x = 0;"); + EXPECT_EQ(Lines[1], "int y = 1;"); ---------------- Neil-N4 wrote:
Will keep in mind when we get to real parsing with discontinuous StringRefs https://github.com/llvm/llvm-project/pull/205609 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
