2013-12-03 19:52:41 +01:00
|
|
|
/*
|
|
|
|
* Created by Phil on 27/11/2013.
|
|
|
|
* Copyright 2013 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)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "catch_common.h"
|
2017-07-06 22:28:42 +02:00
|
|
|
#include "catch_context.h"
|
|
|
|
#include "catch_interfaces_config.h"
|
2013-12-03 19:52:41 +01:00
|
|
|
|
2017-01-29 22:03:27 +01:00
|
|
|
#include <cstring>
|
2017-08-01 18:46:33 +02:00
|
|
|
#include <ostream>
|
2017-01-29 22:03:27 +01:00
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
namespace Catch {
|
|
|
|
|
2017-07-13 09:25:47 +02:00
|
|
|
SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) noexcept
|
2013-12-03 19:52:41 +01:00
|
|
|
: file( _file ),
|
|
|
|
line( _line )
|
|
|
|
{}
|
2017-07-13 09:25:47 +02:00
|
|
|
bool SourceLineInfo::empty() const noexcept {
|
2017-01-29 22:03:27 +01:00
|
|
|
return file[0] == '\0';
|
2013-12-03 19:52:41 +01:00
|
|
|
}
|
2017-07-13 09:25:47 +02:00
|
|
|
bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept {
|
2017-01-29 22:03:27 +01:00
|
|
|
return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0);
|
2013-12-03 19:52:41 +01:00
|
|
|
}
|
2017-07-13 09:25:47 +02:00
|
|
|
bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept {
|
2017-01-29 22:03:27 +01:00
|
|
|
return line < other.line || ( line == other.line && (std::strcmp(file, other.file) < 0));
|
2015-03-04 08:08:53 +01:00
|
|
|
}
|
2013-12-03 19:52:41 +01:00
|
|
|
|
2015-07-03 00:02:35 +02:00
|
|
|
void seedRng( IConfig const& config ) {
|
|
|
|
if( config.rngSeed() != 0 )
|
|
|
|
std::srand( config.rngSeed() );
|
|
|
|
}
|
|
|
|
unsigned int rngSeed() {
|
|
|
|
return getCurrentContext().getConfig()->rngSeed();
|
|
|
|
}
|
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
|
|
|
|
#ifndef __GNUG__
|
2017-01-15 09:41:33 +01:00
|
|
|
os << info.file << '(' << info.line << ')';
|
2013-12-03 19:52:41 +01:00
|
|
|
#else
|
2017-01-15 09:41:33 +01:00
|
|
|
os << info.file << ':' << info.line;
|
2013-12-03 19:52:41 +01:00
|
|
|
#endif
|
|
|
|
return os;
|
|
|
|
}
|
2017-07-12 16:16:55 +02:00
|
|
|
|
|
|
|
bool isTrue( bool value ){ return value; }
|
|
|
|
bool alwaysTrue() { return true; }
|
|
|
|
bool alwaysFalse() { return false; }
|
|
|
|
|
2017-07-25 21:57:35 +02:00
|
|
|
std::string StreamEndStop::operator+() const {
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
}
|