2020-08-30 15:43:45 +02:00
|
|
|
|
|
|
|
|
// Copyright Catch2 Authors
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
|
// https://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
|
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/internal/catch_common.hpp>
|
2013-12-03 18:52:41 +00: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 18:52:41 +00:00
|
|
|
namespace Catch {
|
|
|
|
|
|
2017-07-13 08:25:47 +01: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 18:52:41 +00:00
|
|
|
}
|
2017-07-13 08:25:47 +01:00
|
|
|
bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept {
|
2018-07-23 20:46:36 +02:00
|
|
|
// We can assume that the same file will usually have the same pointer.
|
|
|
|
|
// Thus, if the pointers are the same, there is no point in calling the strcmp
|
|
|
|
|
return line < other.line || ( line == other.line && file != other.file && (std::strcmp(file, other.file) < 0));
|
2015-03-04 07:08:53 +00:00
|
|
|
}
|
2013-12-03 18:52:41 +00: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 18:52:41 +00:00
|
|
|
#else
|
2017-01-15 09:41:33 +01:00
|
|
|
os << info.file << ':' << info.line;
|
2013-12-03 18:52:41 +00:00
|
|
|
#endif
|
|
|
|
|
return os;
|
|
|
|
|
}
|
2017-07-12 16:16:55 +02:00
|
|
|
|
2019-10-30 18:51:14 +01:00
|
|
|
} // end namespace Catch
|