2011-01-14 09:38:46 +01:00
|
|
|
/*
|
|
|
|
* catch_self_test.hpp
|
|
|
|
* Catch
|
|
|
|
*
|
|
|
|
* Created by Phil on 14/01/2011.
|
|
|
|
* Copyright 2011 Two Blue Cubes Ltd. 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_SELF_TEST_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED
|
|
|
|
|
|
|
|
#include "../catch.hpp"
|
|
|
|
#include "catch_runner_impl.hpp"
|
|
|
|
|
|
|
|
namespace Catch
|
|
|
|
{
|
2011-02-09 10:08:10 +01:00
|
|
|
|
|
|
|
class EmbeddedRunner
|
2011-01-14 09:38:46 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2011-02-09 10:08:10 +01:00
|
|
|
EmbeddedRunner
|
2011-02-03 21:00:46 +01:00
|
|
|
()
|
2011-01-14 09:38:46 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-14 17:21:11 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2011-02-09 10:08:10 +01:00
|
|
|
std::size_t runMatching
|
2011-02-03 21:00:46 +01:00
|
|
|
(
|
2011-02-09 10:08:10 +01:00
|
|
|
const std::string& rawTestSpec
|
2011-02-03 21:00:46 +01:00
|
|
|
)
|
2011-01-14 09:38:46 +01:00
|
|
|
{
|
2011-02-09 10:08:10 +01:00
|
|
|
std::ostringstream oss;
|
|
|
|
Config config;
|
|
|
|
config.setStreamBuf( oss.rdbuf() );
|
|
|
|
config.setReporter( "basic" );
|
|
|
|
|
|
|
|
std::size_t result;
|
2011-02-09 20:26:59 +01:00
|
|
|
|
|
|
|
// Scoped because Runner doesn't report EndTesting until its destructor
|
|
|
|
{
|
|
|
|
Runner runner( config );
|
|
|
|
result = runner.runMatching( rawTestSpec );
|
|
|
|
m_successes = runner.getSuccessCount();
|
|
|
|
m_failures = runner.getFailureCount();
|
|
|
|
}
|
2011-02-09 10:08:10 +01:00
|
|
|
m_output = oss.str();
|
|
|
|
return result;
|
2011-01-14 09:38:46 +01:00
|
|
|
}
|
2011-01-14 17:21:11 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2011-02-09 10:08:10 +01:00
|
|
|
std::string getOutput
|
2011-02-03 21:00:46 +01:00
|
|
|
()
|
2011-01-14 09:38:46 +01:00
|
|
|
{
|
2011-02-09 10:08:10 +01:00
|
|
|
return m_output;
|
2011-01-14 09:38:46 +01:00
|
|
|
}
|
|
|
|
|
2011-01-14 17:21:11 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2011-02-09 10:08:10 +01:00
|
|
|
std::size_t getSuccessCount
|
2011-02-03 21:00:46 +01:00
|
|
|
()
|
2011-02-09 10:08:10 +01:00
|
|
|
const
|
2011-01-14 09:38:46 +01:00
|
|
|
{
|
2011-02-09 10:08:10 +01:00
|
|
|
return m_successes;
|
2011-01-14 09:38:46 +01:00
|
|
|
}
|
|
|
|
|
2011-01-14 17:21:11 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2011-02-09 10:08:10 +01:00
|
|
|
std:: size_t getFailureCount
|
2011-02-03 21:00:46 +01:00
|
|
|
()
|
2011-02-09 10:08:10 +01:00
|
|
|
const
|
2011-01-14 09:38:46 +01:00
|
|
|
{
|
2011-02-09 10:08:10 +01:00
|
|
|
return m_failures;
|
2011-01-14 09:38:46 +01:00
|
|
|
}
|
2011-02-09 10:08:10 +01:00
|
|
|
|
2011-01-14 09:38:46 +01:00
|
|
|
private:
|
2011-02-09 10:08:10 +01:00
|
|
|
std::size_t m_successes;
|
|
|
|
std::size_t m_failures;
|
|
|
|
std::string m_output;
|
2011-01-14 09:38:46 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED
|