File: combined_test.cpp

package info (click to toggle)
mapnik 2.0.0%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 35,496 kB
  • sloc: cpp: 91,793; python: 6,051; xml: 3,528; sh: 848; makefile: 70; lisp: 10
file content (56 lines) | stat: -rw-r--r-- 1,568 bytes parent folder | download
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
53
54
55
56
#define BOOST_TEST_MODULE combined_tests

// boost.test
#include <boost/test/included/unit_test.hpp>

// mapnik
#include <mapnik/map.hpp>
#include <mapnik/svg_renderer.hpp>
#include <mapnik/color_factory.hpp>

// std
#include <string>
#include <sstream>
#include <iterator>

/**
 * This test case tests all the generators inside svg_renderer,
 * verifying the correctness of the whole SVG document.
 *
 * The test sets the svg_renderer object with a simple Map that
 * has only its dimensions specified and calls the apply()
 * method to produce the output.
 *
 * The output stream is a stringstream (the output is generated
 * into a stringstream).
 */
BOOST_AUTO_TEST_CASE(combined_test_case)
{
    using namespace mapnik;
    typedef svg_renderer<std::ostream_iterator<char> > svg_ren;

    Map map(800, 600);
    map.set_background(color_factory::from_string("white"));

    std::ostringstream output_stream;
    std::ostream_iterator<char> output_stream_iterator(output_stream);
    svg_ren renderer(map, output_stream_iterator);
    renderer.apply();

    std::string expected_output = 
        svg_ren::XML_DECLARATION 
        + "\n" 
        + svg_ren::SVG_DTD 
        + "\n" 
        + "<svg width=\"800px\" height=\"600px\" version=\"1.1\" xmlns=\"" 
        + svg_ren::SVG_NAMESPACE_URL 
        + "\">"
        +"\n"
        +"<rect x=\"0\" y=\"0\" width=\"800px\" height=\"600px\" style=\"fill: #ffffff\"/>"
        +"\n"
        +"</svg>";

    std::string actual_output = output_stream.str();
    BOOST_CHECK_EQUAL(actual_output, expected_output);
}