blob: c67f71f890e46ea73bf3aababf3c759e7c231a92 [file] [log] [blame]
Ulf Adamsc934fad2015-12-22 07:42:11 +00001// Copyright 2015 The Bazel Authors. All rights reserved.
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// http://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.
14package com.google.devtools.build.docgen;
15
lberkiaea56b32017-05-30 12:35:33 +020016import static com.google.common.truth.Truth.assertThat;
Ulf Adamsc934fad2015-12-22 07:42:11 +000017
18import org.junit.Test;
19import org.junit.runner.RunWith;
20import org.junit.runners.JUnit4;
21
22/**
23 * Tests for DocCheckerUtils.
24 */
25@RunWith(JUnit4.class)
26public class DocCheckerUtilsTest {
27
28 @Test
29 public void testUnclosedTags() {
lberkiaea56b32017-05-30 12:35:33 +020030 assertThat(DocCheckerUtils.getFirstUnclosedTag("<html></html>")).isNull();
31 assertThat(DocCheckerUtils.getFirstUnclosedTag("<html><ol></html>")).isEqualTo("ol");
32 assertThat(DocCheckerUtils.getFirstUnclosedTag("<html><ol><li>foo</li></html>"))
33 .isEqualTo("ol");
34 assertThat(DocCheckerUtils.getFirstUnclosedTag("<html><ol><li/>foo<li/>bar</html>"))
35 .isEqualTo("ol");
Ulf Adamsc934fad2015-12-22 07:42:11 +000036 }
37
38 @Test
39 public void testUncheckedTagsDontFire() {
lberkiaea56b32017-05-30 12:35:33 +020040 assertThat(DocCheckerUtils.getFirstUnclosedTag("<html><br></html>")).isNull();
41 assertThat(DocCheckerUtils.getFirstUnclosedTag("<html><li></html>")).isNull();
42 assertThat(DocCheckerUtils.getFirstUnclosedTag("<html><ul></html>")).isNull();
43 assertThat(DocCheckerUtils.getFirstUnclosedTag("<html><p></html>")).isNull();
Ulf Adamsc934fad2015-12-22 07:42:11 +000044 }
45}