1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.pattern;
15
16 import org.junit.jupiter.api.AfterAll;
17 import org.junit.jupiter.api.AfterEach;
18 import org.junit.jupiter.api.BeforeEach;
19 import org.junit.jupiter.api.BeforeAll;
20 import org.junit.jupiter.api.Test;
21
22 import static org.junit.jupiter.api.Assertions.assertEquals;
23
24 public class SpacePadderTest {
25
26 @BeforeAll
27 public static void setUpBeforeClass() throws Exception {
28 }
29
30 @AfterAll
31 public static void tearDownAfterClass() throws Exception {
32 }
33
34 @BeforeEach
35 public void setUp() throws Exception {
36 }
37
38 @AfterEach
39 public void tearDown() throws Exception {
40 }
41
42 @Test
43 public void smoke() {
44 {
45 StringBuilder buf = new StringBuilder();
46 String s = "a";
47 SpacePadder.leftPad(buf, s, 4);
48 assertEquals(" a", buf.toString());
49 }
50 {
51 StringBuilder buf = new StringBuilder();
52 String s = "a";
53 SpacePadder.rightPad(buf, s, 4);
54 assertEquals("a ", buf.toString());
55 }
56 }
57
58 @Test
59 public void nullString() {
60 String s = null;
61 {
62 StringBuilder buf = new StringBuilder();
63 SpacePadder.leftPad(buf, s, 2);
64 assertEquals(" ", buf.toString());
65 }
66 {
67 StringBuilder buf = new StringBuilder();
68 SpacePadder.rightPad(buf, s, 2);
69 assertEquals(" ", buf.toString());
70 }
71 }
72
73 @Test
74 public void longString() {
75 {
76 StringBuilder buf = new StringBuilder();
77 String s = "abc";
78 SpacePadder.leftPad(buf, s, 2);
79 assertEquals(s, buf.toString());
80 }
81
82 {
83 StringBuilder buf = new StringBuilder();
84 String s = "abc";
85 SpacePadder.rightPad(buf, s, 2);
86 assertEquals(s, buf.toString());
87 }
88 }
89
90 @Test
91 public void lengthyPad() {
92 {
93 StringBuilder buf = new StringBuilder();
94 String s = "abc";
95 SpacePadder.leftPad(buf, s, 33);
96 assertEquals(" abc", buf.toString());
97 }
98 {
99 StringBuilder buf = new StringBuilder();
100 String s = "abc";
101 SpacePadder.rightPad(buf, s, 33);
102 assertEquals("abc ", buf.toString());
103 }
104
105 }
106
107 }