[geos-commits] r3508 - in trunk/tests/unit: . operation/buffer
svn_geos at osgeo.org
svn_geos at osgeo.org
Wed Oct 26 12:14:03 EDT 2011
Author: strk
Date: 2011-10-26 09:14:03 -0700 (Wed, 26 Oct 2011)
New Revision: 3508
Added:
trunk/tests/unit/operation/buffer/BufferParametersTest.cpp
Modified:
trunk/tests/unit/Makefile.am
Log:
Add test for BufferParameters class
Modified: trunk/tests/unit/Makefile.am
===================================================================
--- trunk/tests/unit/Makefile.am 2011-10-26 16:08:55 UTC (rev 3507)
+++ trunk/tests/unit/Makefile.am 2011-10-26 16:14:03 UTC (rev 3508)
@@ -77,6 +77,7 @@
noding/SegmentNodeTest.cpp \
noding/SegmentPointComparatorTest.cpp \
operation/buffer/BufferOpTest.cpp \
+ operation/buffer/BufferParametersTest.cpp \
operation/distance/DistanceOpTest.cpp \
operation/IsSimpleOpTest.cpp \
operation/linemerge/LineMergerTest.cpp \
Added: trunk/tests/unit/operation/buffer/BufferParametersTest.cpp
===================================================================
--- trunk/tests/unit/operation/buffer/BufferParametersTest.cpp (rev 0)
+++ trunk/tests/unit/operation/buffer/BufferParametersTest.cpp 2011-10-26 16:14:03 UTC (rev 3508)
@@ -0,0 +1,203 @@
+//
+// Test Suite for geos::operation::buffer::BufferParameters class.
+
+// tut
+#include <tut.hpp>
+// geos
+#include <geos/operation/buffer/BufferParameters.h>
+#include <geos/platform.h>
+// std
+#include <memory>
+
+namespace tut
+{
+ //
+ // Test Group
+ //
+
+ // Common data used by tests
+ struct test_bufferparameters_data
+ {
+ typedef geos::operation::buffer::BufferParameters BufferParameters;
+
+ test_bufferparameters_data() { }
+
+ private:
+ // noncopyable
+ test_bufferparameters_data(test_bufferparameters_data const& other);
+ test_bufferparameters_data& operator=(test_bufferparameters_data const& rhs);
+ };
+
+ typedef test_group<test_bufferparameters_data> group;
+ typedef group::object object;
+
+ group test_bufferparameters_group("geos::operation::buffer::BufferParameters");
+
+ //
+ // Test Cases
+ //
+
+ // Default constructor
+ template<>
+ template<>
+ void object::test<1>()
+ {
+ BufferParameters bp;
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ ensure_equals( bp.getQuadrantSegments(), int(8) );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // Constructor with single integer argument
+ template<>
+ template<>
+ void object::test<2>()
+ {
+ BufferParameters bp(16);
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ ensure_equals( bp.getQuadrantSegments(), int(16) );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // Constructor with quadrantSegments and EndCapStyle
+ template<>
+ template<>
+ void object::test<3>()
+ {
+ BufferParameters bp(16, BufferParameters::CAP_FLAT);
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_FLAT );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ ensure_equals( bp.getQuadrantSegments(), int(16) );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // Constructor with quadrantSegments and EndCapStyle (2)
+ template<>
+ template<>
+ void object::test<4>()
+ {
+ BufferParameters bp(16, BufferParameters::CAP_ROUND);
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ ensure_equals( bp.getQuadrantSegments(), int(16) );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // Constructor with quadrantSegments, EndCapStyle, JoinStyle and mitreLimit
+ template<>
+ template<>
+ void object::test<5>()
+ {
+ BufferParameters bp(31, BufferParameters::CAP_SQUARE,
+ BufferParameters::JOIN_MITRE,
+ 2.0);
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_SQUARE );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_MITRE );
+ ensure_equals( bp.getMitreLimit(), 2.0 );
+ ensure_equals( bp.getQuadrantSegments(), int(31) );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // setQuadrantSegments and getQuadrantSegments
+ template<>
+ template<>
+ void object::test<6>()
+ {
+ BufferParameters bp;
+ ensure_equals( bp.getQuadrantSegments(), int(8) );
+ bp.setQuadrantSegments(16);
+ ensure_equals( bp.getQuadrantSegments(), int(16) );
+ bp.setQuadrantSegments(3);
+ ensure_equals( bp.getQuadrantSegments(), int(3) );
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // setEndCapStyle and getEndCapStyle
+ template<>
+ template<>
+ void object::test<7>()
+ {
+ BufferParameters bp;
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
+ bp.setEndCapStyle( BufferParameters::CAP_FLAT );
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_FLAT );
+ bp.setEndCapStyle( BufferParameters::CAP_SQUARE );
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_SQUARE );
+
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ ensure_equals( bp.getQuadrantSegments(), int(8) );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // setJoinStyle and getJoinStyle
+ template<>
+ template<>
+ void object::test<8>()
+ {
+ BufferParameters bp;
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ bp.setJoinStyle( BufferParameters::JOIN_MITRE );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_MITRE );
+ bp.setJoinStyle( BufferParameters::JOIN_BEVEL );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_BEVEL );
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ ensure_equals( bp.getQuadrantSegments(), int(8) );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // setMitreLimit and getMitreLimit
+ template<>
+ template<>
+ void object::test<9>()
+ {
+ BufferParameters bp;
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ bp.setMitreLimit( 2.0 );
+ ensure_equals( bp.getMitreLimit(), 2.0 );
+ bp.setMitreLimit( 10.12 );
+ ensure_equals( bp.getMitreLimit(), 10.12 );
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ ensure_equals( bp.getQuadrantSegments(), int(8) );
+ ensure( ! bp.isSingleSided() );
+ }
+
+ // setSingleSided and getSingleSided
+ template<>
+ template<>
+ void object::test<10>()
+ {
+ BufferParameters bp;
+ ensure( ! bp.isSingleSided() );
+ bp.setSingleSided( true );
+ ensure( bp.isSingleSided() );
+ bp.setSingleSided( false );
+ ensure( ! bp.isSingleSided() );
+
+ ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
+ ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
+ ensure_equals( bp.getQuadrantSegments(), int(8) );
+ ensure_equals( bp.getMitreLimit(), 5.0 );
+ }
+
+} // namespace tut
+
More information about the geos-commits
mailing list