### Question:
SQLServerGeometryWriter { public byte[] write(Geometry geometry) throws IOException { visit(geometry, -1); int bytes = calculateCapacity(geometry); boolean singlePoint = geometry instanceof Point; ByteBuffer buffer = ByteBuffer.allocate(bytes); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(geometry.getSRID()); buffer.put((byte) 1); buffer.put((byte) ((geometry.is3D() ? 1 : 0) + (geometry.isMeasured() ? 2 : 0) + 4 + (singlePoint ? 8 : 0) + 0)); if (!singlePoint) { buffer.putInt(points.size()); } for (Point point : points) { buffer.putDouble(point.getX()); buffer.putDouble(point.getY()); } if (geometry.is3D()) { for (Point point : points) { buffer.putDouble(point.getZ()); } } if (geometry.isMeasured()) { for (Point point : points) { buffer.putDouble(point.getM()); } } if (!singlePoint) { buffer.putInt(figures.size()); for (Figure figure : figures) { buffer.put((byte) figure.attributes); buffer.putInt(figure.pointOffset); } buffer.putInt(shapes.size()); for (Shape shape : shapes) { buffer.putInt(shape.parentOffset); buffer.putInt(shape.figureOffset); buffer.put((byte) shape.type); } } return buffer.array(); }  byte[] write(Geometry geometry); void visit(Point point, int parent); void visit(LineString lineString, int parent); void visit(Polygon polygon, int parent); void visit(MultiPoint collection, int parent); void visit(MultiLineString collection, int parent); void visit(MultiPolygon collection, int parent); void visit(GeometryCollection collection, int parent); void visit(PolyHedralSurface surface, int parent);  }### Answer:
@Test public void roundTrip() throws IOException { for (Geometry geometry : getGeometries()) { byte[] bytes = new SQLServerGeometryWriter().write(geometry); Geometry geometry2 = new SQLServerGeometryReader().read(bytes); assertEquals(geometry, geometry2); } }