LCOV - code coverage report
Current view: top level - starmath/qa/cppunit - mock-visitor.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 112 152 73.7 %
Date: 2015-06-13 12:38:46 Functions: 25 33 75.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  */
       9             : 
      10             : #ifndef INCLUDED_STARMATH_QA_CPPUNIT_MOCK_VISITOR_HXX
      11             : #define INCLUDED_STARMATH_QA_CPPUNIT_MOCK_VISITOR_HXX
      12             : 
      13             : #include <cppunit/TestAssert.h>
      14             : #include "visitors.hxx"
      15             : 
      16             : /** Simple visitor for testing SmVisitor */
      17         273 : class MockVisitor : public SmVisitor
      18             : {
      19             : public:
      20         546 :     virtual ~MockVisitor() {}
      21             : 
      22          18 :     void Visit( SmTableNode* pNode ) SAL_OVERRIDE {
      23          36 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmTableNode should have type NTABLE",
      24          18 :                                      NTABLE, pNode->GetType());
      25          18 :         VisitChildren( pNode );
      26          18 :     }
      27             : 
      28          84 :     void Visit( SmBraceNode* pNode ) SAL_OVERRIDE {
      29         168 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBraceNode should have type NBRACE",
      30          84 :                                      NBRACE, pNode->GetType());
      31          84 :         VisitChildren( pNode );
      32          84 :     }
      33             : 
      34          80 :     void Visit( SmBracebodyNode* pNode ) SAL_OVERRIDE {
      35         160 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBracebodyNode should have type NBRACEBODY",
      36          80 :                                      NBRACEBODY, pNode->GetType());
      37          80 :         VisitChildren( pNode );
      38          80 :     }
      39             : 
      40          27 :     void Visit( SmOperNode* pNode ) SAL_OVERRIDE {
      41          54 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmOperNode should have type NOPER",
      42          27 :                                      NOPER, pNode->GetType());
      43          27 :         VisitChildren( pNode );
      44          27 :     }
      45             : 
      46          14 :     void Visit( SmAlignNode* pNode ) SAL_OVERRIDE {
      47          28 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmAlignNode should have type NALIGN",
      48          14 :                                      NALIGN, pNode->GetType());
      49          14 :         VisitChildren( pNode );
      50          14 :     }
      51             : 
      52          36 :     void Visit( SmAttributNode* pNode ) SAL_OVERRIDE {
      53          72 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmAttributNode should have type NATTRIBUT",
      54          36 :                                      NATTRIBUT, pNode->GetType());
      55          36 :         VisitChildren( pNode );
      56          36 :     }
      57             : 
      58          34 :     void Visit( SmFontNode* pNode ) SAL_OVERRIDE {
      59          68 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmFontNode should have type NFONT",
      60          34 :                                      NFONT, pNode->GetType());
      61          34 :         VisitChildren( pNode );
      62          34 :     }
      63             : 
      64          31 :     void Visit( SmUnHorNode* pNode ) SAL_OVERRIDE {
      65          62 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmUnHorNode should have type NUNHOR",
      66          31 :                                      NUNHOR, pNode->GetType());
      67          31 :         VisitChildren( pNode );
      68          31 :     }
      69             : 
      70         104 :     void Visit( SmBinHorNode* pNode ) SAL_OVERRIDE {
      71         208 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinHorNode should have type NBINHOR",
      72         104 :                                      NBINHOR, pNode->GetType());
      73         104 :         VisitChildren( pNode );
      74         104 :     }
      75             : 
      76          19 :     void Visit( SmBinVerNode* pNode ) SAL_OVERRIDE {
      77          38 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinVerNode should have type NBINVER",
      78          19 :                                      NBINVER, pNode->GetType());
      79          19 :         VisitChildren( pNode );
      80          19 :     }
      81             : 
      82           0 :     void Visit( SmBinDiagonalNode* pNode ) SAL_OVERRIDE {
      83           0 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBinDiagonalNode should have type NBINDIAGONAL",
      84           0 :                                      NBINDIAGONAL, pNode->GetType());
      85           0 :         VisitChildren( pNode );
      86           0 :     }
      87             : 
      88          35 :     void Visit( SmSubSupNode* pNode ) SAL_OVERRIDE {
      89          70 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmSubSupNode should have type NSUBSUP",
      90          35 :                                      NSUBSUP, pNode->GetType());
      91          35 :         VisitChildren( pNode );
      92          35 :     }
      93             : 
      94           4 :     void Visit( SmMatrixNode* pNode ) SAL_OVERRIDE {
      95           8 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmMatrixNode should have type NMATRIX",
      96           4 :                                      NMATRIX, pNode->GetType());
      97           4 :         VisitChildren( pNode );
      98           4 :     }
      99             : 
     100           0 :     void Visit( SmPlaceNode* pNode ) SAL_OVERRIDE {
     101           0 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmPlaceNode should have type NPLACE",
     102           0 :                                      NPLACE, pNode->GetType());
     103           0 :         VisitChildren( pNode );
     104           0 :     }
     105             : 
     106         643 :     void Visit( SmTextNode* pNode ) SAL_OVERRIDE {
     107        1286 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmTextNode should have type NTEXT",
     108         643 :                                      NTEXT, pNode->GetType());
     109         643 :         VisitChildren( pNode );
     110         643 :     }
     111             : 
     112         131 :     void Visit( SmSpecialNode* pNode ) SAL_OVERRIDE {
     113         262 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmSpecialNode should have type NSPECIAL",
     114         131 :                                      NSPECIAL, pNode->GetType());
     115         131 :         VisitChildren( pNode );
     116         131 :     }
     117             : 
     118           0 :     void Visit( SmGlyphSpecialNode* pNode ) SAL_OVERRIDE {
     119           0 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmGlyphSpecialNode should have type NGLYPH_SPECIAL",
     120           0 :                                      NGLYPH_SPECIAL, pNode->GetType());
     121           0 :         VisitChildren( pNode );
     122           0 :     }
     123             : 
     124         428 :     void Visit( SmMathSymbolNode* pNode ) SAL_OVERRIDE {
     125         856 :         CPPUNIT_ASSERT_MESSAGE("SmMathSymbolNode should have type NMATH or NMATHIDENT",
     126         428 :                                pNode->GetType() == NMATH || pNode->GetType() == NMATHIDENT);
     127         428 :         VisitChildren( pNode );
     128         428 :     }
     129             : 
     130           4 :     void Visit( SmBlankNode* pNode ) SAL_OVERRIDE {
     131           8 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmBlankNode should have type NBLANK",
     132           4 :                                      NBLANK, pNode->GetType());
     133           4 :         VisitChildren( pNode );
     134           4 :     }
     135             : 
     136           0 :     void Visit( SmErrorNode* pNode ) SAL_OVERRIDE {
     137           0 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmErrorNode should have type NERROR",
     138           0 :                                      NERROR, pNode->GetType());
     139           0 :         VisitChildren( pNode );
     140           0 :     }
     141             : 
     142           0 :     void Visit( SmLineNode* pNode ) SAL_OVERRIDE {
     143           0 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmLineNode should have type NLINE",
     144           0 :                                      NLINE, pNode->GetType());
     145           0 :         VisitChildren( pNode );
     146           0 :     }
     147             : 
     148          78 :     void Visit( SmExpressionNode* pNode ) SAL_OVERRIDE {
     149         156 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmExpressionNode should have type NEXPRESSION",
     150          78 :                                      NEXPRESSION, pNode->GetType());
     151          78 :         VisitChildren( pNode );
     152          78 :     }
     153             : 
     154           0 :     void Visit( SmPolyLineNode* pNode ) SAL_OVERRIDE {
     155           0 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmPolyLineNode should have type NPOLYLINE",
     156           0 :                                      NPOLYLINE, pNode->GetType());
     157           0 :         VisitChildren( pNode );
     158           0 :     }
     159             : 
     160           4 :     void Visit( SmRootNode* pNode ) SAL_OVERRIDE {
     161           8 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRootNode should have type NROOT",
     162           4 :                                      NROOT, pNode->GetType());
     163           4 :         VisitChildren( pNode );
     164           4 :     }
     165             : 
     166           4 :     void Visit( SmRootSymbolNode* pNode ) SAL_OVERRIDE {
     167           8 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRootSymbolNode should have type NROOTSYMBOL",
     168           4 :                                      NROOTSYMBOL, pNode->GetType());
     169           4 :         VisitChildren( pNode );
     170           4 :     }
     171             : 
     172           0 :     void Visit( SmDynIntegralNode* pNode ) SAL_OVERRIDE {
     173           0 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmDynIntegralNode should have type NDYNINT",
     174           0 :                                      NDYNINT, pNode->GetType());
     175           0 :         VisitChildren( pNode );
     176           0 :     }
     177             : 
     178           0 :     void Visit( SmDynIntegralSymbolNode* pNode ) SAL_OVERRIDE {
     179           0 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmDynIntegralSymbolNode should have type NDYNINTSYMBOL",
     180           0 :                                      NDYNINTSYMBOL, pNode->GetType());
     181           0 :         VisitChildren( pNode );
     182           0 :     }
     183             : 
     184          25 :     void Visit( SmRectangleNode* pNode ) SAL_OVERRIDE {
     185          50 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmRectangleNode should have type NRECTANGLE",
     186          25 :                                      NRECTANGLE, pNode->GetType());
     187          25 :         VisitChildren( pNode );
     188          25 :     }
     189             : 
     190           4 :     void Visit( SmVerticalBraceNode* pNode ) SAL_OVERRIDE {
     191           8 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("SmVerticalBraceNode should have type NVERTICAL_BRACE",
     192           4 :                                      NVERTICAL_BRACE, pNode->GetType());
     193           4 :         VisitChildren( pNode );
     194           4 :     }
     195             : 
     196             : private:
     197             :     /** Auxiliary method for visiting the children of a pNode */
     198        1807 :     void VisitChildren( SmNode* pNode ) {
     199        1807 :         SmNodeIterator it( pNode );
     200        4878 :         while( it.Next() )
     201        1264 :             it->Accept( this );
     202        1807 :     }
     203             : };
     204             : 
     205             : #endif
     206             : 
     207             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11