|
| 1 | +// Copyright 2023 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include "docfx/doxygen2toc.h" |
| 16 | +#include <gmock/gmock.h> |
| 17 | + |
| 18 | +namespace docfx { |
| 19 | +namespace { |
| 20 | + |
| 21 | +TEST(Doxygen2Toc, Simple) { |
| 22 | + auto constexpr kXml = |
| 23 | + R"xml(<?xml version="1.0" standalone="yes"?><doxygen version="1.9.1" xml:lang="en-US"> |
| 24 | + <compounddef xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="common-error-handling" kind="page"> |
| 25 | + <compoundname>common-error-handling</compoundname> |
| 26 | + <title>Error Handling</title> |
| 27 | + <briefdescription><para>An overview of error handling in the Google Cloud C++ client libraries.</para> |
| 28 | + </briefdescription> |
| 29 | + <detaileddescription><para>More details about error handling.</para></detaileddescription> |
| 30 | + </compounddef> |
| 31 | + <compounddef xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="indexpage" kind="page"> |
| 32 | + <compoundname>index</compoundname> |
| 33 | + <title>The Page Title: unused in this test</title> |
| 34 | + <briefdescription><para>Some brief description.</para> |
| 35 | + </briefdescription> |
| 36 | + <detaileddescription><para>More details about the index.</para></detaileddescription> |
| 37 | + </compounddef> |
| 38 | + </doxygen>)xml"; |
| 39 | + |
| 40 | + auto constexpr kExpected = R"""(### YamlMime:TableOfContent |
| 41 | +- uid: cloud.google.com/cpp/common |
| 42 | + name: cloud.google.com/cpp/common |
| 43 | + items: |
| 44 | + - name: common-error-handling |
| 45 | + href: common-error-handling.md |
| 46 | + - name: README |
| 47 | + href: indexpage.md |
| 48 | +)"""; |
| 49 | + |
| 50 | + pugi::xml_document doc; |
| 51 | + ASSERT_TRUE(doc.load_string(kXml)); |
| 52 | + auto const config = Config{"test-only-no-input-file", "common"}; |
| 53 | + auto const actual = Doxygen2Toc(config, doc); |
| 54 | + |
| 55 | + EXPECT_EQ(kExpected, actual); |
| 56 | +} |
| 57 | + |
| 58 | +} // namespace |
| 59 | +} // namespace docfx |
0 commit comments