1 //
2 // Test Suite for C-API GEOSConvexHull
3
4 #include <tut/tut.hpp>
5 // geos
6 #include <geos_c.h>
7 // std
8 #include <cstdarg>
9 #include <cstdio>
10 #include <cstdlib>
11
12 namespace tut {
13 //
14 // Test Group
15 //
16
17 // Common data used in test cases.
18 struct test_capigeosconvexhull_data {
19 GEOSGeometry* input_;
20 GEOSGeometry* expected_;
21
22 static void
noticetut::test_capigeosconvexhull_data23 notice(const char* fmt, ...)
24 {
25 std::fprintf(stdout, "NOTICE: ");
26
27 va_list ap;
28 va_start(ap, fmt);
29 std::vfprintf(stdout, fmt, ap);
30 va_end(ap);
31
32 std::fprintf(stdout, "\n");
33 }
34
test_capigeosconvexhull_datatut::test_capigeosconvexhull_data35 test_capigeosconvexhull_data()
36 : input_(nullptr), expected_(nullptr)
37 {
38 initGEOS(notice, notice);
39 }
40
~test_capigeosconvexhull_datatut::test_capigeosconvexhull_data41 ~test_capigeosconvexhull_data()
42 {
43 GEOSGeom_destroy(input_);
44 GEOSGeom_destroy(expected_);
45 input_ = nullptr;
46 expected_ = nullptr;
47 finishGEOS();
48 }
49
50 };
51
52 typedef test_group<test_capigeosconvexhull_data> group;
53 typedef group::object object;
54
55 group test_capigeosconvexhull_group("capi::GEOSConvexHull");
56
57 //
58 // Test Cases
59 //
60
61 template<>
62 template<>
test()63 void object::test<1>
64 ()
65 {
66 input_ = GEOSGeomFromWKT("MULTIPOINT (130 240, 130 240, 130 240, 570 240, 570 240, 570 240, 650 240)");
67 ensure(nullptr != input_);
68
69 expected_ = GEOSGeomFromWKT("LINESTRING (130 240, 650 240, 130 240)");
70 ensure(nullptr != expected_);
71
72 GEOSGeometry* output = GEOSConvexHull(input_);
73 ensure(nullptr != output);
74 ensure(0 == GEOSisEmpty(output));
75 // TODO
76 //ensure( 0 != GEOSEquals(output, expected_));
77 GEOSGeom_destroy(output);
78 }
79
80 } // namespace tut
81
82