File: datasource_registration_test.cpp

package info (click to toggle)
mapnik 4.2.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,592 kB
  • sloc: cpp: 163,859; python: 1,332; sh: 690; xml: 161; makefile: 123; perl: 28; lisp: 13
file content (52 lines) | stat: -rw-r--r-- 1,750 bytes parent folder | download | duplicates (2)
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
#define CATCH_CONFIG_MAIN
#include "catch.hpp"

#include <mapnik/mapnik.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/util/fs.hpp>

#include <iostream>
#include <vector>
#include <algorithm>

TEST_CASE("datasource_cache")
{
    mapnik::setup();
    SECTION("registration")
    {
        try
        {
            bool success = false;
            auto& cache = mapnik::datasource_cache::instance();

            // registering a directory without any plugins should return false
            success = cache.register_datasources("test/data/vrt");
            CHECK(success == false);

            // use existence of shape.input as proxy for whether any datasource plugins are available
            std::string shape_plugin("./plugins/input/shape.input");
            if (mapnik::util::exists(shape_plugin))
            {
                // registering a directory for the first time should return true
                success = cache.register_datasources("plugins/input");
                REQUIRE(success == true);

                // registering the same directory again should now return false
                success = cache.register_datasources("plugins/input");
                CHECK(success == false);

                // registering the same directory again, but recursively should
                // still return false - even though there are subdirectories, they
                // do not contain any more plugins.
                success = cache.register_datasources("plugins/input", true);
                CHECK(success == false);
            }
        }
        catch (std::exception const& ex)
        {
            std::clog << ex.what() << "\n";
            REQUIRE(false);
        }
    }
}