source: trunk/tests/xmltester/XMLTester.h

Last change on this file was 4091, checked in by strk, 9 years ago

Prevent stack allocation of GeometryFactory

Geometry factory objects can be created by static methods
returning a smart pointer with automatic ownership transfer
semantic. The so-created GeometryFactory will be kept alive
as long as Geometry objects referencing it will be alive.

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain
File size: 2.8 KB
Line 
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2005 Refractions Research Inc.
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************/
14
15#ifndef GEOS_XMLTESTER_H
16#define GEOS_XMLTESTER_H
17
18#include <geos/geom/GeometryFactory.h>
19#include <geos/geom/PrecisionModel.h>
20#include <geos/profiler.h>
21#include "tinyxml/tinyxml.h"
22
23using namespace geos;
24
25class XMLTester {
26
27private:
28 enum {
29 SHOW_RUN_INFO=1,
30 SHOW_CASE,
31 SHOW_TEST,
32 SHOW_RESULT,
33 SHOW_GEOMS,
34 SHOW_GEOMS_FULL,
35 PRED
36 };
37
38 void parsePrecisionModel(const TiXmlElement* el);
39 void parseRun(const TiXmlNode* node);
40 void parseCase(const TiXmlNode* node);
41 void parseTest(const TiXmlNode* node);
42 void runPredicates(const geom::Geometry *a, const geom::Geometry *b);
43 geom::Geometry *parseGeometry(const std::string &in, const char* label="parsed");
44 static std::string trimBlanks(const std::string &in);
45 void printGeom(std::ostream& os, const geom::Geometry *g);
46 std::string printGeom(const geom::Geometry *g);
47 void printTest(bool success, const std::string& expected_result, const std::string& actual_result, const util::Profile&);
48
49 geom::Geometry *gA;
50 geom::Geometry *gB;
51 geom::Geometry *gT;
52
53 std::auto_ptr<geom::PrecisionModel> pm;
54 geom::GeometryFactory::unique_ptr factory;
55 std::auto_ptr<io::WKTReader> wktreader;
56 std::auto_ptr<io::WKTWriter> wktwriter;
57 std::auto_ptr<io::WKBReader> wkbreader;
58 std::auto_ptr<io::WKBWriter> wkbwriter;
59 TiXmlDocument xml;
60
61 int verbose;
62 int test_predicates;
63
64 int failed;
65 int succeeded;
66 int caseCount;
67 int testCount;
68 std::string opSignature;
69
70 int testFileCount;
71 int totalTestCount;
72
73 const std::string *curr_file;
74 std::string curr_case_desc;
75
76 bool testValidOutput;
77 bool testValidInput;
78 bool sqlOutput;
79 bool HEXWKB_output;
80
81 bool testValid(const geom::Geometry* g, const std::string& label);
82
83public:
84 XMLTester();
85 ~XMLTester();
86 void run(const std::string &testFile);
87 void resultSummary(std::ostream &os) const;
88 void resetCounters();
89
90 /*
91 * Values:
92 * 0: Show case description, run tests, show result
93 * 1: Show parsed geometry values
94 * 2: Run predicates
95 *
96 * Return previously set verbosity level
97 */
98 int setVerbosityLevel(int val);
99
100 int getFailuresCount() { return failed; }
101
102 void testOutputValidity(bool val) { testValidOutput=val; }
103 void testInputValidity(bool val) { testValidInput=val; }
104 void setSQLOutput(bool val) { sqlOutput=val; }
105 void setHEXWKBOutput(bool val) { HEXWKB_output=val; }
106
107};
108
109#endif // GEOS_XMLTESTER_H
Note: See TracBrowser for help on using the repository browser.