Ulf Adams | c934fad | 2015-12-22 07:42:11 +0000 | [diff] [blame] | 1 | // 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. |
| 14 | package com.google.devtools.build.docgen; |
| 15 | |
lberki | aea56b3 | 2017-05-30 12:35:33 +0200 | [diff] [blame] | 16 | import static com.google.common.truth.Truth.assertThat; |
Ulf Adams | c934fad | 2015-12-22 07:42:11 +0000 | [diff] [blame] | 17 | |
| 18 | import org.junit.Test; |
| 19 | import org.junit.runner.RunWith; |
| 20 | import org.junit.runners.JUnit4; |
| 21 | |
| 22 | /** |
| 23 | * Tests for DocCheckerUtils. |
| 24 | */ |
| 25 | @RunWith(JUnit4.class) |
| 26 | public class DocCheckerUtilsTest { |
| 27 | |
| 28 | @Test |
| 29 | public void testUnclosedTags() { |
lberki | aea56b3 | 2017-05-30 12:35:33 +0200 | [diff] [blame] | 30 | 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 Adams | c934fad | 2015-12-22 07:42:11 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | @Test |
| 39 | public void testUncheckedTagsDontFire() { |
lberki | aea56b3 | 2017-05-30 12:35:33 +0200 | [diff] [blame] | 40 | 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 Adams | c934fad | 2015-12-22 07:42:11 +0000 | [diff] [blame] | 44 | } |
| 45 | } |