[geos-commits] r3507 - in branches/3.3/tests/unit: . operation/buffer

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Oct 26 12:08:56 EDT 2011


Author: strk
Date: 2011-10-26 09:08:55 -0700 (Wed, 26 Oct 2011)
New Revision: 3507

Added:
   branches/3.3/tests/unit/operation/buffer/BufferParametersTest.cpp
Modified:
   branches/3.3/tests/unit/Makefile.am
Log:
Add test for BufferParameters class

Modified: branches/3.3/tests/unit/Makefile.am
===================================================================
--- branches/3.3/tests/unit/Makefile.am	2011-10-26 14:29:06 UTC (rev 3506)
+++ branches/3.3/tests/unit/Makefile.am	2011-10-26 16:08:55 UTC (rev 3507)
@@ -78,6 +78,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: branches/3.3/tests/unit/operation/buffer/BufferParametersTest.cpp
===================================================================
--- branches/3.3/tests/unit/operation/buffer/BufferParametersTest.cpp	                        (rev 0)
+++ branches/3.3/tests/unit/operation/buffer/BufferParametersTest.cpp	2011-10-26 16:08:55 UTC (rev 3507)
@@ -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