File: GEOSGeom_createTest.cpp

package info (click to toggle)
geos 3.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,212 kB
  • sloc: cpp: 199,103; xml: 56,065; ansic: 6,162; sh: 287; makefile: 26
file content (175 lines) | stat: -rw-r--r-- 3,425 bytes parent folder | download
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//
// Test Suite for C-API GEOSGeom_createPolygon

#include <tut/tut.hpp>
// geos
#include <geos_c.h>
// std
#include <cstdio>
#include <cstdlib>

#include "capi_test_utils.h"

namespace tut {
//
// Test Group
//

// Common data used in test cases.
struct test_capigeosgeom_create_data  : public capitest::utility
{
    GEOSGeometry* geom1_;

    test_capigeosgeom_create_data()
        : geom1_(nullptr)
    {
    }

    ~test_capigeosgeom_create_data()
    {
        GEOSGeom_destroy(geom1_);
        geom1_ = nullptr;
    }

};

typedef test_group<test_capigeosgeom_create_data> group;
typedef group::object object;

group test_capigeosgeom_create_group("capi::GEOSGeom_create");

//
// Test Cases
//

// EMPTY point
template<>
template<>
void object::test<1>
()
{
    geom1_ = GEOSGeom_createEmptyPoint();
    ensure(0 != GEOSisEmpty(geom1_));
    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_POINT);

    ensure_equals(GEOSHasZ(geom1_), 0);
    ensure_equals(GEOSHasM(geom1_), 0);

    GEOSGeom_destroy(geom1_);
    geom1_ = nullptr;
}

// EMPTY linestring
template<>
template<>
void object::test<2>
()
{
    geom1_ = GEOSGeom_createEmptyLineString();
    ensure(0 != GEOSisEmpty(geom1_));
    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_LINESTRING);

    ensure_equals(GEOSHasZ(geom1_), 0);
    ensure_equals(GEOSHasM(geom1_), 0);

    GEOSGeom_destroy(geom1_);
    geom1_ = nullptr;
}


// EMPTY polygon
template<>
template<>
void object::test<3>
()
{
    geom1_ = GEOSGeom_createEmptyPolygon();
    ensure(0 != GEOSisEmpty(geom1_));
    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_POLYGON);

    ensure_equals(GEOSHasZ(geom1_), 0);
    ensure_equals(GEOSHasM(geom1_), 0);

    GEOSGeom_destroy(geom1_);
    geom1_ = nullptr;
}

// EMPTY multipoint
template<>
template<>
void object::test<4>
()
{
    geom1_ = GEOSGeom_createEmptyCollection(GEOS_MULTIPOINT);
    ensure(0 != GEOSisEmpty(geom1_));
    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_MULTIPOINT);

    ensure_equals(GEOSHasZ(geom1_), 0);
    ensure_equals(GEOSHasM(geom1_), 0);

    GEOSGeom_destroy(geom1_);
    geom1_ = nullptr;
}

// EMPTY multilinestring
template<>
template<>
void object::test<5>
()
{
    geom1_ = GEOSGeom_createEmptyCollection(GEOS_MULTILINESTRING);
    ensure(0 != GEOSisEmpty(geom1_));
    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_MULTILINESTRING);

    ensure_equals(GEOSHasZ(geom1_), 0);
    ensure_equals(GEOSHasM(geom1_), 0);

    GEOSGeom_destroy(geom1_);
    geom1_ = nullptr;
}

// EMPTY multipolygon
template<>
template<>
void object::test<6>
()
{
    geom1_ = GEOSGeom_createEmptyCollection(GEOS_MULTIPOLYGON);
    ensure(0 != GEOSisEmpty(geom1_));
    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_MULTIPOLYGON);

    ensure_equals(GEOSHasZ(geom1_), 0);
    ensure_equals(GEOSHasM(geom1_), 0);

    GEOSGeom_destroy(geom1_);
    geom1_ = nullptr;
}

// EMPTY collection
template<>
template<>
void object::test<7>
()
{
    geom1_ = GEOSGeom_createEmptyCollection(GEOS_GEOMETRYCOLLECTION);
    ensure(0 != GEOSisEmpty(geom1_));
    ensure_equals(GEOSGeomTypeId(geom1_), GEOS_GEOMETRYCOLLECTION);

    ensure_equals(GEOSHasZ(geom1_), 0);
    ensure_equals(GEOSHasM(geom1_), 0);

    GEOSGeom_destroy(geom1_);
    geom1_ = nullptr;
}

template<>
template<>
void object::test<8>()
{
    input_ = GEOSGeom_createLineString(NULL);
    ensure_equals(GEOSHasZ(input_), 0);
    ensure_equals(GEOSHasM(input_), 0);
}

} // namespace tut