summaryrefslogtreecommitdiffstats
path: root/starmath/qa/cppunit/mock-visitor.hxx
blob: 63134cab648c1eaa1788691fa37919367ec0fe2f (plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_STARMATH_QA_CPPUNIT_MOCK_VISITOR_HXX
#define INCLUDED_STARMATH_QA_CPPUNIT_MOCK_VISITOR_HXX

#include <cppunit/TestAssert.h>
#include "visitors.hxx"

/** Simple visitor for testing SmVisitor */
class MockVisitor : public SmVisitor
{
public:
    virtual ~MockVisitor() {}

    void Visit( SmTableNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmTableNode should have type NTABLE",
                                     NTABLE, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmBraceNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBraceNode should have type NBRACE",
                                     NBRACE, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmBracebodyNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBracebodyNode should have type NBRACEBODY",
                                     NBRACEBODY, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmOperNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmOperNode should have type NOPER",
                                     NOPER, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmAlignNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmAlignNode should have type NALIGN",
                                     NALIGN, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmAttributNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmAttributNode should have type NATTRIBUT",
                                     NATTRIBUT, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmFontNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmFontNode should have type NFONT",
                                     NFONT, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmUnHorNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmUnHorNode should have type NUNHOR",
                                     NUNHOR, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmBinHorNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinHorNode should have type NBINHOR",
                                     NBINHOR, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmBinVerNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinVerNode should have type NBINVER",
                                     NBINVER, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmBinDiagonalNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinDiagonalNode should have type NBINDIAGONAL",
                                     NBINDIAGONAL, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmSubSupNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmSubSupNode should have type NSUBSUP",
                                     NSUBSUP, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmMatrixNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmMatrixNode should have type NMATRIX",
                                     NMATRIX, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmPlaceNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmPlaceNode should have type NPLACE",
                                     NPLACE, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmTextNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmTextNode should have type NTEXT",
                                     NTEXT, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmSpecialNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmSpecialNode should have type NSPECIAL",
                                     NSPECIAL, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmGlyphSpecialNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmGlyphSpecialNode should have type NGLYPH_SPECIAL",
                                     NGLYPH_SPECIAL, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmMathSymbolNode* pNode ) override {
        CPPUNIT_ASSERT_MESSAGE("SmMathSymbolNode should have type NMATH or NMATHIDENT",
                               pNode->GetType() == NMATH || pNode->GetType() == NMATHIDENT);
        VisitChildren( pNode );
    }

    void Visit( SmBlankNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBlankNode should have type NBLANK",
                                     NBLANK, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmErrorNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmErrorNode should have type NERROR",
                                     NERROR, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmLineNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmLineNode should have type NLINE",
                                     NLINE, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmExpressionNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmExpressionNode should have type NEXPRESSION",
                                     NEXPRESSION, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmPolyLineNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmPolyLineNode should have type NPOLYLINE",
                                     NPOLYLINE, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmRootNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRootNode should have type NROOT",
                                     NROOT, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmRootSymbolNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRootSymbolNode should have type NROOTSYMBOL",
                                     NROOTSYMBOL, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmDynIntegralNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmDynIntegralNode should have type NDYNINT",
                                     NDYNINT, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmDynIntegralSymbolNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmDynIntegralSymbolNode should have type NDYNINTSYMBOL",
                                     NDYNINTSYMBOL, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmRectangleNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRectangleNode should have type NRECTANGLE",
                                     NRECTANGLE, pNode->GetType());
        VisitChildren( pNode );
    }

    void Visit( SmVerticalBraceNode* pNode ) override {
        CPPUNIT_ASSERT_EQUAL_MESSAGE("SmVerticalBraceNode should have type NVERTICAL_BRACE",
                                     NVERTICAL_BRACE, pNode->GetType());
        VisitChildren( pNode );
    }

private:
    /** Auxiliary method for visiting the children of a pNode */
    void VisitChildren( SmNode* pNode ) {
        SmNodeIterator it( pNode );
        while( it.Next() )
            it->Accept( this );
    }
};

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */