View Javadoc
1   /*
2    * SPDX-License-Identifier: Apache-2.0
3    * See LICENSE file for details.
4    *
5    * Copyright 2025-2026 Hazendaz
6    * Copyright 2011-2025 Acegi Technology Pty Limited.
7    */
8   package au.com.acegi.xmlformat;
9   
10  import static org.hamcrest.CoreMatchers.is;
11  import static org.hamcrest.MatcherAssert.assertThat;
12  
13  import org.junit.jupiter.api.Test;
14  
15  /**
16   * Tests {@link XmlOutputFormat}.
17   */
18  public class XmlOutputFormatTest {
19  
20      @Test
21      void defaultIndentSizeIsTwo() {
22          final XmlOutputFormat fmt = new XmlOutputFormat();
23          // Default indent is 2 spaces, represented as a string of length 2
24          assertThat(fmt.getIndent().length(), is(2));
25      }
26  
27      @Test
28      void defaultNewlinesIsTrue() {
29          final XmlOutputFormat fmt = new XmlOutputFormat();
30          assertThat(fmt.isNewlines(), is(true));
31      }
32  
33      @Test
34      void defaultTrimTextIsTrue() {
35          final XmlOutputFormat fmt = new XmlOutputFormat();
36          assertThat(fmt.isTrimText(), is(true));
37      }
38  
39      @Test
40      void defaultPadTextIsTrue() {
41          final XmlOutputFormat fmt = new XmlOutputFormat();
42          assertThat(fmt.isPadText(), is(true));
43      }
44  
45      @Test
46      void defaultKeepBlankLinesIsFalse() {
47          final XmlOutputFormat fmt = new XmlOutputFormat();
48          assertThat(fmt.isKeepBlankLines(), is(false));
49      }
50  
51      @Test
52      void setKeepBlankLinesToTrue() {
53          final XmlOutputFormat fmt = new XmlOutputFormat();
54          fmt.setKeepBlankLines(true);
55          assertThat(fmt.isKeepBlankLines(), is(true));
56      }
57  
58      @Test
59      void setKeepBlankLinesToFalse() {
60          final XmlOutputFormat fmt = new XmlOutputFormat();
61          fmt.setKeepBlankLines(true);
62          fmt.setKeepBlankLines(false);
63          assertThat(fmt.isKeepBlankLines(), is(false));
64      }
65  }