More reformatting

This commit is contained in:
Phil Nash 2012-05-16 08:02:20 +01:00
parent c67a7eef2b
commit 6cd2ac7544
11 changed files with 125 additions and 351 deletions

View file

@ -1,15 +1,10 @@
/*
* catch_generators_impl.hpp
* Catch
*
* Created by Phil on 28/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_GENERATORS_IMPL_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
@ -19,37 +14,24 @@
#include <string>
#include <map>
namespace Catch
{
struct GeneratorInfo
{
///////////////////////////////////////////////////////////////////////
GeneratorInfo
(
std::size_t size
)
namespace Catch {
struct GeneratorInfo {
GeneratorInfo( std::size_t size )
: m_size( size ),
m_currentIndex( 0 )
{
}
{}
///////////////////////////////////////////////////////////////////////
bool moveNext
()
{
if( ++m_currentIndex == m_size )
{
bool moveNext() {
if( ++m_currentIndex == m_size ) {
m_currentIndex = 0;
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////
std::size_t getCurrentIndex
()
const
{
std::size_t getCurrentIndex() const {
return m_currentIndex;
}
@ -57,30 +39,18 @@ namespace Catch
std::size_t m_currentIndex;
};
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
class GeneratorsForTest
{
class GeneratorsForTest {
public:
///////////////////////////////////////////////////////////////////////
~GeneratorsForTest
()
{
~GeneratorsForTest() {
deleteAll( m_generatorsInOrder );
}
///////////////////////////////////////////////////////////////////////
GeneratorInfo& getGeneratorInfo
(
const std::string& fileInfo,
std::size_t size
)
{
GeneratorInfo& getGeneratorInfo( const std::string& fileInfo, std::size_t size ) {
std::map<std::string, GeneratorInfo*>::const_iterator it = m_generatorsByName.find( fileInfo );
if( it == m_generatorsByName.end() )
{
if( it == m_generatorsByName.end() ) {
GeneratorInfo* info = new GeneratorInfo( size );
m_generatorsByName.insert( std::make_pair( fileInfo, info ) );
m_generatorsInOrder.push_back( info );
@ -89,14 +59,10 @@ namespace Catch
return *it->second;
}
///////////////////////////////////////////////////////////////////////
bool moveNext
()
{
bool moveNext() {
std::vector<GeneratorInfo*>::const_iterator it = m_generatorsInOrder.begin();
std::vector<GeneratorInfo*>::const_iterator itEnd = m_generatorsInOrder.end();
for(; it != itEnd; ++it )
{
for(; it != itEnd; ++it ) {
if( (*it)->moveNext() )
return true;
}