|
| 1 | +/* |
| 2 | + * Copyright 2017 java-diff-utils. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package difflib.text; |
| 17 | + |
| 18 | +import java.util.Collections; |
| 19 | +import java.util.List; |
| 20 | +import org.junit.After; |
| 21 | +import org.junit.AfterClass; |
| 22 | +import org.junit.Before; |
| 23 | +import org.junit.BeforeClass; |
| 24 | +import org.junit.Test; |
| 25 | +import static org.junit.Assert.*; |
| 26 | + |
| 27 | +/** |
| 28 | + * |
| 29 | + * @author tw |
| 30 | + */ |
| 31 | +public class StringUtilsTest { |
| 32 | + |
| 33 | + public StringUtilsTest() { |
| 34 | + } |
| 35 | + |
| 36 | + @BeforeClass |
| 37 | + public static void setUpClass() { |
| 38 | + } |
| 39 | + |
| 40 | + @AfterClass |
| 41 | + public static void tearDownClass() { |
| 42 | + } |
| 43 | + |
| 44 | + @Before |
| 45 | + public void setUp() { |
| 46 | + } |
| 47 | + |
| 48 | + @After |
| 49 | + public void tearDown() { |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Test of htmlEntites method, of class StringUtils. |
| 54 | + */ |
| 55 | + @Test |
| 56 | + public void testHtmlEntites() { |
| 57 | + assertEquals("<test>", StringUtils.htmlEntites("<test>")); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Test of normalize method, of class StringUtils. |
| 62 | + */ |
| 63 | + @Test |
| 64 | + public void testNormalize_String() { |
| 65 | + assertEquals(" test",StringUtils.normalize("\ttest")); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Test of normalize method, of class StringUtils. |
| 70 | + */ |
| 71 | + @Test |
| 72 | + public void testNormalize_List() { |
| 73 | + assertEquals(Collections.singletonList(" test"),StringUtils.normalize(Collections.singletonList("\ttest"))); |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Test of wrapText method, of class StringUtils. |
| 78 | + */ |
| 79 | + @Test |
| 80 | + public void testWrapText_String_int() { |
| 81 | + assertEquals("te<br/>st", StringUtils.wrapText("test", 2)); |
| 82 | + assertEquals("tes<br/>t", StringUtils.wrapText("test", 3)); |
| 83 | + assertEquals("test", StringUtils.wrapText("test", 10)); |
| 84 | + } |
| 85 | + |
| 86 | + @Test(expected = IllegalArgumentException.class) |
| 87 | + public void testWrapText_String_int_zero() { |
| 88 | + assertEquals("test", StringUtils.wrapText("test", 0)); |
| 89 | + } |
| 90 | + |
| 91 | +} |
0 commit comments