Developer/UnitTests

Developer/Unit Tests

 Unit tests of Generic Geometry Library are implemented with use of tools from  Boost Test library.

The main goals of preparing unit tests are:

  • Testing core elements
  • Testing algorithms
  • Testing geometries and concepts

Preparing Unit Tests

These are only basic guidelines and notes about tests structure:

  • test_main is provided by Boost
  • in test_main call test_all to test for all geometries, using different point types
  • in test_all call test_geometry for different geometries (linestring, polygon, box, etc.)

The above works for generic algorithms working the same for all geometries (such as append).

Other tests will need more specific test cases, so then:

  • in test_all call test_point, test_linestring, test_polygon, etc.
  • there might be specific cases for, e.g., different strategies

Namespaces

  • Unit tests use in general a namespace alias: namespace bg = boost::geometry; to avoid long lines

Header files

  • Unit tests use in general a header file with some common includes: #include <geometry_test_common.hpp>
  • Unit tests do not use #include <boost/geometry/geometry.hpp> to avoid automatic inclusion of everything

WKT

  • WKT (Well Known Text) is a convenient mechanism to test functions for different geometry types (linestring, ring, polygon, etc)

Developer