File: TopologyLocationTest.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 (98 lines) | stat: -rw-r--r-- 2,363 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
//
// Test Suite for geos::geomgraph::TopologyLocation class.

// tut
#include <tut/tut.hpp>
// geos
#include <geos/geomgraph/TopologyLocation.h>
#include <geos/geom/Location.h>

using TopologyLocation = geos::geomgraph::TopologyLocation;
using Location = geos::geom::Location;

namespace tut {
//
// Test Group
//

// Common data used by tests
struct test_topologylocation_data {

    test_topologylocation_data() {}
};

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

group test_topologylocation_group("geos::geomgraph::TopologyLocation");

//
// Test Cases
//

// test constructors
template<>
template<>
void object::test<1>
()
{
    TopologyLocation a(Location::INTERIOR);
    ensure(a.isLine());
    ensure_equals(a.get(0), Location::INTERIOR);

    TopologyLocation b(Location::EXTERIOR, Location::INTERIOR, Location::BOUNDARY);
    ensure(b.isArea());
    ensure_equals(b.get(0), Location::EXTERIOR);
    ensure_equals(b.get(1), Location::INTERIOR);
    ensure_equals(b.get(2), Location::BOUNDARY);
}

// test basic setters
template<>
template<>
void object::test<2>
()
{
    TopologyLocation b(Location::EXTERIOR, Location::INTERIOR, Location::BOUNDARY);

    ensure_equals(b.get(0), Location::EXTERIOR);
    ensure_equals(b.get(1), Location::INTERIOR);
    ensure_equals(b.get(2), Location::BOUNDARY);

    b.setLocation(0, Location::INTERIOR);
    b.setLocation(1, Location::BOUNDARY);
    b.setLocation(2, Location::EXTERIOR);

    ensure_equals(b.get(0), Location::INTERIOR);
    ensure_equals(b.get(1), Location::BOUNDARY);
    ensure_equals(b.get(2), Location::EXTERIOR);
}

// test setAllLocations()
template<>
template<>
void object::test<3>
()
{
    TopologyLocation b(Location::EXTERIOR, Location::INTERIOR, Location::BOUNDARY);

    b.setAllLocations(Location::NONE);

    ensure_equals(b.get(0), Location::NONE);
    ensure_equals(b.get(1), Location::NONE);
    ensure_equals(b.get(2), Location::NONE);

    b.setLocation(0, Location::BOUNDARY);

    ensure_equals(b.get(0), Location::BOUNDARY);
    ensure_equals(b.get(1), Location::NONE);
    ensure_equals(b.get(2), Location::NONE);

    b.setAllLocationsIfNull(Location::EXTERIOR);

    ensure_equals(b.get(0), Location::BOUNDARY);
    ensure_equals(b.get(1), Location::EXTERIOR);
    ensure_equals(b.get(2), Location::EXTERIOR);
}

} // namespace tut