⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testcaseadapter.cpp

📁 "More for C++" is a class library that provides some features that are usually common for object ori
💻 CPP
字号:
////  This file is part of the "More for C++" library////  Copyright (c) 1999-2003 by Thorsten Goertz (thorsten@morefor.org)////  The "More for C++" library is free software; you can redistribute it and/or//  modify it under the terms of the license that comes with this package.////  Read "license.txt" for more details.////  THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED//  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES//  OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.////////////////////////////////////////////////////////////////////////////////#include <more/exception.hpp>#include "duplicatestring.hpp"#include "testcaseadapter.hpp"#include "testexception.hpp"using namespace more;using namespace more::test;////////////////////////////////////////////////////////////////////////////////TestCaseAdapter::TestCaseAdapter(  const char*           pcNameOfSuite,  TestCase*             pTestCase,  TestCase::TestMethod  pTestMethod): m_pcNameOfSuite( createDuplicatedString( pcNameOfSuite ) ),  m_pTestCase( pTestCase ),  m_pTestCaseMethod( pTestMethod ){}////////////////////////////////////////////////////////////////////////////////TestCaseAdapter::~TestCaseAdapter( ){  deleteDuplicatedString( m_pcNameOfSuite );  delete m_pTestCase;}////////////////////////////////////////////////////////////////////////////////const char* TestCaseAdapter::getName( ) const{  return m_pTestCase -> getName( );}////////////////////////////////////////////////////////////////////////size_t TestCaseAdapter::getNoOfTestCases( ) const{  return 1;}////////////////////////////////////////////////////////////////////////////////void TestCaseAdapter::run(  TestObserver& rTestObserver,  size_t        nNestingLevel){  if( setUp( rTestObserver, nNestingLevel ) )  {    try    {      ( *m_pTestCase.*m_pTestCaseMethod )( );      rTestObserver.onTestCaseSucceeded( m_pcNameOfSuite, getName( ) );    }    catch( const TestException& e )    {      rTestObserver.onTestCaseFailed( m_pcNameOfSuite,                                      getName( ),                                      e.getMessage( ),                                      e.getExplanation( ) );    }    catch( const more::Exception& e )    {      rTestObserver.onException( m_pcNameOfSuite, getName( ), "<more::Exception>", e );    }    catch( ... )    {      rTestObserver.onException( m_pcNameOfSuite, getName( ), "<Unexpected>", "" );    }  }  tearDown( rTestObserver, nNestingLevel );}////////////////////////////////////////////////////////////////////////////////bool TestCaseAdapter::setUp(  TestObserver& rTestObserver,  size_t        nNestingLevel){  bool bResult = false;  try  {    m_pTestCase -> setUp( );    bResult = true;  }  catch( const TestException& e )  {    rTestObserver.onSetupFailed( m_pcNameOfSuite, getName( ), e.getMessage( ), e.getExplanation( ) );  }  catch( const more::Exception& e )  {    rTestObserver.onSetupFailed( m_pcNameOfSuite, getName( ), "<more::Exception>", e );  }  catch( ... )  {    rTestObserver.onSetupFailed( m_pcNameOfSuite, getName( ), "<Unexpected>", "" );  }  return bResult;}////////////////////////////////////////////////////////////////////////////////void TestCaseAdapter::tearDown(  TestObserver& rTestObserver,  size_t        nNestingLevel){  try  {    m_pTestCase -> tearDown( );  }  catch( const TestException& e )  {    rTestObserver.onTeardownFailed( m_pcNameOfSuite, getName( ), e.getMessage( ), e.getExplanation( ) );  }  catch( const more::Exception& e )  {    rTestObserver.onTeardownFailed( m_pcNameOfSuite, getName( ), "<more::Exception>", e );  }  catch( ... )  {    rTestObserver.onTeardownFailed( m_pcNameOfSuite, getName( ), "<Unexpected>", "" );  }}////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -