Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_message.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2017-07-06 22:28:42 +0200
committerMartin Hořeňovský2017-07-06 22:28:42 +0200
commitfc32165d48f0a46a60ac02e0e52f8c89adafd8be (patch)
treeacf2c6dc020615db581ce425b7ce0a424d801f83 /include/internal/catch_message.cpp
parent0016362f69804ae18953a0ec11d0c108e8402e1d (diff)
downloadcatch3-fc32165d48f0a46a60ac02e0e52f8c89adafd8be.tar.gz
Started work on splitting out .cpp files from header files
Diffstat (limited to 'include/internal/catch_message.cpp')
-rw-r--r--include/internal/catch_message.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/include/internal/catch_message.cpp b/include/internal/catch_message.cpp
new file mode 100644
index 00000000..2f474a90
--- /dev/null
+++ b/include/internal/catch_message.cpp
@@ -0,0 +1,62 @@
+/*
+ * Created by Phil Nash on 1/2/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_message.h"
+#include "catch_interfaces_capture.h"
+
+namespace Catch {
+
+ MessageInfo::MessageInfo( std::string const& _macroName,
+ SourceLineInfo const& _lineInfo,
+ ResultWas::OfType _type )
+ : macroName( _macroName ),
+ lineInfo( _lineInfo ),
+ type( _type ),
+ sequence( ++globalCount )
+ {}
+
+ bool MessageInfo::operator==( MessageInfo const& other ) const {
+ return sequence == other.sequence;
+ }
+
+ bool MessageInfo::operator<( MessageInfo const& other ) const {
+ return sequence < other.sequence;
+ }
+
+ // This may need protecting if threading support is added
+ unsigned int MessageInfo::globalCount = 0;
+
+
+ ////////////////////////////////////////////////////////////////////////////
+
+ Catch::MessageBuilder::MessageBuilder( std::string const& macroName,
+ SourceLineInfo const& lineInfo,
+ ResultWas::OfType type )
+ :m_info(macroName, lineInfo, type) {}
+
+ ////////////////////////////////////////////////////////////////////////////
+
+
+ ScopedMessage::ScopedMessage( MessageBuilder const& builder )
+ : m_info( builder.m_info )
+ {
+ m_info.message = builder.m_stream.str();
+ getResultCapture().pushScopedMessage( m_info );
+ }
+ ScopedMessage::ScopedMessage( ScopedMessage const& other )
+ : m_info( other.m_info )
+ {}
+
+ ScopedMessage::~ScopedMessage() {
+ if ( !std::uncaught_exception() ){
+ getResultCapture().popScopedMessage(m_info);
+ }
+ }
+
+
+} // end namespace Catch