Skip to content

Commit 13ce4ab

Browse files
Copilotmicycle1
andcommitted
fix: align Path64/PathD toString formatting with C# 1.4 diff
Co-authored-by: micycle1 <9304234+micycle1@users.noreply.github.com>
1 parent d37acbf commit 13ce4ab

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/main/java/clipper2/core/Path64.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ public Path64(Point64... path) {
3636
public String toString() {
3737
StringBuilder s = new StringBuilder();
3838
for (Point64 p : this) {
39-
s.append(p.toString()).append(" ");
39+
s.append(p.toString()).append(", ");
40+
}
41+
if (!s.isEmpty()) {
42+
s.setLength(s.length() - 2);
4043
}
4144
return s.toString();
4245
}

src/main/java/clipper2/core/PathD.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public PathD(List<PointD> path) {
3131
public String toString() {
3232
StringBuilder s = new StringBuilder();
3333
for (PointD p : this) {
34-
s.append(p.toString()).append(" ");
34+
s.append(p.toString()).append(", ");
35+
}
36+
if (!s.isEmpty()) {
37+
s.setLength(s.length() - 2);
3538
}
3639
return s.toString();
3740
}

src/test/java/clipper2/TestToStringOutput.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ class TestToStringOutput {
1818
@Test
1919
void path64ToStringMatchesExistingFormat() {
2020
Path64 path = new Path64(new Point64(1, 2), new Point64(3, 4));
21-
assertEquals("(1,2) (3,4) ", path.toString());
21+
assertEquals("(1,2) , (3,4) ", path.toString());
2222
}
2323

2424
@Test
2525
void pathDToStringMatchesExistingFormat() {
2626
PathD path = new PathD(2);
2727
path.add(new PointD(1.5, 2.5));
2828
path.add(new PointD(3.5, 4.5));
29-
assertEquals("(1.500000,2.500000) (3.500000,4.500000) ", path.toString());
29+
assertEquals("(1.500000,2.500000) , (3.500000,4.500000) ", path.toString());
3030
}
3131

3232
@Test
3333
void paths64ToStringMatchesExistingFormat() {
3434
Paths64 paths = new Paths64(new Path64(new Point64(1, 2)));
35-
assertEquals("(1,2) \n", paths.toString());
35+
assertEquals("(1,2) \n", paths.toString());
3636
}
3737

3838
@Test
@@ -41,7 +41,7 @@ void pathsDToStringMatchesExistingFormat() {
4141
PathD path = new PathD(1);
4242
path.add(new PointD(1.5, 2.5));
4343
paths.add(path);
44-
assertEquals("(1.500000,2.500000) \n", paths.toString());
44+
assertEquals("(1.500000,2.500000) \n", paths.toString());
4545
}
4646

4747
@Test

0 commit comments

Comments
 (0)