catch_common.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Created by Phil on 27/11/2013.
  3. * Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
  4. *
  5. * Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #include "catch_common.h"
  9. #include "catch_context.h"
  10. #include "catch_interfaces_config.h"
  11. #include <cstring>
  12. #include <ostream>
  13. namespace Catch {
  14. bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept {
  15. return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0);
  16. }
  17. bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept {
  18. // We can assume that the same file will usually have the same pointer.
  19. // Thus, if the pointers are the same, there is no point in calling the strcmp
  20. return line < other.line || ( line == other.line && file != other.file && (std::strcmp(file, other.file) < 0));
  21. }
  22. std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
  23. #ifndef __GNUG__
  24. os << info.file << '(' << info.line << ')';
  25. #else
  26. os << info.file << ':' << info.line;
  27. #endif
  28. return os;
  29. }
  30. std::string StreamEndStop::operator+() const {
  31. return std::string();
  32. }
  33. NonCopyable::NonCopyable() = default;
  34. NonCopyable::~NonCopyable() = default;
  35. }