mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-17 03:02:24 +01:00
Refactor to fix single include
This commit is contained in:
parent
04acaebe74
commit
434f8c9b9f
@ -19,7 +19,6 @@
|
||||
|
||||
#if (_MANAGED == 1) || (_M_CEE == 1) // detect CLR
|
||||
#define INTERNAL_CATCH_VS_MANAGED
|
||||
#define INTERNAL_CATCH_INLINE inline
|
||||
#else
|
||||
|
||||
#if defined(_WINDLL)
|
||||
@ -27,7 +26,6 @@
|
||||
// It's possible that this is not enough for someone so allow it to be overridden...
|
||||
#if !defined( CATCH_CONFIG_MAIN ) && !defined( CATCH_CONFIG_RUNNER )
|
||||
#define INTERNAL_CATCH_VS_NATIVE
|
||||
#define INTERNAL_CATCH_INLINE inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -35,6 +33,7 @@
|
||||
|
||||
#include "internal/catch_notimplemented_exception.h"
|
||||
#include "internal/catch_context.h"
|
||||
#include "internal/catch_test_registry.hpp"
|
||||
#include "internal/catch_capture.hpp"
|
||||
#include "internal/catch_section.h"
|
||||
#include "internal/catch_generators.hpp"
|
||||
@ -48,25 +47,18 @@
|
||||
#include "internal/catch_test_case_info.h"
|
||||
#include "internal/catch_interfaces_runner.h"
|
||||
|
||||
|
||||
#ifdef __OBJC__
|
||||
#include "internal/catch_objc.hpp"
|
||||
#endif
|
||||
|
||||
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||
#ifdef INTERNAL_CATCH_VS_MANAGED
|
||||
#include "internal/catch_vs_managed_impl.hpp"
|
||||
#else // INTERNAL_CATCH_VS_MANAGED
|
||||
#ifdef INTERNAL_CATCH_VS_NATIVE
|
||||
#include "internal/catch_vs_native_impl.hpp"
|
||||
#endif // INTERNAL_CATCH_VS_NATIVE
|
||||
#endif // INTERNAL_CATCH_VS_MANAGED
|
||||
#define INTERNAL_CATCH_INLINE inline
|
||||
#define CATCH_CONFIG_RUNNER (1)
|
||||
#else
|
||||
|
||||
#include "internal/catch_test_registry.hpp"
|
||||
#define INTERNAL_CATCH_INLINE
|
||||
#endif
|
||||
|
||||
#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER )
|
||||
#define INTERNAL_CATCH_INLINE
|
||||
#include "internal/catch_impl.hpp"
|
||||
#endif // CATCH_CONFIG_MAIN || CATCH_CONFIG_RUNNER
|
||||
|
||||
@ -74,8 +66,6 @@
|
||||
#include "internal/catch_default_main.hpp"
|
||||
#endif // CATCH_CONFIG_MAIN
|
||||
|
||||
#endif // INTERNAL_CATCH_VS_MANAGED or INTERNAL_CATCH_VS_NATIVE defined
|
||||
|
||||
//////
|
||||
|
||||
// If this config identifier is defined then all CATCH macros are prefixed with CATCH_
|
||||
|
@ -17,8 +17,6 @@
|
||||
#include "catch_common.h"
|
||||
#include "catch_tostring.hpp"
|
||||
#include "catch_interfaces_reporter.h"
|
||||
//#include "catch_interfaces_registry_hub.h"
|
||||
//#include "catch_interfaces_config.h"
|
||||
#include "internal/catch_compiler_capabilities.h"
|
||||
|
||||
#include <ostream>
|
||||
|
@ -96,9 +96,6 @@ namespace Catch {
|
||||
template <typename Runner, typename ResultCapture>
|
||||
Context<Runner,ResultCapture>* Context<Runner, ResultCapture>::currentContext = NULL;
|
||||
|
||||
/*namespace {
|
||||
Context* currentContext = NULL;
|
||||
}*/
|
||||
typedef Context<NullRunner, NullResultCapture> DefaultContext;
|
||||
INTERNAL_CATCH_INLINE IMutableContext& getCurrentMutableContext() {
|
||||
if( !DefaultContext::currentContext )
|
||||
|
@ -40,47 +40,47 @@
|
||||
#include "../reporters/catch_reporter_console.hpp"
|
||||
|
||||
namespace Catch {
|
||||
NonCopyable::~NonCopyable() {}
|
||||
IShared::~IShared() {}
|
||||
StreamBufBase::~StreamBufBase() throw() {}
|
||||
IContext::~IContext() {}
|
||||
IResultCapture::~IResultCapture() {}
|
||||
ITestCase::~ITestCase() {}
|
||||
ITestCaseRegistry::~ITestCaseRegistry() {}
|
||||
IRegistryHub::~IRegistryHub() {}
|
||||
IMutableRegistryHub::~IMutableRegistryHub() {}
|
||||
IExceptionTranslator::~IExceptionTranslator() {}
|
||||
IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
|
||||
IReporter::~IReporter() {}
|
||||
IReporterFactory::~IReporterFactory() {}
|
||||
IReporterRegistry::~IReporterRegistry() {}
|
||||
IStreamingReporter::~IStreamingReporter() {}
|
||||
AssertionStats::~AssertionStats() {}
|
||||
SectionStats::~SectionStats() {}
|
||||
TestCaseStats::~TestCaseStats() {}
|
||||
TestGroupStats::~TestGroupStats() {}
|
||||
TestRunStats::~TestRunStats() {}
|
||||
CumulativeReporterBase::SectionNode::~SectionNode() {}
|
||||
CumulativeReporterBase::~CumulativeReporterBase() {}
|
||||
INTERNAL_CATCH_INLINE NonCopyable::~NonCopyable() {}
|
||||
INTERNAL_CATCH_INLINE IShared::~IShared() {}
|
||||
INTERNAL_CATCH_INLINE StreamBufBase::~StreamBufBase() throw() {}
|
||||
INTERNAL_CATCH_INLINE IContext::~IContext() {}
|
||||
INTERNAL_CATCH_INLINE IResultCapture::~IResultCapture() {}
|
||||
INTERNAL_CATCH_INLINE ITestCase::~ITestCase() {}
|
||||
INTERNAL_CATCH_INLINE ITestCaseRegistry::~ITestCaseRegistry() {}
|
||||
INTERNAL_CATCH_INLINE IRegistryHub::~IRegistryHub() {}
|
||||
INTERNAL_CATCH_INLINE IMutableRegistryHub::~IMutableRegistryHub() {}
|
||||
INTERNAL_CATCH_INLINE IExceptionTranslator::~IExceptionTranslator() {}
|
||||
INTERNAL_CATCH_INLINE IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
|
||||
INTERNAL_CATCH_INLINE IReporter::~IReporter() {}
|
||||
INTERNAL_CATCH_INLINE IReporterFactory::~IReporterFactory() {}
|
||||
INTERNAL_CATCH_INLINE IReporterRegistry::~IReporterRegistry() {}
|
||||
INTERNAL_CATCH_INLINE IStreamingReporter::~IStreamingReporter() {}
|
||||
INTERNAL_CATCH_INLINE AssertionStats::~AssertionStats() {}
|
||||
INTERNAL_CATCH_INLINE SectionStats::~SectionStats() {}
|
||||
INTERNAL_CATCH_INLINE TestCaseStats::~TestCaseStats() {}
|
||||
INTERNAL_CATCH_INLINE TestGroupStats::~TestGroupStats() {}
|
||||
INTERNAL_CATCH_INLINE TestRunStats::~TestRunStats() {}
|
||||
INTERNAL_CATCH_INLINE CumulativeReporterBase::SectionNode::~SectionNode() {}
|
||||
INTERNAL_CATCH_INLINE CumulativeReporterBase::~CumulativeReporterBase() {}
|
||||
|
||||
StreamingReporterBase::~StreamingReporterBase() {}
|
||||
ConsoleReporter::~ConsoleReporter() {}
|
||||
IRunner::~IRunner() {}
|
||||
IMutableContext::~IMutableContext() {}
|
||||
IConfig::~IConfig() {}
|
||||
XmlReporter::~XmlReporter() {}
|
||||
JunitReporter::~JunitReporter() {}
|
||||
TestRegistry::~TestRegistry() {}
|
||||
FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
||||
IGeneratorInfo::~IGeneratorInfo() {}
|
||||
IGeneratorsForTest::~IGeneratorsForTest() {}
|
||||
INTERNAL_CATCH_INLINE StreamingReporterBase::~StreamingReporterBase() {}
|
||||
INTERNAL_CATCH_INLINE ConsoleReporter::~ConsoleReporter() {}
|
||||
INTERNAL_CATCH_INLINE IRunner::~IRunner() {}
|
||||
INTERNAL_CATCH_INLINE IMutableContext::~IMutableContext() {}
|
||||
INTERNAL_CATCH_INLINE IConfig::~IConfig() {}
|
||||
INTERNAL_CATCH_INLINE XmlReporter::~XmlReporter() {}
|
||||
INTERNAL_CATCH_INLINE JunitReporter::~JunitReporter() {}
|
||||
INTERNAL_CATCH_INLINE TestRegistry::~TestRegistry() {}
|
||||
INTERNAL_CATCH_INLINE FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
||||
INTERNAL_CATCH_INLINE IGeneratorInfo::~IGeneratorInfo() {}
|
||||
INTERNAL_CATCH_INLINE IGeneratorsForTest::~IGeneratorsForTest() {}
|
||||
|
||||
Matchers::Impl::StdString::Equals::~Equals() {}
|
||||
Matchers::Impl::StdString::Contains::~Contains() {}
|
||||
Matchers::Impl::StdString::StartsWith::~StartsWith() {}
|
||||
Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
||||
INTERNAL_CATCH_INLINE Matchers::Impl::StdString::Equals::~Equals() {}
|
||||
INTERNAL_CATCH_INLINE Matchers::Impl::StdString::Contains::~Contains() {}
|
||||
INTERNAL_CATCH_INLINE Matchers::Impl::StdString::StartsWith::~StartsWith() {}
|
||||
INTERNAL_CATCH_INLINE Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
||||
|
||||
void Config::dummy() {}
|
||||
INTERNAL_CATCH_INLINE void Config::dummy() {}
|
||||
|
||||
INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( "xml", XmlReporter )
|
||||
}
|
||||
|
@ -12,35 +12,35 @@
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
LegacyReporterAdapter::LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter )
|
||||
INTERNAL_CATCH_INLINE LegacyReporterAdapter::LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter )
|
||||
: m_legacyReporter( legacyReporter )
|
||||
{}
|
||||
LegacyReporterAdapter::~LegacyReporterAdapter() {}
|
||||
INTERNAL_CATCH_INLINE LegacyReporterAdapter::~LegacyReporterAdapter() {}
|
||||
|
||||
ReporterPreferences LegacyReporterAdapter::getPreferences() const {
|
||||
INTERNAL_CATCH_INLINE ReporterPreferences LegacyReporterAdapter::getPreferences() const {
|
||||
ReporterPreferences prefs;
|
||||
prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout();
|
||||
return prefs;
|
||||
}
|
||||
|
||||
void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {}
|
||||
void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {}
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) {
|
||||
m_legacyReporter->StartTesting();
|
||||
}
|
||||
void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) {
|
||||
m_legacyReporter->StartGroup( groupInfo.name );
|
||||
}
|
||||
void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) {
|
||||
m_legacyReporter->StartTestCase( testInfo );
|
||||
}
|
||||
void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) {
|
||||
m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description );
|
||||
}
|
||||
void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) {
|
||||
// Not on legacy interface
|
||||
}
|
||||
|
||||
bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) {
|
||||
INTERNAL_CATCH_INLINE bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) {
|
||||
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
|
||||
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
||||
it != itEnd;
|
||||
@ -57,24 +57,24 @@ namespace Catch
|
||||
m_legacyReporter->Result( assertionStats.assertionResult );
|
||||
return true;
|
||||
}
|
||||
void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) {
|
||||
if( sectionStats.missingAssertions )
|
||||
m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name );
|
||||
m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions );
|
||||
}
|
||||
void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) {
|
||||
m_legacyReporter->EndTestCase
|
||||
( testCaseStats.testInfo,
|
||||
testCaseStats.totals,
|
||||
testCaseStats.stdOut,
|
||||
testCaseStats.stdErr );
|
||||
}
|
||||
void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) {
|
||||
if( testGroupStats.aborting )
|
||||
m_legacyReporter->Aborted();
|
||||
m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals );
|
||||
}
|
||||
void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) {
|
||||
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) {
|
||||
m_legacyReporter->EndTesting( testRunStats.totals );
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,7 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
|
||||
|
||||
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||
#include "internal/catch_vs_test_registry.hpp"
|
||||
#else
|
||||
#include "catch_test_registry.hpp"
|
||||
#endif
|
||||
#include "catch_test_case_info.h"
|
||||
#include "catch_test_spec.h"
|
||||
#include "catch_context.h"
|
||||
|
@ -12,6 +12,10 @@
|
||||
#include "catch_interfaces_testcase.h"
|
||||
#include "internal/catch_compiler_capabilities.h"
|
||||
|
||||
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||
#include "catch_vs_test_registry.hpp"
|
||||
#else // defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||
|
||||
namespace Catch {
|
||||
|
||||
template<typename C>
|
||||
@ -117,4 +121,6 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif // defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
||||
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Created by Malcolm on 10/11/2013.
|
||||
* Copyright 2013 Malcolm Noyes
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#ifndef TWOBLUECUBES_CATCH_VS_MANAGED_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_VS_MANAGED_HPP_INCLUDED
|
||||
|
||||
#ifdef INTERNAL_CATCH_VS_MANAGED
|
||||
|
||||
#include <windows.h>
|
||||
using namespace System;
|
||||
using namespace System::Text;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
|
||||
|
||||
namespace Catch {
|
||||
inline String^ convert_string_for_assert(const std::string& s)
|
||||
{
|
||||
String^ result = gcnew String(s.c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "catch_common.hpp"
|
||||
#include "catch_debugger.hpp"
|
||||
#include "catch_tags.hpp"
|
||||
#include "catch_test_spec.hpp"
|
||||
#include "catch_section.hpp"
|
||||
#include "internal/catch_timer.hpp"
|
||||
#include "internal/catch_vs_test_registry.hpp"
|
||||
#include "internal/catch_reporter_registrars.hpp"
|
||||
#include "reporters/catch_vs_reporter.hpp"
|
||||
#include "catch_registry_hub.hpp"
|
||||
#include "internal/catch_console_colour_impl.hpp"
|
||||
#include "catch_runner.hpp"
|
||||
|
||||
namespace Catch {
|
||||
inline NonCopyable::~NonCopyable() {}
|
||||
inline IShared::~IShared() {}
|
||||
inline StreamBufBase::~StreamBufBase() throw() {}
|
||||
inline IContext::~IContext() {}
|
||||
inline IResultCapture::~IResultCapture() {}
|
||||
inline ITestCase::~ITestCase() {}
|
||||
inline ITestCaseRegistry::~ITestCaseRegistry() {}
|
||||
inline IRegistryHub::~IRegistryHub() {}
|
||||
inline IMutableRegistryHub::~IMutableRegistryHub() {}
|
||||
inline IExceptionTranslator::~IExceptionTranslator() {}
|
||||
inline IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
|
||||
inline IReporter::~IReporter() {}
|
||||
inline IReporterFactory::~IReporterFactory() {}
|
||||
inline IReporterRegistry::~IReporterRegistry() {}
|
||||
inline IStreamingReporter::~IStreamingReporter() {}
|
||||
inline AssertionStats::~AssertionStats() {}
|
||||
inline SectionStats::~SectionStats() {}
|
||||
inline TestCaseStats::~TestCaseStats() {}
|
||||
inline TestGroupStats::~TestGroupStats() {}
|
||||
inline TestRunStats::~TestRunStats() {}
|
||||
|
||||
inline IRunner::~IRunner() {}
|
||||
inline IMutableContext::~IMutableContext() {}
|
||||
inline IConfig::~IConfig() {}
|
||||
inline TestRegistry::~TestRegistry() {}
|
||||
inline FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
||||
inline IGeneratorInfo::~IGeneratorInfo() {}
|
||||
inline IGeneratorsForTest::~IGeneratorsForTest() {}
|
||||
|
||||
inline Matchers::Impl::StdString::Equals::~Equals() {}
|
||||
inline Matchers::Impl::StdString::Contains::~Contains() {}
|
||||
inline Matchers::Impl::StdString::StartsWith::~StartsWith() {}
|
||||
inline Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
||||
|
||||
inline void Config::dummy() {}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_VS_MANAGED_HPP_INCLUDED
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Created by Malcolm on 10/11/2013.
|
||||
* Copyright 2013 Malcolm Noyes
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#ifndef TWOBLUECUBES_CATCH_VS_NATIVE_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_VS_NATIVE_HPP_INCLUDED
|
||||
|
||||
#ifdef INTERNAL_CATCH_VS_NATIVE
|
||||
|
||||
#pragma warning( disable : 4505 )
|
||||
|
||||
#include <CppUnitTest.h>
|
||||
|
||||
using Microsoft::VisualStudio::CppUnitTestFramework::Logger;
|
||||
using Microsoft::VisualStudio::CppUnitTestFramework::Assert;
|
||||
using Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo;
|
||||
|
||||
#include <cvt/wstring>
|
||||
#include <codecvt>
|
||||
|
||||
#include "catch_common.hpp"
|
||||
#include "catch_debugger.hpp"
|
||||
#include "catch_tags.hpp"
|
||||
#include "catch_test_spec.hpp"
|
||||
#include "catch_section.hpp"
|
||||
#include "internal/catch_vs_test_registry.hpp"
|
||||
#include "internal/catch_reporter_registrars.hpp"
|
||||
#include "reporters/catch_vs_reporter.hpp"
|
||||
#include "catch_registry_hub.hpp"
|
||||
#include "internal/catch_timer.hpp"
|
||||
#include "internal/catch_console_colour_impl.hpp"
|
||||
#include "catch_runner.hpp"
|
||||
|
||||
namespace Catch {
|
||||
inline NonCopyable::~NonCopyable() {}
|
||||
inline IShared::~IShared() {}
|
||||
inline StreamBufBase::~StreamBufBase() throw() {}
|
||||
inline IContext::~IContext() {}
|
||||
inline IResultCapture::~IResultCapture() {}
|
||||
inline ITestCase::~ITestCase() {}
|
||||
inline ITestCaseRegistry::~ITestCaseRegistry() {}
|
||||
inline IRegistryHub::~IRegistryHub() {}
|
||||
inline IMutableRegistryHub::~IMutableRegistryHub() {}
|
||||
inline IExceptionTranslator::~IExceptionTranslator() {}
|
||||
inline IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
|
||||
inline IReporter::~IReporter() {}
|
||||
inline IReporterFactory::~IReporterFactory() {}
|
||||
inline IReporterRegistry::~IReporterRegistry() {}
|
||||
inline IStreamingReporter::~IStreamingReporter() {}
|
||||
inline AssertionStats::~AssertionStats() {}
|
||||
inline SectionStats::~SectionStats() {}
|
||||
inline TestCaseStats::~TestCaseStats() {}
|
||||
inline TestGroupStats::~TestGroupStats() {}
|
||||
inline TestRunStats::~TestRunStats() {}
|
||||
|
||||
inline IRunner::~IRunner() {}
|
||||
inline IMutableContext::~IMutableContext() {}
|
||||
inline IConfig::~IConfig() {}
|
||||
inline TestRegistry::~TestRegistry() {}
|
||||
inline FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
||||
inline IGeneratorInfo::~IGeneratorInfo() {}
|
||||
inline IGeneratorsForTest::~IGeneratorsForTest() {}
|
||||
|
||||
inline Matchers::Impl::StdString::Equals::~Equals() {}
|
||||
inline Matchers::Impl::StdString::Contains::~Contains() {}
|
||||
inline Matchers::Impl::StdString::StartsWith::~StartsWith() {}
|
||||
inline Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
||||
|
||||
inline void Config::dummy() {}
|
||||
}
|
||||
|
||||
#endif // INTERNAL_CATCH_VS_NATIVE
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_VS_NATIVE_HPP_INCLUDED
|
@ -8,16 +8,42 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_MSTEST_REGISTRY_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_MSTEST_REGISTRY_HPP_INCLUDED
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#ifdef INTERNAL_CATCH_VS_MANAGED
|
||||
|
||||
#include <windows.h>
|
||||
using namespace System;
|
||||
using namespace System::Text;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
|
||||
|
||||
namespace Catch {
|
||||
inline String^ convert_string_for_assert(const std::string& s)
|
||||
{
|
||||
String^ result = gcnew String(s.c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef INTERNAL_CATCH_VS_NATIVE
|
||||
|
||||
#pragma warning( disable : 4505 ) // required for including CppUnitTest.h at /W4
|
||||
|
||||
#include <CppUnitTest.h>
|
||||
|
||||
using Microsoft::VisualStudio::CppUnitTestFramework::Logger;
|
||||
using Microsoft::VisualStudio::CppUnitTestFramework::Assert;
|
||||
using Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo;
|
||||
|
||||
#endif
|
||||
|
||||
#include "catch_common.h"
|
||||
#include "catch_interfaces_testcase.h"
|
||||
#include "internal/catch_compiler_capabilities.h"
|
||||
#include "internal/clara.h"
|
||||
#include <tchar.h>
|
||||
#ifdef INTERNAL_CATCH_VS_NATIVE
|
||||
#include <cvt/wstring>
|
||||
#include <codecvt>
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -274,6 +300,87 @@ private:
|
||||
#define CATCH_INTERNAL_CONFIG_ADD_TEST( v ) \
|
||||
CATCH_INTERNAL_CONFIG_ADD_TEST2( v, __COUNTER__)
|
||||
|
||||
struct CollectConsoleOutput
|
||||
{
|
||||
CollectConsoleOutput()
|
||||
#if defined(INTERNAL_CATCH_VS_NATIVE) || _MSC_VER >= 1700
|
||||
: m_addLineFeeds(false)
|
||||
#else
|
||||
: m_addLineFeeds(true)
|
||||
#endif
|
||||
{}
|
||||
CollectConsoleOutput( bool v)
|
||||
: m_addLineFeeds(v)
|
||||
{}
|
||||
~CollectConsoleOutput()
|
||||
{
|
||||
std::string output = oss.str();
|
||||
if( !output.empty() ) {
|
||||
if( m_addLineFeeds ) {
|
||||
std::string revised;
|
||||
replaceSingleLinefeed(output, revised);
|
||||
write_output_message(revised);
|
||||
}
|
||||
else {
|
||||
write_output_message(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined(INTERNAL_CATCH_VS_MANAGED)
|
||||
|
||||
void write_output_message(const std::string& msg)
|
||||
{
|
||||
String^ tmp = gcnew String(msg.c_str());
|
||||
Console::WriteLine(tmp);
|
||||
}
|
||||
|
||||
#else // detect CLR
|
||||
|
||||
#if defined(INTERNAL_CATCH_VS_NATIVE)
|
||||
|
||||
#ifdef _UNICODE
|
||||
void write_output_message(const std::string& msg)
|
||||
{
|
||||
std::wstringstream _s;
|
||||
_s << msg.c_str();
|
||||
std::wstring ws = _s.str();
|
||||
Logger::WriteMessage(ws.c_str());
|
||||
}
|
||||
#else
|
||||
void write_output_message(const std::string& msg)
|
||||
{
|
||||
Logger::WriteMessage(msg.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _WINDLL
|
||||
|
||||
#endif // detect CLR
|
||||
void replaceSingleLinefeed(const std::string& s, std::string& result)
|
||||
{
|
||||
bool needr(false);
|
||||
for(std::string::const_iterator it = s.begin(); it != s.end(); ++it ) {
|
||||
if( *it == '\r' ) {
|
||||
needr = false;
|
||||
}
|
||||
else if( *it == '\n' && needr ) {
|
||||
needr = false;
|
||||
result += '\r';
|
||||
result += *it;
|
||||
}
|
||||
else {
|
||||
needr = true;
|
||||
}
|
||||
result += *it;
|
||||
}
|
||||
}
|
||||
|
||||
std::streambuf* rdbuf() {return oss.rdbuf(); }
|
||||
|
||||
std::ostringstream oss;
|
||||
bool m_addLineFeeds;
|
||||
};
|
||||
|
||||
#define CATCH_INTERNAL_RUN_SINGLE_TEST( Count ) \
|
||||
{ CatchOverrides::ConfigGuard cg; \
|
||||
Catch::ConfigData cd(cg.value().get()); \
|
||||
@ -281,9 +388,10 @@ private:
|
||||
cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, __LINE__ ); \
|
||||
cd.warnings = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, __LINE__ ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \
|
||||
cd.abortAfter = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, __LINE__ ); \
|
||||
CollectConsoleOutput ptr; { \
|
||||
Catch::Ptr<Catch::Config> config(new Catch::Config(cd)); \
|
||||
Catch::ReporterRegistrar<Catch::MSTestReporter> reporterReg("vs_reporter"); \
|
||||
Catch::RunContext context(config.get(), Catch::getRegistryHub().getReporterRegistry().create( "vs_reporter", config.get())); \
|
||||
config->setStreamBuf(ptr.rdbuf()); \
|
||||
Catch::RunContext context(config.get(), Catch::getRegistryHub().getReporterRegistry().create( "console", config.get())); \
|
||||
std::vector<Catch::TestCase> testCase = Catch::getRegistryHub().getTestCaseRegistry().getMatchingTestCases(name_desc.name); \
|
||||
if( testCase.empty() ) Assert::Fail(FAIL_STRING("No tests match")); \
|
||||
if( testCase.size() > 1 ) Assert::Fail(FAIL_STRING("More than one test with the same name")); \
|
||||
@ -293,6 +401,7 @@ private:
|
||||
if( totals.assertions.failed > 0 ) { \
|
||||
INTERNAL_CATCH_TEST_THROW_FAILURE \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define INTERNAL_CATCH_TESTCASE2( Count, Name, Desc ) \
|
||||
@ -372,17 +481,18 @@ private:
|
||||
cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, __LINE__ ); \
|
||||
cd.warnings = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, __LINE__ ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \
|
||||
cd.abortAfter = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, __LINE__ ); \
|
||||
cd.reporterName = "vs_reporterlf"; \
|
||||
cd.name = "Batch run using tag : " Tag; \
|
||||
cd.testsOrTags.push_back( Tag ); \
|
||||
CollectConsoleOutput ptr(false); { \
|
||||
Catch::Ptr<Catch::Config> config(new Catch::Config(cd)); \
|
||||
Catch::ReporterRegistrar<Catch::MSTestReporterLineFeed> reporterReg("vs_reporterlf"); \
|
||||
config->setStreamBuf(ptr.rdbuf()); \
|
||||
Catch::Runner runner(config); \
|
||||
Catch::Totals totals = runner.runTests(); \
|
||||
if( totals.assertions.failed > 0 ) { \
|
||||
INTERNAL_CATCH_TEST_REPORT_BATCH_FAILURE(totals.assertions.failed) \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}; \
|
||||
}
|
||||
|
||||
@ -399,12 +509,12 @@ private:
|
||||
cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, __LINE__ ); \
|
||||
cd.warnings = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, __LINE__ ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \
|
||||
cd.abortAfter = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, __LINE__ ); \
|
||||
cd.reporterName = "vs_reporterlf"; \
|
||||
cd.name = "Batch run using category : " CategoryName; \
|
||||
std::vector<std::string> stringNames = CatchOverrides::Config<Catch::IConfig const*>::instance().listOfTests(__FILE__, __LINE__ ); \
|
||||
CollectConsoleOutput ptr(false); { \
|
||||
Catch::Ptr<Catch::Config> config(new Catch::Config(cd)); \
|
||||
Catch::ReporterRegistrar<Catch::MSTestReporterLineFeed> reporterReg("vs_reporterlf"); \
|
||||
Catch::RunContext context(config.get(), Catch::getRegistryHub().getReporterRegistry().create( "vs_reporterlf", config.get())); \
|
||||
config->setStreamBuf(ptr.rdbuf()); \
|
||||
Catch::RunContext context(config.get(), Catch::getRegistryHub().getReporterRegistry().create( "console", config.get())); \
|
||||
Catch::Totals totals; \
|
||||
context.testGroupStarting( "", 0, 1 ); \
|
||||
for( std::vector<std::string>::iterator it = stringNames.begin(); it != stringNames.end(); ++it ) { \
|
||||
@ -418,10 +528,11 @@ private:
|
||||
INTERNAL_CATCH_TEST_REPORT_BATCH_FAILURE(totals.assertions.failed) \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}; \
|
||||
}
|
||||
|
||||
//#undef CATCH_CONFIG_VARIADIC_MACROS
|
||||
// #undef CATCH_CONFIG_VARIADIC_MACROS
|
||||
|
||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||
|
||||
@ -459,21 +570,4 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#include "catch_test_case_info.hpp"
|
||||
#include "catch_assertionresult.hpp"
|
||||
#include "catch_expressionresult_builder.hpp"
|
||||
#include "catch_version.hpp"
|
||||
#include "catch_runner_impl.hpp"
|
||||
#include "catch_message.hpp"
|
||||
#include "catch_context_impl.hpp"
|
||||
#include "catch_generators_impl.hpp"
|
||||
#include "catch_test_case_info.hpp"
|
||||
#include "catch_notimplemented_exception.hpp"
|
||||
|
||||
#include "catch_exception_translator_registry.hpp"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_MSTEST_REGISTRY_HPP_INCLUDED
|
||||
|
@ -15,6 +15,11 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||
static const bool DefaultRedirectStdout = true;
|
||||
#else
|
||||
static const bool DefaultRedirectStdout = false;
|
||||
#endif
|
||||
struct ConsoleReporter : StreamingReporterBase {
|
||||
ConsoleReporter( ReporterConfig const& _config )
|
||||
: StreamingReporterBase( _config ),
|
||||
@ -28,7 +33,7 @@ namespace Catch {
|
||||
}
|
||||
virtual ReporterPreferences getPreferences() const {
|
||||
ReporterPreferences prefs;
|
||||
prefs.shouldRedirectStdOut = false;
|
||||
prefs.shouldRedirectStdOut = DefaultRedirectStdout;
|
||||
return prefs;
|
||||
}
|
||||
|
||||
@ -86,6 +91,11 @@ namespace Catch {
|
||||
}
|
||||
|
||||
virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) {
|
||||
if( getPreferences().shouldRedirectStdOut )
|
||||
{
|
||||
stream << _testCaseStats.stdOut;
|
||||
stream << _testCaseStats.stdErr;
|
||||
}
|
||||
StreamingReporterBase::testCaseEnded( _testCaseStats );
|
||||
m_headerPrinted = false;
|
||||
}
|
||||
@ -382,6 +392,24 @@ namespace Catch {
|
||||
void printSummaryDivider() {
|
||||
stream << getDashes() << "\n";
|
||||
}
|
||||
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||
static std::string getDashes() {
|
||||
const std::string dashes( CATCH_CONFIG_CONSOLE_WIDTH-1, '-' );
|
||||
return dashes;
|
||||
}
|
||||
static std::string getDots() {
|
||||
const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '.' );
|
||||
return dots;
|
||||
}
|
||||
static std::string getDoubleDashes() {
|
||||
const std::string doubleDashes( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );
|
||||
return doubleDashes;
|
||||
}
|
||||
static std::string getTildes() {
|
||||
const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '~' );
|
||||
return dots;
|
||||
}
|
||||
#else
|
||||
static std::string const& getDashes() {
|
||||
static const std::string dashes( CATCH_CONFIG_CONSOLE_WIDTH-1, '-' );
|
||||
return dashes;
|
||||
@ -398,6 +426,7 @@ namespace Catch {
|
||||
static const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '~' );
|
||||
return dots;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool m_headerPrinted;
|
||||
|
@ -1,551 +0,0 @@
|
||||
/*
|
||||
* Created by Malcolm on 4/11/2013.
|
||||
* Copyright 2013 Malcolm Noyes. All rights reserved.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef TWOBLUECUBES_CATCH_REPORTER_MSTEST_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_REPORTER_MSTEST_HPP_INCLUDED
|
||||
|
||||
#include "../internal/catch_interfaces_reporter.h"
|
||||
#include "../internal/catch_text.h"
|
||||
#include "../internal/catch_version.h"
|
||||
#include "../internal/catch_console_colour.hpp"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
#if (_MANAGED == 1) || (_M_CEE == 1) // detect CLR
|
||||
|
||||
inline void write_output_message(const std::string& msg)
|
||||
{
|
||||
String^ tmp = gcnew String(msg.c_str());
|
||||
Console::WriteLine(tmp);
|
||||
}
|
||||
|
||||
#else // detect CLR
|
||||
|
||||
#ifdef _WINDLL
|
||||
|
||||
#ifdef _UNICODE
|
||||
inline void write_output_message(const std::string& msg)
|
||||
{
|
||||
std::wstringstream _s;
|
||||
_s << msg.c_str();
|
||||
std::wstring ws = _s.str();
|
||||
Logger::WriteMessage(ws.c_str());
|
||||
}
|
||||
#else
|
||||
inline void write_output_message(const std::string& msg)
|
||||
{
|
||||
Logger::WriteMessage(msg.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _WINDLL
|
||||
|
||||
#endif // detect CLR
|
||||
inline void replaceSingleLinefeed(const std::string& s, std::string& result)
|
||||
{
|
||||
bool needr(false);
|
||||
for(std::string::const_iterator it = s.begin(); it != s.end(); ++it ) {
|
||||
if( *it == '\r' ) {
|
||||
needr = false;
|
||||
}
|
||||
else if( *it == '\n' && needr ) {
|
||||
needr = false;
|
||||
result += '\r';
|
||||
result += *it;
|
||||
}
|
||||
else {
|
||||
needr = true;
|
||||
}
|
||||
result += *it;
|
||||
}
|
||||
}
|
||||
|
||||
struct VSStreamingReporterBase : SharedImpl<IStreamingReporter> {
|
||||
|
||||
VSStreamingReporterBase( ReporterConfig const& _config )
|
||||
: m_config( _config.fullConfig() )
|
||||
{}
|
||||
|
||||
virtual ~VSStreamingReporterBase() {}
|
||||
|
||||
virtual void noMatchingTestCases( std::string const& ) {}
|
||||
|
||||
virtual void testRunStarting( TestRunInfo const& _testRunInfo ) {
|
||||
currentTestRunInfo = _testRunInfo;
|
||||
}
|
||||
virtual void testGroupStarting( GroupInfo const& _groupInfo ) {
|
||||
currentGroupInfo = _groupInfo;
|
||||
}
|
||||
|
||||
virtual void testCaseStarting( TestCaseInfo const& _testInfo ) {
|
||||
currentTestCaseInfo = _testInfo;
|
||||
}
|
||||
virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
|
||||
m_sectionStack.push_back( _sectionInfo );
|
||||
}
|
||||
|
||||
virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) {
|
||||
m_sectionStack.pop_back();
|
||||
}
|
||||
virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) {
|
||||
currentTestCaseInfo.reset();
|
||||
assert( m_sectionStack.empty() );
|
||||
}
|
||||
virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) {
|
||||
currentGroupInfo.reset();
|
||||
}
|
||||
virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) {
|
||||
currentTestCaseInfo.reset();
|
||||
currentGroupInfo.reset();
|
||||
currentTestRunInfo.reset();
|
||||
}
|
||||
|
||||
Ptr<IConfig> m_config;
|
||||
|
||||
LazyStat<TestRunInfo> currentTestRunInfo;
|
||||
LazyStat<GroupInfo> currentGroupInfo;
|
||||
LazyStat<TestCaseInfo> currentTestCaseInfo;
|
||||
|
||||
std::vector<SectionInfo> m_sectionStack;
|
||||
};
|
||||
|
||||
struct MSTestReporter : VSStreamingReporterBase {
|
||||
typedef VSStreamingReporterBase StreamingReporterBase;
|
||||
MSTestReporter( ReporterConfig const& _config )
|
||||
: VSStreamingReporterBase( _config ),
|
||||
m_prevCout( std::cout.rdbuf() ),
|
||||
m_prevCerr( std::cerr.rdbuf() ),
|
||||
#if defined(INTERNAL_CATCH_VS_NATIVE) || _MSC_VER >= 1700
|
||||
m_addLineFeeds(false),
|
||||
#else
|
||||
m_addLineFeeds(true),
|
||||
#endif
|
||||
m_headerPrinted( false ),
|
||||
m_atLeastOneTestCasePrinted( false )
|
||||
{
|
||||
std::cout.rdbuf( stream.rdbuf() );
|
||||
std::cerr.rdbuf( stream.rdbuf() );
|
||||
}
|
||||
|
||||
virtual ~MSTestReporter() {
|
||||
std::string output = stream.str();
|
||||
if( !output.empty() ) {
|
||||
if( m_addLineFeeds ) {
|
||||
std::string revised;
|
||||
replaceSingleLinefeed(output, revised);
|
||||
write_output_message(revised);
|
||||
}
|
||||
else {
|
||||
write_output_message(output);
|
||||
}
|
||||
}
|
||||
std::cout.rdbuf( m_prevCout );
|
||||
std::cerr.rdbuf( m_prevCerr );
|
||||
}
|
||||
|
||||
static std::string getDescription() {
|
||||
return "Reports test results as plain lines of text";
|
||||
}
|
||||
virtual ReporterPreferences getPreferences() const {
|
||||
ReporterPreferences prefs;
|
||||
prefs.shouldRedirectStdOut = false;
|
||||
return prefs;
|
||||
}
|
||||
|
||||
virtual void noMatchingTestCases( std::string const& spec ) {
|
||||
stream << "No test cases matched '" << spec << "'" << std::endl;
|
||||
}
|
||||
|
||||
virtual void assertionStarting( AssertionInfo const& ) {
|
||||
}
|
||||
|
||||
virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
|
||||
AssertionResult const& result = _assertionStats.assertionResult;
|
||||
|
||||
bool printInfoMessages = true;
|
||||
|
||||
// Drop out if result was successful and we're not printing those
|
||||
if( !m_config->includeSuccessfulResults() && result.isOk() ) {
|
||||
if( result.getResultType() != ResultWas::Warning )
|
||||
return false;
|
||||
printInfoMessages = false;
|
||||
}
|
||||
|
||||
lazyPrint();
|
||||
|
||||
AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
|
||||
printer.print();
|
||||
stream << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
|
||||
m_headerPrinted = false;
|
||||
StreamingReporterBase::sectionStarting( _sectionInfo );
|
||||
}
|
||||
virtual void sectionEnded( SectionStats const& _sectionStats ) {
|
||||
if( _sectionStats.missingAssertions ) {
|
||||
lazyPrint();
|
||||
Colour colour( Colour::ResultError );
|
||||
if( m_sectionStack.size() > 1 )
|
||||
stream << "\nNo assertions in section";
|
||||
else
|
||||
stream << "\nNo assertions in test case";
|
||||
stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
|
||||
}
|
||||
if( m_headerPrinted ) {
|
||||
if( m_config->showDurations() == ShowDurations::Always )
|
||||
stream << "Completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
|
||||
m_headerPrinted = false;
|
||||
}
|
||||
else {
|
||||
if( m_config->showDurations() == ShowDurations::Always )
|
||||
stream << _sectionStats.sectionInfo.name << " completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
|
||||
}
|
||||
StreamingReporterBase::sectionEnded( _sectionStats );
|
||||
}
|
||||
|
||||
virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) {
|
||||
StreamingReporterBase::testCaseEnded( _testCaseStats );
|
||||
m_headerPrinted = false;
|
||||
}
|
||||
virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) {
|
||||
if( currentGroupInfo.used ) {
|
||||
printSummaryDivider();
|
||||
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
||||
printTotals( _testGroupStats.totals );
|
||||
stream << "\n" << std::endl;
|
||||
}
|
||||
StreamingReporterBase::testGroupEnded( _testGroupStats );
|
||||
}
|
||||
virtual void testRunEnded( TestRunStats const& _testRunStats ) {
|
||||
if( m_atLeastOneTestCasePrinted )
|
||||
printTotalsDivider();
|
||||
printTotals( _testRunStats.totals );
|
||||
stream << "\n" << std::endl;
|
||||
StreamingReporterBase::testRunEnded( _testRunStats );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
class AssertionPrinter {
|
||||
void operator= ( AssertionPrinter const& );
|
||||
public:
|
||||
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages )
|
||||
: stream( _stream ),
|
||||
stats( _stats ),
|
||||
result( _stats.assertionResult ),
|
||||
colour( Colour::None ),
|
||||
message( result.getMessage() ),
|
||||
messages( _stats.infoMessages ),
|
||||
printInfoMessages( _printInfoMessages )
|
||||
{
|
||||
switch( result.getResultType() ) {
|
||||
case ResultWas::Ok:
|
||||
colour = Colour::Success;
|
||||
passOrFail = "PASSED";
|
||||
//if( result.hasMessage() )
|
||||
if( _stats.infoMessages.size() == 1 )
|
||||
messageLabel = "with message";
|
||||
if( _stats.infoMessages.size() > 1 )
|
||||
messageLabel = "with messages";
|
||||
break;
|
||||
case ResultWas::ExpressionFailed:
|
||||
if( result.isOk() ) {
|
||||
colour = Colour::Success;
|
||||
passOrFail = "FAILED - but was ok";
|
||||
}
|
||||
else {
|
||||
colour = Colour::Error;
|
||||
passOrFail = "FAILED";
|
||||
}
|
||||
if( _stats.infoMessages.size() == 1 )
|
||||
messageLabel = "with message";
|
||||
if( _stats.infoMessages.size() > 1 )
|
||||
messageLabel = "with messages";
|
||||
break;
|
||||
case ResultWas::ThrewException:
|
||||
colour = Colour::Error;
|
||||
passOrFail = "FAILED";
|
||||
messageLabel = "due to unexpected exception with message";
|
||||
break;
|
||||
case ResultWas::DidntThrowException:
|
||||
colour = Colour::Error;
|
||||
passOrFail = "FAILED";
|
||||
messageLabel = "because no exception was thrown where one was expected";
|
||||
break;
|
||||
case ResultWas::Info:
|
||||
messageLabel = "info";
|
||||
break;
|
||||
case ResultWas::Warning:
|
||||
messageLabel = "warning";
|
||||
break;
|
||||
case ResultWas::ExplicitFailure:
|
||||
passOrFail = "FAILED";
|
||||
colour = Colour::Error;
|
||||
if( _stats.infoMessages.size() == 1 )
|
||||
messageLabel = "explicitly with message";
|
||||
if( _stats.infoMessages.size() > 1 )
|
||||
messageLabel = "explicitly with messages";
|
||||
break;
|
||||
// These cases are here to prevent compiler warnings
|
||||
case ResultWas::Unknown:
|
||||
case ResultWas::FailureBit:
|
||||
case ResultWas::Exception:
|
||||
passOrFail = "** internal error **";
|
||||
colour = Colour::Error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void print() const {
|
||||
printSourceInfo();
|
||||
if( stats.totals.assertions.total() > 0 ) {
|
||||
if( result.isOk() )
|
||||
stream << "\n";
|
||||
printResultType();
|
||||
printOriginalExpression();
|
||||
printReconstructedExpression();
|
||||
}
|
||||
else {
|
||||
stream << "\n";
|
||||
}
|
||||
printMessage();
|
||||
}
|
||||
|
||||
private:
|
||||
void printResultType() const {
|
||||
if( !passOrFail.empty() ) {
|
||||
Colour colourGuard( colour );
|
||||
stream << passOrFail << ":\n";
|
||||
}
|
||||
}
|
||||
void printOriginalExpression() const {
|
||||
if( result.hasExpression() ) {
|
||||
Colour colourGuard( Colour::OriginalExpression );
|
||||
stream << " ";
|
||||
stream << result.getExpressionInMacro();
|
||||
stream << "\n";
|
||||
}
|
||||
}
|
||||
void printReconstructedExpression() const {
|
||||
if( result.hasExpandedExpression() ) {
|
||||
stream << "with expansion:\n";
|
||||
Colour colourGuard( Colour::ReconstructedExpression );
|
||||
stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << "\n";
|
||||
}
|
||||
}
|
||||
void printMessage() const {
|
||||
if( !messageLabel.empty() )
|
||||
stream << messageLabel << ":" << "\n";
|
||||
for( std::vector<MessageInfo>::const_iterator it = messages.begin(), itEnd = messages.end();
|
||||
it != itEnd;
|
||||
++it ) {
|
||||
// If this assertion is a warning ignore any INFO messages
|
||||
if( printInfoMessages || it->type != ResultWas::Info )
|
||||
stream << Text( it->message, TextAttributes().setIndent(2) ) << "\n";
|
||||
}
|
||||
}
|
||||
void printSourceInfo() const {
|
||||
Colour colourGuard( Colour::FileName );
|
||||
stream << result.getSourceInfo() << ": ";
|
||||
}
|
||||
|
||||
std::ostream& stream;
|
||||
AssertionStats const& stats;
|
||||
AssertionResult const& result;
|
||||
Colour::Code colour;
|
||||
std::string passOrFail;
|
||||
std::string messageLabel;
|
||||
std::string message;
|
||||
std::vector<MessageInfo> messages;
|
||||
bool printInfoMessages;
|
||||
};
|
||||
|
||||
void lazyPrint() {
|
||||
|
||||
if( !currentTestRunInfo.used )
|
||||
lazyPrintRunInfo();
|
||||
if( !currentGroupInfo.used )
|
||||
lazyPrintGroupInfo();
|
||||
|
||||
if( !m_headerPrinted ) {
|
||||
printTestCaseAndSectionHeader();
|
||||
m_headerPrinted = true;
|
||||
}
|
||||
m_atLeastOneTestCasePrinted = true;
|
||||
}
|
||||
void lazyPrintRunInfo() {
|
||||
stream << "\n" << getTildes() << "\n";
|
||||
Colour colour( Colour::SecondaryText );
|
||||
stream << "Using Catch v" << libraryVersion::value.majorVersion << "."
|
||||
<< libraryVersion::value.minorVersion << " b"
|
||||
<< libraryVersion::value.buildNumber;
|
||||
if( libraryVersion::value.branchName != "master" )
|
||||
stream << " (" << libraryVersion::value.branchName << ")";
|
||||
#if (_MANAGED == 1) || (_M_CEE == 1) // detect CLR
|
||||
stream << " for a managed MSTest project." << "\n";
|
||||
#else
|
||||
#ifdef _WINDLL
|
||||
stream << " for a native MSTest project." << "\n";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
currentTestRunInfo.used = true;
|
||||
}
|
||||
void lazyPrintGroupInfo() {
|
||||
if( !currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1 ) {
|
||||
printClosedHeader( "Group: " + currentGroupInfo->name );
|
||||
currentGroupInfo.used = true;
|
||||
}
|
||||
}
|
||||
void printTestCaseAndSectionHeader() {
|
||||
assert( !m_sectionStack.empty() );
|
||||
printOpenHeader( currentTestCaseInfo->name );
|
||||
|
||||
if( m_sectionStack.size() > 1 ) {
|
||||
Colour colourGuard( Colour::Headers );
|
||||
|
||||
std::vector<SectionInfo>::const_iterator
|
||||
it = m_sectionStack.begin()+1, // Skip first section (test case)
|
||||
itEnd = m_sectionStack.end();
|
||||
for( ; it != itEnd; ++it )
|
||||
printHeaderString( it->name, 2 );
|
||||
}
|
||||
|
||||
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
|
||||
|
||||
if( !lineInfo.empty() ){
|
||||
stream << getDashes() << "\n";
|
||||
Colour colourGuard( Colour::FileName );
|
||||
stream << lineInfo << "\n";
|
||||
}
|
||||
stream << getDots() << "\n" << std::endl;
|
||||
}
|
||||
|
||||
void printClosedHeader( std::string const& _name ) {
|
||||
printOpenHeader( _name );
|
||||
stream << getDots() << "\n";
|
||||
}
|
||||
void printOpenHeader( std::string const& _name ) {
|
||||
stream << getDashes() << "\n";
|
||||
{
|
||||
Colour colourGuard( Colour::Headers );
|
||||
printHeaderString( _name );
|
||||
}
|
||||
}
|
||||
|
||||
// if string has a : in first line will set indent to follow it on
|
||||
// subsequent lines
|
||||
void printHeaderString( std::string const& _string, std::size_t indent = 0 ) {
|
||||
std::size_t i = _string.find( ": " );
|
||||
if( i != std::string::npos )
|
||||
i+=2;
|
||||
else
|
||||
i = 0;
|
||||
stream << Text( _string, TextAttributes()
|
||||
.setIndent( indent+i)
|
||||
.setInitialIndent( indent ) ) << "\n";
|
||||
}
|
||||
|
||||
void printTotals( const Totals& totals ) {
|
||||
if( totals.testCases.total() == 0 ) {
|
||||
stream << "No tests ran";
|
||||
}
|
||||
else if( totals.assertions.total() == 0 ) {
|
||||
Colour colour( Colour::Yellow );
|
||||
printCounts( "test case", totals.testCases );
|
||||
stream << " (no assertions)";
|
||||
}
|
||||
else if( totals.assertions.failed ) {
|
||||
Colour colour( Colour::ResultError );
|
||||
printCounts( "test case", totals.testCases );
|
||||
if( totals.testCases.failed > 0 ) {
|
||||
stream << " (";
|
||||
printCounts( "assertion", totals.assertions );
|
||||
stream << ")";
|
||||
}
|
||||
}
|
||||
else {
|
||||
Colour colour( Colour::ResultSuccess );
|
||||
stream << "All tests passed ("
|
||||
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
|
||||
<< pluralise( totals.testCases.passed, "test case" ) << ")";
|
||||
}
|
||||
}
|
||||
void printCounts( std::string const& label, Counts const& counts ) {
|
||||
if( counts.total() == 1 ) {
|
||||
stream << "1 " << label << " - ";
|
||||
if( counts.failed )
|
||||
stream << "failed";
|
||||
else
|
||||
stream << "passed";
|
||||
}
|
||||
else {
|
||||
stream << counts.total() << " " << label << "s ";
|
||||
if( counts.passed ) {
|
||||
if( counts.failed )
|
||||
stream << "- " << counts.failed << " failed";
|
||||
else if( counts.passed == 2 )
|
||||
stream << "- both passed";
|
||||
else
|
||||
stream << "- all passed";
|
||||
}
|
||||
else {
|
||||
if( counts.failed == 2 )
|
||||
stream << "- both failed";
|
||||
else
|
||||
stream << "- all failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void printTotalsDivider() {
|
||||
stream << getDoubleDashes() << "\n";
|
||||
}
|
||||
void printSummaryDivider() {
|
||||
stream << getDashes() << "\n";
|
||||
}
|
||||
static std::string getDashes() {
|
||||
const std::string dashes( CATCH_CONFIG_CONSOLE_WIDTH-1, '-' );
|
||||
return dashes;
|
||||
}
|
||||
static std::string getDots() {
|
||||
const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '.' );
|
||||
return dots;
|
||||
}
|
||||
static std::string getDoubleDashes() {
|
||||
const std::string doubleDashes( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );
|
||||
return doubleDashes;
|
||||
}
|
||||
static std::string getTildes() {
|
||||
const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '~' );
|
||||
return dots;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ostringstream stream;
|
||||
std::streambuf* m_prevCout;
|
||||
std::streambuf* m_prevCerr;
|
||||
protected:
|
||||
bool m_addLineFeeds;
|
||||
|
||||
private:
|
||||
bool m_headerPrinted;
|
||||
bool m_atLeastOneTestCasePrinted;
|
||||
};
|
||||
|
||||
struct MSTestReporterLineFeed : MSTestReporter {
|
||||
MSTestReporterLineFeed( ReporterConfig const& _config )
|
||||
: MSTestReporter( _config )
|
||||
{
|
||||
m_addLineFeeds = false;
|
||||
}
|
||||
};
|
||||
} // end namespace Catch
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_REPORTER_MSTEST_HPP_INCLUDED
|
@ -84,7 +84,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../../../include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -677,11 +677,11 @@ def parseTrxFile(baseName, trxFile):
|
||||
for tmp in lines:
|
||||
if (len(lines) >= (index + 2) and
|
||||
lines[index].startswith("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") and
|
||||
lines[index + 1].startswith("Using Catch v") ):
|
||||
lines[index + 1].startswith("Batch run using") ):
|
||||
found = True
|
||||
break
|
||||
index += 1
|
||||
lines = lines[index + 2:]
|
||||
lines = lines[index + 3:]
|
||||
#print "*******",desc
|
||||
#print lines
|
||||
if found:
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user