Revert "Run clang-format on all *.h and *.cpp files"

This reverts commit ba5cabaae5.
This commit is contained in:
Ted Lyngmo 2019-03-12 18:55:27 +01:00
parent b8360657dc
commit 0beba2c30f
138 changed files with 10531 additions and 12363 deletions

View File

@ -12,6 +12,6 @@
namespace YAML { namespace YAML {
typedef std::size_t anchor_t; typedef std::size_t anchor_t;
const anchor_t NullAnchor = 0; const anchor_t NullAnchor = 0;
} // namespace YAML }
#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -22,10 +22,10 @@ class YAML_CPP_API Binary {
Binary(const unsigned char *data_, std::size_t size_) Binary(const unsigned char *data_, std::size_t size_)
: m_data{}, m_unownedData(data_), m_unownedSize(size_) {} : m_data{}, m_unownedData(data_), m_unownedSize(size_) {}
Binary() : Binary(nullptr, 0) {} Binary() : Binary(nullptr, 0) {}
Binary(const Binary &) = default; Binary(const Binary&) = default;
Binary(Binary &&) = default; Binary(Binary&&) = default;
Binary &operator=(const Binary &) = default; Binary& operator=(const Binary&) = default;
Binary &operator=(Binary &&) = default; Binary& operator=(Binary&&) = default;
bool owned() const { return !m_unownedData; } bool owned() const { return !m_unownedData; }
std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; }
@ -66,6 +66,6 @@ class YAML_CPP_API Binary {
const unsigned char *m_unownedData; const unsigned char *m_unownedData;
std::size_t m_unownedSize; std::size_t m_unownedSize;
}; };
} // namespace YAML }
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -35,6 +35,6 @@ class AnchorDict {
private: private:
std::vector<T> m_data; std::vector<T> m_data;
}; };
} // namespace YAML }
#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -144,6 +144,6 @@ typename Impl::Node *BuildGraphOfNextDocument(Parser &parser, Impl &impl) {
return static_cast<typename Impl::Node *>( return static_cast<typename Impl::Node *>(
BuildGraphOfNextDocument(parser, graphBuilder)); BuildGraphOfNextDocument(parser, graphBuilder));
} }
} // namespace YAML }
#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -52,6 +52,6 @@ class EmitFromEvents : public EventHandler {
}; };
std::stack<State::value> m_stateStack; std::stack<State::value> m_stateStack;
}; };
} // namespace YAML }
#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -250,6 +250,6 @@ inline Emitter& operator<<(Emitter& emitter, _Indent indent) {
inline Emitter& operator<<(Emitter& emitter, _Precision precision) { inline Emitter& operator<<(Emitter& emitter, _Precision precision) {
return emitter.SetLocalPrecision(precision); return emitter.SetLocalPrecision(precision);
} }
} // namespace YAML }
#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -11,6 +11,6 @@ namespace YAML {
struct EmitterNodeType { struct EmitterNodeType {
enum value { NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap }; enum value { NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap };
}; };
} // namespace YAML }
#endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -132,6 +132,6 @@ inline _Precision FloatPrecision(int n) { return _Precision(n, -1); }
inline _Precision DoublePrecision(int n) { return _Precision(-1, n); } inline _Precision DoublePrecision(int n) { return _Precision(-1, n); }
inline _Precision Precision(int n) { return _Precision(n, n); } inline _Precision Precision(int n) { return _Precision(n, n); }
} // namespace YAML }
#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -11,6 +11,6 @@ namespace YAML {
struct EmitterStyle { struct EmitterStyle {
enum value { Default, Block, Flow }; enum value { Default, Block, Flow };
}; };
} // namespace YAML }
#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -35,6 +35,6 @@ class EventHandler {
anchor_t anchor, EmitterStyle::value style) = 0; anchor_t anchor, EmitterStyle::value style) = 0;
virtual void OnMapEnd() = 0; virtual void OnMapEnd() = 0;
}; };
} // namespace YAML }
#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -16,9 +16,9 @@
// This is here for compatibility with older versions of Visual Studio // This is here for compatibility with older versions of Visual Studio
// which don't support noexcept // which don't support noexcept
#if defined(_MSC_VER) && _MSC_VER < 1900 #if defined(_MSC_VER) && _MSC_VER < 1900
#define YAML_CPP_NOEXCEPT _NOEXCEPT #define YAML_CPP_NOEXCEPT _NOEXCEPT
#else #else
#define YAML_CPP_NOEXCEPT noexcept #define YAML_CPP_NOEXCEPT noexcept
#endif #endif
namespace YAML { namespace YAML {
@ -114,7 +114,7 @@ inline const std::string KEY_NOT_FOUND_WITH_KEY(
stream << KEY_NOT_FOUND << ": " << key; stream << KEY_NOT_FOUND << ": " << key;
return stream.str(); return stream.str();
} }
} // namespace ErrorMsg }
class YAML_CPP_API Exception : public std::runtime_error { class YAML_CPP_API Exception : public std::runtime_error {
public: public:
@ -260,7 +260,7 @@ class YAML_CPP_API BadFile : public Exception {
BadFile(const BadFile&) = default; BadFile(const BadFile&) = default;
virtual ~BadFile() YAML_CPP_NOEXCEPT; virtual ~BadFile() YAML_CPP_NOEXCEPT;
}; };
} // namespace YAML }
#undef YAML_CPP_NOEXCEPT #undef YAML_CPP_NOEXCEPT

View File

@ -24,6 +24,6 @@ struct YAML_CPP_API Mark {
Mark(int pos_, int line_, int column_) Mark(int pos_, int line_, int column_)
: pos(pos_), line(line_), column(column_) {} : pos(pos_), line(line_), column(column_) {}
}; };
} // namespace YAML }
#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -42,7 +42,7 @@ inline bool IsNegativeInfinity(const std::string& input) {
inline bool IsNaN(const std::string& input) { inline bool IsNaN(const std::string& input) {
return input == ".nan" || input == ".NaN" || input == ".NAN"; return input == ".nan" || input == ".NaN" || input == ".NAN";
} }
} // namespace conversion }
// Node // Node
template <> template <>
@ -76,7 +76,7 @@ struct convert<const char*> {
template <std::size_t N> template <std::size_t N>
struct convert<const char[N]> { struct convert<const char[N]> {
static Node encode(const char (&rhs)[N]) { return Node(rhs); } static Node encode(const char(&rhs)[N]) { return Node(rhs); }
}; };
template <> template <>
@ -327,6 +327,6 @@ struct convert<Binary> {
return true; return true;
} }
}; };
} // namespace YAML }
#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -14,8 +14,8 @@ struct unspecified_bool {
static void true_value(NOT_ALLOWED*) {} static void true_value(NOT_ALLOWED*) {}
}; };
typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*); typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*);
} // namespace detail }
} // namespace YAML }
#define YAML_CPP_OPERATOR_BOOL() \ #define YAML_CPP_OPERATOR_BOOL() \
operator YAML::detail::unspecified_bool_type() const { \ operator YAML::detail::unspecified_bool_type() const { \

View File

@ -212,7 +212,7 @@ inline node& node_data::convert_to_node(const T& rhs,
pMemory->merge(*value.m_pMemory); pMemory->merge(*value.m_pMemory);
return *value.m_pNode; return *value.m_pNode;
} }
} // namespace detail }
} // namespace YAML }
#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -14,6 +14,7 @@
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
namespace YAML { namespace YAML {
namespace detail { namespace detail {
struct iterator_value; struct iterator_value;

View File

@ -18,10 +18,10 @@ namespace detail {
struct iterator_value; struct iterator_value;
template <typename V> template <typename V>
class iterator_base; class iterator_base;
} // namespace detail }
typedef detail::iterator_base<detail::iterator_value> iterator; typedef detail::iterator_base<detail::iterator_value> iterator;
typedef detail::iterator_base<const detail::iterator_value> const_iterator; typedef detail::iterator_base<const detail::iterator_value> const_iterator;
} // namespace YAML }
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -41,7 +41,7 @@ class YAML_CPP_API memory_holder {
private: private:
shared_memory m_pMemory; shared_memory m_pMemory;
}; };
} // namespace detail }
} // namespace YAML }
#endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -7,11 +7,11 @@
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/dll.h"
#include "yaml-cpp/emitterstyle.h" #include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/node/detail/node_ref.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h" #include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_ref.h"
#include <set> #include <set>
namespace YAML { namespace YAML {
@ -163,7 +163,7 @@ class node {
typedef std::set<node*> nodes; typedef std::set<node*> nodes;
nodes m_dependencies; nodes m_dependencies;
}; };
} // namespace detail }
} // namespace YAML }
#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -121,7 +121,7 @@ class YAML_CPP_API node_data {
typedef std::list<kv_pair> kv_pairs; typedef std::list<kv_pair> kv_pairs;
mutable kv_pairs m_undefinedPairs; mutable kv_pairs m_undefinedPairs;
}; };
} // namespace detail }
} // namespace YAML }
#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -11,8 +11,8 @@
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
#include <map>
#include <memory> #include <memory>
#include <map>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -174,7 +174,7 @@ class node_iterator_base
typedef node_iterator_base<node> node_iterator; typedef node_iterator_base<node> node_iterator;
typedef node_iterator_base<const node> const_node_iterator; typedef node_iterator_base<const node> const_node_iterator;
} // namespace detail }
} // namespace YAML }
#endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -8,9 +8,9 @@
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/detail/node_data.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/type.h" #include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_data.h"
namespace YAML { namespace YAML {
namespace detail { namespace detail {
@ -92,7 +92,7 @@ class node_ref {
private: private:
shared_node_data m_pData; shared_node_data m_pData;
}; };
} // namespace detail }
} // namespace YAML }
#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -7,8 +7,8 @@
#pragma once #pragma once
#endif #endif
#include <iosfwd>
#include <string> #include <string>
#include <iosfwd>
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"

View File

@ -7,11 +7,11 @@
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/exceptions.h" #include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/detail/memory.h" #include "yaml-cpp/node/detail/memory.h"
#include "yaml-cpp/node/detail/node.h" #include "yaml-cpp/node/detail/node.h"
#include "yaml-cpp/node/iterator.h" #include "yaml-cpp/exceptions.h"
#include "yaml-cpp/node/node.h"
#include <string> #include <string>
namespace YAML { namespace YAML {
@ -366,7 +366,7 @@ template <typename T>
inline typename to_value_t<T>::return_type to_value(const T& t) { inline typename to_value_t<T>::return_type to_value(const T& t) {
return to_value_t<T>(t)(); return to_value_t<T>(t)();
} }
} // namespace detail }
// indexing // indexing
template <typename Key> template <typename Key>
@ -374,8 +374,8 @@ inline const Node Node::operator[](const Key& key) const {
if (!m_isValid) if (!m_isValid)
throw InvalidNode(); throw InvalidNode();
EnsureNodeExists(); EnsureNodeExists();
detail::node* value = static_cast<const detail::node&>(*m_pNode).get( detail::node* value = static_cast<const detail::node&>(*m_pNode)
detail::to_value(key), m_pMemory); .get(detail::to_value(key), m_pMemory);
if (!value) { if (!value) {
return Node(ZombieNode); return Node(ZombieNode);
} }
@ -443,6 +443,6 @@ inline void Node::force_insert(const Key& key, const Value& value) {
// free functions // free functions
inline bool operator==(const Node& lhs, const Node& rhs) { return lhs.is(rhs); } inline bool operator==(const Node& lhs, const Node& rhs) { return lhs.is(rhs); }
} // namespace YAML }
#endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -8,9 +8,9 @@
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/detail/iterator.h"
#include "yaml-cpp/node/detail/iterator_fwd.h"
#include "yaml-cpp/node/node.h" #include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/detail/iterator_fwd.h"
#include "yaml-cpp/node/detail/iterator.h"
#include <list> #include <list>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -25,7 +25,7 @@ struct iterator_value : public Node, std::pair<Node, Node> {
explicit iterator_value(const Node& key, const Node& value) explicit iterator_value(const Node& key, const Node& value)
: Node(Node::ZombieNode), std::pair<Node, Node>(key, value) {} : Node(Node::ZombieNode), std::pair<Node, Node>(key, value) {}
}; };
} // namespace detail }
} // namespace YAML }
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -140,6 +140,6 @@ YAML_CPP_API Node Clone(const Node& node);
template <typename T> template <typename T>
struct convert; struct convert;
} // namespace YAML }
#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -23,7 +23,7 @@ typedef std::shared_ptr<node_ref> shared_node_ref;
typedef std::shared_ptr<node_data> shared_node_data; typedef std::shared_ptr<node_data> shared_node_data;
typedef std::shared_ptr<memory_holder> shared_memory_holder; typedef std::shared_ptr<memory_holder> shared_memory_holder;
typedef std::shared_ptr<memory> shared_memory; typedef std::shared_ptr<memory> shared_memory;
} // namespace detail }
} // namespace YAML }
#endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -11,6 +11,6 @@ namespace YAML {
struct NodeType { struct NodeType {
enum value { Undefined, Null, Scalar, Sequence, Map }; enum value { Undefined, Null, Scalar, Sequence, Map };
}; };
} // namespace YAML }
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -21,6 +21,6 @@ YAML_CPP_API bool IsNull(const Node& node); // old API only
YAML_CPP_API bool IsNullString(const std::string& str); YAML_CPP_API bool IsNullString(const std::string& str);
extern YAML_CPP_API _Null Null; extern YAML_CPP_API _Null Null;
} // namespace YAML }
#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -56,7 +56,7 @@ class YAML_CPP_API ostream_wrapper {
template <std::size_t N> template <std::size_t N>
inline ostream_wrapper& operator<<(ostream_wrapper& stream, inline ostream_wrapper& operator<<(ostream_wrapper& stream,
const char (&str)[N]) { const char(&str)[N]) {
stream.write(str, N - 1); stream.write(str, N - 1);
return stream; return stream;
} }
@ -71,6 +71,6 @@ inline ostream_wrapper& operator<<(ostream_wrapper& stream, char ch) {
stream.write(&ch, 1); stream.write(&ch, 1);
return stream; return stream;
} }
} // namespace YAML }
#endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -86,6 +86,6 @@ class YAML_CPP_API Parser {
std::unique_ptr<Scanner> m_pScanner; std::unique_ptr<Scanner> m_pScanner;
std::unique_ptr<Directives> m_pDirectives; std::unique_ptr<Directives> m_pDirectives;
}; };
} // namespace YAML }
#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -7,10 +7,10 @@
#pragma once #pragma once
#endif #endif
#include <list>
#include <map>
#include <set>
#include <vector> #include <vector>
#include <list>
#include <set>
#include <map>
namespace YAML { namespace YAML {
template <typename Seq> template <typename Seq>
@ -46,6 +46,6 @@ inline Emitter& operator<<(Emitter& emitter, const std::map<K, V>& m) {
emitter << EndMap; emitter << EndMap;
return emitter; return emitter;
} }
} // namespace YAML }
#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -98,6 +98,6 @@ struct disable_if_c<true, T> {};
template <class Cond, class T = void> template <class Cond, class T = void>
struct disable_if : public disable_if_c<Cond::value, T> {}; struct disable_if : public disable_if_c<Cond::value, T> {};
} // namespace YAML }
#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -7,18 +7,18 @@
#pragma once #pragma once
#endif #endif
#include "yaml-cpp/parser.h"
#include "yaml-cpp/emitter.h" #include "yaml-cpp/emitter.h"
#include "yaml-cpp/emitterstyle.h" #include "yaml-cpp/emitterstyle.h"
#include "yaml-cpp/exceptions.h"
#include "yaml-cpp/parser.h"
#include "yaml-cpp/stlemitter.h" #include "yaml-cpp/stlemitter.h"
#include "yaml-cpp/exceptions.h"
#include "yaml-cpp/node/convert.h"
#include "yaml-cpp/node/detail/impl.h"
#include "yaml-cpp/node/emit.h"
#include "yaml-cpp/node/impl.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/node.h" #include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/impl.h"
#include "yaml-cpp/node/convert.h"
#include "yaml-cpp/node/iterator.h"
#include "yaml-cpp/node/detail/impl.h"
#include "yaml-cpp/node/parse.h" #include "yaml-cpp/node/parse.h"
#include "yaml-cpp/node/emit.h"
#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -97,4 +97,4 @@ std::vector<unsigned char> DecodeBase64(const std::string &input) {
ret.resize(out - &ret[0]); ret.resize(out - &ret[0]);
return ret; return ret;
} }
} // namespace YAML }

View File

@ -7,8 +7,8 @@
#pragma once #pragma once
#endif #endif
#include <cassert>
#include <stack> #include <stack>
#include <cassert>
namespace YAML { namespace YAML {
struct CollectionType { struct CollectionType {
@ -36,6 +36,6 @@ class CollectionStack {
private: private:
std::stack<CollectionType::value> collectionStack; std::stack<CollectionType::value> collectionStack;
}; };
} // namespace YAML }
#endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -14,4 +14,4 @@ void* BuildGraphOfNextDocument(Parser& parser,
return nullptr; return nullptr;
} }
} }
} // namespace YAML }

View File

@ -91,4 +91,4 @@ void GraphBuilderAdapter::DispositionNode(void *pNode) {
m_builder.AppendToSequence(pContainer, pNode); m_builder.AppendToSequence(pContainer, pNode);
} }
} }
} // namespace YAML }

View File

