more copy/move tests
This commit is contained in:
parent
0669e190de
commit
01ac0fb7d9
1 changed files with 43 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
//#include <mapnik/value_types.hpp>
|
//#include <mapnik/value_types.hpp>
|
||||||
#include <mapnik/map.hpp>
|
#include <mapnik/map.hpp>
|
||||||
|
#include <mapnik/datasource_cache.hpp>
|
||||||
//#include <mapnik/params.hpp>
|
//#include <mapnik/params.hpp>
|
||||||
//#include <mapnik/boolean.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();
|
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
|
||||||
|
|
||||||
mapnik::Map m0(100,100);
|
mapnik::Map m0(100,100);
|
||||||
mapnik::Map m1(100,100);
|
|
||||||
mapnik::Map m2(200,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 == m1);
|
||||||
BOOST_TEST(m0 != m2);
|
BOOST_TEST(m0 != m2);
|
||||||
|
|
||||||
|
@ -30,6 +69,9 @@ int main(int argc, char** argv)
|
||||||
BOOST_TEST(m2 == m0);
|
BOOST_TEST(m2 == m0);
|
||||||
BOOST_TEST(m1 != m0);
|
BOOST_TEST(m1 != m0);
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_TEST(m0 == m2);
|
||||||
|
|
||||||
if (!::boost::detail::test_errors())
|
if (!::boost::detail::test_errors())
|
||||||
{
|
{
|
||||||
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
|
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
|
||||||
|
|
Loading…
Add table
Reference in a new issue