more cpp test cleanup

This commit is contained in:
Dane Springmeyer 2013-05-25 18:16:18 -07:00
parent 738c2e5566
commit a41c2205d5
6 changed files with 56 additions and 35 deletions

View file

@ -8,7 +8,7 @@ failures=$((failures+$?))
echo "*** Running C++ tests..."
for FILE in tests/cpp_tests/*-bin; do
${FILE} -q;
${FILE} -q -d .;
failures=$((failures+$?))
done

View file

@ -21,6 +21,7 @@
//#include "agg_path_storage.h"
//#include "agg_conv_clipper.h"
#include "utils.hpp"
template <typename T>
std::string dump_path(T & path)
@ -87,6 +88,9 @@ int main(int argc, char** argv)
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
try {
BOOST_TEST(set_working_dir(args));
std::string filename("tests/cpp_tests/data/cases.txt");
std::ifstream stream(filename.c_str(),std::ios_base::in | std::ios_base::binary);
if (!stream.is_open())

View file

@ -261,6 +261,12 @@ int main(int argc, char** argv)
to_string(out,mapnik::value_integer(9223372036854775807));
BOOST_TEST_EQ( out, "9223372036854775807" );
out.clear();
#else
#ifdef _MSC_VER
#pragma NOTE("BIGINT not defined so skipping large number conversion tests")
#else
#warning BIGINT not defined so skipping large number conversion tests
#endif
#endif
// bool
to_string(out, true);

View file

@ -22,6 +22,8 @@
#include <vector>
#include <algorithm>
#include "utils.hpp"
int main(int argc, char** argv)
{
std::vector<std::string> args;
@ -32,6 +34,7 @@ int main(int argc, char** argv)
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
try {
BOOST_TEST(set_working_dir(args));
mapnik::projection srs("foo");
// to avoid unused variable warning
srs.params();

View file

@ -20,6 +20,8 @@
#include <vector>
#include <algorithm>
#include "utils.hpp"
int main(int argc, char** argv)
{
std::vector<std::string> args;
@ -29,41 +31,43 @@ int main(int argc, char** argv)
}
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
// create a renderable map with a fontset and a text symbolizer
// and do not register any fonts, to ensure the error thrown is reasonable
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
ctx->push("name");
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1));
mapnik::transcoder tr("utf-8");
UnicodeString ustr = tr.transcode("hello world!");
feature->put("name",ustr);
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
pt->move_to(128,128);
feature->add_geometry(pt);
mapnik::datasource_ptr memory_ds = boost::make_shared<mapnik::memory_datasource>();
mapnik::memory_datasource *cache = dynamic_cast<mapnik::memory_datasource *>(memory_ds.get());
cache->push(feature);
mapnik::Map m(256,256);
mapnik::font_set fontset("fontset");
// NOTE: this is a valid font, but will fail because none are registered
fontset.add_face_name("DejaVu Sans Book");
m.insert_fontset("fontset", fontset);
mapnik::layer lyr("layer");
lyr.set_datasource(memory_ds);
lyr.add_style("style");
m.addLayer(lyr);
mapnik::feature_type_style the_style;
mapnik::rule the_rule;
mapnik::text_symbolizer text_sym(mapnik::parse_expression("[name]"),10,mapnik::color(0,0,0));
text_sym.set_fontset(fontset);
the_rule.append(text_sym);
the_style.add_rule(the_rule);
m.insert_style("style",the_style );
m.zoom_to_box(mapnik::box2d<double>(-256,-256,
256,256));
mapnik::image_32 buf(m.width(),m.height());
mapnik::agg_renderer<mapnik::image_32> ren(m,buf);
try {
BOOST_TEST(set_working_dir(args));
// create a renderable map with a fontset and a text symbolizer
// and do not register any fonts, to ensure the error thrown is reasonable
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
ctx->push("name");
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1));
mapnik::transcoder tr("utf-8");
UnicodeString ustr = tr.transcode("hello world!");
feature->put("name",ustr);
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
pt->move_to(128,128);
feature->add_geometry(pt);
mapnik::datasource_ptr memory_ds = boost::make_shared<mapnik::memory_datasource>();
mapnik::memory_datasource *cache = dynamic_cast<mapnik::memory_datasource *>(memory_ds.get());
cache->push(feature);
mapnik::Map m(256,256);
mapnik::font_set fontset("fontset");
// NOTE: this is a valid font, but will fail because none are registered
fontset.add_face_name("DejaVu Sans Book");
m.insert_fontset("fontset", fontset);
mapnik::layer lyr("layer");
lyr.set_datasource(memory_ds);
lyr.add_style("style");
m.addLayer(lyr);
mapnik::feature_type_style the_style;
mapnik::rule the_rule;
mapnik::text_symbolizer text_sym(mapnik::parse_expression("[name]"),10,mapnik::color(0,0,0));
text_sym.set_fontset(fontset);
the_rule.append(text_sym);
the_style.add_rule(the_rule);
m.insert_style("style",the_style );
m.zoom_to_box(mapnik::box2d<double>(-256,-256,
256,256));
mapnik::image_32 buf(m.width(),m.height());
mapnik::agg_renderer<mapnik::image_32> ren(m,buf);
ren.apply();
} catch (std::exception const& ex) {
BOOST_TEST_EQ(std::string(ex.what()),std::string("No valid font face could be loaded for font set: 'fontset'"));

View file

@ -20,6 +20,8 @@
#include <vector>
#include <algorithm>
#include "utils.hpp"
struct output_geometry_backend
{
output_geometry_backend(boost::ptr_vector<mapnik::geometry_type> & paths, mapnik::eGeomType type)
@ -133,6 +135,8 @@ int main(int argc, char** argv)
}
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
BOOST_TEST(set_working_dir(args));
// LineString/bbox clipping
{
std::string wkt_in("LineString(0 0,200 200)");