@ -26,11 +26,7 @@ namespace YAML {
class GraphBuilderAdapter : public EventHandler { class GraphBuilderAdapter : public EventHandler {
public: public:
GraphBuilderAdapter(GraphBuilderInterface& builder) GraphBuilderAdapter(GraphBuilderInterface& builder)
: m_builder(builder), : m_builder(builder), m_containers{}, m_anchors{}, m_pRootNode(nullptr), m_pKeyNode(nullptr) {}
m_containers{},
m_anchors{},
m_pRootNode(nullptr),
m_pKeyNode(nullptr) {}
GraphBuilderAdapter(const GraphBuilderAdapter&) = delete; GraphBuilderAdapter(const GraphBuilderAdapter&) = delete;
GraphBuilderAdapter(GraphBuilderAdapter&&) = delete; GraphBuilderAdapter(GraphBuilderAdapter&&) = delete;
GraphBuilderAdapter& operator=(const GraphBuilderAdapter&) = delete; GraphBuilderAdapter& operator=(const GraphBuilderAdapter&) = delete;
@ -82,6 +78,6 @@ class GraphBuilderAdapter : public EventHandler {
void RegisterAnchor(anchor_t anchor, void* pNode); void RegisterAnchor(anchor_t anchor, void* pNode);
void DispositionNode(void* pNode); void DispositionNode(void* pNode);
}; };
} // namespace YAML }
#endif // GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -39,7 +39,7 @@ bool IsFlexibleCase(const std::string& str) {
std::string rest = str.substr(1); std::string rest = str.substr(1);
return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper)); return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper));
} }
} // namespace }
namespace YAML { namespace YAML {
bool convert<bool>::decode(const Node& node, bool& rhs) { bool convert<bool>::decode(const Node& node, bool& rhs) {
@ -52,10 +52,7 @@ bool convert<bool>::decode(const Node& node, bool& rhs) {
static const struct { static const struct {
std::string truename, falsename; std::string truename, falsename;
} names[] = { } names[] = {
{"y", "n"}, {"y", "n"}, {"yes", "no"}, {"true", "false"}, {"on", "off"},
{"yes", "no"},
{"true", "false"},
{"on", "off"},
}; };
if (!IsFlexibleCase(node.Scalar())) if (!IsFlexibleCase(node.Scalar()))
@ -75,4 +72,4 @@ bool convert<bool>::decode(const Node& node, bool& rhs) {
return false; return false;
} }
} // namespace YAML }

View File

@ -14,4 +14,4 @@ const std::string Directives::TranslateTagHandle(
return it->second; return it->second;
} }
} // namespace YAML }

View File

@ -7,8 +7,8 @@
#pragma once #pragma once
#endif #endif
#include <map>
#include <string> #include <string>
#include <map>
namespace YAML { namespace YAML {
struct Version { struct Version {
@ -24,6 +24,6 @@ struct Directives {
Version version; Version version;
std::map<std::string, std::string> tags; std::map<std::string, std::string> tags;
}; };
} // namespace YAML }
#endif // DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -1,7 +1,7 @@
#include "yaml-cpp/node/emit.h" #include "yaml-cpp/node/emit.h"
#include "nodeevents.h"
#include "yaml-cpp/emitfromevents.h" #include "yaml-cpp/emitfromevents.h"
#include "yaml-cpp/emitter.h" #include "yaml-cpp/emitter.h"
#include "nodeevents.h"
namespace YAML { namespace YAML {
Emitter& operator<<(Emitter& out, const Node& node) { Emitter& operator<<(Emitter& out, const Node& node) {

View File

@ -16,11 +16,10 @@ std::string ToString(YAML::anchor_t anchor) {
stream << anchor; stream << anchor;
return stream.str(); return stream.str();
} }
} // namespace }
namespace YAML { namespace YAML {
EmitFromEvents::EmitFromEvents(Emitter& emitter) EmitFromEvents::EmitFromEvents(Emitter& emitter) : m_emitter(emitter), m_stateStack{} {}
: m_emitter(emitter), m_stateStack{} {}
void EmitFromEvents::OnDocumentStart(const Mark&) {} void EmitFromEvents::OnDocumentStart(const Mark&) {}
@ -117,4 +116,4 @@ void EmitFromEvents::EmitProps(const std::string& tag, anchor_t anchor) {
if (anchor) if (anchor)
m_emitter << Anchor(ToString(anchor)); m_emitter << Anchor(ToString(anchor));
} }
} // namespace YAML }

View File

@ -906,4 +906,4 @@ Emitter& Emitter::Write(const Binary& binary) {
return *this; return *this;
} }
} // namespace YAML }

View File

@ -30,7 +30,8 @@ EmitterState::EmitterState()
m_hasAnchor(false), m_hasAnchor(false),
m_hasTag(false), m_hasTag(false),
m_hasNonContent(false), m_hasNonContent(false),
m_docCount(0) {} m_docCount(0)
{}
EmitterState::~EmitterState() {} EmitterState::~EmitterState() {}
@ -366,4 +367,4 @@ bool EmitterState::SetDoublePrecision(std::size_t value,
_Set(m_doublePrecision, value, scope); _Set(m_doublePrecision, value, scope);
return true; return true;
} }
} // namespace YAML }

View File

@ -145,12 +145,7 @@ class EmitterState {
struct Group { struct Group {
explicit Group(GroupType::value type_) explicit Group(GroupType::value type_)
: type(type_), : type(type_), flowType{}, indent(0), childCount(0), longKey(false), modifiedSettings{} {}
flowType{},
indent(0),
childCount(0),
longKey(false),
modifiedSettings{} {}
GroupType::value type; GroupType::value type;
FlowType::value flowType; FlowType::value flowType;
@ -203,6 +198,6 @@ void EmitterState::_Set(Setting<T>& fmt, T value, FmtScope::value scope) {
assert(false); assert(false);
} }
} }
} // namespace YAML }
#endif // EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -8,8 +8,8 @@
#include "regeximpl.h" #include "regeximpl.h"
#include "stringsource.h" #include "stringsource.h"
#include "yaml-cpp/binary.h" // IWYU pragma: keep #include "yaml-cpp/binary.h" // IWYU pragma: keep
#include "yaml-cpp/null.h"
#include "yaml-cpp/ostream_wrapper.h" #include "yaml-cpp/ostream_wrapper.h"
#include "yaml-cpp/null.h"
namespace YAML { namespace YAML {
namespace Utils { namespace Utils {
@ -258,7 +258,7 @@ bool WriteAliasName(ostream_wrapper& out, const std::string& str) {
} }
return true; return true;
} }
} // namespace }
StringFormat::value ComputeStringFormat(const std::string& str, StringFormat::value ComputeStringFormat(const std::string& str,
EMITTER_MANIP strFormat, EMITTER_MANIP strFormat,
@ -401,8 +401,8 @@ bool WriteComment(ostream_wrapper& out, const std::string& str,
for (std::string::const_iterator i = str.begin(); for (std::string::const_iterator i = str.begin();
GetNextCodePointAndAdvance(codePoint, i, str.end());) { GetNextCodePointAndAdvance(codePoint, i, str.end());) {
if (codePoint == '\n') { if (codePoint == '\n') {
out << "\n" out << "\n" << IndentTo(curIndent) << "#"
<< IndentTo(curIndent) << "#" << Indentation(postCommentIndent); << Indentation(postCommentIndent);
out.set_comment(); out.set_comment();
} else { } else {
WriteCodePoint(out, codePoint); WriteCodePoint(out, codePoint);
@ -479,5 +479,5 @@ bool WriteBinary(ostream_wrapper& out, const Binary& binary) {
false); false);
return true; return true;
} }
} // namespace Utils }
} // namespace YAML }

View File

@ -44,7 +44,7 @@ bool WriteTag(ostream_wrapper& out, const std::string& str, bool verbatim);
bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix, bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix,
const std::string& tag); const std::string& tag);
bool WriteBinary(ostream_wrapper& out, const Binary& binary); bool WriteBinary(ostream_wrapper& out, const Binary& binary);
} // namespace Utils }
} // namespace YAML }
#endif // EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -3,9 +3,9 @@
// This is here for compatibility with older versions of Visual Studio // This is here for compatibility with older versions of Visual Studio
// which don't support noexcept // which don't support noexcept
#if defined(_MSC_VER) && _MSC_VER < 1900 #if defined(_MSC_VER) && _MSC_VER < 1900
#define YAML_CPP_NOEXCEPT _NOEXCEPT #define YAML_CPP_NOEXCEPT _NOEXCEPT
#else #else
#define YAML_CPP_NOEXCEPT noexcept #define YAML_CPP_NOEXCEPT noexcept
#endif #endif
namespace YAML { namespace YAML {
@ -24,6 +24,8 @@ BadPushback::~BadPushback() YAML_CPP_NOEXCEPT {}
BadInsert::~BadInsert() YAML_CPP_NOEXCEPT {} BadInsert::~BadInsert() YAML_CPP_NOEXCEPT {}
EmitterException::~EmitterException() YAML_CPP_NOEXCEPT {} EmitterException::~EmitterException() YAML_CPP_NOEXCEPT {}
BadFile::~BadFile() YAML_CPP_NOEXCEPT {} BadFile::~BadFile() YAML_CPP_NOEXCEPT {}
} // namespace YAML }
#undef YAML_CPP_NOEXCEPT #undef YAML_CPP_NOEXCEPT

View File

@ -132,5 +132,5 @@ std::string Escape(Stream& in) {
std::stringstream msg; std::stringstream msg;
throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch); throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch);
} }
} // namespace Exp }
} // namespace YAML }

View File

@ -7,8 +7,8 @@
#pragma once #pragma once
#endif #endif
#include <cstddef>
#include <iostream> #include <iostream>
#include <cstddef>
#include "yaml-cpp/ostream_wrapper.h" #include "yaml-cpp/ostream_wrapper.h"
@ -36,6 +36,6 @@ inline ostream_wrapper& operator<<(ostream_wrapper& out,
out << ' '; out << ' ';
return out; return out;
} }
} // namespace YAML }
#endif // INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -22,5 +22,5 @@ node& memory::create_node() {
void memory::merge(const memory& rhs) { void memory::merge(const memory& rhs) {
m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end()); m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end());
} }
} // namespace detail }
} // namespace YAML }

View File

@ -9,4 +9,4 @@ Node Clone(const Node& node) {
events.Emit(builder); events.Emit(builder);
return builder.Root(); return builder.Root();
} }
} // namespace YAML }

View File

@ -14,8 +14,8 @@ namespace YAML {
namespace detail { namespace detail {
const std::string& node_data::empty_scalar() { const std::string& node_data::empty_scalar() {
static const std::string svalue; static const std::string svalue;
return svalue; return svalue;
} }
node_data::node_data() node_data::node_data()
@ -28,7 +28,8 @@ node_data::node_data()
m_sequence{}, m_sequence{},
m_seqSize(0), m_seqSize(0),
m_map{}, m_map{},
m_undefinedPairs{} {} m_undefinedPairs{}
{}
void node_data::mark_defined() { void node_data::mark_defined() {
if (m_type == NodeType::Undefined) if (m_type == NodeType::Undefined)
@ -243,8 +244,7 @@ bool node_data::remove(node& key, shared_memory_holder /* pMemory */) {
if (m_type != NodeType::Map) if (m_type != NodeType::Map)
return false; return false;
for (kv_pairs::iterator it = m_undefinedPairs.begin(); for(kv_pairs::iterator it = m_undefinedPairs.begin(); it != m_undefinedPairs.end();) {
it != m_undefinedPairs.end();) {
kv_pairs::iterator jt = std::next(it); kv_pairs::iterator jt = std::next(it);
if (it->first->is(key)) if (it->first->is(key))
m_undefinedPairs.erase(it); m_undefinedPairs.erase(it);
@ -312,5 +312,5 @@ void node_data::convert_sequence_to_map(shared_memory_holder pMemory) {
reset_sequence(); reset_sequence();
m_type = NodeType::Map; m_type = NodeType::Map;
} }
} // namespace detail }
} // namespace YAML }

View File

@ -16,7 +16,8 @@ NodeBuilder::NodeBuilder()
m_stack{}, m_stack{},
m_anchors{}, m_anchors{},
m_keys{}, m_keys{},
m_mapDepth(0) { m_mapDepth(0)
{
m_anchors.push_back(nullptr); // since the anchors start at 1 m_anchors.push_back(nullptr); // since the anchors start at 1
} }
@ -132,4 +133,4 @@ void NodeBuilder::RegisterAnchor(anchor_t anchor, detail::node& node) {
m_anchors.push_back(&node); m_anchors.push_back(&node);
} }
} }
} // namespace YAML }

View File

@ -69,6 +69,6 @@ class NodeBuilder : public EventHandler {
std::vector<PushedKey> m_keys; std::vector<PushedKey> m_keys;
std::size_t m_mapDepth; std::size_t m_mapDepth;
}; };
} // namespace YAML }
#endif // NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -98,4 +98,4 @@ bool NodeEvents::IsAliased(const detail::node& node) const {
RefCount::const_iterator it = m_refCount.find(node.ref()); RefCount::const_iterator it = m_refCount.find(node.ref());
return it != m_refCount.end() && it->second > 1; return it != m_refCount.end() && it->second > 1;
} }
} // namespace YAML }

View File

@ -63,6 +63,6 @@ class NodeEvents {
typedef std::map<const detail::node_ref*, int> RefCount; typedef std::map<const detail::node_ref*, int> RefCount;
RefCount m_refCount; RefCount m_refCount;
}; };
} // namespace YAML }
#endif // NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -7,4 +7,4 @@ bool IsNullString(const std::string& str) {
return str.empty() || str == "~" || str == "null" || str == "Null" || return str.empty() || str == "~" || str == "null" || str == "Null" ||
str == "NULL"; str == "NULL";
} }
} // namespace YAML }

View File

@ -14,12 +14,7 @@ ostream_wrapper::ostream_wrapper()
m_comment(false) {} m_comment(false) {}
ostream_wrapper::ostream_wrapper(std::ostream& stream) ostream_wrapper::ostream_wrapper(std::ostream& stream)
: m_buffer{}, : m_buffer{}, m_pStream(&stream), m_pos(0), m_row(0), m_col(0), m_comment(false) {}
m_pStream(&stream),
m_pos(0),
m_row(0),
m_col(0),
m_comment(false) {}
ostream_wrapper::~ostream_wrapper() {} ostream_wrapper::~ostream_wrapper() {}
@ -59,4 +54,4 @@ void ostream_wrapper::update_pos(char ch) {
m_comment = false; m_comment = false;
} }
} }
} // namespace YAML }

View File

@ -3,10 +3,10 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include "nodebuilder.h"
#include "yaml-cpp/node/impl.h"
#include "yaml-cpp/node/node.h" #include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/impl.h"
#include "yaml-cpp/parser.h" #include "yaml-cpp/parser.h"
#include "nodebuilder.h"
namespace YAML { namespace YAML {
Node Load(const std::string& input) { Node Load(const std::string& input) {

View File

@ -126,4 +126,4 @@ void Parser::PrintTokens(std::ostream& out) {
m_pScanner->pop(); m_pScanner->pop();
} }
} }
} // namespace YAML }

View File

@ -40,6 +40,6 @@ class ptr_vector {
private: private:
std::vector<std::unique_ptr<T>> m_data; std::vector<std::unique_ptr<T>> m_data;
}; };
} // namespace YAML }
#endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -10,8 +10,7 @@ RegEx::RegEx(char ch) : m_op(REGEX_MATCH), m_a(ch), m_z(0), m_params{} {}
RegEx::RegEx(char a, char z) : m_op(REGEX_RANGE), m_a(a), m_z(z), m_params{} {} RegEx::RegEx(char a, char z) : m_op(REGEX_RANGE), m_a(a), m_z(z), m_params{} {}
RegEx::RegEx(const std::string& str, REGEX_OP op) RegEx::RegEx(const std::string& str, REGEX_OP op) : m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {}
: m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {}
// combination constructors // combination constructors
RegEx operator!(const RegEx& ex) { RegEx operator!(const RegEx& ex) {
@ -40,4 +39,4 @@ RegEx operator+(const RegEx& ex1, const RegEx& ex2) {
ret.m_params.push_back(ex2); ret.m_params.push_back(ex2);
return ret; return ret;
} }
} // namespace YAML }

View File

@ -8,8 +8,8 @@
#endif #endif
#include "stream.h" #include "stream.h"
#include "streamcharsource.h"
#include "stringsource.h" #include "stringsource.h"
#include "streamcharsource.h"
namespace YAML { namespace YAML {
// query matches // query matches
@ -106,8 +106,9 @@ inline int RegEx::MatchOpEmpty(const Source& source) const {
template <> template <>
inline int RegEx::MatchOpEmpty<StringCharSource>( inline int RegEx::MatchOpEmpty<StringCharSource>(
const StringCharSource& source) const { const StringCharSource& source) const {
return !source ? 0 : -1; // the empty regex only is successful on the empty return !source
// string ? 0
: -1; // the empty regex only is successful on the empty string
} }
// MatchOperator // MatchOperator
@ -180,6 +181,6 @@ inline int RegEx::MatchOpSeq(const Source& source) const {
return offset; return offset;
} }
} // namespace YAML }
#endif // REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -17,7 +17,8 @@ Scanner::Scanner(std::istream& in)
m_simpleKeys{}, m_simpleKeys{},
m_indents{}, m_indents{},
m_indentRefs{}, m_indentRefs{},
m_flows{} {} m_flows{}
{}
Scanner::~Scanner() {} Scanner::~Scanner() {}

View File

@ -185,6 +185,6 @@ class Scanner {
ptr_vector<IndentMarker> m_indentRefs; // for "garbage collection" ptr_vector<IndentMarker> m_indentRefs; // for "garbage collection"
std::stack<FLOW_MARKER> m_flows; std::stack<FLOW_MARKER> m_flows;
}; };
} // namespace YAML }
#endif // SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -247,4 +247,4 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
return scalar; return scalar;
} }
} // namespace YAML }

View File

@ -58,6 +58,6 @@ struct ScanScalarParams {
}; };
std::string ScanScalar(Stream& INPUT, ScanScalarParams& info); std::string ScanScalar(Stream& INPUT, ScanScalarParams& info);
} // namespace YAML }
#endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -78,4 +78,4 @@ const std::string ScanTagSuffix(Stream& INPUT) {
return tag; return tag;
} }
} // namespace YAML }

View File

@ -7,13 +7,13 @@
#pragma once #pragma once
#endif #endif
#include "stream.h"
#include <string> #include <string>
#include "stream.h"
namespace YAML { namespace YAML {
const std::string ScanVerbatimTag(Stream& INPUT); const std::string ScanVerbatimTag(Stream& INPUT);
const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle); const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle);
const std::string ScanTagSuffix(Stream& INPUT); const std::string ScanTagSuffix(Stream& INPUT);
} // namespace YAML }
#endif // SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -434,4 +434,4 @@ void Scanner::ScanBlockScalar() {
token.value = scalar; token.value = scalar;
m_tokens.push(token); m_tokens.push(token);
} }
} // namespace YAML }

View File

