build fix
[LibreOffice.git] / starmath / qa / cppunit / mock-visitor.hxx
blobb3ed74803cbe4f52ca27d9163e70b4b54ffe0448
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_STARMATH_QA_CPPUNIT_MOCK_VISITOR_HXX
11 #define INCLUDED_STARMATH_QA_CPPUNIT_MOCK_VISITOR_HXX
13 #include <cppunit/TestAssert.h>
14 #include "visitors.hxx"
16 /** Simple visitor for testing SmVisitor */
17 class MockVisitor : public SmVisitor
19 public:
20 virtual ~MockVisitor() {}
22 void Visit( SmTableNode* pNode ) override {
23 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmTableNode should have type NTABLE",
24 NTABLE, pNode->GetType());
25 auto eTT = pNode->GetToken().eType;
26 CPPUNIT_ASSERT_MESSAGE("The type of SmTableNode's token should be either TEND, TBINOM, or TSTACK",
27 eTT == TEND || eTT == TBINOM || eTT == TSTACK);
28 VisitChildren( pNode );
31 void Visit( SmBraceNode* pNode ) override {
32 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBraceNode should have type NBRACE",
33 NBRACE, pNode->GetType());
34 VisitChildren( pNode );
37 void Visit( SmBracebodyNode* pNode ) override {
38 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBracebodyNode should have type NBRACEBODY",
39 NBRACEBODY, pNode->GetType());
40 VisitChildren( pNode );
43 void Visit( SmOperNode* pNode ) override {
44 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmOperNode should have type NOPER",
45 NOPER, pNode->GetType());
46 VisitChildren( pNode );
49 void Visit( SmAlignNode* pNode ) override {
50 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmAlignNode should have type NALIGN",
51 NALIGN, pNode->GetType());
52 VisitChildren( pNode );
55 void Visit( SmAttributNode* pNode ) override {
56 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmAttributNode should have type NATTRIBUT",
57 NATTRIBUT, pNode->GetType());
58 VisitChildren( pNode );
61 void Visit( SmFontNode* pNode ) override {
62 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmFontNode should have type NFONT",
63 NFONT, pNode->GetType());
64 VisitChildren( pNode );
67 void Visit( SmUnHorNode* pNode ) override {
68 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmUnHorNode should have type NUNHOR",
69 NUNHOR, pNode->GetType());
70 VisitChildren( pNode );
73 void Visit( SmBinHorNode* pNode ) override {
74 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinHorNode should have type NBINHOR",
75 NBINHOR, pNode->GetType());
76 VisitChildren( pNode );
79 void Visit( SmBinVerNode* pNode ) override {
80 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinVerNode should have type NBINVER",
81 NBINVER, pNode->GetType());
82 VisitChildren( pNode );
85 void Visit( SmBinDiagonalNode* pNode ) override {
86 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinDiagonalNode should have type NBINDIAGONAL",
87 NBINDIAGONAL, pNode->GetType());
88 VisitChildren( pNode );
91 void Visit( SmSubSupNode* pNode ) override {
92 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmSubSupNode should have type NSUBSUP",
93 NSUBSUP, pNode->GetType());
94 VisitChildren( pNode );
97 void Visit( SmMatrixNode* pNode ) override {
98 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmMatrixNode should have type NMATRIX",
99 NMATRIX, pNode->GetType());
100 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmMatrixNode's token should be of type TMATRIX",
101 TMATRIX, pNode->GetToken().eType);
102 VisitChildren( pNode );
105 void Visit( SmPlaceNode* pNode ) override {
106 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmPlaceNode should have type NPLACE",
107 NPLACE, pNode->GetType());
110 void Visit( SmTextNode* pNode ) override {
111 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmTextNode should have type NTEXT",
112 NTEXT, pNode->GetType());
115 void Visit( SmSpecialNode* pNode ) override {
116 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmSpecialNode should have type NSPECIAL",
117 NSPECIAL, pNode->GetType());
120 void Visit( SmGlyphSpecialNode* pNode ) override {
121 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmGlyphSpecialNode should have type NGLYPH_SPECIAL",
122 NGLYPH_SPECIAL, pNode->GetType());
125 void Visit( SmMathSymbolNode* pNode ) override {
126 CPPUNIT_ASSERT_MESSAGE("SmMathSymbolNode should have type NMATH or NMATHIDENT",
127 pNode->GetType() == NMATH || pNode->GetType() == NMATHIDENT);
130 void Visit( SmBlankNode* pNode ) override {
131 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBlankNode should have type NBLANK",
132 NBLANK, pNode->GetType());
135 void Visit( SmErrorNode* pNode ) override {
136 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmErrorNode should have type NERROR",
137 NERROR, pNode->GetType());
140 void Visit( SmLineNode* pNode ) override {
141 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmLineNode should have type NLINE",
142 NLINE, pNode->GetType());
143 VisitChildren( pNode );
146 void Visit( SmExpressionNode* pNode ) override {
147 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmExpressionNode should have type NEXPRESSION",
148 NEXPRESSION, pNode->GetType());
149 VisitChildren( pNode );
152 void Visit( SmPolyLineNode* pNode ) override {
153 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmPolyLineNode should have type NPOLYLINE",
154 NPOLYLINE, pNode->GetType());
157 void Visit( SmRootNode* pNode ) override {
158 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRootNode should have type NROOT",
159 NROOT, pNode->GetType());
160 VisitChildren( pNode );
163 void Visit( SmRootSymbolNode* pNode ) override {
164 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRootSymbolNode should have type NROOTSYMBOL",
165 NROOTSYMBOL, pNode->GetType());
168 void Visit( SmRectangleNode* pNode ) override {
169 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRectangleNode should have type NRECTANGLE",
170 NRECTANGLE, pNode->GetType());
173 void Visit( SmVerticalBraceNode* pNode ) override {
174 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmVerticalBraceNode should have type NVERTICAL_BRACE",
175 NVERTICAL_BRACE, pNode->GetType());
176 VisitChildren( pNode );
179 private:
180 /** Auxiliary method for visiting the children of a pNode */
181 void VisitChildren( SmStructureNode* pNode ) {
182 for (auto pChild : *pNode)
184 if (pChild)
185 pChild->Accept(this);
190 #endif
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */