1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
//
// Test Suite for C-API GEOSReverse
#include <tut/tut.hpp>
// geos
#include <geos_c.h>
#include "capi_test_utils.h"
namespace tut {
//
// Test Group
//
// Common data used in test cases.
struct test_capigeosreverse : public capitest::utility {
};
typedef test_group<test_capigeosreverse> group;
typedef group::object object;
group test_capigeosreverse_group("capi::GEOSReverse");
void
testReverse(const std::string& wkt_input,
const std::string& wkt_output)
{
GEOSGeometry* input = GEOSGeomFromWKT(wkt_input.c_str());
GEOSGeometry* expected_result = GEOSGeomFromWKT(wkt_output.c_str());
GEOSGeometry* result = GEOSReverse(input);
ensure(result != nullptr);
ensure_equals(1, GEOSEqualsExact(result, expected_result, 0.0));
GEOSGeom_destroy(input);
GEOSGeom_destroy(expected_result);
GEOSGeom_destroy(result);
}
//
// Test Cases
//
template<>
template<>
void object::test<1>
()
{
testReverse("POINT (3 5)", "POINT (3 5)");
}
template<>
template<>
void object::test<2>
()
{
testReverse("MULTIPOINT ((100 100), (10 100), (30 100))",
"MULTIPOINT ((100 100), (10 100), (30 100))");
}
template<>
template<>
void object::test<3>
()
{
testReverse("LINESTRING (200 200, 200 100)",
"LINESTRING (200 100, 200 200)");
}
template<>
template<>
void object::test<4>
()
{
testReverse("MULTILINESTRING ((1 1, 2 2), (3 3, 4 4))",
"MULTILINESTRING ((2 2, 1 1), (4 4, 3 3))");
}
template<>
template<>
void object::test<5>
()
{
testReverse("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))",
"POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))");
}
template<>
template<>
void object::test<6>
()
{
testReverse("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((100 100, 100 200, 200 200, 100 100)))",
"MULTIPOLYGON (((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), ((100 100, 200 200, 100 200, 100 100)))");
}
template<>
template<>
void object::test<7>
()
{
testReverse("GEOMETRYCOLLECTION (LINESTRING (1 1, 2 2), GEOMETRYCOLLECTION(LINESTRING (3 5, 2 9)))",
"GEOMETRYCOLLECTION (LINESTRING (2 2, 1 1), GEOMETRYCOLLECTION(LINESTRING (2 9, 3 5)))");
}
template<>
template<>
void object::test<8>
()
{
testReverse("POINT EMPTY", "POINT EMPTY");
testReverse("LINESTRING EMPTY", "LINESTRING EMPTY");
testReverse("LINEARRING EMPTY", "LINEARRING EMPTY");
testReverse("POLYGON EMPTY", "POLYGON EMPTY");
testReverse("MULTIPOINT EMPTY", "MULTIPOINT EMPTY");
testReverse("MULTILINESTRING EMPTY", "MULTILINESTRING EMPTY");
testReverse("MULTIPOLYGON EMPTY", "MULTIPOLYGON EMPTY");
testReverse("GEOMETRYCOLLECTION EMPTY", "GEOMETRYCOLLECTION EMPTY");
}
template<>
template<>
void object::test<9>()
{
testReverse("CIRCULARSTRING (0 0, 1 1, 2 0)",
"CIRCULARSTRING (2 0, 1 1, 0 0)");
}
} // namespace tut
|