@ -8,8 +8,8 @@
#endif #endif
#include <memory> #include <memory>
#include <utility>
#include <vector> #include <vector>
#include <utility>
namespace YAML { namespace YAML {
class SettingChangeBase; class SettingChangeBase;
@ -18,7 +18,9 @@ template <typename T>
class Setting { class Setting {
public: public:
Setting() : m_value() {} Setting() : m_value() {}
Setting(const T& value) : m_value() { set(value); } Setting(const T& value) : m_value() {
set(value);
}
const T get() const { return m_value; } const T get() const { return m_value; }
std::unique_ptr<SettingChangeBase> set(const T& value); std::unique_ptr<SettingChangeBase> set(const T& value);
@ -37,9 +39,9 @@ class SettingChangeBase {
template <typename T> template <typename T>
class SettingChange : public SettingChangeBase { class SettingChange : public SettingChangeBase {
public: public:
SettingChange(Setting<T>* pSetting) SettingChange(Setting<T>* pSetting) :
: m_pCurSetting(pSetting), m_pCurSetting(pSetting),
m_oldSetting(*pSetting) // copy old setting to save its state m_oldSetting(*pSetting) // copy old setting to save its state
{} {}
SettingChange(const SettingChange&) = delete; SettingChange(const SettingChange&) = delete;
SettingChange(SettingChange&&) = delete; SettingChange(SettingChange&&) = delete;
@ -64,8 +66,7 @@ class SettingChanges {
public: public:
SettingChanges() : m_settingChanges{} {} SettingChanges() : m_settingChanges{} {}
SettingChanges(const SettingChanges&) = delete; SettingChanges(const SettingChanges&) = delete;
SettingChanges(SettingChanges&& rhs) SettingChanges(SettingChanges&& rhs) : m_settingChanges(std::move(rhs.m_settingChanges)) {}
: m_settingChanges(std::move(rhs.m_settingChanges)) {}
SettingChanges& operator=(const SettingChanges&) = delete; SettingChanges& operator=(const SettingChanges&) = delete;
~SettingChanges() { clear(); } ~SettingChanges() { clear(); }
@ -99,6 +100,6 @@ class SettingChanges {
typedef std::vector<std::unique_ptr<SettingChangeBase>> setting_changes; typedef std::vector<std::unique_ptr<SettingChangeBase>> setting_changes;
setting_changes m_settingChanges; setting_changes m_settingChanges;
}; };
} // namespace YAML }
#endif // SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -5,11 +5,7 @@ namespace YAML {
struct Mark; struct Mark;
Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_) Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_)
: mark(mark_), : mark(mark_), flowLevel(flowLevel_), pIndent(nullptr), pMapStart(nullptr), pKey(nullptr) {}
flowLevel(flowLevel_),
pIndent(nullptr),
pMapStart(nullptr),
pKey(nullptr) {}
void Scanner::SimpleKey::Validate() { void Scanner::SimpleKey::Validate() {
// Note: pIndent will *not* be garbage here; // Note: pIndent will *not* be garbage here;
@ -129,4 +125,4 @@ void Scanner::PopAllSimpleKeys() {
while (!m_simpleKeys.empty()) while (!m_simpleKeys.empty())
m_simpleKeys.pop(); m_simpleKeys.pop();
} }
} // namespace YAML }

View File

@ -19,7 +19,8 @@ SingleDocParser::SingleDocParser(Scanner& scanner, const Directives& directives)
m_directives(directives), m_directives(directives),
m_pCollectionStack(new CollectionStack), m_pCollectionStack(new CollectionStack),
m_anchors{}, m_anchors{},
m_curAnchor(0) {} m_curAnchor(0)
{}
SingleDocParser::~SingleDocParser() {} SingleDocParser::~SingleDocParser() {}
@ -412,4 +413,4 @@ anchor_t SingleDocParser::LookupAnchor(const Mark& mark,
return it->second; return it->second;
} }
} // namespace YAML }

View File

@ -63,6 +63,6 @@ class SingleDocParser {
anchor_t m_curAnchor; anchor_t m_curAnchor;
}; };
} // namespace YAML }
#endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -111,15 +111,24 @@ static UtfIntroState s_introTransitions[][uictMax] = {
static char s_introUngetCount[][uictMax] = { static char s_introUngetCount[][uictMax] = {
// uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther // uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther
{0, 1, 1, 0, 0, 0, 0, 1}, {0, 2, 2, 2, 2, 2, 2, 2}, {0, 1, 1, 0, 0, 0, 0, 1},
{3, 3, 3, 3, 0, 3, 3, 3}, {4, 4, 4, 4, 4, 0, 4, 4}, {0, 2, 2, 2, 2, 2, 2, 2},
{1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1}, {3, 3, 3, 3, 0, 3, 3, 3},
{2, 2, 2, 2, 2, 0, 2, 2}, {2, 2, 2, 2, 0, 2, 2, 2}, {4, 4, 4, 4, 4, 0, 4, 4},
{0, 1, 1, 1, 1, 1, 1, 1}, {0, 2, 2, 2, 2, 2, 2, 2}, {1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1},
{0, 2, 2, 2, 2, 2, 2, 2}, {0, 3, 3, 3, 3, 3, 3, 3}, {2, 2, 2, 2, 2, 0, 2, 2},
{4, 4, 4, 4, 4, 4, 4, 4}, {2, 0, 2, 2, 2, 2, 2, 2}, {2, 2, 2, 2, 0, 2, 2, 2},
{3, 3, 0, 3, 3, 3, 3, 3}, {1, 1, 1, 1, 1, 1, 1, 1}, {0, 1, 1, 1, 1, 1, 1, 1},
{0, 2, 2, 2, 2, 2, 2, 2},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{0, 2, 2, 2, 2, 2, 2, 2},
{0, 3, 3, 3, 3, 3, 3, 3},
{4, 4, 4, 4, 4, 4, 4, 4},
{2, 0, 2, 2, 2, 2, 2, 2},
{3, 3, 0, 3, 3, 3, 3, 3},
{1, 1, 1, 1, 1, 1, 1, 1},
}; };
inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) { inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) {
@ -188,7 +197,8 @@ Stream::Stream(std::istream& input)
m_readahead{}, m_readahead{},
m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]), m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]),
m_nPrefetchedAvailable(0), m_nPrefetchedAvailable(0),
m_nPrefetchedUsed(0) { m_nPrefetchedUsed(0)
{
typedef std::istream::traits_type char_traits; typedef std::istream::traits_type char_traits;
if (!input) if (!input)
@ -439,4 +449,4 @@ void Stream::StreamInUtf32() const {
QueueUnicodeCodepoint(m_readahead, ch); QueueUnicodeCodepoint(m_readahead, ch);
} }
} // namespace YAML }

View File

