jdk/test/java/util/StringJoiner/MergeTest.java
author martin
Tue, 15 Sep 2015 21:56:04 -0700
changeset 32649 2ee9017c7597
parent 25967 0060a996fe1c
permissions -rw-r--r--
8136583: Core libraries should use blessed modifier order Summary: Run blessed-modifier-order script (see bug) Reviewed-by: psandoz, chegar, alanb, plevart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     1
/*
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     4
 *
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     8
 *
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    13
 * accompanied this code).
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    14
 *
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    18
 *
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    21
 * questions.
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    22
 */
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    23
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    24
/**
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    25
 * @test
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    26
 * @bug 8017231 8020977 8054221
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    27
 * @summary test  StringJoiner::merge
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    28
 * @run testng MergeTest
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    29
 */
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    30
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    31
import java.util.StringJoiner;
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    32
import java.util.stream.Stream;
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    33
import org.testng.annotations.Test;
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    34
import static org.testng.Assert.assertEquals;
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    35
import static org.testng.Assert.fail;
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    36
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    37
@Test
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    38
public class MergeTest {
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25967
diff changeset
    39
    private static final String[] PREFIXES = {"", "{", "@#$%"};
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25967
diff changeset
    40
    private static final String[] SUFFIXES = {"", "}", "*&%$"};
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    41
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    42
    private static class Fixes {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    43
        public String pre0, suf0;
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    44
        public String pre1, suf1;
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    45
        public Fixes(String prefix0, String suffix0,
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    46
                     String prefix1, String suffix1) {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    47
            this.pre0 = prefix0;
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    48
            this.suf0 = suffix0;
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    49
            this.pre1 = prefix1;
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    50
            this.suf1 = suffix1;
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    51
        }
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    52
    }
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    53
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    54
    private static Stream<Fixes> fixesStream() {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    55
        Stream.Builder<Fixes> builder = Stream.builder();
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    56
        for (final String prefix0 : PREFIXES) {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    57
            for (final String suffix0 : SUFFIXES) {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    58
                for (final String prefix1 : PREFIXES) {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    59
                    for (final String suffix1 : SUFFIXES) {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    60
                        builder.accept(new Fixes(prefix0, suffix0,
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    61
                                                 prefix1, suffix1));
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    62
                    }
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    63
                }
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    64
            }
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    65
        }
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    66
        return builder.build();
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    67
    }
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    68
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    69
    @Test(expectedExceptions = {NullPointerException.class})
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    70
    public void testNull() {
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    71
        StringJoiner sj = new StringJoiner(",", "{", "}");
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    72
        sj.merge(null);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    73
    }
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    74
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    75
    public void testSimple() {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    76
        fixesStream().forEach(fixes -> {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    77
            StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    78
            StringJoiner other = new StringJoiner(",", fixes.pre1, fixes.suf1);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    79
            Stream.of("a", "b", "c").forEachOrdered(sj::add);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    80
            Stream.of("d", "e", "f").forEachOrdered(other::add);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    81
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    82
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    83
            assertEquals(sj.toString(), fixes.pre0 + "a,b,c,d,e,f" + fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    84
        });
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    85
    }
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    86
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    87
    public void testEmptyOther() {
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    88
        fixesStream().forEach(fixes -> {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    89
            StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    90
            StringJoiner other = new StringJoiner(",", fixes.pre1, fixes.suf1);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    91
            Stream.of("a", "b", "c").forEachOrdered(sj::add);
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    92
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    93
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    94
            assertEquals(sj.toString(), fixes.pre0 + "a,b,c" + fixes.suf0);
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
    95
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    96
            other.setEmptyValue("EMPTY");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    97
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    98
            assertEquals(sj.toString(), fixes.pre0 + "a,b,c" + fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
    99
        });
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   100
    }
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   101
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   102
    public void testEmptyThis() {
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   103
        fixesStream().forEach(fixes -> {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   104
            StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   105
            StringJoiner other = new StringJoiner(":", fixes.pre1, fixes.suf1);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   106
            Stream.of("d", "e", "f").forEachOrdered(other::add);
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   107
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   108
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   109
            assertEquals(sj.toString(), fixes.pre0 + "d:e:f" + fixes.suf0);
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   110
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   111
            sj = new StringJoiner(",", fixes.pre0, fixes.suf0).setEmptyValue("EMPTY");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   112
            assertEquals(sj.toString(), "EMPTY");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   113
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   114
            assertEquals(sj.toString(), fixes.pre0 + "d:e:f" + fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   115
        });
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   116
    }
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   117
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   118
    public void testEmptyBoth() {
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   119
        fixesStream().forEach(fixes -> {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   120
            StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   121
            StringJoiner other = new StringJoiner(":", fixes.pre1, fixes.suf1);
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   122
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   123
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   124
            assertEquals(sj.toString(), fixes.pre0 + fixes.suf0);
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   125
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   126
            other.setEmptyValue("NOTHING");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   127
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   128
            assertEquals(sj.toString(), fixes.pre0 + fixes.suf0);
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   129
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   130
            sj = new StringJoiner(",", fixes.pre0, fixes.suf0).setEmptyValue("EMPTY");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   131
            assertEquals(sj.toString(), "EMPTY");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   132
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   133
            assertEquals(sj.toString(), "EMPTY");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   134
        });
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   135
    }
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   136
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   137
    public void testCascadeEmpty() {
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   138
        fixesStream().forEach(fixes -> {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   139
            StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   140
            StringJoiner o1 = new StringJoiner(":", fixes.pre1, fixes.suf1).setEmptyValue("Empty1");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   141
            StringJoiner o2 = new StringJoiner(",", "<", ">").setEmptyValue("Empty2");
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   142
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   143
            o1.merge(o2);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   144
            assertEquals(o1.toString(), "Empty1");
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   145
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   146
            sj.merge(o1);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   147
            assertEquals(sj.toString(), fixes.pre0 + fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   148
        });
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   149
    }
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   150
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   151
    public void testDelimiter() {
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   152
        fixesStream().forEach(fixes -> {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   153
            StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   154
            StringJoiner other = new StringJoiner(":", fixes.pre1, fixes.suf1);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   155
            Stream.of("a", "b", "c").forEachOrdered(sj::add);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   156
            Stream.of("d", "e", "f").forEachOrdered(other::add);
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   157
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   158
            sj.merge(other);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   159
            assertEquals(sj.toString(), fixes.pre0 + "a,b,c,d:e:f" + fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   160
        });
18778
7214a903b084 8017231: Add StringJoiner.merge
alanb
parents:
diff changeset
   161
    }
19071
bc096b85d91d 8020977: StringJoiner merges with itself not as expected
henryjen
parents: 18778
diff changeset
   162
bc096b85d91d 8020977: StringJoiner merges with itself not as expected
henryjen
parents: 18778
diff changeset
   163
    public void testMergeSelf() {
25967
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   164
        fixesStream().forEach(fixes -> {
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   165
            final StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0).add("a").add("b");
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   166
            assertEquals(sj.merge(sj).toString(), fixes.pre0 + "a,b,a,b" + fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   167
            assertEquals(sj.merge(sj).toString(), fixes.pre0 + "a,b,a,b,a,b,a,b" + fixes.suf0);
0060a996fe1c 8054221: StringJoiner imlementation optimization
igerasim
parents: 19071
diff changeset
   168
        });
19071
bc096b85d91d 8020977: StringJoiner merges with itself not as expected
henryjen
parents: 18778
diff changeset
   169
    }
bc096b85d91d 8020977: StringJoiner merges with itself not as expected
henryjen
parents: 18778
diff changeset
   170
}