File: XMLTester.h

package info (click to toggle)
geos 3.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 28,996 kB
  • sloc: cpp: 157,310; xml: 53,816; ansic: 6,956; sh: 302; makefile: 30
file content (130 lines) | stat: -rw-r--r-- 3,272 bytes parent folder | download | duplicates (2)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.osgeo.org
 *
 * Copyright (C) 2005 Refractions Research Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************/

#pragma once

#include <geos/geom/GeometryFactory.h>
#include <geos/geom/PrecisionModel.h>
#include <geos/profiler.h>
#include <tinyxml2.h>

using namespace geos;

class XMLTester {

private:
    enum {
        SHOW_RUN_INFO = 1,
        SHOW_CASE,
        SHOW_TEST,
        SHOW_RESULT,
        SHOW_GEOMS,
        SHOW_GEOMS_FULL,
        PRED
    };

    void parsePrecisionModel(const tinyxml2::XMLElement* el);
    void parseRun(const tinyxml2::XMLNode* node);
    void parseCase(const tinyxml2::XMLNode* node);
    void parseTest(const tinyxml2::XMLNode* node);
    void runPredicates(const geom::Geometry* a, const geom::Geometry* b);
    geom::Geometry* parseGeometry(const std::string& in, const char* label = "parsed");
    static std::string trimBlanks(const std::string& in);
    void printGeom(std::ostream& os, const geom::Geometry* g);
    double areaDelta(const geom::Geometry* a, const geom::Geometry* b, std::string& rsltMaxDiffOp, double maxDiff, std::stringstream& ss);

    std::string printGeom(const geom::Geometry* g);
    void printTest(bool success, const std::string& expected_result, const std::string& actual_result,
                   const util::Profile&);

    geom::Geometry* gA;
    geom::Geometry* gB;

    bool usePrepared;
    std::unique_ptr<geom::PrecisionModel> pm;
    geom::GeometryFactory::Ptr factory;
    std::unique_ptr<io::WKTReader> wktreader;
    std::unique_ptr<io::WKTWriter> wktwriter;
    std::unique_ptr<io::WKBReader> wkbreader;
    std::unique_ptr<io::WKBWriter> wkbwriter;
    tinyxml2::XMLDocument xml;

    int verbose;
    int test_predicates;

    int failed;
    int succeeded;
    int caseCount;
    int testCount;
    std::string opSignature;

    int testFileCount;
    int totalTestCount;

    const std::string* curr_file;
    std::string curr_case_desc;

    bool testValidOutput;
    bool testValidInput;
    bool sqlOutput;
    bool HEXWKB_output;

    bool testValid(const geom::Geometry* g, const std::string& label);

public:
    XMLTester();
    ~XMLTester();
    void run(const std::string& testFile);
    void resultSummary(std::ostream& os) const;
    void resetCounters();

    /*
     * Values:
     *	0: Show case description, run tests, show result
     *	1: Show parsed geometry values
     *	2: Run predicates
     *
     * Return previously set verbosity level
     */
    int setVerbosityLevel(int val);

    int
    getFailuresCount()
    {
        return failed;
    }

    void
    testOutputValidity(bool val)
    {
        testValidOutput = val;
    }
    void
    testInputValidity(bool val)
    {
        testValidInput = val;
    }
    void
    setSQLOutput(bool val)
    {
        sqlOutput = val;
    }
    void
    setHEXWKBOutput(bool val)
    {
        HEXWKB_output = val;
    }

};