@ -74,6 +74,6 @@ inline bool Stream::ReadAheadTo(size_t i) const {
return true; return true;
return _ReadAheadTo(i); return _ReadAheadTo(i);
} }
} // namespace YAML }
#endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -43,6 +43,6 @@ inline const StreamCharSource StreamCharSource::operator+(int i) const {
source.m_offset = 0; source.m_offset = 0;
return source; return source;
} }
} // namespace YAML }
#endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -43,6 +43,6 @@ class StringCharSource {
std::size_t m_size; std::size_t m_size;
std::size_t m_offset; std::size_t m_offset;
}; };
} // namespace YAML }
#endif // STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -6,8 +6,7 @@
#include "token.h" #include "token.h"
namespace YAML { namespace YAML {
Tag::Tag(const Token& token) Tag::Tag(const Token& token) : type(static_cast<TYPE>(token.data)), handle{}, value{} {
: type(static_cast<TYPE>(token.data)), handle{}, value{} {
switch (type) { switch (type) {
case VERBATIM: case VERBATIM:
value = token.value; value = token.value;
@ -47,4 +46,4 @@ const std::string Tag::Translate(const Directives& directives) {
} }
throw std::runtime_error("yaml-cpp: internal error, bad tag type"); throw std::runtime_error("yaml-cpp: internal error, bad tag type");
} }
} // namespace YAML }

View File

@ -28,6 +28,6 @@ struct Tag {
TYPE type; TYPE type;
std::string handle, value; std::string handle, value;
}; };
} // namespace YAML }
#endif // TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -14,11 +14,10 @@
namespace YAML { namespace YAML {
const std::string TokenNames[] = { const std::string TokenNames[] = {
"DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START", "DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START", "BLOCK_MAP_START",
"BLOCK_MAP_START", "BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY", "BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY", "FLOW_SEQ_START",
"FLOW_SEQ_START", "FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END", "FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END", "FLOW_MAP_COMPACT",
"FLOW_MAP_COMPACT", "FLOW_ENTRY", "KEY", "VALUE", "FLOW_ENTRY", "KEY", "VALUE", "ANCHOR", "ALIAS", "TAG", "SCALAR"};
"ANCHOR", "ALIAS", "TAG", "SCALAR"};
struct Token { struct Token {
// enums // enums
@ -65,6 +64,6 @@ struct Token {
std::vector<std::string> params; std::vector<std::string> params;
int data; int data;
}; };
} // namespace YAML }
#endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66

View File

@ -37,7 +37,7 @@
#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
#include <errno.h> # include <errno.h>
#endif #endif
#include <algorithm> #include <algorithm>
@ -98,7 +98,9 @@ class BuiltInDefaultValue {
public: public:
#if GTEST_HAS_STD_TYPE_TRAITS_ #if GTEST_HAS_STD_TYPE_TRAITS_
// This function returns true iff type T has a built-in default value. // This function returns true iff type T has a built-in default value.
static bool Exists() { return ::std::is_default_constructible<T>::value; } static bool Exists() {
return ::std::is_default_constructible<T>::value;
}
static T Get() { static T Get() {
return BuiltInDefaultValueGetter< return BuiltInDefaultValueGetter<
@ -107,9 +109,13 @@ class BuiltInDefaultValue {
#else // GTEST_HAS_STD_TYPE_TRAITS_ #else // GTEST_HAS_STD_TYPE_TRAITS_
// This function returns true iff type T has a built-in default value. // This function returns true iff type T has a built-in default value.
static bool Exists() { return false; } static bool Exists() {
return false;
}
static T Get() { return BuiltInDefaultValueGetter<T, false>::Get(); } static T Get() {
return BuiltInDefaultValueGetter<T, false>::Get();
}
#endif // GTEST_HAS_STD_TYPE_TRAITS_ #endif // GTEST_HAS_STD_TYPE_TRAITS_
}; };
@ -135,11 +141,11 @@ class BuiltInDefaultValue<T*> {
// The following specializations define the default values for // The following specializations define the default values for
// specific types we care about. // specific types we care about.
#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \ #define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
template <> \ template <> \
class BuiltInDefaultValue<type> { \ class BuiltInDefaultValue<type> { \
public: \ public: \
static bool Exists() { return true; } \ static bool Exists() { return true; } \
static type Get() { return value; } \ static type Get() { return value; } \
} }
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT
@ -228,8 +234,8 @@ class DefaultValue {
// otherwise returns the built-in default value. Requires that Exists() // otherwise returns the built-in default value. Requires that Exists()
// is true, which ensures that the return value is well-defined. // is true, which ensures that the return value is well-defined.
static T Get() { static T Get() {
return producer_ == NULL ? internal::BuiltInDefaultValue<T>::Get() return producer_ == NULL ?
: producer_->Produce(); internal::BuiltInDefaultValue<T>::Get() : producer_->Produce();
} }
private: private:
@ -274,7 +280,9 @@ class DefaultValue<T&> {
} }
// Unsets the default value for type T&. // Unsets the default value for type T&.
static void Clear() { address_ = NULL; } static void Clear() {
address_ = NULL;
}
// Returns true iff the user has set the default value for type T&. // Returns true iff the user has set the default value for type T&.
static bool IsSet() { return address_ != NULL; } static bool IsSet() { return address_ != NULL; }
@ -289,8 +297,8 @@ class DefaultValue<T&> {
// otherwise returns the built-in default value if there is one; // otherwise returns the built-in default value if there is one;
// otherwise aborts the process. // otherwise aborts the process.
static T& Get() { static T& Get() {
return address_ == NULL ? internal::BuiltInDefaultValue<T&>::Get() return address_ == NULL ?
: *address_; internal::BuiltInDefaultValue<T&>::Get() : *address_;
} }
private: private:
@ -391,7 +399,7 @@ class Action {
template <typename F1, typename F2> template <typename F1, typename F2>
friend class internal::ActionAdaptor; friend class internal::ActionAdaptor;
internal::linked_ptr<ActionInterface<F>> impl_; internal::linked_ptr<ActionInterface<F> > impl_;
}; };
// The PolymorphicAction class template makes it easy to implement a // The PolymorphicAction class template makes it easy to implement a
@ -485,7 +493,7 @@ class ActionAdaptor : public ActionInterface<F1> {
} }
private: private:
const internal::linked_ptr<ActionInterface<F2>> impl_; const internal::linked_ptr<ActionInterface<F2> > impl_;
GTEST_DISALLOW_ASSIGN_(ActionAdaptor); GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
}; };
@ -671,7 +679,9 @@ class ReturnRefAction {
explicit Impl(T& ref) : ref_(ref) {} // NOLINT explicit Impl(T& ref) : ref_(ref) {} // NOLINT
virtual Result Perform(const ArgumentTuple&) { return ref_; } virtual Result Perform(const ArgumentTuple&) {
return ref_;
}
private: private:
T& ref_; T& ref_;
@ -718,7 +728,9 @@ class ReturnRefOfCopyAction {
explicit Impl(const T& value) : value_(value) {} // NOLINT explicit Impl(const T& value) : value_(value) {} // NOLINT
virtual Result Perform(const ArgumentTuple&) { return value_; } virtual Result Perform(const ArgumentTuple&) {
return value_;
}
private: private:
T value_; T value_;
@ -737,9 +749,7 @@ class DoDefaultAction {
// This template type conversion operator allows DoDefault() to be // This template type conversion operator allows DoDefault() to be
// used in any function. // used in any function.
template <typename F> template <typename F>
operator Action<F>() const { operator Action<F>() const { return Action<F>(NULL); }
return Action<F>(NULL);
}
}; };
// Implements the Assign action to set a given pointer referent to a // Implements the Assign action to set a given pointer referent to a
@ -769,7 +779,8 @@ template <typename T>
class SetErrnoAndReturnAction { class SetErrnoAndReturnAction {
public: public:
SetErrnoAndReturnAction(int errno_value, T result) SetErrnoAndReturnAction(int errno_value, T result)
: errno_(errno_value), result_(result) {} : errno_(errno_value),
result_(result) {}
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& /* args */) const { Result Perform(const ArgumentTuple& /* args */) const {
errno = errno_; errno = errno_;
@ -847,9 +858,7 @@ class InvokeWithoutArgsAction {
// Allows InvokeWithoutArgs(f) to be used as any action whose type is // Allows InvokeWithoutArgs(f) to be used as any action whose type is
// compatible with f. // compatible with f.
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple&) { Result Perform(const ArgumentTuple&) { return function_impl_(); }
return function_impl_();
}
private: private:
FunctionImpl function_impl_; FunctionImpl function_impl_;
@ -917,8 +926,8 @@ class IgnoreResultAction {
private: private:
// Type OriginalFunction is the same as F except that its return // Type OriginalFunction is the same as F except that its return
// type is IgnoredValue. // type is IgnoredValue.
typedef typedef typename internal::Function<F>::MakeResultIgnoredValue
typename internal::Function<F>::MakeResultIgnoredValue OriginalFunction; OriginalFunction;
const Action<OriginalFunction> action_; const Action<OriginalFunction> action_;
@ -946,7 +955,6 @@ class ReferenceWrapper {
// Allows a ReferenceWrapper<T> object to be implicitly converted to // Allows a ReferenceWrapper<T> object to be implicitly converted to
// a T&. // a T&.
operator T&() const { return *pointer_; } operator T&() const { return *pointer_; }
private: private:
T* pointer_; T* pointer_;
}; };
@ -1095,12 +1103,12 @@ inline internal::DoDefaultAction DoDefault() {
// Creates an action that sets the variable pointed by the N-th // Creates an action that sets the variable pointed by the N-th
// (0-based) function argument to 'value'. // (0-based) function argument to 'value'.
template <size_t N, typename T> template <size_t N, typename T>
PolymorphicAction<internal::SetArgumentPointeeAction< PolymorphicAction<
N, T, internal::IsAProtocolMessage<T>::value>> internal::SetArgumentPointeeAction<
SetArgPointee(const T& x) { N, T, internal::IsAProtocolMessage<T>::value> >
return MakePolymorphicAction( SetArgPointee(const T& x) {
internal::SetArgumentPointeeAction< return MakePolymorphicAction(internal::SetArgumentPointeeAction<
N, T, internal::IsAProtocolMessage<T>::value>(x)); N, T, internal::IsAProtocolMessage<T>::value>(x));
} }
#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN) #if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
@ -1108,33 +1116,35 @@ PolymorphicAction<internal::SetArgumentPointeeAction<
// GCC prior to the version 4.0 and Symbian C++ compiler cannot distinguish // GCC prior to the version 4.0 and Symbian C++ compiler cannot distinguish
// this overload from the templated version and emit a compile error. // this overload from the templated version and emit a compile error.
template <size_t N> template <size_t N>
PolymorphicAction<internal::SetArgumentPointeeAction<N, const char*, false>> PolymorphicAction<
SetArgPointee(const char* p) { internal::SetArgumentPointeeAction<N, const char*, false> >
return MakePolymorphicAction( SetArgPointee(const char* p) {
internal::SetArgumentPointeeAction<N, const char*, false>(p)); return MakePolymorphicAction(internal::SetArgumentPointeeAction<
N, const char*, false>(p));
} }
template <size_t N> template <size_t N>
PolymorphicAction<internal::SetArgumentPointeeAction<N, const wchar_t*, false>> PolymorphicAction<
SetArgPointee(const wchar_t* p) { internal::SetArgumentPointeeAction<N, const wchar_t*, false> >
return MakePolymorphicAction( SetArgPointee(const wchar_t* p) {
internal::SetArgumentPointeeAction<N, const wchar_t*, false>(p)); return MakePolymorphicAction(internal::SetArgumentPointeeAction<
N, const wchar_t*, false>(p));
} }
#endif #endif
// The following version is DEPRECATED. // The following version is DEPRECATED.
template <size_t N, typename T> template <size_t N, typename T>
PolymorphicAction<internal::SetArgumentPointeeAction< PolymorphicAction<
N, T, internal::IsAProtocolMessage<T>::value>> internal::SetArgumentPointeeAction<
SetArgumentPointee(const T& x) { N, T, internal::IsAProtocolMessage<T>::value> >
return MakePolymorphicAction( SetArgumentPointee(const T& x) {
internal::SetArgumentPointeeAction< return MakePolymorphicAction(internal::SetArgumentPointeeAction<
N, T, internal::IsAProtocolMessage<T>::value>(x)); N, T, internal::IsAProtocolMessage<T>::value>(x));
} }
// Creates an action that sets a pointer referent to a given value. // Creates an action that sets a pointer referent to a given value.
template <typename T1, typename T2> template <typename T1, typename T2>
PolymorphicAction<internal::AssignAction<T1, T2>> Assign(T1* ptr, T2 val) { PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val)); return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
} }
@ -1142,8 +1152,8 @@ PolymorphicAction<internal::AssignAction<T1, T2>> Assign(T1* ptr, T2 val) {
// Creates an action that sets errno and returns the appropriate error. // Creates an action that sets errno and returns the appropriate error.
template <typename T> template <typename T>
PolymorphicAction<internal::SetErrnoAndReturnAction<T>> SetErrnoAndReturn( PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
int errval, T result) { SetErrnoAndReturn(int errval, T result) {
return MakePolymorphicAction( return MakePolymorphicAction(
internal::SetErrnoAndReturnAction<T>(errval, result)); internal::SetErrnoAndReturnAction<T>(errval, result));
} }
@ -1154,8 +1164,8 @@ PolymorphicAction<internal::SetErrnoAndReturnAction<T>> SetErrnoAndReturn(
// Creates an action that invokes 'function_impl' with no argument. // Creates an action that invokes 'function_impl' with no argument.
template <typename FunctionImpl> template <typename FunctionImpl>
PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl>> PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >
InvokeWithoutArgs(FunctionImpl function_impl) { InvokeWithoutArgs(FunctionImpl function_impl) {
return MakePolymorphicAction( return MakePolymorphicAction(
internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl)); internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl));
} }
@ -1163,11 +1173,11 @@ PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl>>
// Creates an action that invokes the given method on the given object // Creates an action that invokes the given method on the given object
// with no argument. // with no argument.
template <class Class, typename MethodPtr> template <class Class, typename MethodPtr>
PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>> PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> >
InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) { InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) {
return MakePolymorphicAction( return MakePolymorphicAction(
internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(obj_ptr, internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(
method_ptr)); obj_ptr, method_ptr));
} }
// Creates an action that performs an_action and throws away its // Creates an action that performs an_action and throws away its

View File

@ -38,10 +38,10 @@
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#include <limits.h> #include <limits.h>
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
namespace testing { namespace testing {
@ -108,7 +108,7 @@ class GTEST_API_ Cardinality {
// cardinality, i.e. exceed the maximum number of allowed calls. // cardinality, i.e. exceed the maximum number of allowed calls.
bool IsOverSaturatedByCallCount(int call_count) const { bool IsOverSaturatedByCallCount(int call_count) const {
return impl_->IsSaturatedByCallCount(call_count) && return impl_->IsSaturatedByCallCount(call_count) &&
!impl_->IsSatisfiedByCallCount(call_count); !impl_->IsSatisfiedByCallCount(call_count);
} }
// Describes self to an ostream // Describes self to an ostream

View File

@ -106,61 +106,59 @@ class NiceMock : public MockClass {
} }
template <typename A1, typename A2, typename A3, typename A4> template <typename A1, typename A2, typename A3, typename A4>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4) NiceMock(const A1& a1, const A2& a2, const A3& a3,
: MockClass(a1, a2, a3, a4) { const A4& a4) : MockClass(a1, a2, a3, a4) {
::testing::Mock::AllowUninterestingCalls( ::testing::Mock::AllowUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5> template <typename A1, typename A2, typename A3, typename A4, typename A5>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
: MockClass(a1, a2, a3, a4, a5) { const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
::testing::Mock::AllowUninterestingCalls( ::testing::Mock::AllowUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6> typename A6>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A6& a6) const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
: MockClass(a1, a2, a3, a4, a5, a6) {
::testing::Mock::AllowUninterestingCalls( ::testing::Mock::AllowUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7> typename A6, typename A7>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A6& a6, const A7& a7) const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
: MockClass(a1, a2, a3, a4, a5, a6, a7) { a6, a7) {
::testing::Mock::AllowUninterestingCalls( ::testing::Mock::AllowUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8> typename A6, typename A7, typename A8>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A6& a6, const A7& a7, const A8& a8) const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8) { a2, a3, a4, a5, a6, a7, a8) {
::testing::Mock::AllowUninterestingCalls( ::testing::Mock::AllowUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9> typename A6, typename A7, typename A8, typename A9>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A6& a6, const A7& a7, const A8& a8, const A9& a9) const A5& a5, const A6& a6, const A7& a7, const A8& a8,
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) { const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
::testing::Mock::AllowUninterestingCalls( ::testing::Mock::AllowUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9, typename A10> typename A6, typename A7, typename A8, typename A9, typename A10>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
const A10& a10) const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
::testing::Mock::AllowUninterestingCalls( ::testing::Mock::AllowUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
@ -204,63 +202,59 @@ class NaggyMock : public MockClass {
} }
template <typename A1, typename A2, typename A3, typename A4> template <typename A1, typename A2, typename A3, typename A4>
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4) NaggyMock(const A1& a1, const A2& a2, const A3& a3,
: MockClass(a1, a2, a3, a4) { const A4& a4) : MockClass(a1, a2, a3, a4) {
::testing::Mock::WarnUninterestingCalls( ::testing::Mock::WarnUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5> template <typename A1, typename A2, typename A3, typename A4, typename A5>
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5) const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
: MockClass(a1, a2, a3, a4, a5) {
::testing::Mock::WarnUninterestingCalls( ::testing::Mock::WarnUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6> typename A6>
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6) const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
: MockClass(a1, a2, a3, a4, a5, a6) {
::testing::Mock::WarnUninterestingCalls( ::testing::Mock::WarnUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7> typename A6, typename A7>
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7) const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
: MockClass(a1, a2, a3, a4, a5, a6, a7) { a6, a7) {
::testing::Mock::WarnUninterestingCalls( ::testing::Mock::WarnUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8> typename A6, typename A7, typename A8>
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8) const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8) { a2, a3, a4, a5, a6, a7, a8) {
::testing::Mock::WarnUninterestingCalls( ::testing::Mock::WarnUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9> typename A6, typename A7, typename A8, typename A9>
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A5& a5, const A6& a6, const A7& a7, const A8& a8,
const A9& a9) const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
::testing::Mock::WarnUninterestingCalls( ::testing::Mock::WarnUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9, typename A10> typename A6, typename A7, typename A8, typename A9, typename A10>
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
const A9& a9, const A10& a10) const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
::testing::Mock::WarnUninterestingCalls( ::testing::Mock::WarnUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
@ -304,63 +298,59 @@ class StrictMock : public MockClass {
} }
template <typename A1, typename A2, typename A3, typename A4> template <typename A1, typename A2, typename A3, typename A4>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4) StrictMock(const A1& a1, const A2& a2, const A3& a3,
: MockClass(a1, a2, a3, a4) { const A4& a4) : MockClass(a1, a2, a3, a4) {
::testing::Mock::FailUninterestingCalls( ::testing::Mock::FailUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5> template <typename A1, typename A2, typename A3, typename A4, typename A5>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5) const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
: MockClass(a1, a2, a3, a4, a5) {
::testing::Mock::FailUninterestingCalls( ::testing::Mock::FailUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6> typename A6>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6) const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
: MockClass(a1, a2, a3, a4, a5, a6) {
::testing::Mock::FailUninterestingCalls( ::testing::Mock::FailUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7> typename A6, typename A7>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7) const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
: MockClass(a1, a2, a3, a4, a5, a6, a7) { a6, a7) {
::testing::Mock::FailUninterestingCalls( ::testing::Mock::FailUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8> typename A6, typename A7, typename A8>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8) const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8) { a2, a3, a4, a5, a6, a7, a8) {
::testing::Mock::FailUninterestingCalls( ::testing::Mock::FailUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9> typename A6, typename A7, typename A8, typename A9>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A5& a5, const A6& a6, const A7& a7, const A8& a8,
const A9& a9) const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
::testing::Mock::FailUninterestingCalls( ::testing::Mock::FailUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9, typename A10> typename A6, typename A7, typename A8, typename A9, typename A10>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
const A9& a9, const A10& a10) const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
::testing::Mock::FailUninterestingCalls( ::testing::Mock::FailUninterestingCalls(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
@ -382,25 +372,25 @@ class StrictMock : public MockClass {
// NaggyMock, and StrictMock cannot be nested. // NaggyMock, and StrictMock cannot be nested.
template <typename MockClass> template <typename MockClass>
class NiceMock<NiceMock<MockClass>>; class NiceMock<NiceMock<MockClass> >;
template <typename MockClass> template <typename MockClass>
class NiceMock<NaggyMock<MockClass>>; class NiceMock<NaggyMock<MockClass> >;
template <typename MockClass> template <typename MockClass>
class NiceMock<StrictMock<MockClass>>; class NiceMock<StrictMock<MockClass> >;
template <typename MockClass> template <typename MockClass>
class NaggyMock<NiceMock<MockClass>>; class NaggyMock<NiceMock<MockClass> >;
template <typename MockClass> template <typename MockClass>
class NaggyMock<NaggyMock<MockClass>>; class NaggyMock<NaggyMock<MockClass> >;
template <typename MockClass> template <typename MockClass>
class NaggyMock<StrictMock<MockClass>>; class NaggyMock<StrictMock<MockClass> >;
template <typename MockClass> template <typename MockClass>
class StrictMock<NiceMock<MockClass>>; class StrictMock<NiceMock<MockClass> >;
template <typename MockClass> template <typename MockClass>
class StrictMock<NaggyMock<MockClass>>; class StrictMock<NaggyMock<MockClass> >;
template <typename MockClass> template <typename MockClass>
class StrictMock<StrictMock<MockClass>>; class StrictMock<StrictMock<MockClass> >;
} // namespace testing } // namespace testing

File diff suppressed because it is too large Load Diff

View File

@ -76,8 +76,8 @@ class InvokeMethodAction {
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) const { Result Perform(const ArgumentTuple& args) const {
return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(obj_ptr_, return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
method_ptr_, args); obj_ptr_, method_ptr_, args);
} }
private: private:
@ -94,8 +94,9 @@ class InvokeMethodAction {
// necessary because Visual Studio deprecates ::std::copy, issuing warning 4996. // necessary because Visual Studio deprecates ::std::copy, issuing warning 4996.
// However Visual Studio 2010 and later do not honor #pragmas which disable that // However Visual Studio 2010 and later do not honor #pragmas which disable that
// warning. // warning.
template <typename InputIterator, typename OutputIterator> template<typename InputIterator, typename OutputIterator>
inline OutputIterator CopyElements(InputIterator first, InputIterator last, inline OutputIterator CopyElements(InputIterator first,
InputIterator last,
OutputIterator output) { OutputIterator output) {
for (; first != last; ++first, ++output) { for (; first != last; ++first, ++output) {
*output = *first; *output = *first;
@ -110,7 +111,7 @@ inline OutputIterator CopyElements(InputIterator first, InputIterator last,
// Creates an action that invokes 'function_impl' with the mock // Creates an action that invokes 'function_impl' with the mock
// function's arguments. // function's arguments.
template <typename FunctionImpl> template <typename FunctionImpl>
PolymorphicAction<internal::InvokeAction<FunctionImpl>> Invoke( PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(
FunctionImpl function_impl) { FunctionImpl function_impl) {
return MakePolymorphicAction( return MakePolymorphicAction(
internal::InvokeAction<FunctionImpl>(function_impl)); internal::InvokeAction<FunctionImpl>(function_impl));
@ -119,7 +120,7 @@ PolymorphicAction<internal::InvokeAction<FunctionImpl>> Invoke(
// Creates an action that invokes the given method on the given object // Creates an action that invokes the given method on the given object
// with the mock function's arguments. // with the mock function's arguments.
template <class Class, typename MethodPtr> template <class Class, typename MethodPtr>
PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr>> Invoke( PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
Class* obj_ptr, MethodPtr method_ptr) { Class* obj_ptr, MethodPtr method_ptr) {
return MakePolymorphicAction( return MakePolymorphicAction(
internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr)); internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr));
@ -130,8 +131,8 @@ PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr>> Invoke(
// argument. In other words, it adapts an action accepting no // argument. In other words, it adapts an action accepting no
// argument to one that accepts (and ignores) arguments. // argument to one that accepts (and ignores) arguments.
template <typename InnerAction> template <typename InnerAction>
inline internal::WithArgsAction<InnerAction> WithoutArgs( inline internal::WithArgsAction<InnerAction>
const InnerAction& action) { WithoutArgs(const InnerAction& action) {
return internal::WithArgsAction<InnerAction>(action); return internal::WithArgsAction<InnerAction>(action);
} }
@ -141,8 +142,8 @@ inline internal::WithArgsAction<InnerAction> WithoutArgs(
// multiple arguments. For convenience, we also provide // multiple arguments. For convenience, we also provide
// WithArgs<k>(an_action) (defined below) as a synonym. // WithArgs<k>(an_action) (defined below) as a synonym.
template <int k, typename InnerAction> template <int k, typename InnerAction>
inline internal::WithArgsAction<InnerAction, k> WithArg( inline internal::WithArgsAction<InnerAction, k>
const InnerAction& action) { WithArg(const InnerAction& action) {
return internal::WithArgsAction<InnerAction, k>(action); return internal::WithArgsAction<InnerAction, k>(action);
} }
@ -152,33 +153,37 @@ inline internal::WithArgsAction<InnerAction, k> WithArg(
// is expanded and macro expansion cannot contain #pragma. Therefore // is expanded and macro expansion cannot contain #pragma. Therefore
// we suppress them here. // we suppress them here.
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) # pragma warning(push)
#pragma warning(disable : 4100) # pragma warning(disable:4100)
#endif #endif
// Action ReturnArg<k>() returns the k-th argument of the mock function. // Action ReturnArg<k>() returns the k-th argument of the mock function.
ACTION_TEMPLATE(ReturnArg, HAS_1_TEMPLATE_PARAMS(int, k), ACTION_TEMPLATE(ReturnArg,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_0_VALUE_PARAMS()) { AND_0_VALUE_PARAMS()) {
return ::testing::get<k>(args); return ::testing::get<k>(args);
} }
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the // Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
// mock function to *pointer. // mock function to *pointer.
ACTION_TEMPLATE(SaveArg, HAS_1_TEMPLATE_PARAMS(int, k), ACTION_TEMPLATE(SaveArg,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(pointer)) { AND_1_VALUE_PARAMS(pointer)) {
*pointer = ::testing::get<k>(args); *pointer = ::testing::get<k>(args);
} }
// Action SaveArgPointee<k>(pointer) saves the value pointed to // Action SaveArgPointee<k>(pointer) saves the value pointed to
// by the k-th (0-based) argument of the mock function to *pointer. // by the k-th (0-based) argument of the mock function to *pointer.
ACTION_TEMPLATE(SaveArgPointee, HAS_1_TEMPLATE_PARAMS(int, k), ACTION_TEMPLATE(SaveArgPointee,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(pointer)) { AND_1_VALUE_PARAMS(pointer)) {
*pointer = *::testing::get<k>(args); *pointer = *::testing::get<k>(args);
} }
// Action SetArgReferee<k>(value) assigns 'value' to the variable // Action SetArgReferee<k>(value) assigns 'value' to the variable
// referenced by the k-th (0-based) argument of the mock function. // referenced by the k-th (0-based) argument of the mock function.
ACTION_TEMPLATE(SetArgReferee, HAS_1_TEMPLATE_PARAMS(int, k), ACTION_TEMPLATE(SetArgReferee,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(value)) { AND_1_VALUE_PARAMS(value)) {
typedef typename ::testing::tuple_element<k, args_type>::type argk_type; typedef typename ::testing::tuple_element<k, args_type>::type argk_type;
// Ensures that argument #k is a reference. If you get a compiler // Ensures that argument #k is a reference. If you get a compiler
@ -194,7 +199,8 @@ ACTION_TEMPLATE(SetArgReferee, HAS_1_TEMPLATE_PARAMS(int, k),
// (0-based) argument, which can be either a pointer or an // (0-based) argument, which can be either a pointer or an
// iterator. The action does not take ownership of the elements in the // iterator. The action does not take ownership of the elements in the
// source range. // source range.
ACTION_TEMPLATE(SetArrayArgument, HAS_1_TEMPLATE_PARAMS(int, k), ACTION_TEMPLATE(SetArrayArgument,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_2_VALUE_PARAMS(first, last)) { AND_2_VALUE_PARAMS(first, last)) {
// Visual Studio deprecates ::std::copy, so we use our own copy in that case. // Visual Studio deprecates ::std::copy, so we use our own copy in that case.
#ifdef _MSC_VER #ifdef _MSC_VER
@ -206,7 +212,8 @@ ACTION_TEMPLATE(SetArrayArgument, HAS_1_TEMPLATE_PARAMS(int, k),
// Action DeleteArg<k>() deletes the k-th (0-based) argument of the mock // Action DeleteArg<k>() deletes the k-th (0-based) argument of the mock
// function. // function.
ACTION_TEMPLATE(DeleteArg, HAS_1_TEMPLATE_PARAMS(int, k), ACTION_TEMPLATE(DeleteArg,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_0_VALUE_PARAMS()) { AND_0_VALUE_PARAMS()) {
delete ::testing::get<k>(args); delete ::testing::get<k>(args);
} }
@ -219,19 +226,19 @@ ACTION_P(ReturnPointee, pointer) { return *pointer; }
#if GTEST_HAS_EXCEPTIONS #if GTEST_HAS_EXCEPTIONS
// Suppresses the 'unreachable code' warning that VC generates in opt modes. // Suppresses the 'unreachable code' warning that VC generates in opt modes.
#ifdef _MSC_VER # ifdef _MSC_VER
#pragma warning(push) // Saves the current warning state. # pragma warning(push) // Saves the current warning state.
#pragma warning(disable : 4702) // Temporarily disables warning 4702. # pragma warning(disable:4702) // Temporarily disables warning 4702.
#endif # endif
ACTION_P(Throw, exception) { throw exception; } ACTION_P(Throw, exception) { throw exception; }
#ifdef _MSC_VER # ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state. # pragma warning(pop) // Restores the warning state.
#endif # endif
#endif // GTEST_HAS_EXCEPTIONS #endif // GTEST_HAS_EXCEPTIONS
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) # pragma warning(pop)
#endif #endif
} // namespace testing } // namespace testing

View File

@ -67,7 +67,7 @@
#include <vector> #include <vector>
#if GTEST_HAS_EXCEPTIONS #if GTEST_HAS_EXCEPTIONS
#include <stdexcept> // NOLINT # include <stdexcept> // NOLINT
#endif #endif
#include "gmock/gmock-actions.h" #include "gmock/gmock-actions.h"
@ -90,22 +90,19 @@ class ExpectationSet;
namespace internal { namespace internal {
// Implements a mock function. // Implements a mock function.
template <typename F> template <typename F> class FunctionMocker;
class FunctionMocker;
// Base class for expectations. // Base class for expectations.
class ExpectationBase; class ExpectationBase;
// Implements an expectation. // Implements an expectation.
template <typename F> template <typename F> class TypedExpectation;
class TypedExpectation;
// Helper class for testing the Expectation class template. // Helper class for testing the Expectation class template.
class ExpectationTester; class ExpectationTester;
// Base class for function mockers. // Base class for function mockers.
template <typename F> template <typename F> class FunctionMockerBase;
class FunctionMockerBase;
// Protects the mock object registry (in class Mock), all function // Protects the mock object registry (in class Mock), all function
// mockers, and all expectations. // mockers, and all expectations.
@ -151,20 +148,23 @@ class GTEST_API_ UntypedFunctionMockerBase {
// action fails. // action fails.
// L = * // L = *
virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction( virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
const void* untyped_args, const string& call_description) const = 0; const void* untyped_args,
const string& call_description) const = 0;
// Performs the given action with the given arguments and returns // Performs the given action with the given arguments and returns
// the action's result. // the action's result.
// L = * // L = *
virtual UntypedActionResultHolderBase* UntypedPerformAction( virtual UntypedActionResultHolderBase* UntypedPerformAction(
const void* untyped_action, const void* untyped_args) const = 0; const void* untyped_action,
const void* untyped_args) const = 0;
// Writes a message that the call is uninteresting (i.e. neither // Writes a message that the call is uninteresting (i.e. neither
// explicitly expected nor explicitly unexpected) to the given // explicitly expected nor explicitly unexpected) to the given
// ostream. // ostream.
virtual void UntypedDescribeUninterestingCall(const void* untyped_args, virtual void UntypedDescribeUninterestingCall(
::std::ostream* os) const const void* untyped_args,
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0; ::std::ostream* os) const
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
// Returns the expectation that matches the given function arguments // Returns the expectation that matches the given function arguments
// (or NULL is there's no match); when a match is found, // (or NULL is there's no match); when a match is found,
@ -173,9 +173,10 @@ class GTEST_API_ UntypedFunctionMockerBase {
// is_excessive is modified to indicate whether the call exceeds the // is_excessive is modified to indicate whether the call exceeds the
// expected number. // expected number.
virtual const ExpectationBase* UntypedFindMatchingExpectation( virtual const ExpectationBase* UntypedFindMatchingExpectation(
const void* untyped_args, const void** untyped_action, bool* is_excessive, const void* untyped_args,
const void** untyped_action, bool* is_excessive,
::std::ostream* what, ::std::ostream* why) ::std::ostream* what, ::std::ostream* why)
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0; GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
// Prints the given function arguments to the ostream. // Prints the given function arguments to the ostream.
virtual void UntypedPrintArgs(const void* untyped_args, virtual void UntypedPrintArgs(const void* untyped_args,
@ -186,7 +187,8 @@ class GTEST_API_ UntypedFunctionMockerBase {
// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock // whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
// method. // method.
// TODO(wan@google.com): rename to SetAndRegisterOwner(). // TODO(wan@google.com): rename to SetAndRegisterOwner().
void RegisterOwner(const void* mock_obj) GTEST_LOCK_EXCLUDED_(g_gmock_mutex); void RegisterOwner(const void* mock_obj)
GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
// Sets the mock object this mock method belongs to, and sets the // Sets the mock object this mock method belongs to, and sets the
// name of the mock function. Will be called upon each invocation // name of the mock function. Will be called upon each invocation
@ -197,24 +199,27 @@ class GTEST_API_ UntypedFunctionMockerBase {
// Returns the mock object this mock method belongs to. Must be // Returns the mock object this mock method belongs to. Must be
// called after RegisterOwner() or SetOwnerAndName() has been // called after RegisterOwner() or SetOwnerAndName() has been
// called. // called.
const void* MockObject() const GTEST_LOCK_EXCLUDED_(g_gmock_mutex); const void* MockObject() const
GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
// Returns the name of this mock method. Must be called after // Returns the name of this mock method. Must be called after
// SetOwnerAndName() has been called. // SetOwnerAndName() has been called.
const char* Name() const GTEST_LOCK_EXCLUDED_(g_gmock_mutex); const char* Name() const
GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
// Returns the result of invoking this mock function with the given // Returns the result of invoking this mock function with the given
// arguments. This function can be safely called from multiple // arguments. This function can be safely called from multiple
// threads concurrently. The caller is responsible for deleting the // threads concurrently. The caller is responsible for deleting the
// result. // result.
UntypedActionResultHolderBase* UntypedInvokeWith(const void* untyped_args) UntypedActionResultHolderBase* UntypedInvokeWith(
GTEST_LOCK_EXCLUDED_(g_gmock_mutex); const void* untyped_args)
GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
protected: protected:
typedef std::vector<const void*> UntypedOnCallSpecs; typedef std::vector<const void*> UntypedOnCallSpecs;
typedef std::vector<internal::linked_ptr<ExpectationBase>> typedef std::vector<internal::linked_ptr<ExpectationBase> >
UntypedExpectations; UntypedExpectations;
// Returns an Expectation object that references and co-owns exp, // Returns an Expectation object that references and co-owns exp,
// which must be an expectation on this mock function. // which must be an expectation on this mock function.
@ -292,7 +297,8 @@ class OnCallSpec : public UntypedOnCallSpecBase {
// we cannot initialize it with _ as that triggers a compiler // we cannot initialize it with _ as that triggers a compiler
// bug in Symbian's C++ compiler (cannot decide between two // bug in Symbian's C++ compiler (cannot decide between two
// overloaded constructors of Matcher<const ArgumentTuple&>). // overloaded constructors of Matcher<const ArgumentTuple&>).
extra_matcher_(A<const ArgumentTuple&>()) {} extra_matcher_(A<const ArgumentTuple&>()) {
}
// Implements the .With() clause. // Implements the .With() clause.
OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) { OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) {
@ -423,7 +429,8 @@ class GTEST_API_ Mock {
// Returns the reaction Google Mock will have on uninteresting calls // Returns the reaction Google Mock will have on uninteresting calls
// made on the given mock object. // made on the given mock object.
static internal::CallReaction GetReactionOnUninterestingCalls( static internal::CallReaction GetReactionOnUninterestingCalls(
const void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); const void* mock_obj)
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
// Verifies that all expectations on the given mock object have been // Verifies that all expectations on the given mock object have been
// satisfied. Reports one or more Google Test non-fatal failures // satisfied. Reports one or more Google Test non-fatal failures
@ -436,16 +443,17 @@ class GTEST_API_ Mock {
GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex); GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
// Registers a mock object and a mock method it owns. // Registers a mock object and a mock method it owns.
static void Register(const void* mock_obj, static void Register(
internal::UntypedFunctionMockerBase* mocker) const void* mock_obj,
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); internal::UntypedFunctionMockerBase* mocker)
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
// Tells Google Mock where in the source code mock_obj is used in an // Tells Google Mock where in the source code mock_obj is used in an
// ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this // ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this
// information helps the user identify which object it is. // information helps the user identify which object it is.
static void RegisterUseByOnCallOrExpectCall(const void* mock_obj, static void RegisterUseByOnCallOrExpectCall(
const char* file, int line) const void* mock_obj, const char* file, int line)
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
// Unregisters a mock method; removes the owning mock object from // Unregisters a mock method; removes the owning mock object from
// the registry when the last mock method associated with it has // the registry when the last mock method associated with it has
@ -530,8 +538,8 @@ class GTEST_API_ Expectation {
const internal::linked_ptr<internal::ExpectationBase>& expectation_base); const internal::linked_ptr<internal::ExpectationBase>& expectation_base);
// Returns the expectation this object references. // Returns the expectation this object references.
const internal::linked_ptr<internal::ExpectationBase>& expectation_base() const internal::linked_ptr<internal::ExpectationBase>&
const { expectation_base() const {
return expectation_base_; return expectation_base_;
} }
@ -604,6 +612,7 @@ class ExpectationSet {
Expectation::Set expectations_; Expectation::Set expectations_;
}; };
// Sequence objects are used by a user to specify the relative order // Sequence objects are used by a user to specify the relative order
// in which the expectations should match. They are copyable (we rely // in which the expectations should match. They are copyable (we rely
// on the compiler-defined copy constructor and assignment operator). // on the compiler-defined copy constructor and assignment operator).
@ -652,7 +661,6 @@ class GTEST_API_ InSequence {
public: public:
InSequence(); InSequence();
~InSequence(); ~InSequence();
private: private:
bool sequence_created_; bool sequence_created_;
@ -757,34 +765,40 @@ class GTEST_API_ ExpectationBase {
// the current thread. // the current thread.
// Retires all pre-requisites of this expectation. // Retires all pre-requisites of this expectation.
void RetireAllPreRequisites() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex); void RetireAllPreRequisites()
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
// Returns true iff this expectation is retired. // Returns true iff this expectation is retired.
bool is_retired() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { bool is_retired() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return retired_; return retired_;
} }
// Retires this expectation. // Retires this expectation.
void Retire() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { void Retire()
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
retired_ = true; retired_ = true;
} }
// Returns true iff this expectation is satisfied. // Returns true iff this expectation is satisfied.
bool IsSatisfied() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { bool IsSatisfied() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return cardinality().IsSatisfiedByCallCount(call_count_); return cardinality().IsSatisfiedByCallCount(call_count_);
} }
// Returns true iff this expectation is saturated. // Returns true iff this expectation is saturated.
bool IsSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { bool IsSaturated() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return cardinality().IsSaturatedByCallCount(call_count_); return cardinality().IsSaturatedByCallCount(call_count_);
} }
// Returns true iff this expectation is over-saturated. // Returns true iff this expectation is over-saturated.
bool IsOverSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { bool IsOverSaturated() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return cardinality().IsOverSaturatedByCallCount(call_count_); return cardinality().IsOverSaturatedByCallCount(call_count_);
} }
@ -798,13 +812,15 @@ class GTEST_API_ ExpectationBase {
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex); GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
// Returns the number this expectation has been invoked. // Returns the number this expectation has been invoked.
int call_count() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { int call_count() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return call_count_; return call_count_;
} }
// Increments the number this expectation has been invoked. // Increments the number this expectation has been invoked.
void IncrementCallCount() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { void IncrementCallCount()
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
call_count_++; call_count_++;
} }
@ -813,7 +829,8 @@ class GTEST_API_ ExpectationBase {
// WillRepeatedly() clauses) against the cardinality if this hasn't // WillRepeatedly() clauses) against the cardinality if this hasn't
// been done before. Prints a warning if there are too many or too // been done before. Prints a warning if there are too many or too
// few actions. // few actions.
void CheckActionCountIfNotDone() const GTEST_LOCK_EXCLUDED_(mutex_); void CheckActionCountIfNotDone() const
GTEST_LOCK_EXCLUDED_(mutex_);
friend class ::testing::Sequence; friend class ::testing::Sequence;
friend class ::testing::internal::ExpectationTester; friend class ::testing::internal::ExpectationTester;
@ -831,7 +848,7 @@ class GTEST_API_ ExpectationBase {
const string source_text_; // The EXPECT_CALL(...) source text. const string source_text_; // The EXPECT_CALL(...) source text.
// True iff the cardinality is specified explicitly. // True iff the cardinality is specified explicitly.
bool cardinality_specified_; bool cardinality_specified_;
Cardinality cardinality_; // The cardinality of the expectation. Cardinality cardinality_; // The cardinality of the expectation.
// The immediate pre-requisites (i.e. expectations that must be // The immediate pre-requisites (i.e. expectations that must be
// satisfied before this expectation can be matched) of this // satisfied before this expectation can be matched) of this
// expectation. We use linked_ptr in the set because we want an // expectation. We use linked_ptr in the set because we want an
@ -850,7 +867,7 @@ class GTEST_API_ ExpectationBase {
bool retires_on_saturation_; bool retires_on_saturation_;
Clause last_clause_; Clause last_clause_;
mutable bool action_count_checked_; // Under mutex_. mutable bool action_count_checked_; // Under mutex_.
mutable Mutex mutex_; // Protects action_count_checked_. mutable Mutex mutex_; // Protects action_count_checked_.
GTEST_DISALLOW_ASSIGN_(ExpectationBase); GTEST_DISALLOW_ASSIGN_(ExpectationBase);
}; // class ExpectationBase }; // class ExpectationBase
@ -863,8 +880,9 @@ class TypedExpectation : public ExpectationBase {
typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
typedef typename Function<F>::Result Result; typedef typename Function<F>::Result Result;
TypedExpectation(FunctionMockerBase<F>* owner, const char* a_file, int a_line, TypedExpectation(FunctionMockerBase<F>* owner,
const string& a_source_text, const ArgumentMatcherTuple& m) const char* a_file, int a_line, const string& a_source_text,
const ArgumentMatcherTuple& m)
: ExpectationBase(a_file, a_line, a_source_text), : ExpectationBase(a_file, a_line, a_source_text),
owner_(owner), owner_(owner),
matchers_(m), matchers_(m),
@ -910,7 +928,9 @@ class TypedExpectation : public ExpectationBase {
} }
// Implements the .Times() clause. // Implements the .Times() clause.
TypedExpectation& Times(int n) { return Times(Exactly(n)); } TypedExpectation& Times(int n) {
return Times(Exactly(n));
}
// Implements the .InSequence() clause. // Implements the .InSequence() clause.
TypedExpectation& InSequence(const Sequence& s) { TypedExpectation& InSequence(const Sequence& s) {
@ -1025,7 +1045,9 @@ class TypedExpectation : public ExpectationBase {
// Returns the matchers for the arguments as specified inside the // Returns the matchers for the arguments as specified inside the
// EXPECT_CALL() macro. // EXPECT_CALL() macro.
const ArgumentMatcherTuple& matchers() const { return matchers_; } const ArgumentMatcherTuple& matchers() const {
return matchers_;
}
// Returns the matcher specified by the .With() clause. // Returns the matcher specified by the .With() clause.
const Matcher<const ArgumentTuple&>& extra_matcher() const { const Matcher<const ArgumentTuple&>& extra_matcher() const {
@ -1051,7 +1073,9 @@ class TypedExpectation : public ExpectationBase {
// Returns an Expectation object that references and co-owns this // Returns an Expectation object that references and co-owns this
// expectation. // expectation.
virtual Expectation GetHandle() { return owner_->GetHandleOf(this); } virtual Expectation GetHandle() {
return owner_->GetHandleOf(this);
}
// The following methods will be called only after the EXPECT_CALL() // The following methods will be called only after the EXPECT_CALL()
// statement finishes and when the current thread holds // statement finishes and when the current thread holds
@ -1079,8 +1103,10 @@ class TypedExpectation : public ExpectationBase {
// Describes the result of matching the arguments against this // Describes the result of matching the arguments against this
// expectation to the given ostream. // expectation to the given ostream.
void ExplainMatchResultTo(const ArgumentTuple& args, ::std::ostream* os) const void ExplainMatchResultTo(
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { const ArgumentTuple& args,
::std::ostream* os) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
if (is_retired()) { if (is_retired()) {
@ -1122,9 +1148,10 @@ class TypedExpectation : public ExpectationBase {
} }
// Returns the action that should be taken for the current invocation. // Returns the action that should be taken for the current invocation.
const Action<F>& GetCurrentAction(const FunctionMockerBase<F>* mocker, const Action<F>& GetCurrentAction(
const ArgumentTuple& args) const const FunctionMockerBase<F>* mocker,
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { const ArgumentTuple& args) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
const int count = call_count(); const int count = call_count();
Assert(count >= 1, __FILE__, __LINE__, Assert(count >= 1, __FILE__, __LINE__,
@ -1139,16 +1166,16 @@ class TypedExpectation : public ExpectationBase {
::std::stringstream ss; ::std::stringstream ss;
DescribeLocationTo(&ss); DescribeLocationTo(&ss);
ss << "Actions ran out in " << source_text() << "...\n" ss << "Actions ran out in " << source_text() << "...\n"
<< "Called " << count << " times, but only " << action_count << "Called " << count << " times, but only "
<< " WillOnce()" << (action_count == 1 ? " is" : "s are") << action_count << " WillOnce()"
<< " specified - "; << (action_count == 1 ? " is" : "s are") << " specified - ";
mocker->DescribeDefaultActionTo(args, &ss); mocker->DescribeDefaultActionTo(args, &ss);
Log(kWarning, ss.str(), 1); Log(kWarning, ss.str(), 1);
} }
return count <= action_count return count <= action_count ?
? *static_cast<const Action<F>*>(untyped_actions_[count - 1]) *static_cast<const Action<F>*>(untyped_actions_[count - 1]) :
: repeated_action(); repeated_action();
} }
// Given the arguments of a mock function call, if the call will // Given the arguments of a mock function call, if the call will
@ -1158,11 +1185,12 @@ class TypedExpectation : public ExpectationBase {
// Mock does it to 'why'. This method is not const as it calls // Mock does it to 'why'. This method is not const as it calls
// IncrementCallCount(). A return value of NULL means the default // IncrementCallCount(). A return value of NULL means the default
// action. // action.
const Action<F>* GetActionForArguments(const FunctionMockerBase<F>* mocker, const Action<F>* GetActionForArguments(
const ArgumentTuple& args, const FunctionMockerBase<F>* mocker,
::std::ostream* what, const ArgumentTuple& args,
::std::ostream* why) ::std::ostream* what,
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { ::std::ostream* why)
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
if (IsSaturated()) { if (IsSaturated()) {
// We have an excessive call. // We have an excessive call.
@ -1185,7 +1213,7 @@ class TypedExpectation : public ExpectationBase {
} }
// Must be done after IncrementCount()! // Must be done after IncrementCount()!
*what << "Mock function call matches " << source_text() << "...\n"; *what << "Mock function call matches " << source_text() <<"...\n";
return &(GetCurrentAction(mocker, args)); return &(GetCurrentAction(mocker, args));
} }
@ -1218,8 +1246,8 @@ template <typename F>
class MockSpec { class MockSpec {
public: public:
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
typedef typedef typename internal::Function<F>::ArgumentMatcherTuple
typename internal::Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; ArgumentMatcherTuple;
// Constructs a MockSpec object, given the function mocker object // Constructs a MockSpec object, given the function mocker object
// that the spec is associated with. // that the spec is associated with.
@ -1228,23 +1256,21 @@ class MockSpec {
// Adds a new default action spec to the function mocker and returns // Adds a new default action spec to the function mocker and returns
// the newly created spec. // the newly created spec.
internal::OnCallSpec<F>& InternalDefaultActionSetAt(const char* file, internal::OnCallSpec<F>& InternalDefaultActionSetAt(
int line, const char* obj, const char* file, int line, const char* obj, const char* call) {
const char* call) {
LogWithLocation(internal::kInfo, file, line, LogWithLocation(internal::kInfo, file, line,
string("ON_CALL(") + obj + ", " + call + ") invoked"); string("ON_CALL(") + obj + ", " + call + ") invoked");
return function_mocker_->AddNewOnCallSpec(file, line, matchers_); return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
} }
// Adds a new expectation spec to the function mocker and returns // Adds a new expectation spec to the function mocker and returns
// the newly created spec. // the newly created spec.
internal::TypedExpectation<F>& InternalExpectedAt(const char* file, int line, internal::TypedExpectation<F>& InternalExpectedAt(
const char* obj, const char* file, int line, const char* obj, const char* call) {
const char* call) {
const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")"); const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
LogWithLocation(internal::kInfo, file, line, source_text + " invoked"); LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
return function_mocker_->AddNewExpectation(file, line, source_text, return function_mocker_->AddNewExpectation(
matchers_); file, line, source_text, matchers_);
} }
private: private:
@ -1277,7 +1303,8 @@ class ReferenceOrValueWrapper {
public: public:
// Constructs a wrapper from the given value/reference. // Constructs a wrapper from the given value/reference.
explicit ReferenceOrValueWrapper(T value) explicit ReferenceOrValueWrapper(T value)
: value_(::testing::internal::move(value)) {} : value_(::testing::internal::move(value)) {
}
// Unwraps and returns the underlying value/reference, exactly as // Unwraps and returns the underlying value/reference, exactly as
// originally passed. The behavior of calling this more than once on // originally passed. The behavior of calling this more than once on
@ -1288,7 +1315,9 @@ class ReferenceOrValueWrapper {
// Always returns a const reference (more precisely, // Always returns a const reference (more precisely,
// const RemoveReference<T>&). The behavior of calling this after // const RemoveReference<T>&). The behavior of calling this after
// calling Unwrap on the same object is unspecified. // calling Unwrap on the same object is unspecified.
const T& Peek() const { return value_; } const T& Peek() const {
return value_;
}
private: private:
T value_; T value_;
@ -1302,7 +1331,8 @@ class ReferenceOrValueWrapper<T&> {
// Workaround for debatable pass-by-reference lint warning (c-library-team // Workaround for debatable pass-by-reference lint warning (c-library-team
// policy precludes NOLINT in this context) // policy precludes NOLINT in this context)
typedef T& reference; typedef T& reference;
explicit ReferenceOrValueWrapper(reference ref) : value_ptr_(&ref) {} explicit ReferenceOrValueWrapper(reference ref)
: value_ptr_(&ref) {}
T& Unwrap() { return *value_ptr_; } T& Unwrap() { return *value_ptr_; }
const T& Peek() const { return *value_ptr_; } const T& Peek() const { return *value_ptr_; }
@ -1316,9 +1346,9 @@ class ReferenceOrValueWrapper<T&> {
// the constructor only. // the constructor only.
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) // Saves the current warning state. # pragma warning(push) // Saves the current warning state.
#pragma warning(disable : 4355) // Temporarily disables warning 4355. # pragma warning(disable:4355) // Temporarily disables warning 4355.
#endif // _MSV_VER #endif // _MSV_VER
// C++ treats the void type specially. For example, you cannot define // C++ treats the void type specially. For example, you cannot define
// a void-typed variable or pass a void value to a function. // a void-typed variable or pass a void value to a function.
@ -1342,7 +1372,9 @@ template <typename T>
class ActionResultHolder : public UntypedActionResultHolderBase { class ActionResultHolder : public UntypedActionResultHolderBase {
public: public:
// Returns the held value. Must not be called more than once. // Returns the held value. Must not be called more than once.
T Unwrap() { return result_.Unwrap(); } T Unwrap() {
return result_.Unwrap();
}
// Prints the held value as an action's result to os. // Prints the held value as an action's result to os.
virtual void PrintAsActionResult(::std::ostream* os) const { virtual void PrintAsActionResult(::std::ostream* os) const {
@ -1358,16 +1390,16 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
const FunctionMockerBase<F>* func_mocker, const FunctionMockerBase<F>* func_mocker,
const typename Function<F>::ArgumentTuple& args, const typename Function<F>::ArgumentTuple& args,
const string& call_description) { const string& call_description) {
return new ActionResultHolder( return new ActionResultHolder(Wrapper(
Wrapper(func_mocker->PerformDefaultAction(args, call_description))); func_mocker->PerformDefaultAction(args, call_description)));
} }
// Performs the given action and returns the result in a new-ed // Performs the given action and returns the result in a new-ed
// ActionResultHolder. // ActionResultHolder.
template <typename F> template <typename F>
static ActionResultHolder* PerformAction( static ActionResultHolder*
const Action<F>& action, PerformAction(const Action<F>& action,
const typename Function<F>::ArgumentTuple& args) { const typename Function<F>::ArgumentTuple& args) {
return new ActionResultHolder(Wrapper(action.Perform(args))); return new ActionResultHolder(Wrapper(action.Perform(args)));
} }
@ -1375,7 +1407,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
typedef ReferenceOrValueWrapper<T> Wrapper; typedef ReferenceOrValueWrapper<T> Wrapper;
explicit ActionResultHolder(Wrapper result) explicit ActionResultHolder(Wrapper result)
: result_(::testing::internal::move(result)) {} : result_(::testing::internal::move(result)) {
}
Wrapper result_; Wrapper result_;
@ -1386,7 +1419,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
template <> template <>
class ActionResultHolder<void> : public UntypedActionResultHolderBase { class ActionResultHolder<void> : public UntypedActionResultHolderBase {
public: public:
void Unwrap() {} void Unwrap() { }
virtual void PrintAsActionResult(::std::ostream* /* os */) const {} virtual void PrintAsActionResult(::std::ostream* /* os */) const {}
@ -1431,7 +1464,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// The destructor verifies that all expectations on this mock // The destructor verifies that all expectations on this mock
// function have been satisfied. If not, it will report Google Test // function have been satisfied. If not, it will report Google Test
// non-fatal failures for the violations. // non-fatal failures for the violations.
virtual ~FunctionMockerBase() GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { virtual ~FunctionMockerBase()
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
MutexLock l(&g_gmock_mutex); MutexLock l(&g_gmock_mutex);
VerifyAndClearExpectationsLocked(); VerifyAndClearExpectationsLocked();
Mock::UnregisterLocked(this); Mock::UnregisterLocked(this);
@ -1441,9 +1475,10 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// Returns the ON_CALL spec that matches this mock function with the // Returns the ON_CALL spec that matches this mock function with the
// given arguments; returns NULL if no matching ON_CALL is found. // given arguments; returns NULL if no matching ON_CALL is found.
// L = * // L = *
const OnCallSpec<F>* FindOnCallSpec(const ArgumentTuple& args) const { const OnCallSpec<F>* FindOnCallSpec(
for (UntypedOnCallSpecs::const_reverse_iterator it = const ArgumentTuple& args) const {
untyped_on_call_specs_.rbegin(); for (UntypedOnCallSpecs::const_reverse_iterator it
= untyped_on_call_specs_.rbegin();
it != untyped_on_call_specs_.rend(); ++it) { it != untyped_on_call_specs_.rend(); ++it) {
const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it); const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);
if (spec->Matches(args)) if (spec->Matches(args))
@ -1462,13 +1497,14 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// L = * // L = *
Result PerformDefaultAction(const ArgumentTuple& args, Result PerformDefaultAction(const ArgumentTuple& args,
const string& call_description) const { const string& call_description) const {
const OnCallSpec<F>* const spec = this->FindOnCallSpec(args); const OnCallSpec<F>* const spec =
this->FindOnCallSpec(args);
if (spec != NULL) { if (spec != NULL) {
return spec->GetAction().Perform(args); return spec->GetAction().Perform(args);
} }
const string message = call_description + const string message = call_description +
"\n The mock function has no default action " "\n The mock function has no default action "
"set, and its return type has no default value set."; "set, and its return type has no default value set.";
#if GTEST_HAS_EXCEPTIONS #if GTEST_HAS_EXCEPTIONS
if (!DefaultValue<Result>::Exists()) { if (!DefaultValue<Result>::Exists()) {
throw std::runtime_error(message); throw std::runtime_error(message);
@ -1523,7 +1559,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
untyped_on_call_specs_.swap(specs_to_delete); untyped_on_call_specs_.swap(specs_to_delete);
g_gmock_mutex.Unlock(); g_gmock_mutex.Unlock();
for (UntypedOnCallSpecs::const_iterator it = specs_to_delete.begin(); for (UntypedOnCallSpecs::const_iterator it =
specs_to_delete.begin();
it != specs_to_delete.end(); ++it) { it != specs_to_delete.end(); ++it) {
delete static_cast<const OnCallSpec<F>*>(*it); delete static_cast<const OnCallSpec<F>*>(*it);
} }
@ -1543,16 +1580,17 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// arguments. This function can be safely called from multiple // arguments. This function can be safely called from multiple
// threads concurrently. // threads concurrently.
Result InvokeWith(const ArgumentTuple& args) Result InvokeWith(const ArgumentTuple& args)
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
scoped_ptr<ResultHolder> holder( scoped_ptr<ResultHolder> holder(
DownCast_<ResultHolder*>(this->UntypedInvokeWith(&args))); DownCast_<ResultHolder*>(this->UntypedInvokeWith(&args)));
return holder->Unwrap(); return holder->Unwrap();
} }
// Adds and returns a default action spec for this mock function. // Adds and returns a default action spec for this mock function.
OnCallSpec<F>& AddNewOnCallSpec(const char* file, int line, OnCallSpec<F>& AddNewOnCallSpec(
const ArgumentMatcherTuple& m) const char* file, int line,
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { const ArgumentMatcherTuple& m)
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line); Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m); OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);
untyped_on_call_specs_.push_back(on_call_spec); untyped_on_call_specs_.push_back(on_call_spec);
@ -1560,10 +1598,12 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
} }
// Adds and returns an expectation spec for this mock function. // Adds and returns an expectation spec for this mock function.
TypedExpectation<F>& AddNewExpectation(const char* file, int line, TypedExpectation<F>& AddNewExpectation(
const string& source_text, const char* file,
const ArgumentMatcherTuple& m) int line,
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { const string& source_text,
const ArgumentMatcherTuple& m)
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line); Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
TypedExpectation<F>* const expectation = TypedExpectation<F>* const expectation =
new TypedExpectation<F>(this, file, line, source_text, m); new TypedExpectation<F>(this, file, line, source_text, m);
@ -1584,8 +1624,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
MockSpec<F>& current_spec() { return current_spec_; } MockSpec<F>& current_spec() { return current_spec_; }
private: private:
template <typename Func> template <typename Func> friend class TypedExpectation;
friend class TypedExpectation;
// Some utilities needed for implementing UntypedInvokeWith(). // Some utilities needed for implementing UntypedInvokeWith().
@ -1597,9 +1636,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
const OnCallSpec<F>* const spec = FindOnCallSpec(args); const OnCallSpec<F>* const spec = FindOnCallSpec(args);
if (spec == NULL) { if (spec == NULL) {
*os << (internal::type_equals<Result, void>::value *os << (internal::type_equals<Result, void>::value ?
? "returning directly.\n" "returning directly.\n" :
: "returning default value.\n"); "returning default value.\n");
} else { } else {
*os << "taking default action specified at:\n" *os << "taking default action specified at:\n"
<< FormatFileLocation(spec->file(), spec->line()) << "\n"; << FormatFileLocation(spec->file(), spec->line()) << "\n";
@ -1609,9 +1648,10 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// Writes a message that the call is uninteresting (i.e. neither // Writes a message that the call is uninteresting (i.e. neither
// explicitly expected nor explicitly unexpected) to the given // explicitly expected nor explicitly unexpected) to the given
// ostream. // ostream.
virtual void UntypedDescribeUninterestingCall(const void* untyped_args, virtual void UntypedDescribeUninterestingCall(
::std::ostream* os) const const void* untyped_args,
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { ::std::ostream* os) const
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
const ArgumentTuple& args = const ArgumentTuple& args =
*static_cast<const ArgumentTuple*>(untyped_args); *static_cast<const ArgumentTuple*>(untyped_args);
*os << "Uninteresting mock function call - "; *os << "Uninteresting mock function call - ";
@ -1637,9 +1677,10 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// action does (it can invoke an arbitrary user function or even a // action does (it can invoke an arbitrary user function or even a
// mock function) and excessive locking could cause a dead lock. // mock function) and excessive locking could cause a dead lock.
virtual const ExpectationBase* UntypedFindMatchingExpectation( virtual const ExpectationBase* UntypedFindMatchingExpectation(
const void* untyped_args, const void** untyped_action, bool* is_excessive, const void* untyped_args,
const void** untyped_action, bool* is_excessive,
::std::ostream* what, ::std::ostream* why) ::std::ostream* what, ::std::ostream* why)
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
const ArgumentTuple& args = const ArgumentTuple& args =
*static_cast<const ArgumentTuple*>(untyped_args); *static_cast<const ArgumentTuple*>(untyped_args);
MutexLock l(&g_gmock_mutex); MutexLock l(&g_gmock_mutex);
@ -1670,8 +1711,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// Returns the expectation that matches the arguments, or NULL if no // Returns the expectation that matches the arguments, or NULL if no
// expectation matches them. // expectation matches them.
TypedExpectation<F>* FindMatchingExpectationLocked(const ArgumentTuple& args) TypedExpectation<F>* FindMatchingExpectationLocked(
const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { const ArgumentTuple& args) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
for (typename UntypedExpectations::const_reverse_iterator it = for (typename UntypedExpectations::const_reverse_iterator it =
untyped_expectations_.rbegin(); untyped_expectations_.rbegin();
@ -1686,10 +1728,11 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
} }
// Returns a message that the arguments don't match any expectation. // Returns a message that the arguments don't match any expectation.
void FormatUnexpectedCallMessageLocked(const ArgumentTuple& args, void FormatUnexpectedCallMessageLocked(
::std::ostream* os, const ArgumentTuple& args,
::std::ostream* why) const ::std::ostream* os,
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { ::std::ostream* why) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
*os << "\nUnexpected mock function call - "; *os << "\nUnexpected mock function call - ";
DescribeDefaultActionTo(args, os); DescribeDefaultActionTo(args, os);
@ -1698,14 +1741,15 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// Prints a list of expectations that have been tried against the // Prints a list of expectations that have been tried against the
// current mock function call. // current mock function call.
void PrintTriedExpectationsLocked(const ArgumentTuple& args, void PrintTriedExpectationsLocked(
::std::ostream* why) const const ArgumentTuple& args,
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { ::std::ostream* why) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
const int count = static_cast<int>(untyped_expectations_.size()); const int count = static_cast<int>(untyped_expectations_.size());
*why << "Google Mock tried the following " << count << " " *why << "Google Mock tried the following " << count << " "
<< (count == 1 ? "expectation, but it didn't match" << (count == 1 ? "expectation, but it didn't match" :
: "expectations, but none matched") "expectations, but none matched")
<< ":\n"; << ":\n";
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
TypedExpectation<F>* const expectation = TypedExpectation<F>* const expectation =
@ -1741,8 +1785,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
}; // class FunctionMockerBase }; // class FunctionMockerBase
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state. # pragma warning(pop) // Restores the warning state.
#endif // _MSV_VER #endif // _MSV_VER
// Implements methods of FunctionMockerBase. // Implements methods of FunctionMockerBase.
@ -1779,9 +1823,7 @@ using internal::MockSpec;
// // Expects a call to const MockFoo::Bar(). // // Expects a call to const MockFoo::Bar().
// EXPECT_CALL(Const(foo), Bar()); // EXPECT_CALL(Const(foo), Bar());
template <typename T> template <typename T>
inline const T& Const(const T& x) { inline const T& Const(const T& x) { return x; }
return x;
}
// Constructs an Expectation object that references and co-owns exp. // Constructs an Expectation object that references and co-owns exp.
inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
@ -1794,12 +1836,12 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
// See CompilesWithMethodNameExpandedFromMacro tests in // See CompilesWithMethodNameExpandedFromMacro tests in
// internal/gmock-spec-builders_test.cc for more details. // internal/gmock-spec-builders_test.cc for more details.
#define GMOCK_ON_CALL_IMPL_(obj, call) \ #define GMOCK_ON_CALL_IMPL_(obj, call) \
((obj).gmock_##call) \ ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
.InternalDefaultActionSetAt(__FILE__, __LINE__, #obj, #call) #obj, #call)
#define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call) #define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
#define GMOCK_EXPECT_CALL_IMPL_(obj, call) \ #define GMOCK_EXPECT_CALL_IMPL_(obj, call) \
((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call) ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call)
#define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call) #define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_

View File

@ -59,8 +59,8 @@
#include "gmock/gmock-cardinalities.h" #include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-generated-actions.h" #include "gmock/gmock-generated-actions.h"
#include "gmock/gmock-generated-function-mockers.h" #include "gmock/gmock-generated-function-mockers.h"
#include "gmock/gmock-generated-matchers.h"
#include "gmock/gmock-generated-nice-strict.h" #include "gmock/gmock-generated-nice-strict.h"
#include "gmock/gmock-generated-matchers.h"
#include "gmock/gmock-matchers.h" #include "gmock/gmock-matchers.h"
#include "gmock/gmock-more-actions.h" #include "gmock/gmock-more-actions.h"
#include "gmock/gmock-more-matchers.h" #include "gmock/gmock-more-matchers.h"

View File

@ -69,78 +69,72 @@ template <typename Tuple>
struct MatcherTuple; struct MatcherTuple;
template <> template <>
struct MatcherTuple<::testing::tuple<>> { struct MatcherTuple< ::testing::tuple<> > {
typedef ::testing::tuple<> type; typedef ::testing::tuple< > type;
}; };
template <typename A1> template <typename A1>
struct MatcherTuple<::testing::tuple<A1>> { struct MatcherTuple< ::testing::tuple<A1> > {
typedef ::testing::tuple<Matcher<A1>> type; typedef ::testing::tuple<Matcher<A1> > type;
}; };
template <typename A1, typename A2> template <typename A1, typename A2>
struct MatcherTuple<::testing::tuple<A1, A2>> { struct MatcherTuple< ::testing::tuple<A1, A2> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>> type; typedef ::testing::tuple<Matcher<A1>, Matcher<A2> > type;
}; };
template <typename A1, typename A2, typename A3> template <typename A1, typename A2, typename A3>
struct MatcherTuple<::testing::tuple<A1, A2, A3>> { struct MatcherTuple< ::testing::tuple<A1, A2, A3> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>> type; typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
}; };
template <typename A1, typename A2, typename A3, typename A4> template <typename A1, typename A2, typename A3, typename A4>
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4>> { struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>> typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
type; Matcher<A4> > type;
}; };
template <typename A1, typename A2, typename A3, typename A4, typename A5> template <typename A1, typename A2, typename A3, typename A4, typename A5>
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5>> { struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>, typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>> Matcher<A5> > type;
type;
}; };
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6> typename A6>
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6>> { struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>, typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>> Matcher<A5>, Matcher<A6> > type;
type;
}; };
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7> typename A6, typename A7>
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6, A7>> { struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>, typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>> Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
type;
}; };
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8> typename A6, typename A7, typename A8>
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8>> { struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>, typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>> Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
type;
}; };
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9> typename A6, typename A7, typename A8, typename A9>
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9>> { struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>, typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
Matcher<A9>>
type;
}; };
template <typename A1, typename A2, typename A3, typename A4, typename A5, template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9, typename A10> typename A6, typename A7, typename A8, typename A9, typename A10>
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>> { struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>, typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
Matcher<A9>, Matcher<A10>> Matcher<A10> > type;
type;
}; };
// Template struct Function<F>, where F must be a function type, contains // Template struct Function<F>, where F must be a function type, contains
@ -169,7 +163,8 @@ struct Function<R()> {
}; };
template <typename R, typename A1> template <typename R, typename A1>
struct Function<R(A1)> : Function<R()> { struct Function<R(A1)>
: Function<R()> {
typedef A1 Argument1; typedef A1 Argument1;
typedef ::testing::tuple<A1> ArgumentTuple; typedef ::testing::tuple<A1> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple; typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
@ -178,7 +173,8 @@ struct Function<R(A1)> : Function<R()> {
}; };
template <typename R, typename A1, typename A2> template <typename R, typename A1, typename A2>
struct Function<R(A1, A2)> : Function<R(A1)> { struct Function<R(A1, A2)>
: Function<R(A1)> {
typedef A2 Argument2; typedef A2 Argument2;
typedef ::testing::tuple<A1, A2> ArgumentTuple; typedef ::testing::tuple<A1, A2> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple; typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
@ -187,7 +183,8 @@ struct Function<R(A1, A2)> : Function<R(A1)> {
}; };
template <typename R, typename A1, typename A2, typename A3> template <typename R, typename A1, typename A2, typename A3>
struct Function<R(A1, A2, A3)> : Function<R(A1, A2)> { struct Function<R(A1, A2, A3)>
: Function<R(A1, A2)> {
typedef A3 Argument3; typedef A3 Argument3;
typedef ::testing::tuple<A1, A2, A3> ArgumentTuple; typedef ::testing::tuple<A1, A2, A3> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple; typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
@ -196,7 +193,8 @@ struct Function<R(A1, A2, A3)> : Function<R(A1, A2)> {
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4> template <typename R, typename A1, typename A2, typename A3, typename A4>
struct Function<R(A1, A2, A3, A4)> : Function<R(A1, A2, A3)> { struct Function<R(A1, A2, A3, A4)>
: Function<R(A1, A2, A3)> {
typedef A4 Argument4; typedef A4 Argument4;
typedef ::testing::tuple<A1, A2, A3, A4> ArgumentTuple; typedef ::testing::tuple<A1, A2, A3, A4> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple; typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
@ -205,8 +203,9 @@ struct Function<R(A1, A2, A3, A4)> : Function<R(A1, A2, A3)> {
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5> typename A5>
struct Function<R(A1, A2, A3, A4, A5)> : Function<R(A1, A2, A3, A4)> { struct Function<R(A1, A2, A3, A4, A5)>
: Function<R(A1, A2, A3, A4)> {
typedef A5 Argument5; typedef A5 Argument5;
typedef ::testing::tuple<A1, A2, A3, A4, A5> ArgumentTuple; typedef ::testing::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple; typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
@ -215,8 +214,9 @@ struct Function<R(A1, A2, A3, A4, A5)> : Function<R(A1, A2, A3, A4)> {
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6> typename A5, typename A6>
struct Function<R(A1, A2, A3, A4, A5, A6)> : Function<R(A1, A2, A3, A4, A5)> { struct Function<R(A1, A2, A3, A4, A5, A6)>
: Function<R(A1, A2, A3, A4, A5)> {
typedef A6 Argument6; typedef A6 Argument6;
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple; typedef ::testing::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple; typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
@ -225,7 +225,7 @@ struct Function<R(A1, A2, A3, A4, A5, A6)> : Function<R(A1, A2, A3, A4, A5)> {
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7> typename A5, typename A6, typename A7>
struct Function<R(A1, A2, A3, A4, A5, A6, A7)> struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
: Function<R(A1, A2, A3, A4, A5, A6)> { : Function<R(A1, A2, A3, A4, A5, A6)> {
typedef A7 Argument7; typedef A7 Argument7;
@ -236,7 +236,7 @@ struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8> typename A5, typename A6, typename A7, typename A8>
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
: Function<R(A1, A2, A3, A4, A5, A6, A7)> { : Function<R(A1, A2, A3, A4, A5, A6, A7)> {
typedef A8 Argument8; typedef A8 Argument8;
@ -247,7 +247,7 @@ struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9> typename A5, typename A6, typename A7, typename A8, typename A9>
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> { : Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
typedef A9 Argument9; typedef A9 Argument9;
@ -255,21 +255,21 @@ struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple; typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9); typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8, typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
A9); A9);
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9, typename A5, typename A6, typename A7, typename A8, typename A9,
typename A10> typename A10>
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> { : Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
typedef A10 Argument10; typedef A10 Argument10;
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
ArgumentTuple; A10> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple; typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8, typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
A9, A10); A9, A10);
}; };
} // namespace internal } // namespace internal

View File

@ -38,8 +38,8 @@
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
#include <ostream> // NOLINT
#include <stdio.h> #include <stdio.h>
#include <ostream> // NOLINT
#include <string> #include <string>
#include "gmock/internal/gmock-generated-internal-utils.h" #include "gmock/internal/gmock-generated-internal-utils.h"
@ -67,9 +67,7 @@ struct PointeeOf {
}; };
// This specialization is for the raw pointer case. // This specialization is for the raw pointer case.
template <typename T> template <typename T>
struct PointeeOf<T*> { struct PointeeOf<T*> { typedef T type; }; // NOLINT
typedef T type;
}; // NOLINT
// GetRawPointer(p) returns the raw pointer underlying p when p is a // GetRawPointer(p) returns the raw pointer underlying p when p is a
// smart pointer, or returns p itself when p is already a raw pointer. // smart pointer, or returns p itself when p is already a raw pointer.
@ -80,9 +78,7 @@ inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
} }
// This overloaded version is for the raw pointer case. // This overloaded version is for the raw pointer case.
template <typename Element> template <typename Element>
inline Element* GetRawPointer(Element* p) { inline Element* GetRawPointer(Element* p) { return p; }
return p;
}
// This comparator allows linked_ptr to be stored in sets. // This comparator allows linked_ptr to be stored in sets.
template <typename T> template <typename T>
@ -105,7 +101,7 @@ struct LinkedPtrLessThan {
(defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)) (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
// wchar_t is a typedef. // wchar_t is a typedef.
#else #else
#define GMOCK_WCHAR_T_IS_NATIVE_ 1 # define GMOCK_WCHAR_T_IS_NATIVE_ 1
#endif #endif
// signed wchar_t and unsigned wchar_t are NOT in the C++ standard. // signed wchar_t and unsigned wchar_t are NOT in the C++ standard.
@ -119,7 +115,7 @@ struct LinkedPtrLessThan {
// wchar_t == signed wchar_t != unsigned wchar_t == unsigned int // wchar_t == signed wchar_t != unsigned wchar_t == unsigned int
#ifdef __GNUC__ #ifdef __GNUC__
// signed/unsigned wchar_t are valid types. // signed/unsigned wchar_t are valid types.
#define GMOCK_HAS_SIGNED_WCHAR_T_ 1 # define GMOCK_HAS_SIGNED_WCHAR_T_ 1
#endif #endif
// In what follows, we use the term "kind" to indicate whether a type // In what follows, we use the term "kind" to indicate whether a type
@ -127,20 +123,18 @@ struct LinkedPtrLessThan {
// or none of them. This categorization is useful for determining // or none of them. This categorization is useful for determining
// when a matcher argument type can be safely converted to another // when a matcher argument type can be safely converted to another
// type in the implementation of SafeMatcherCast. // type in the implementation of SafeMatcherCast.
enum TypeKind { kBool, kInteger, kFloatingPoint, kOther }; enum TypeKind {
kBool, kInteger, kFloatingPoint, kOther
};
// KindOf<T>::value is the kind of type T. // KindOf<T>::value is the kind of type T.
template <typename T> template <typename T> struct KindOf {
struct KindOf {
enum { value = kOther }; // The default kind. enum { value = kOther }; // The default kind.
}; };
// This macro declares that the kind of 'type' is 'kind'. // This macro declares that the kind of 'type' is 'kind'.
#define GMOCK_DECLARE_KIND_(type, kind) \ #define GMOCK_DECLARE_KIND_(type, kind) \
template <> \ template <> struct KindOf<type> { enum { value = kind }; }
struct KindOf<type> { \
enum { value = kind }; \
}
GMOCK_DECLARE_KIND_(bool, kBool); GMOCK_DECLARE_KIND_(bool, kBool);
@ -148,11 +142,11 @@ GMOCK_DECLARE_KIND_(bool, kBool);
GMOCK_DECLARE_KIND_(char, kInteger); GMOCK_DECLARE_KIND_(char, kInteger);
GMOCK_DECLARE_KIND_(signed char, kInteger); GMOCK_DECLARE_KIND_(signed char, kInteger);
GMOCK_DECLARE_KIND_(unsigned char, kInteger); GMOCK_DECLARE_KIND_(unsigned char, kInteger);
GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(int, kInteger); GMOCK_DECLARE_KIND_(int, kInteger);
GMOCK_DECLARE_KIND_(unsigned int, kInteger); GMOCK_DECLARE_KIND_(unsigned int, kInteger);
GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
#if GMOCK_WCHAR_T_IS_NATIVE_ #if GMOCK_WCHAR_T_IS_NATIVE_
@ -171,8 +165,8 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
#undef GMOCK_DECLARE_KIND_ #undef GMOCK_DECLARE_KIND_
// Evaluates to the kind of 'type'. // Evaluates to the kind of 'type'.
#define GMOCK_KIND_OF_(type) \ #define GMOCK_KIND_OF_(type) \
static_cast<::testing::internal::TypeKind>( \ static_cast< ::testing::internal::TypeKind>( \
::testing::internal::KindOf<type>::value) ::testing::internal::KindOf<type>::value)
// Evaluates to true iff integer type T is signed. // Evaluates to true iff integer type T is signed.
@ -215,13 +209,13 @@ struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
template <typename From, typename To> template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To> struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
: public bool_constant< : public bool_constant<
// When converting from a smaller size to a larger size, we are // When converting from a smaller size to a larger size, we are
// fine as long as we are not converting from signed to unsigned. // fine as long as we are not converting from signed to unsigned.
((sizeof(From) < sizeof(To)) && ((sizeof(From) < sizeof(To)) &&
(!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) || (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
// When converting between the same size, the signedness must match. // When converting between the same size, the signedness must match.
((sizeof(From) == sizeof(To)) && ((sizeof(From) == sizeof(To)) &&
(GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT
#undef GMOCK_IS_SIGNED_ #undef GMOCK_IS_SIGNED_
@ -244,8 +238,8 @@ struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
// Converting a floating-point to another floating-point is lossless // Converting a floating-point to another floating-point is lossless
// iff the target type is at least as big as the source type. // iff the target type is at least as big as the source type.
template <typename From, typename To> template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kFloatingPoint, struct LosslessArithmeticConvertibleImpl<
To> kFloatingPoint, From, kFloatingPoint, To>
: public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT : public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
// LosslessArithmeticConvertible<From, To>::value is true iff arithmetic // LosslessArithmeticConvertible<From, To>::value is true iff arithmetic
@ -257,16 +251,17 @@ struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kFloatingPoint,
// implementation-defined when the above pre-condition is violated. // implementation-defined when the above pre-condition is violated.
template <typename From, typename To> template <typename From, typename To>
struct LosslessArithmeticConvertible struct LosslessArithmeticConvertible
: public LosslessArithmeticConvertibleImpl<GMOCK_KIND_OF_(From), From, : public LosslessArithmeticConvertibleImpl<
GMOCK_KIND_OF_(To), To> { GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {}; // NOLINT
}; // NOLINT
// This interface knows how to report a Google Mock failure (either // This interface knows how to report a Google Mock failure (either
// non-fatal or fatal). // non-fatal or fatal).
class FailureReporterInterface { class FailureReporterInterface {
public: public:
// The type of a failure (either non-fatal or fatal). // The type of a failure (either non-fatal or fatal).
enum FailureType { kNonfatal, kFatal }; enum FailureType {
kNonfatal, kFatal
};
virtual ~FailureReporterInterface() {} virtual ~FailureReporterInterface() {}
@ -286,8 +281,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter();
inline void Assert(bool condition, const char* file, int line, inline void Assert(bool condition, const char* file, int line,
const string& msg) { const string& msg) {
if (!condition) { if (!condition) {
GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal, file, GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
line, msg); file, line, msg);
} }
} }
inline void Assert(bool condition, const char* file, int line) { inline void Assert(bool condition, const char* file, int line) {
@ -308,7 +303,10 @@ inline void Expect(bool condition, const char* file, int line) {
} }
// Severity level of a log. // Severity level of a log.
enum LogSeverity { kInfo = 0, kWarning = 1 }; enum LogSeverity {
kInfo = 0,
kWarning = 1
};
// Valid values for the --gmock_verbose flag. // Valid values for the --gmock_verbose flag.
@ -330,7 +328,8 @@ GTEST_API_ bool LogIsVisible(LogSeverity severity);
// stack_frames_to_skip is treated as 0, since we don't know which // stack_frames_to_skip is treated as 0, since we don't know which
// function calls will be inlined by the compiler and need to be // function calls will be inlined by the compiler and need to be
// conservative. // conservative.
GTEST_API_ void Log(LogSeverity severity, const string& message, GTEST_API_ void Log(LogSeverity severity,
const string& message,
int stack_frames_to_skip); int stack_frames_to_skip);
// TODO(wan@google.com): group all type utilities together. // TODO(wan@google.com): group all type utilities together.
@ -338,50 +337,35 @@ GTEST_API_ void Log(LogSeverity severity, const string& message,
// Type traits. // Type traits.
// is_reference<T>::value is non-zero iff T is a reference type. // is_reference<T>::value is non-zero iff T is a reference type.
template <typename T> template <typename T> struct is_reference : public false_type {};
struct is_reference : public false_type {}; template <typename T> struct is_reference<T&> : public true_type {};
template <typename T>
struct is_reference<T&> : public true_type {};
// type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type. // type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type.
template <typename T1, typename T2> template <typename T1, typename T2> struct type_equals : public false_type {};
struct type_equals : public false_type {}; template <typename T> struct type_equals<T, T> : public true_type {};
template <typename T>
struct type_equals<T, T> : public true_type {};
// remove_reference<T>::type removes the reference from type T, if any. // remove_reference<T>::type removes the reference from type T, if any.
template <typename T> template <typename T> struct remove_reference { typedef T type; }; // NOLINT
struct remove_reference { template <typename T> struct remove_reference<T&> { typedef T type; }; // NOLINT
typedef T type;
}; // NOLINT
template <typename T>
struct remove_reference<T&> {
typedef T type;
}; // NOLINT
// DecayArray<T>::type turns an array type U[N] to const U* and preserves // DecayArray<T>::type turns an array type U[N] to const U* and preserves
// other types. Useful for saving a copy of a function argument. // other types. Useful for saving a copy of a function argument.
template <typename T> template <typename T> struct DecayArray { typedef T type; }; // NOLINT
struct DecayArray { template <typename T, size_t N> struct DecayArray<T[N]> {
typedef T type;
}; // NOLINT
template <typename T, size_t N>
struct DecayArray<T[N]> {
typedef const T* type; typedef const T* type;
}; };
// Sometimes people use arrays whose size is not available at the use site // Sometimes people use arrays whose size is not available at the use site
// (e.g. extern const char kNamePrefix[]). This specialization covers that // (e.g. extern const char kNamePrefix[]). This specialization covers that
// case. // case.
template <typename T> template <typename T> struct DecayArray<T[]> {
struct DecayArray<T[]> {
typedef const T* type; typedef const T* type;
}; };
// Disable MSVC warnings for infinite recursion, since in this case the // Disable MSVC warnings for infinite recursion, since in this case the
// the recursion is unreachable. // the recursion is unreachable.
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) # pragma warning(push)
#pragma warning(disable : 4717) # pragma warning(disable:4717)
#endif #endif
// Invalid<T>() is usable as an expression of type T, but will terminate // Invalid<T>() is usable as an expression of type T, but will terminate
@ -399,7 +383,7 @@ inline T Invalid() {
} }
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) # pragma warning(pop)
#endif #endif
// Given a raw type (i.e. having no top-level reference or const // Given a raw type (i.e. having no top-level reference or const
@ -427,7 +411,7 @@ class StlContainerView {
static const_reference ConstReference(const RawContainer& container) { static const_reference ConstReference(const RawContainer& container) {
// Ensures that RawContainer is not a const type. // Ensures that RawContainer is not a const type.
testing::StaticAssertTypeEq<RawContainer, testing::StaticAssertTypeEq<RawContainer,
GTEST_REMOVE_CONST_(RawContainer)>(); GTEST_REMOVE_CONST_(RawContainer)>();
return container; return container;
} }
static type Copy(const RawContainer& container) { return container; } static type Copy(const RawContainer& container) { return container; }
@ -481,7 +465,7 @@ class StlContainerView<Element[N]> {
// This specialization is used when RawContainer is a native array // This specialization is used when RawContainer is a native array
// represented as a (pointer, size) tuple. // represented as a (pointer, size) tuple.
template <typename ElementPointer, typename Size> template <typename ElementPointer, typename Size>
class StlContainerView<::testing::tuple<ElementPointer, Size>> { class StlContainerView< ::testing::tuple<ElementPointer, Size> > {
public: public:
typedef GTEST_REMOVE_CONST_( typedef GTEST_REMOVE_CONST_(
typename internal::PointeeOf<ElementPointer>::type) RawElement; typename internal::PointeeOf<ElementPointer>::type) RawElement;
@ -499,8 +483,7 @@ class StlContainerView<::testing::tuple<ElementPointer, Size>> {
// The following specialization prevents the user from instantiating // The following specialization prevents the user from instantiating
// StlContainer with a reference type. // StlContainer with a reference type.
template <typename T> template <typename T> class StlContainerView<T&>;
class StlContainerView<T&>;
// A type transform to remove constness from the first part of a pair. // A type transform to remove constness from the first part of a pair.
// Pairs like that are used as the value_type of associative containers, // Pairs like that are used as the value_type of associative containers,
@ -512,7 +495,7 @@ struct RemoveConstFromKey {
// Partially specialized to remove constness from std::pair<const K, V>. // Partially specialized to remove constness from std::pair<const K, V>.
template <typename K, typename V> template <typename K, typename V>
struct RemoveConstFromKey<std::pair<const K, V>> { struct RemoveConstFromKey<std::pair<const K, V> > {
typedef std::pair<K, V> type; typedef std::pair<K, V> type;
}; };
@ -525,3 +508,4 @@ struct BooleanConstant {};
} // namespace testing } // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_

View File

@ -40,8 +40,8 @@
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
#include <assert.h> #include <assert.h>
#include <iostream>
#include <stdlib.h> #include <stdlib.h>
#include <iostream>
// Most of the utilities needed for porting Google Mock are also // Most of the utilities needed for porting Google Mock are also
// required for Google Test and are defined in gtest-port.h. // required for Google Test and are defined in gtest-port.h.
@ -50,9 +50,9 @@
// portability utilities to Google Test's gtest-port.h instead of // portability utilities to Google Test's gtest-port.h instead of
// here, as Google Mock depends on Google Test. Only add a utility // here, as Google Mock depends on Google Test. Only add a utility
// here if it's truly specific to Google Mock. // here if it's truly specific to Google Mock.
#include "gmock/internal/custom/gmock-port.h"
#include "gtest/internal/gtest-linked_ptr.h" #include "gtest/internal/gtest-linked_ptr.h"
#include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-port.h"
#include "gmock/internal/custom/gmock-port.h"
// To avoid conditional compilation everywhere, we make it // To avoid conditional compilation everywhere, we make it
// gmock-port.h's responsibility to #include the header implementing // gmock-port.h's responsibility to #include the header implementing
@ -62,7 +62,7 @@
// For MS Visual C++, check the compiler version. At least VS 2003 is // For MS Visual C++, check the compiler version. At least VS 2003 is
// required to compile Google Mock. // required to compile Google Mock.
#if defined(_MSC_VER) && _MSC_VER < 1310 #if defined(_MSC_VER) && _MSC_VER < 1310
#error "At least Visual C++ 2003 (7.1) is required to compile Google Mock." # error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
#endif #endif
// Macro for referencing flags. This is public as we want the user to // Macro for referencing flags. This is public as we want the user to
@ -74,17 +74,17 @@
// Macros for declaring flags. // Macros for declaring flags.
#define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name) #define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
#define GMOCK_DECLARE_int32_(name) \ #define GMOCK_DECLARE_int32_(name) \
extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name)
#define GMOCK_DECLARE_string_(name) \ #define GMOCK_DECLARE_string_(name) \
extern GTEST_API_ ::std::string GMOCK_FLAG(name) extern GTEST_API_ ::std::string GMOCK_FLAG(name)
// Macros for defining flags. // Macros for defining flags.
#define GMOCK_DEFINE_bool_(name, default_val, doc) \ #define GMOCK_DEFINE_bool_(name, default_val, doc) \
GTEST_API_ bool GMOCK_FLAG(name) = (default_val) GTEST_API_ bool GMOCK_FLAG(name) = (default_val)
#define GMOCK_DEFINE_int32_(name, default_val, doc) \ #define GMOCK_DEFINE_int32_(name, default_val, doc) \
GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val) GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
#define GMOCK_DEFINE_string_(name, default_val, doc) \ #define GMOCK_DEFINE_string_(name, default_val, doc) \
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val) GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
#endif // !defined(GMOCK_DECLARE_bool_) #endif // !defined(GMOCK_DECLARE_bool_)

View File

@ -117,7 +117,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#if !GTEST_OS_WINDOWS_MOBILE #if !GTEST_OS_WINDOWS_MOBILE
#include <errno.h> # include <errno.h>
#endif #endif
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
@ -195,14 +195,14 @@ class Interface {
virtual char* StringFromString(char* str) = 0; virtual char* StringFromString(char* str) = 0;
virtual int IntFromString(char* str) = 0; virtual int IntFromString(char* str) = 0;
virtual int& IntRefFromString(char* str) = 0; virtual int& IntRefFromString(char* str) = 0;
virtual void VoidFromFunc(void (*func)(char* str)) = 0; virtual void VoidFromFunc(void(*func)(char* str)) = 0;
virtual void VoidFromIntRef(int& n) = 0; // NOLINT virtual void VoidFromIntRef(int& n) = 0; // NOLINT
virtual void VoidFromFloat(float n) = 0; virtual void VoidFromFloat(float n) = 0;
virtual void VoidFromDouble(double n) = 0; virtual void VoidFromDouble(double n) = 0;
virtual void VoidFromVector(const std::vector<int>& v) = 0; virtual void VoidFromVector(const std::vector<int>& v) = 0;
}; };
class Mock : public Interface { class Mock: public Interface {
public: public:
Mock() {} Mock() {}
@ -210,7 +210,7 @@ class Mock : public Interface {
MOCK_METHOD1(StringFromString, char*(char* str)); MOCK_METHOD1(StringFromString, char*(char* str));
MOCK_METHOD1(IntFromString, int(char* str)); MOCK_METHOD1(IntFromString, int(char* str));
MOCK_METHOD1(IntRefFromString, int&(char* str)); MOCK_METHOD1(IntRefFromString, int&(char* str));
MOCK_METHOD1(VoidFromFunc, void(void (*func)(char* str))); MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str)));
MOCK_METHOD1(VoidFromIntRef, void(int& n)); // NOLINT MOCK_METHOD1(VoidFromIntRef, void(int& n)); // NOLINT
MOCK_METHOD1(VoidFromFloat, void(float n)); MOCK_METHOD1(VoidFromFloat, void(float n));
MOCK_METHOD1(VoidFromDouble, void(double n)); MOCK_METHOD1(VoidFromDouble, void(double n));
@ -296,8 +296,8 @@ TEST(LinkTest, TestSetArrayArgument) {
char ch = 'x'; char ch = 'x';
char ch2 = 'y'; char ch2 = 'y';
EXPECT_CALL(mock, VoidFromString(_)) EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,
.WillOnce(SetArrayArgument<0>(&ch2, &ch2 + 1)); &ch2 + 1));
mock.VoidFromString(&ch); mock.VoidFromString(&ch);
} }
@ -334,8 +334,8 @@ TEST(LinkTest, TestInvokeWithoutArgs) {
EXPECT_CALL(mock, VoidFromString(_)) EXPECT_CALL(mock, VoidFromString(_))
.WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid)) .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
.WillOnce( .WillOnce(InvokeWithoutArgs(&test_invoke_helper,
InvokeWithoutArgs(&test_invoke_helper, &InvokeHelper::VoidFromVoid)); &InvokeHelper::VoidFromVoid));
mock.VoidFromString(NULL); mock.VoidFromString(NULL);
mock.VoidFromString(NULL); mock.VoidFromString(NULL);
} }
@ -419,14 +419,14 @@ TEST(LinkTest, TestThrow) {
// is expanded and macro expansion cannot contain #pragma. Therefore // is expanded and macro expansion cannot contain #pragma. Therefore
// we suppress them here. // we suppress them here.
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) # pragma warning(push)
#pragma warning(disable : 4100) # pragma warning(disable:4100)
#endif #endif
// Tests the linkage of actions created using ACTION macro. // Tests the linkage of actions created using ACTION macro.
namespace { namespace {
ACTION(Return1) { return 1; } ACTION(Return1) { return 1; }
} // namespace }
TEST(LinkTest, TestActionMacro) { TEST(LinkTest, TestActionMacro) {
Mock mock; Mock mock;
@ -438,7 +438,7 @@ TEST(LinkTest, TestActionMacro) {
// Tests the linkage of actions created using ACTION_P macro. // Tests the linkage of actions created using ACTION_P macro.
namespace { namespace {
ACTION_P(ReturnArgument, ret_value) { return ret_value; } ACTION_P(ReturnArgument, ret_value) { return ret_value; }
} // namespace }
TEST(LinkTest, TestActionPMacro) { TEST(LinkTest, TestActionPMacro) {
Mock mock; Mock mock;
@ -452,10 +452,10 @@ namespace {
ACTION_P2(ReturnEqualsEitherOf, first, second) { ACTION_P2(ReturnEqualsEitherOf, first, second) {
return arg0 == first || arg0 == second; return arg0 == first || arg0 == second;
} }
} // namespace }
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) # pragma warning(pop)
#endif #endif
TEST(LinkTest, TestActionP2Macro) { TEST(LinkTest, TestActionP2Macro) {
@ -487,7 +487,8 @@ TEST(LinkTest, TestMatchersEq) {
const char* p = "x"; const char* p = "x";
ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return()); ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return());
ON_CALL(mock, VoidFromString(const_cast<char*>("y"))).WillByDefault(Return()); ON_CALL(mock, VoidFromString(const_cast<char*>("y")))
.WillByDefault(Return());
} }
// Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers. // Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers.
@ -586,7 +587,7 @@ TEST(LinkTest, TestMatcherElementsAre) {
// Tests the linkage of the ElementsAreArray matcher. // Tests the linkage of the ElementsAreArray matcher.
TEST(LinkTest, TestMatcherElementsAreArray) { TEST(LinkTest, TestMatcherElementsAreArray) {
Mock mock; Mock mock;
char arr[] = {'a', 'b'}; char arr[] = { 'a', 'b' };
ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return()); ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());
} }

View File

@ -165,24 +165,24 @@ GTEST_API_ bool InDeathTestChild();
// Asserts that a given statement causes the program to exit, with an // Asserts that a given statement causes the program to exit, with an
// integer exit status that satisfies predicate, and emitting error output // integer exit status that satisfies predicate, and emitting error output
// that matches regex. // that matches regex.
#define ASSERT_EXIT(statement, predicate, regex) \ # define ASSERT_EXIT(statement, predicate, regex) \
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_) GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
// Like ASSERT_EXIT, but continues on to successive tests in the // Like ASSERT_EXIT, but continues on to successive tests in the
// test case, if any: // test case, if any:
#define EXPECT_EXIT(statement, predicate, regex) \ # define EXPECT_EXIT(statement, predicate, regex) \
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_) GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
// Asserts that a given statement causes the program to exit, either by // Asserts that a given statement causes the program to exit, either by
// explicitly exiting with a nonzero exit code or being killed by a // explicitly exiting with a nonzero exit code or being killed by a
// signal, and emitting error output that matches regex. // signal, and emitting error output that matches regex.
#define ASSERT_DEATH(statement, regex) \ # define ASSERT_DEATH(statement, regex) \
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
// Like ASSERT_DEATH, but continues on to successive tests in the // Like ASSERT_DEATH, but continues on to successive tests in the
// test case, if any: // test case, if any:
#define EXPECT_DEATH(statement, regex) \ # define EXPECT_DEATH(statement, regex) \
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
@ -191,7 +191,6 @@ class GTEST_API_ ExitedWithCode {
public: public:
explicit ExitedWithCode(int exit_code); explicit ExitedWithCode(int exit_code);
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
private: private:
// No implementation - assignment is unsupported. // No implementation - assignment is unsupported.
void operator=(const ExitedWithCode& other); void operator=(const ExitedWithCode& other);
@ -199,18 +198,17 @@ class GTEST_API_ ExitedWithCode {
const int exit_code_; const int exit_code_;
}; };
#if !GTEST_OS_WINDOWS # if !GTEST_OS_WINDOWS
// Tests that an exit code describes an exit due to termination by a // Tests that an exit code describes an exit due to termination by a
// given signal. // given signal.
class GTEST_API_ KilledBySignal { class GTEST_API_ KilledBySignal {
public: public:
explicit KilledBySignal(int signum); explicit KilledBySignal(int signum);
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
private: private:
const int signum_; const int signum_;
}; };
#endif // !GTEST_OS_WINDOWS # endif // !GTEST_OS_WINDOWS
// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode. // EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
// The death testing framework causes this to have interesting semantics, // The death testing framework causes this to have interesting semantics,
@ -255,21 +253,23 @@ class GTEST_API_ KilledBySignal {
// EXPECT_EQ(12, DieInDebugOr12(&sideeffect)); // EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
// }, "death"); // }, "death");
// //
#ifdef NDEBUG # ifdef NDEBUG
#define EXPECT_DEBUG_DEATH(statement, regex) \ # define EXPECT_DEBUG_DEATH(statement, regex) \
GTEST_EXECUTE_STATEMENT_(statement, regex) GTEST_EXECUTE_STATEMENT_(statement, regex)
#define ASSERT_DEBUG_DEATH(statement, regex) \ # define ASSERT_DEBUG_DEATH(statement, regex) \
GTEST_EXECUTE_STATEMENT_(statement, regex) GTEST_EXECUTE_STATEMENT_(statement, regex)
#else # else
#define EXPECT_DEBUG_DEATH(statement, regex) EXPECT_DEATH(statement, regex) # define EXPECT_DEBUG_DEATH(statement, regex) \
EXPECT_DEATH(statement, regex)
#define ASSERT_DEBUG_DEATH(statement, regex) ASSERT_DEATH(statement, regex) # define ASSERT_DEBUG_DEATH(statement, regex) \
ASSERT_DEATH(statement, regex)
#endif // NDEBUG for EXPECT_DEBUG_DEATH # endif // NDEBUG for EXPECT_DEBUG_DEATH
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and // EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
@ -278,15 +278,15 @@ class GTEST_API_ KilledBySignal {
// useful when you are combining death test assertions with normal test // useful when you are combining death test assertions with normal test
// assertions in one test. // assertions in one test.
#if GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
EXPECT_DEATH(statement, regex) EXPECT_DEATH(statement, regex)
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
ASSERT_DEATH(statement, regex) ASSERT_DEATH(statement, regex)
#else #else
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, ) GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return ) GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
#endif #endif
} // namespace testing } // namespace testing

View File

@ -105,14 +105,14 @@ class GTEST_API_ Message {
#if GTEST_OS_SYMBIAN #if GTEST_OS_SYMBIAN
// Streams a value (either a pointer or not) to this object. // Streams a value (either a pointer or not) to this object.
template <typename T> template <typename T>
inline Message& operator<<(const T& value) { inline Message& operator <<(const T& value) {
StreamHelper(typename internal::is_pointer<T>::type(), value); StreamHelper(typename internal::is_pointer<T>::type(), value);
return *this; return *this;
} }
#else #else
// Streams a non-pointer value to this object. // Streams a non-pointer value to this object.
template <typename T> template <typename T>
inline Message& operator<<(const T& val) { inline Message& operator <<(const T& val) {
// Some libraries overload << for STL containers. These // Some libraries overload << for STL containers. These
// overloads are defined in the global namespace instead of ::std. // overloads are defined in the global namespace instead of ::std.
// //
@ -127,7 +127,7 @@ class GTEST_API_ Message {
// from the global namespace. With this using declaration, // from the global namespace. With this using declaration,
// overloads of << defined in the global namespace and those // overloads of << defined in the global namespace and those
// visible via Koenig lookup are both exposed in this function. // visible via Koenig lookup are both exposed in this function.
using ::operator<<; using ::operator <<;
*ss_ << val; *ss_ << val;
return *this; return *this;
} }
@ -146,7 +146,7 @@ class GTEST_API_ Message {
// ensure consistent result across compilers, we always treat NULL // ensure consistent result across compilers, we always treat NULL
// as "(null)". // as "(null)".
template <typename T> template <typename T>
inline Message& operator<<(T* const& pointer) { // NOLINT inline Message& operator <<(T* const& pointer) { // NOLINT
if (pointer == NULL) { if (pointer == NULL) {
*ss_ << "(null)"; *ss_ << "(null)";
} else { } else {
@ -162,29 +162,31 @@ class GTEST_API_ Message {
// templatized version above. Without this definition, streaming // templatized version above. Without this definition, streaming
// endl or other basic IO manipulators to Message will confuse the // endl or other basic IO manipulators to Message will confuse the
// compiler. // compiler.
Message& operator<<(BasicNarrowIoManip val) { Message& operator <<(BasicNarrowIoManip val) {
*ss_ << val; *ss_ << val;
return *this; return *this;
} }
// Instead of 1/0, we want to see true/false for bool values. // Instead of 1/0, we want to see true/false for bool values.
Message& operator<<(bool b) { return *this << (b ? "true" : "false"); } Message& operator <<(bool b) {
return *this << (b ? "true" : "false");
}
// These two overloads allow streaming a wide C string to a Message // These two overloads allow streaming a wide C string to a Message
// using the UTF-8 encoding. // using the UTF-8 encoding.
Message& operator<<(const wchar_t* wide_c_str); Message& operator <<(const wchar_t* wide_c_str);
Message& operator<<(wchar_t* wide_c_str); Message& operator <<(wchar_t* wide_c_str);
#if GTEST_HAS_STD_WSTRING #if GTEST_HAS_STD_WSTRING
// Converts the given wide string to a narrow string using the UTF-8 // Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object. // encoding, and streams the result to this Message object.
Message& operator<<(const ::std::wstring& wstr); Message& operator <<(const ::std::wstring& wstr);
#endif // GTEST_HAS_STD_WSTRING #endif // GTEST_HAS_STD_WSTRING
#if GTEST_HAS_GLOBAL_WSTRING #if GTEST_HAS_GLOBAL_WSTRING
// Converts the given wide string to a narrow string using the UTF-8 // Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object. // encoding, and streams the result to this Message object.
Message& operator<<(const ::wstring& wstr); Message& operator <<(const ::wstring& wstr);
#endif // GTEST_HAS_GLOBAL_WSTRING #endif // GTEST_HAS_GLOBAL_WSTRING
// Gets the text streamed to this object so far as an std::string. // Gets the text streamed to this object so far as an std::string.
@ -194,6 +196,7 @@ class GTEST_API_ Message {
std::string GetString() const; std::string GetString() const;
private: private:
#if GTEST_OS_SYMBIAN #if GTEST_OS_SYMBIAN
// These are needed as the Nokia Symbian Compiler cannot decide between // These are needed as the Nokia Symbian Compiler cannot decide between
// const T& and const T* in a function template. The Nokia compiler _can_ // const T& and const T* in a function template. The Nokia compiler _can_
@ -212,13 +215,13 @@ class GTEST_API_ Message {
const T& value) { const T& value) {
// See the comments in Message& operator <<(const T&) above for why // See the comments in Message& operator <<(const T&) above for why
// we need this using statement. // we need this using statement.
using ::operator<<; using ::operator <<;
*ss_ << value; *ss_ << value;
} }
#endif // GTEST_OS_SYMBIAN #endif // GTEST_OS_SYMBIAN
// We'll hold the text streamed to this object here. // We'll hold the text streamed to this object here.
const internal::scoped_ptr<::std::stringstream> ss_; const internal::scoped_ptr< ::std::stringstream> ss_;
// We declare (but don't implement) this to prevent the compiler // We declare (but don't implement) this to prevent the compiler
// from implementing the assignment operator. // from implementing the assignment operator.
@ -226,7 +229,7 @@ class GTEST_API_ Message {
}; };
// Streams a Message to an ostream. // Streams a Message to an ostream.
inline std::ostream& operator<<(std::ostream& os, const Message& sb) { inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
return os << sb.GetString(); return os << sb.GetString();
} }

Some files were not shown because too many files have changed in this diff Show More