author | igerasim |
Thu, 07 Aug 2014 15:07:33 +0400 | |
changeset 25967 | 0060a996fe1c |
parent 18778 | 7214a903b084 |
permissions | -rw-r--r-- |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
1 |
/* |
17333 | 2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
4 |
* |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
8 |
* |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
13 |
* accompanied this code). |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
14 |
* |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
18 |
* |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
21 |
* questions. |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
22 |
*/ |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
23 |
/** |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
24 |
* @test |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
25 |
* @bug 5015163 7172553 |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
26 |
* @summary tests StringJoinerTest |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
27 |
* @run testng StringJoinerTest |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
28 |
* @author Jim Gish |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
29 |
*/ |
18778 | 30 |
import java.util.ArrayList; |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
31 |
import java.util.StringJoiner; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
32 |
import org.testng.annotations.Test; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
33 |
import static org.testng.Assert.assertEquals; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
34 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
35 |
@Test(groups = {"unit","string","util","libs"}) |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
36 |
public class StringJoinerTest { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
37 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
38 |
private static final String EMPTY = "EMPTY"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
39 |
private static final String ONE = "One"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
40 |
private static final int ONE_LEN = ONE.length(); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
41 |
private static final String TWO = "Two"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
42 |
private static final int TWO_LEN = TWO.length(); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
43 |
private static final String THREE = "Three"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
44 |
private static final String FOUR = "Four"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
45 |
private static final String FIVE = "Five"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
46 |
private static final String DASH = "-"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
47 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
48 |
public void addAddAll() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
49 |
StringJoiner sj = new StringJoiner(DASH, "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
50 |
sj.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
51 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
52 |
ArrayList<String> nextOne = new ArrayList<>(); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
53 |
nextOne.add(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
54 |
nextOne.add(THREE); |
18778 | 55 |
nextOne.stream().forEachOrdered(sj::add); |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
56 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
57 |
String expected = "{"+ONE+DASH+TWO+DASH+THREE+"}"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
58 |
assertEquals(sj.toString(), expected); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
59 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
60 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
61 |
void addAlladd() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
62 |
StringJoiner sj = new StringJoiner(DASH, "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
63 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
64 |
ArrayList<String> firstOne = new ArrayList<>(); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
65 |
firstOne.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
66 |
firstOne.add(TWO); |
18778 | 67 |
firstOne.stream().forEachOrdered(sj::add); |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
68 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
69 |
sj.add(THREE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
70 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
71 |
String expected = "{"+ONE+DASH+TWO+DASH+THREE+"}"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
72 |
assertEquals(sj.toString(), expected); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
73 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
74 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
75 |
// The following tests do two successive adds of different types |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
76 |
public void addAlladdAll() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
77 |
StringJoiner sj = new StringJoiner(DASH, "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
78 |
ArrayList<String> firstOne = new ArrayList<>(); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
79 |
firstOne.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
80 |
firstOne.add(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
81 |
firstOne.add(THREE); |
18778 | 82 |
firstOne.stream().forEachOrdered(sj::add); |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
83 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
84 |
ArrayList<String> nextOne = new ArrayList<>(); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
85 |
nextOne.add(FOUR); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
86 |
nextOne.add(FIVE); |
18778 | 87 |
nextOne.stream().forEachOrdered(sj::add); |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
88 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
89 |
String expected = "{"+ONE+DASH+TWO+DASH+THREE+DASH+FOUR+DASH+FIVE+"}"; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
90 |
assertEquals(sj.toString(), expected); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
91 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
92 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
93 |
public void addCharSequence() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
94 |
StringJoiner sj = new StringJoiner(","); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
95 |
CharSequence cs_one = ONE; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
96 |
CharSequence cs_two = TWO; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
97 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
98 |
sj.add(cs_one); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
99 |
sj.add(cs_two); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
100 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
101 |
assertEquals(sj.toString(), ONE + "," + TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
102 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
103 |
sj = new StringJoiner(DASH, "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
104 |
sj.add(cs_one); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
105 |
sj.add(cs_two); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
106 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
107 |
assertEquals(sj.toString(), "{" + ONE + DASH + TWO + "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
108 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
109 |
StringBuilder builder = new StringBuilder(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
110 |
StringBuffer buffer = new StringBuffer(THREE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
111 |
sj = new StringJoiner(", ", "{ ", " }"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
112 |
sj.add(builder).add(buffer); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
113 |
builder.append(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
114 |
buffer.append(FOUR); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
115 |
assertEquals(sj.toString(), "{ " + ONE + ", " + THREE + " }", |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
116 |
"CharSequence is copied when add"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
117 |
sj.add(builder); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
118 |
assertEquals(sj.toString(), "{ " + ONE + ", " + THREE + ", " + ONE + |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
119 |
TWO + " }"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
120 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
121 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
122 |
public void addCharSequenceWithEmptyValue() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
123 |
StringJoiner sj = new StringJoiner(",").setEmptyValue(EMPTY); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
124 |
CharSequence cs_one = ONE; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
125 |
CharSequence cs_two = TWO; |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
126 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
127 |
sj.add(cs_one); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
128 |
sj.add(cs_two); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
129 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
130 |
assertEquals(sj.toString(), ONE + "," + TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
131 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
132 |
sj = new StringJoiner(DASH, "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
133 |
sj.add(cs_one); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
134 |
sj.add(cs_two); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
135 |
assertEquals(sj.toString(), "{" + ONE + DASH + TWO + "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
136 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
137 |
sj = new StringJoiner(DASH, "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
138 |
assertEquals(sj.toString(), "{}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
139 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
140 |
sj = new StringJoiner("=", "{", "}").setEmptyValue(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
141 |
assertEquals(sj.toString(), ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
142 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
143 |
sj = new StringJoiner(DASH, "{", "}").setEmptyValue(EMPTY); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
144 |
assertEquals(sj.toString(), EMPTY); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
145 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
146 |
sj.add(cs_one); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
147 |
sj.add(cs_two); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
148 |
assertEquals(sj.toString(), "{" + ONE + DASH + TWO + "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
149 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
150 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
151 |
public void addString() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
152 |
StringJoiner sj = new StringJoiner(DASH); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
153 |
sj.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
154 |
assertEquals(sj.toString(), ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
155 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
156 |
sj = new StringJoiner(DASH, "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
157 |
sj.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
158 |
assertEquals(sj.toString(), "{" + ONE + "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
159 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
160 |
sj.add(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
161 |
assertEquals(sj.toString(), "{" + ONE + DASH + TWO + "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
162 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
163 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
164 |
public void lengthWithCustomEmptyValue() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
165 |
StringJoiner sj = new StringJoiner(DASH, "<", ">").setEmptyValue(EMPTY); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
166 |
assertEquals(sj.length(), EMPTY.length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
167 |
sj.add(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
168 |
assertEquals(sj.length(), "<>".length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
169 |
sj.add(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
170 |
assertEquals(sj.length(), "<->".length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
171 |
sj.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
172 |
assertEquals(sj.length(), 4 + ONE_LEN); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
173 |
assertEquals(sj.toString().length(), sj.length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
174 |
sj.add(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
175 |
assertEquals(sj.length(), 5 + ONE_LEN + TWO_LEN); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
176 |
assertEquals(sj.toString().length(), sj.length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
177 |
sj = new StringJoiner("||", "<", "-->"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
178 |
assertEquals(sj.length(), 4); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
179 |
assertEquals(sj.toString().length(), sj.length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
180 |
sj.add("abcdef"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
181 |
assertEquals(sj.length(), 10); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
182 |
assertEquals(sj.toString().length(), sj.length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
183 |
sj.add("xyz"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
184 |
assertEquals(sj.length(), 15); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
185 |
assertEquals(sj.toString().length(), sj.length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
186 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
187 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
188 |
public void noAddAndEmptyValue() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
189 |
StringJoiner sj = new StringJoiner(DASH, "", "").setEmptyValue(EMPTY); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
190 |
assertEquals(sj.toString(), EMPTY); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
191 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
192 |
sj = new StringJoiner(DASH, "<..", ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
193 |
assertEquals(sj.toString(), "<.."); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
194 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
195 |
sj = new StringJoiner(DASH, "<..", ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
196 |
assertEquals(sj.toString(), "<.."); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
197 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
198 |
sj = new StringJoiner(DASH, "", "==>"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
199 |
assertEquals(sj.toString(), "==>"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
200 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
201 |
sj = new StringJoiner(DASH, "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
202 |
assertEquals(sj.toString(), "{}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
203 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
204 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
205 |
@Test(expectedExceptions = {NullPointerException.class}) |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
206 |
public void setEmptyValueNull() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
207 |
new StringJoiner(DASH, "{", "}").setEmptyValue(null); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
208 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
209 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
210 |
@Test(expectedExceptions = {NullPointerException.class}) |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
211 |
public void setDelimiterNull() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
212 |
new StringJoiner(null); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
213 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
214 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
215 |
@Test(expectedExceptions = {NullPointerException.class}) |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
216 |
public void setPrefixNull() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
217 |
new StringJoiner(DASH, null, "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
218 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
219 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
220 |
@Test(expectedExceptions = {NullPointerException.class}) |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
221 |
public void setSuffixNull() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
222 |
new StringJoiner(DASH, "{", null); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
223 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
224 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
225 |
public void stringFromtoString() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
226 |
StringJoiner sj = new StringJoiner(", "); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
227 |
assertEquals(sj.toString(), ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
228 |
sj = new StringJoiner(",", "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
229 |
assertEquals(sj.toString(), "{}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
230 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
231 |
sj = new StringJoiner(","); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
232 |
sj.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
233 |
assertEquals(sj.toString(), ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
234 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
235 |
sj.add(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
236 |
assertEquals(sj.toString(), ONE + "," + TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
237 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
238 |
sj = new StringJoiner(",", "{--", "--}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
239 |
sj.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
240 |
sj.add(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
241 |
assertEquals(sj.toString(), "{--" + ONE + "," + TWO + "--}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
242 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
243 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
244 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
245 |
public void stringFromtoStringWithEmptyValue() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
246 |
StringJoiner sj = new StringJoiner(" ", "", ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
247 |
assertEquals(sj.toString(), ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
248 |
sj = new StringJoiner(", "); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
249 |
assertEquals(sj.toString(), ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
250 |
sj = new StringJoiner(",", "{", "}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
251 |
assertEquals(sj.toString(), "{}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
252 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
253 |
sj = new StringJoiner(",", "{", "}").setEmptyValue(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
254 |
assertEquals(sj.toString(), ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
255 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
256 |
sj = new StringJoiner(","); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
257 |
sj.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
258 |
assertEquals(sj.toString(), ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
259 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
260 |
sj.add(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
261 |
assertEquals(sj.toString(), ONE + "," + TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
262 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
263 |
sj = new StringJoiner(",", "{--", "--}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
264 |
sj.add(ONE); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
265 |
assertEquals(sj.toString(), "{--" + ONE + "--}" ); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
266 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
267 |
sj.add(TWO); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
268 |
assertEquals(sj.toString(), "{--" + ONE + "," + TWO + "--}"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
269 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
270 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
271 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
272 |
public void toStringWithCustomEmptyValue() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
273 |
StringJoiner sj = new StringJoiner(DASH, "<", ">").setEmptyValue(EMPTY); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
274 |
assertEquals(sj.toString(), EMPTY); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
275 |
sj.add(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
276 |
assertEquals(sj.toString(), "<>"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
277 |
sj.add(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
278 |
assertEquals(sj.toString(), "<->"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
279 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
280 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
281 |
private void testCombos(String infix, String prefix, String suffix) { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
282 |
StringJoiner sj = new StringJoiner(infix, prefix, suffix); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
283 |
assertEquals(sj.toString(), prefix + suffix); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
284 |
assertEquals(sj.toString().length(), sj.length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
285 |
// EmptyValue |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
286 |
sj = new StringJoiner(infix, prefix, suffix).setEmptyValue("<NONE>"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
287 |
assertEquals(sj.toString(), "<NONE>"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
288 |
assertEquals(sj.toString().length(), sj.length()); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
289 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
290 |
// empty in front |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
291 |
sj.add(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
292 |
assertEquals(sj.toString(), prefix + suffix); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
293 |
// empty in middle |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
294 |
sj.add(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
295 |
assertEquals(sj.toString(), prefix + infix + suffix); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
296 |
sj.add("1"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
297 |
assertEquals(sj.toString(), prefix + infix + infix + "1" + suffix); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
298 |
// empty at end |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
299 |
sj.add(""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
300 |
assertEquals(sj.toString(), prefix + infix + infix + "1" + infix + suffix); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
301 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
302 |
sj = new StringJoiner(infix, prefix, suffix).setEmptyValue("<NONE>"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
303 |
sj.add("1"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
304 |
assertEquals(sj.toString(), prefix + "1" + suffix); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
305 |
sj.add("2"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
306 |
assertEquals(sj.toString(), prefix + "1" + infix + "2" + suffix); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
307 |
sj.add(""); |
25967
0060a996fe1c
8054221: StringJoiner imlementation optimization
igerasim
parents:
18778
diff
changeset
|
308 |
assertEquals(sj.toString(), prefix + "1" + infix + "2" + infix + suffix); |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
309 |
sj.add("3"); |
25967
0060a996fe1c
8054221: StringJoiner imlementation optimization
igerasim
parents:
18778
diff
changeset
|
310 |
assertEquals(sj.toString(), prefix + "1" + infix + "2" + infix + infix + "3" + suffix); |
17181
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
311 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
312 |
|
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
313 |
public void testDelimiterCombinations() { |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
314 |
testCombos("", "", ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
315 |
testCombos("", "<", ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
316 |
testCombos("", "", ">"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
317 |
testCombos("", "<", ">"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
318 |
testCombos(",", "", ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
319 |
testCombos(",", "<", ""); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
320 |
testCombos(",", "", ">"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
321 |
testCombos(",", "<", ">"); |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
322 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
323 |
} |
e3d13a15c5c0
5015163: (str) String merge/join that is the inverse of String.split()
jgish
parents:
diff
changeset
|
324 |