more copy/move tests

This commit is contained in:
artemp 2014-05-28 15:19:14 +01:00
parent 0669e190de
commit 01ac0fb7d9

View file

@ -2,6 +2,7 @@
#include <iostream>
//#include <mapnik/value_types.hpp>
#include <mapnik/map.hpp>
#include <mapnik/datasource_cache.hpp>
//#include <mapnik/params.hpp>
//#include <mapnik/boolean.hpp>
@ -18,9 +19,47 @@ int main(int argc, char** argv)
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
mapnik::Map m0(100,100);
mapnik::Map m1(100,100);
mapnik::Map m2(200,100);
// mapnik::datasource
mapnik::datasource_cache::instance().register_datasources("plugins/input/");
mapnik::parameters p;
p["type"]="shape";
p["file"]="demo/data/boundaries";
p["encoding"]="latin1";
auto ds0 = mapnik::datasource_cache::instance().create(p);
auto ds1 = ds0; // shared ptr copy
BOOST_TEST(ds1 == ds0);
BOOST_TEST(*ds1 == *ds0);
ds1 = mapnik::datasource_cache::instance().create(p); // new with the same parameters
BOOST_TEST(ds1 != ds0);
BOOST_TEST(*ds1 == *ds0);
auto ds2 = std::move(ds1);
BOOST_TEST(ds2 != ds0);
BOOST_TEST(*ds2 == *ds0);
// mapnik::layer
mapnik::layer l0("test-layer");
l0.set_datasource(ds0);
mapnik::layer l1 = l0; // copy assignment
BOOST_TEST(l1 == l0);
mapnik::layer l2(l0); // copy ctor
BOOST_TEST(l2 == l0);
mapnik::layer l3(mapnik::layer("test-layer")); // move ctor
l3.set_datasource(ds2);
BOOST_TEST(l3 == l0);
mapnik::layer l4 = std::move(l3);
BOOST_TEST(l4 == l0); // move assignment
m0.add_layer(l4);
m0.set_background(mapnik::color("skyblue"));
m2.set_background(mapnik::color("skyblue"));
auto m1 = m0;
BOOST_TEST(m0 == m1);
BOOST_TEST(m0 != m2);
@ -30,6 +69,9 @@ int main(int argc, char** argv)
BOOST_TEST(m2 == m0);
BOOST_TEST(m1 != m0);
BOOST_TEST(m0 == m2);
if (!::boost::detail::test_errors())
{
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";