Skip to content

Commit ba02b13

Browse files
committed
Improve BufferCommand test coverage
1 parent 9af8422 commit ba02b13

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/test/java/org/geometrycommands/BufferCommandTest.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ public void execute() throws Exception {
6363
command = new BufferCommand();
6464
command.execute(options, reader, writer);
6565
assertEquals(polygonWkt, writer.getBuffer().toString());
66+
67+
// Single sided
68+
options = new BufferOptions();
69+
options.setDistance(10);
70+
options.setSingleSided(true);
71+
options.setEndCapStyle("square");
72+
options.setQuadrantSegements(6);
73+
74+
reader = new StringReader("LINESTRING (0 1, 2 3, 4 5)");
75+
writer = new StringWriter();
76+
77+
command = new BufferCommand();
78+
command.execute(options, reader, writer);
79+
assertEquals("POLYGON ((4 5, 2 3, 0 1, -7.071067811865475 8.071067811865476, " +
80+
"-3.0710678118654746 12.071067811865476, 4 5))", writer.getBuffer().toString());
6681
}
6782

6883
@Test
@@ -81,6 +96,36 @@ public void run() throws Exception {
8196
"-d", "10"
8297
}, "POINT (100 100)");
8398
assertEquals(polygonWkt, result);
99+
100+
// Butt
101+
result = runApp(new String[]{
102+
"buffer",
103+
"-d", "10",
104+
"-c", "butt"
105+
}, "LINESTRING (0 1, 2 3, 4 5)");
106+
assertEquals("POLYGON ((-3.0710678118654746 12.071067811865476, 11.071067811865476 -2.0710678118654746, " +
107+
"7.071067811865475 -6.071067811865475, -7.071067811865475 8.071067811865476, " +
108+
"-3.0710678118654746 12.071067811865476))", result);
109+
110+
// Flat
111+
result = runApp(new String[]{
112+
"buffer",
113+
"-d", "10",
114+
"-c", "flat"
115+
}, "LINESTRING (0 1, 2 3, 4 5)");
116+
assertEquals("POLYGON ((-3.0710678118654746 12.071067811865476, 11.071067811865476 -2.0710678118654746, " +
117+
"7.071067811865475 -6.071067811865475, -7.071067811865475 8.071067811865476, " +
118+
"-3.0710678118654746 12.071067811865476))", result);
119+
120+
// Square
121+
result = runApp(new String[]{
122+
"buffer",
123+
"-d", "10",
124+
"-c", "square"
125+
}, "LINESTRING (0 1, 2 3, 4 5)");
126+
assertEquals("POLYGON ((-3.0710678118654746 12.071067811865476, 4.000000000000001 19.14213562373095, " +
127+
"18.14213562373095 5, 7.071067811865475 -6.071067811865475, 0 -13.142135623730951, " +
128+
"-14.14213562373095 1, -3.0710678118654746 12.071067811865476))", result);
84129
}
85130

86131
}

0 commit comments

Comments
 (0)