1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.imagery;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import java.util.Arrays;
|
---|
7 |
|
---|
8 | import org.junit.jupiter.api.Test;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Unit tests for class {@link Shape}.
|
---|
12 | */
|
---|
13 | class ShapeTest {
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Tests string conversion
|
---|
17 | */
|
---|
18 | @Test
|
---|
19 | void test() {
|
---|
20 | Shape shape = new Shape();
|
---|
21 | shape.addPoint("47.1", "11.1");
|
---|
22 | shape.addPoint("47.2", "11.2");
|
---|
23 | shape.addPoint("47.3", "11.3");
|
---|
24 | String shapeString = "47.1 11.1 47.2 11.2 47.3 11.3";
|
---|
25 | Shape fromString = new Shape(shapeString, " ");
|
---|
26 | assertEquals(shape, fromString);
|
---|
27 | assertEquals(shapeString, shape.encodeAsString(" "));
|
---|
28 | assertEquals("47.1//11.1//47.2//11.2//47.3//11.3", shape.encodeAsString("//"));
|
---|
29 | assertEquals("47.1,11.1,47.2,11.2,47.3,11.3;47.1,11.1,47.2,11.2,47.3,11.3", Shape.encodeAsString(Arrays.asList(shape, shape)));
|
---|
30 | }
|
---|
31 | }
|
---|