Revert "Run clang-format on all *.h and *.cpp files"
This reverts commit ba5cabaae5.
This commit is contained in:
parent
b8360657dc
commit
0beba2c30f
@ -12,6 +12,6 @@
|
||||
namespace YAML {
|
||||
typedef std::size_t anchor_t;
|
||||
const anchor_t NullAnchor = 0;
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -22,10 +22,10 @@ class YAML_CPP_API Binary {
|
||||
Binary(const unsigned char *data_, std::size_t size_)
|
||||
: m_data{}, m_unownedData(data_), m_unownedSize(size_) {}
|
||||
Binary() : Binary(nullptr, 0) {}
|
||||
Binary(const Binary &) = default;
|
||||
Binary(Binary &&) = default;
|
||||
Binary &operator=(const Binary &) = default;
|
||||
Binary &operator=(Binary &&) = default;
|
||||
Binary(const Binary&) = default;
|
||||
Binary(Binary&&) = default;
|
||||
Binary& operator=(const Binary&) = default;
|
||||
Binary& operator=(Binary&&) = default;
|
||||
|
||||
bool owned() const { return !m_unownedData; }
|
||||
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;
|
||||
std::size_t m_unownedSize;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -35,6 +35,6 @@ class AnchorDict {
|
||||
private:
|
||||
std::vector<T> m_data;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -144,6 +144,6 @@ typename Impl::Node *BuildGraphOfNextDocument(Parser &parser, Impl &impl) {
|
||||
return static_cast<typename Impl::Node *>(
|
||||
BuildGraphOfNextDocument(parser, graphBuilder));
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -52,6 +52,6 @@ class EmitFromEvents : public EventHandler {
|
||||
};
|
||||
std::stack<State::value> m_stateStack;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -250,6 +250,6 @@ inline Emitter& operator<<(Emitter& emitter, _Indent indent) {
|
||||
inline Emitter& operator<<(Emitter& emitter, _Precision precision) {
|
||||
return emitter.SetLocalPrecision(precision);
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -11,6 +11,6 @@ namespace YAML {
|
||||
struct EmitterNodeType {
|
||||
enum value { NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap };
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -132,6 +132,6 @@ inline _Precision FloatPrecision(int n) { return _Precision(n, -1); }
|
||||
inline _Precision DoublePrecision(int n) { return _Precision(-1, n); }
|
||||
|
||||
inline _Precision Precision(int n) { return _Precision(n, n); }
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -11,6 +11,6 @@ namespace YAML {
|
||||
struct EmitterStyle {
|
||||
enum value { Default, Block, Flow };
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -35,6 +35,6 @@ class EventHandler {
|
||||
anchor_t anchor, EmitterStyle::value style) = 0;
|
||||
virtual void OnMapEnd() = 0;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
// This is here for compatibility with older versions of Visual Studio
|
||||
// which don't support noexcept
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
||||
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
||||
#else
|
||||
#define YAML_CPP_NOEXCEPT noexcept
|
||||
#define YAML_CPP_NOEXCEPT noexcept
|
||||
#endif
|
||||
|
||||
namespace YAML {
|
||||
@ -114,7 +114,7 @@ inline const std::string KEY_NOT_FOUND_WITH_KEY(
|
||||
stream << KEY_NOT_FOUND << ": " << key;
|
||||
return stream.str();
|
||||
}
|
||||
} // namespace ErrorMsg
|
||||
}
|
||||
|
||||
class YAML_CPP_API Exception : public std::runtime_error {
|
||||
public:
|
||||
@ -260,7 +260,7 @@ class YAML_CPP_API BadFile : public Exception {
|
||||
BadFile(const BadFile&) = default;
|
||||
virtual ~BadFile() YAML_CPP_NOEXCEPT;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#undef YAML_CPP_NOEXCEPT
|
||||
|
||||
|
||||
@ -24,6 +24,6 @@ struct YAML_CPP_API Mark {
|
||||
Mark(int pos_, int line_, int column_)
|
||||
: pos(pos_), line(line_), column(column_) {}
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -42,7 +42,7 @@ inline bool IsNegativeInfinity(const std::string& input) {
|
||||
inline bool IsNaN(const std::string& input) {
|
||||
return input == ".nan" || input == ".NaN" || input == ".NAN";
|
||||
}
|
||||
} // namespace conversion
|
||||
}
|
||||
|
||||
// Node
|
||||
template <>
|
||||
@ -76,7 +76,7 @@ struct convert<const char*> {
|
||||
|
||||
template <std::size_t 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 <>
|
||||
@ -327,6 +327,6 @@ struct convert<Binary> {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -14,8 +14,8 @@ struct unspecified_bool {
|
||||
static void true_value(NOT_ALLOWED*) {}
|
||||
};
|
||||
typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*);
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#define YAML_CPP_OPERATOR_BOOL() \
|
||||
operator YAML::detail::unspecified_bool_type() const { \
|
||||
|
||||
@ -212,7 +212,7 @@ inline node& node_data::convert_to_node(const T& rhs,
|
||||
pMemory->merge(*value.m_pMemory);
|
||||
return *value.m_pNode;
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
struct iterator_value;
|
||||
|
||||
@ -18,10 +18,10 @@ namespace detail {
|
||||
struct iterator_value;
|
||||
template <typename V>
|
||||
class iterator_base;
|
||||
} // namespace detail
|
||||
}
|
||||
|
||||
typedef detail::iterator_base<detail::iterator_value> iterator;
|
||||
typedef detail::iterator_base<const detail::iterator_value> const_iterator;
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -41,7 +41,7 @@ class YAML_CPP_API memory_holder {
|
||||
private:
|
||||
shared_memory m_pMemory;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -7,11 +7,11 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/node/detail/node_ref.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/node/type.h"
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include "yaml-cpp/node/detail/node_ref.h"
|
||||
#include <set>
|
||||
|
||||
namespace YAML {
|
||||
@ -163,7 +163,7 @@ class node {
|
||||
typedef std::set<node*> nodes;
|
||||
nodes m_dependencies;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -121,7 +121,7 @@ class YAML_CPP_API node_data {
|
||||
typedef std::list<kv_pair> kv_pairs;
|
||||
mutable kv_pairs m_undefinedPairs;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#include "yaml-cpp/node/ptr.h"
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -174,7 +174,7 @@ class node_iterator_base
|
||||
|
||||
typedef node_iterator_base<node> 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
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
#endif
|
||||
|
||||
#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/ptr.h"
|
||||
#include "yaml-cpp/node/detail/node_data.h"
|
||||
|
||||
namespace YAML {
|
||||
namespace detail {
|
||||
@ -92,7 +92,7 @@ class node_ref {
|
||||
private:
|
||||
shared_node_data m_pData;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
|
||||
@ -7,11 +7,11 @@
|
||||
#pragma once
|
||||
#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/node.h"
|
||||
#include "yaml-cpp/node/iterator.h"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include <string>
|
||||
|
||||
namespace YAML {
|
||||
@ -366,7 +366,7 @@ template <typename T>
|
||||
inline typename to_value_t<T>::return_type to_value(const T& t) {
|
||||
return to_value_t<T>(t)();
|
||||
}
|
||||
} // namespace detail
|
||||
}
|
||||
|
||||
// indexing
|
||||
template <typename Key>
|
||||
@ -374,8 +374,8 @@ inline const Node Node::operator[](const Key& key) const {
|
||||
if (!m_isValid)
|
||||
throw InvalidNode();
|
||||
EnsureNodeExists();
|
||||
detail::node* value = static_cast<const detail::node&>(*m_pNode).get(
|
||||
detail::to_value(key), m_pMemory);
|
||||
detail::node* value = static_cast<const detail::node&>(*m_pNode)
|
||||
.get(detail::to_value(key), m_pMemory);
|
||||
if (!value) {
|
||||
return Node(ZombieNode);
|
||||
}
|
||||
@ -443,6 +443,6 @@ inline void Node::force_insert(const Key& key, const Value& value) {
|
||||
|
||||
// free functions
|
||||
inline bool operator==(const Node& lhs, const Node& rhs) { return lhs.is(rhs); }
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
#endif
|
||||
|
||||
#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/detail/iterator_fwd.h"
|
||||
#include "yaml-cpp/node/detail/iterator.h"
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@ -25,7 +25,7 @@ struct iterator_value : public Node, std::pair<Node, Node> {
|
||||
explicit iterator_value(const Node& key, const Node& value)
|
||||
: Node(Node::ZombieNode), std::pair<Node, Node>(key, value) {}
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -140,6 +140,6 @@ YAML_CPP_API Node Clone(const Node& node);
|
||||
|
||||
template <typename T>
|
||||
struct convert;
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -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<memory_holder> shared_memory_holder;
|
||||
typedef std::shared_ptr<memory> shared_memory;
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -11,6 +11,6 @@ namespace YAML {
|
||||
struct NodeType {
|
||||
enum value { Undefined, Null, Scalar, Sequence, Map };
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -21,6 +21,6 @@ YAML_CPP_API bool IsNull(const Node& node); // old API only
|
||||
YAML_CPP_API bool IsNullString(const std::string& str);
|
||||
|
||||
extern YAML_CPP_API _Null Null;
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -56,7 +56,7 @@ class YAML_CPP_API ostream_wrapper {
|
||||
|
||||
template <std::size_t N>
|
||||
inline ostream_wrapper& operator<<(ostream_wrapper& stream,
|
||||
const char (&str)[N]) {
|
||||
const char(&str)[N]) {
|
||||
stream.write(str, N - 1);
|
||||
return stream;
|
||||
}
|
||||
@ -71,6 +71,6 @@ inline ostream_wrapper& operator<<(ostream_wrapper& stream, char ch) {
|
||||
stream.write(&ch, 1);
|
||||
return stream;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -86,6 +86,6 @@ class YAML_CPP_API Parser {
|
||||
std::unique_ptr<Scanner> m_pScanner;
|
||||
std::unique_ptr<Directives> m_pDirectives;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -7,10 +7,10 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
namespace YAML {
|
||||
template <typename Seq>
|
||||
@ -46,6 +46,6 @@ inline Emitter& operator<<(Emitter& emitter, const std::map<K, V>& m) {
|
||||
emitter << EndMap;
|
||||
return emitter;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -98,6 +98,6 @@ struct disable_if_c<true, T> {};
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct disable_if : public disable_if_c<Cond::value, T> {};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -7,18 +7,18 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/parser.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "yaml-cpp/parser.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/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/emit.h"
|
||||
|
||||
#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -97,4 +97,4 @@ std::vector<unsigned char> DecodeBase64(const std::string &input) {
|
||||
ret.resize(out - &ret[0]);
|
||||
return ret;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <stack>
|
||||
#include <cassert>
|
||||
|
||||
namespace YAML {
|
||||
struct CollectionType {
|
||||
@ -36,6 +36,6 @@ class CollectionStack {
|
||||
private:
|
||||
std::stack<CollectionType::value> collectionStack;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -14,4 +14,4 @@ void* BuildGraphOfNextDocument(Parser& parser,
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -91,4 +91,4 @@ void GraphBuilderAdapter::DispositionNode(void *pNode) {
|
||||
m_builder.AppendToSequence(pContainer, pNode);
|
||||
}
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -26,11 +26,7 @@ namespace YAML {
|
||||
class GraphBuilderAdapter : public EventHandler {
|
||||
public:
|
||||
GraphBuilderAdapter(GraphBuilderInterface& builder)
|
||||
: m_builder(builder),
|
||||
m_containers{},
|
||||
m_anchors{},
|
||||
m_pRootNode(nullptr),
|
||||
m_pKeyNode(nullptr) {}
|
||||
: m_builder(builder), m_containers{}, m_anchors{}, m_pRootNode(nullptr), m_pKeyNode(nullptr) {}
|
||||
GraphBuilderAdapter(const GraphBuilderAdapter&) = delete;
|
||||
GraphBuilderAdapter(GraphBuilderAdapter&&) = delete;
|
||||
GraphBuilderAdapter& operator=(const GraphBuilderAdapter&) = delete;
|
||||
@ -82,6 +78,6 @@ class GraphBuilderAdapter : public EventHandler {
|
||||
void RegisterAnchor(anchor_t anchor, void* pNode);
|
||||
void DispositionNode(void* pNode);
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -39,7 +39,7 @@ bool IsFlexibleCase(const std::string& str) {
|
||||
std::string rest = str.substr(1);
|
||||
return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper));
|
||||
}
|
||||
} // namespace
|
||||
}
|
||||
|
||||
namespace YAML {
|
||||
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 {
|
||||
std::string truename, falsename;
|
||||
} names[] = {
|
||||
{"y", "n"},
|
||||
{"yes", "no"},
|
||||
{"true", "false"},
|
||||
{"on", "off"},
|
||||
{"y", "n"}, {"yes", "no"}, {"true", "false"}, {"on", "off"},
|
||||
};
|
||||
|
||||
if (!IsFlexibleCase(node.Scalar()))
|
||||
@ -75,4 +72,4 @@ bool convert<bool>::decode(const Node& node, bool& rhs) {
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -14,4 +14,4 @@ const std::string Directives::TranslateTagHandle(
|
||||
|
||||
return it->second;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace YAML {
|
||||
struct Version {
|
||||
@ -24,6 +24,6 @@ struct Directives {
|
||||
Version version;
|
||||
std::map<std::string, std::string> tags;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "yaml-cpp/node/emit.h"
|
||||
#include "nodeevents.h"
|
||||
#include "yaml-cpp/emitfromevents.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "nodeevents.h"
|
||||
|
||||
namespace YAML {
|
||||
Emitter& operator<<(Emitter& out, const Node& node) {
|
||||
|
||||
@ -16,11 +16,10 @@ std::string ToString(YAML::anchor_t anchor) {
|
||||
stream << anchor;
|
||||
return stream.str();
|
||||
}
|
||||
} // namespace
|
||||
}
|
||||
|
||||
namespace YAML {
|
||||
EmitFromEvents::EmitFromEvents(Emitter& emitter)
|
||||
: m_emitter(emitter), m_stateStack{} {}
|
||||
EmitFromEvents::EmitFromEvents(Emitter& emitter) : m_emitter(emitter), m_stateStack{} {}
|
||||
|
||||
void EmitFromEvents::OnDocumentStart(const Mark&) {}
|
||||
|
||||
@ -117,4 +116,4 @@ void EmitFromEvents::EmitProps(const std::string& tag, anchor_t anchor) {
|
||||
if (anchor)
|
||||
m_emitter << Anchor(ToString(anchor));
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -906,4 +906,4 @@ Emitter& Emitter::Write(const Binary& binary) {
|
||||
|
||||
return *this;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -30,7 +30,8 @@ EmitterState::EmitterState()
|
||||
m_hasAnchor(false),
|
||||
m_hasTag(false),
|
||||
m_hasNonContent(false),
|
||||
m_docCount(0) {}
|
||||
m_docCount(0)
|
||||
{}
|
||||
|
||||
EmitterState::~EmitterState() {}
|
||||
|
||||
@ -366,4 +367,4 @@ bool EmitterState::SetDoublePrecision(std::size_t value,
|
||||
_Set(m_doublePrecision, value, scope);
|
||||
return true;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -145,12 +145,7 @@ class EmitterState {
|
||||
|
||||
struct Group {
|
||||
explicit Group(GroupType::value type_)
|
||||
: type(type_),
|
||||
flowType{},
|
||||
indent(0),
|
||||
childCount(0),
|
||||
longKey(false),
|
||||
modifiedSettings{} {}
|
||||
: type(type_), flowType{}, indent(0), childCount(0), longKey(false), modifiedSettings{} {}
|
||||
|
||||
GroupType::value type;
|
||||
FlowType::value flowType;
|
||||
@ -203,6 +198,6 @@ void EmitterState::_Set(Setting<T>& fmt, T value, FmtScope::value scope) {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
#include "regeximpl.h"
|
||||
#include "stringsource.h"
|
||||
#include "yaml-cpp/binary.h" // IWYU pragma: keep
|
||||
#include "yaml-cpp/null.h"
|
||||
#include "yaml-cpp/ostream_wrapper.h"
|
||||
#include "yaml-cpp/null.h"
|
||||
|
||||
namespace YAML {
|
||||
namespace Utils {
|
||||
@ -258,7 +258,7 @@ bool WriteAliasName(ostream_wrapper& out, const std::string& str) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
}
|
||||
|
||||
StringFormat::value ComputeStringFormat(const std::string& str,
|
||||
EMITTER_MANIP strFormat,
|
||||
@ -401,8 +401,8 @@ bool WriteComment(ostream_wrapper& out, const std::string& str,
|
||||
for (std::string::const_iterator i = str.begin();
|
||||
GetNextCodePointAndAdvance(codePoint, i, str.end());) {
|
||||
if (codePoint == '\n') {
|
||||
out << "\n"
|
||||
<< IndentTo(curIndent) << "#" << Indentation(postCommentIndent);
|
||||
out << "\n" << IndentTo(curIndent) << "#"
|
||||
<< Indentation(postCommentIndent);
|
||||
out.set_comment();
|
||||
} else {
|
||||
WriteCodePoint(out, codePoint);
|
||||
@ -479,5 +479,5 @@ bool WriteBinary(ostream_wrapper& out, const Binary& binary) {
|
||||
false);
|
||||
return true;
|
||||
}
|
||||
} // namespace Utils
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ bool WriteTag(ostream_wrapper& out, const std::string& str, bool verbatim);
|
||||
bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix,
|
||||
const std::string& tag);
|
||||
bool WriteBinary(ostream_wrapper& out, const Binary& binary);
|
||||
} // namespace Utils
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
#endif // EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
// This is here for compatibility with older versions of Visual Studio
|
||||
// which don't support noexcept
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
||||
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
||||
#else
|
||||
#define YAML_CPP_NOEXCEPT noexcept
|
||||
#define YAML_CPP_NOEXCEPT noexcept
|
||||
#endif
|
||||
|
||||
namespace YAML {
|
||||
@ -24,6 +24,8 @@ BadPushback::~BadPushback() YAML_CPP_NOEXCEPT {}
|
||||
BadInsert::~BadInsert() YAML_CPP_NOEXCEPT {}
|
||||
EmitterException::~EmitterException() YAML_CPP_NOEXCEPT {}
|
||||
BadFile::~BadFile() YAML_CPP_NOEXCEPT {}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#undef YAML_CPP_NOEXCEPT
|
||||
|
||||
|
||||
|
||||
@ -132,5 +132,5 @@ std::string Escape(Stream& in) {
|
||||
std::stringstream msg;
|
||||
throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch);
|
||||
}
|
||||
} // namespace Exp
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <cstddef>
|
||||
|
||||
#include "yaml-cpp/ostream_wrapper.h"
|
||||
|
||||
@ -36,6 +36,6 @@ inline ostream_wrapper& operator<<(ostream_wrapper& out,
|
||||
out << ' ';
|
||||
return out;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -22,5 +22,5 @@ node& memory::create_node() {
|
||||
void memory::merge(const memory& rhs) {
|
||||
m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end());
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,4 +9,4 @@ Node Clone(const Node& node) {
|
||||
events.Emit(builder);
|
||||
return builder.Root();
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -14,8 +14,8 @@ namespace YAML {
|
||||
namespace detail {
|
||||
|
||||
const std::string& node_data::empty_scalar() {
|
||||
static const std::string svalue;
|
||||
return svalue;
|
||||
static const std::string svalue;
|
||||
return svalue;
|
||||
}
|
||||
|
||||
node_data::node_data()
|
||||
@ -28,7 +28,8 @@ node_data::node_data()
|
||||
m_sequence{},
|
||||
m_seqSize(0),
|
||||
m_map{},
|
||||
m_undefinedPairs{} {}
|
||||
m_undefinedPairs{}
|
||||
{}
|
||||
|
||||
void node_data::mark_defined() {
|
||||
if (m_type == NodeType::Undefined)
|
||||
@ -243,8 +244,7 @@ bool node_data::remove(node& key, shared_memory_holder /* pMemory */) {
|
||||
if (m_type != NodeType::Map)
|
||||
return false;
|
||||
|
||||
for (kv_pairs::iterator it = m_undefinedPairs.begin();
|
||||
it != m_undefinedPairs.end();) {
|
||||
for(kv_pairs::iterator it = m_undefinedPairs.begin(); it != m_undefinedPairs.end();) {
|
||||
kv_pairs::iterator jt = std::next(it);
|
||||
if (it->first->is(key))
|
||||
m_undefinedPairs.erase(it);
|
||||
@ -312,5 +312,5 @@ void node_data::convert_sequence_to_map(shared_memory_holder pMemory) {
|
||||
reset_sequence();
|
||||
m_type = NodeType::Map;
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,8 @@ NodeBuilder::NodeBuilder()
|
||||
m_stack{},
|
||||
m_anchors{},
|
||||
m_keys{},
|
||||
m_mapDepth(0) {
|
||||
m_mapDepth(0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -69,6 +69,6 @@ class NodeBuilder : public EventHandler {
|
||||
std::vector<PushedKey> m_keys;
|
||||
std::size_t m_mapDepth;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -98,4 +98,4 @@ bool NodeEvents::IsAliased(const detail::node& node) const {
|
||||
RefCount::const_iterator it = m_refCount.find(node.ref());
|
||||
return it != m_refCount.end() && it->second > 1;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -63,6 +63,6 @@ class NodeEvents {
|
||||
typedef std::map<const detail::node_ref*, int> RefCount;
|
||||
RefCount m_refCount;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -7,4 +7,4 @@ bool IsNullString(const std::string& str) {
|
||||
return str.empty() || str == "~" || str == "null" || str == "Null" ||
|
||||
str == "NULL";
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -14,12 +14,7 @@ ostream_wrapper::ostream_wrapper()
|
||||
m_comment(false) {}
|
||||
|
||||
ostream_wrapper::ostream_wrapper(std::ostream& stream)
|
||||
: m_buffer{},
|
||||
m_pStream(&stream),
|
||||
m_pos(0),
|
||||
m_row(0),
|
||||
m_col(0),
|
||||
m_comment(false) {}
|
||||
: m_buffer{}, m_pStream(&stream), m_pos(0), m_row(0), m_col(0), m_comment(false) {}
|
||||
|
||||
ostream_wrapper::~ostream_wrapper() {}
|
||||
|
||||
@ -59,4 +54,4 @@ void ostream_wrapper::update_pos(char ch) {
|
||||
m_comment = false;
|
||||
}
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "nodebuilder.h"
|
||||
#include "yaml-cpp/node/impl.h"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
#include "yaml-cpp/node/impl.h"
|
||||
#include "yaml-cpp/parser.h"
|
||||
#include "nodebuilder.h"
|
||||
|
||||
namespace YAML {
|
||||
Node Load(const std::string& input) {
|
||||
|
||||
@ -126,4 +126,4 @@ void Parser::PrintTokens(std::ostream& out) {
|
||||
m_pScanner->pop();
|
||||
}
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -40,6 +40,6 @@ class ptr_vector {
|
||||
private:
|
||||
std::vector<std::unique_ptr<T>> m_data;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -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(const std::string& str, REGEX_OP op)
|
||||
: m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {}
|
||||
RegEx::RegEx(const std::string& str, REGEX_OP op) : m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {}
|
||||
|
||||
// combination constructors
|
||||
RegEx operator!(const RegEx& ex) {
|
||||
@ -40,4 +39,4 @@ RegEx operator+(const RegEx& ex1, const RegEx& ex2) {
|
||||
ret.m_params.push_back(ex2);
|
||||
return ret;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
#endif
|
||||
|
||||
#include "stream.h"
|
||||
#include "streamcharsource.h"
|
||||
#include "stringsource.h"
|
||||
#include "streamcharsource.h"
|
||||
|
||||
namespace YAML {
|
||||
// query matches
|
||||
@ -106,8 +106,9 @@ inline int RegEx::MatchOpEmpty(const Source& source) const {
|
||||
template <>
|
||||
inline int RegEx::MatchOpEmpty<StringCharSource>(
|
||||
const StringCharSource& source) const {
|
||||
return !source ? 0 : -1; // the empty regex only is successful on the empty
|
||||
// string
|
||||
return !source
|
||||
? 0
|
||||
: -1; // the empty regex only is successful on the empty string
|
||||
}
|
||||
|
||||
// MatchOperator
|
||||
@ -180,6 +181,6 @@ inline int RegEx::MatchOpSeq(const Source& source) const {
|
||||
|
||||
return offset;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -17,7 +17,8 @@ Scanner::Scanner(std::istream& in)
|
||||
m_simpleKeys{},
|
||||
m_indents{},
|
||||
m_indentRefs{},
|
||||
m_flows{} {}
|
||||
m_flows{}
|
||||
{}
|
||||
|
||||
Scanner::~Scanner() {}
|
||||
|
||||
|
||||
@ -185,6 +185,6 @@ class Scanner {
|
||||
ptr_vector<IndentMarker> m_indentRefs; // for "garbage collection"
|
||||
std::stack<FLOW_MARKER> m_flows;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -247,4 +247,4 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
|
||||
|
||||
return scalar;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -58,6 +58,6 @@ struct ScanScalarParams {
|
||||
};
|
||||
|
||||
std::string ScanScalar(Stream& INPUT, ScanScalarParams& info);
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -78,4 +78,4 @@ const std::string ScanTagSuffix(Stream& INPUT) {
|
||||
|
||||
return tag;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -7,13 +7,13 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "stream.h"
|
||||
#include <string>
|
||||
#include "stream.h"
|
||||
|
||||
namespace YAML {
|
||||
const std::string ScanVerbatimTag(Stream& INPUT);
|
||||
const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle);
|
||||
const std::string ScanTagSuffix(Stream& INPUT);
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -434,4 +434,4 @@ void Scanner::ScanBlockScalar() {
|
||||
token.value = scalar;
|
||||
m_tokens.push(token);
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
namespace YAML {
|
||||
class SettingChangeBase;
|
||||
@ -18,7 +18,9 @@ template <typename T>
|
||||
class Setting {
|
||||
public:
|
||||
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; }
|
||||
std::unique_ptr<SettingChangeBase> set(const T& value);
|
||||
@ -37,9 +39,9 @@ class SettingChangeBase {
|
||||
template <typename T>
|
||||
class SettingChange : public SettingChangeBase {
|
||||
public:
|
||||
SettingChange(Setting<T>* pSetting)
|
||||
: m_pCurSetting(pSetting),
|
||||
m_oldSetting(*pSetting) // copy old setting to save its state
|
||||
SettingChange(Setting<T>* pSetting) :
|
||||
m_pCurSetting(pSetting),
|
||||
m_oldSetting(*pSetting) // copy old setting to save its state
|
||||
{}
|
||||
SettingChange(const SettingChange&) = delete;
|
||||
SettingChange(SettingChange&&) = delete;
|
||||
@ -64,8 +66,7 @@ class SettingChanges {
|
||||
public:
|
||||
SettingChanges() : m_settingChanges{} {}
|
||||
SettingChanges(const SettingChanges&) = delete;
|
||||
SettingChanges(SettingChanges&& rhs)
|
||||
: m_settingChanges(std::move(rhs.m_settingChanges)) {}
|
||||
SettingChanges(SettingChanges&& rhs) : m_settingChanges(std::move(rhs.m_settingChanges)) {}
|
||||
SettingChanges& operator=(const SettingChanges&) = delete;
|
||||
~SettingChanges() { clear(); }
|
||||
|
||||
@ -99,6 +100,6 @@ class SettingChanges {
|
||||
typedef std::vector<std::unique_ptr<SettingChangeBase>> setting_changes;
|
||||
setting_changes m_settingChanges;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -5,11 +5,7 @@ namespace YAML {
|
||||
struct Mark;
|
||||
|
||||
Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_)
|
||||
: mark(mark_),
|
||||
flowLevel(flowLevel_),
|
||||
pIndent(nullptr),
|
||||
pMapStart(nullptr),
|
||||
pKey(nullptr) {}
|
||||
: mark(mark_), flowLevel(flowLevel_), pIndent(nullptr), pMapStart(nullptr), pKey(nullptr) {}
|
||||
|
||||
void Scanner::SimpleKey::Validate() {
|
||||
// Note: pIndent will *not* be garbage here;
|
||||
@ -129,4 +125,4 @@ void Scanner::PopAllSimpleKeys() {
|
||||
while (!m_simpleKeys.empty())
|
||||
m_simpleKeys.pop();
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -19,7 +19,8 @@ SingleDocParser::SingleDocParser(Scanner& scanner, const Directives& directives)
|
||||
m_directives(directives),
|
||||
m_pCollectionStack(new CollectionStack),
|
||||
m_anchors{},
|
||||
m_curAnchor(0) {}
|
||||
m_curAnchor(0)
|
||||
{}
|
||||
|
||||
SingleDocParser::~SingleDocParser() {}
|
||||
|
||||
@ -412,4 +413,4 @@ anchor_t SingleDocParser::LookupAnchor(const Mark& mark,
|
||||
|
||||
return it->second;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -63,6 +63,6 @@ class SingleDocParser {
|
||||
|
||||
anchor_t m_curAnchor;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -111,15 +111,24 @@ static UtfIntroState s_introTransitions[][uictMax] = {
|
||||
|
||||
static char s_introUngetCount[][uictMax] = {
|
||||
// uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther
|
||||
{0, 1, 1, 0, 0, 0, 0, 1}, {0, 2, 2, 2, 2, 2, 2, 2},
|
||||
{3, 3, 3, 3, 0, 3, 3, 3}, {4, 4, 4, 4, 4, 0, 4, 4},
|
||||
{1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{2, 2, 2, 2, 2, 0, 2, 2}, {2, 2, 2, 2, 0, 2, 2, 2},
|
||||
{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},
|
||||
{0, 1, 1, 0, 0, 0, 0, 1},
|
||||
{0, 2, 2, 2, 2, 2, 2, 2},
|
||||
{3, 3, 3, 3, 0, 3, 3, 3},
|
||||
{4, 4, 4, 4, 4, 0, 4, 4},
|
||||
{1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{2, 2, 2, 2, 2, 0, 2, 2},
|
||||
{2, 2, 2, 2, 0, 2, 2, 2},
|
||||
{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) {
|
||||
@ -188,7 +197,8 @@ Stream::Stream(std::istream& input)
|
||||
m_readahead{},
|
||||
m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]),
|
||||
m_nPrefetchedAvailable(0),
|
||||
m_nPrefetchedUsed(0) {
|
||||
m_nPrefetchedUsed(0)
|
||||
{
|
||||
typedef std::istream::traits_type char_traits;
|
||||
|
||||
if (!input)
|
||||
@ -439,4 +449,4 @@ void Stream::StreamInUtf32() const {
|
||||
|
||||
QueueUnicodeCodepoint(m_readahead, ch);
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -74,6 +74,6 @@ inline bool Stream::ReadAheadTo(size_t i) const {
|
||||
return true;
|
||||
return _ReadAheadTo(i);
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -43,6 +43,6 @@ inline const StreamCharSource StreamCharSource::operator+(int i) const {
|
||||
source.m_offset = 0;
|
||||
return source;
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -43,6 +43,6 @@ class StringCharSource {
|
||||
std::size_t m_size;
|
||||
std::size_t m_offset;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -6,8 +6,7 @@
|
||||
#include "token.h"
|
||||
|
||||
namespace YAML {
|
||||
Tag::Tag(const Token& token)
|
||||
: type(static_cast<TYPE>(token.data)), handle{}, value{} {
|
||||
Tag::Tag(const Token& token) : type(static_cast<TYPE>(token.data)), handle{}, value{} {
|
||||
switch (type) {
|
||||
case VERBATIM:
|
||||
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");
|
||||
}
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
@ -28,6 +28,6 @@ struct Tag {
|
||||
TYPE type;
|
||||
std::string handle, value;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
11
src/token.h
11
src/token.h
@ -14,11 +14,10 @@
|
||||
|
||||
namespace YAML {
|
||||
const std::string TokenNames[] = {
|
||||
"DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START",
|
||||
"BLOCK_MAP_START", "BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY",
|
||||
"FLOW_SEQ_START", "FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END",
|
||||
"FLOW_MAP_COMPACT", "FLOW_ENTRY", "KEY", "VALUE",
|
||||
"ANCHOR", "ALIAS", "TAG", "SCALAR"};
|
||||
"DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START", "BLOCK_MAP_START",
|
||||
"BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY", "FLOW_SEQ_START",
|
||||
"FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END", "FLOW_MAP_COMPACT",
|
||||
"FLOW_ENTRY", "KEY", "VALUE", "ANCHOR", "ALIAS", "TAG", "SCALAR"};
|
||||
|
||||
struct Token {
|
||||
// enums
|
||||
@ -65,6 +64,6 @@ struct Token {
|
||||
std::vector<std::string> params;
|
||||
int data;
|
||||
};
|
||||
} // namespace YAML
|
||||
}
|
||||
|
||||
#endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
#include <errno.h>
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
@ -98,7 +98,9 @@ class BuiltInDefaultValue {
|
||||
public:
|
||||
#if GTEST_HAS_STD_TYPE_TRAITS_
|
||||
// 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() {
|
||||
return BuiltInDefaultValueGetter<
|
||||
@ -107,9 +109,13 @@ class BuiltInDefaultValue {
|
||||
|
||||
#else // GTEST_HAS_STD_TYPE_TRAITS_
|
||||
// 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_
|
||||
};
|
||||
@ -135,11 +141,11 @@ class BuiltInDefaultValue<T*> {
|
||||
// The following specializations define the default values for
|
||||
// specific types we care about.
|
||||
#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
|
||||
template <> \
|
||||
class BuiltInDefaultValue<type> { \
|
||||
public: \
|
||||
static bool Exists() { return true; } \
|
||||
static type Get() { return value; } \
|
||||
template <> \
|
||||
class BuiltInDefaultValue<type> { \
|
||||
public: \
|
||||
static bool Exists() { return true; } \
|
||||
static type Get() { return value; } \
|
||||
}
|
||||
|
||||
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()
|
||||
// is true, which ensures that the return value is well-defined.
|
||||
static T Get() {
|
||||
return producer_ == NULL ? internal::BuiltInDefaultValue<T>::Get()
|
||||
: producer_->Produce();
|
||||
return producer_ == NULL ?
|
||||
internal::BuiltInDefaultValue<T>::Get() : producer_->Produce();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -274,7 +280,9 @@ class DefaultValue<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&.
|
||||
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 aborts the process.
|
||||
static T& Get() {
|
||||
return address_ == NULL ? internal::BuiltInDefaultValue<T&>::Get()
|
||||
: *address_;
|
||||
return address_ == NULL ?
|
||||
internal::BuiltInDefaultValue<T&>::Get() : *address_;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -391,7 +399,7 @@ class Action {
|
||||
template <typename F1, typename F2>
|
||||
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
|
||||
@ -485,7 +493,7 @@ class ActionAdaptor : public ActionInterface<F1> {
|
||||
}
|
||||
|
||||
private:
|
||||
const internal::linked_ptr<ActionInterface<F2>> impl_;
|
||||
const internal::linked_ptr<ActionInterface<F2> > impl_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
|
||||
};
|
||||
@ -671,7 +679,9 @@ class ReturnRefAction {
|
||||
|
||||
explicit Impl(T& ref) : ref_(ref) {} // NOLINT
|
||||
|
||||
virtual Result Perform(const ArgumentTuple&) { return ref_; }
|
||||
virtual Result Perform(const ArgumentTuple&) {
|
||||
return ref_;
|
||||
}
|
||||
|
||||
private:
|
||||
T& ref_;
|
||||
@ -718,7 +728,9 @@ class ReturnRefOfCopyAction {
|
||||
|
||||
explicit Impl(const T& value) : value_(value) {} // NOLINT
|
||||
|
||||
virtual Result Perform(const ArgumentTuple&) { return value_; }
|
||||
virtual Result Perform(const ArgumentTuple&) {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
T value_;
|
||||
@ -737,9 +749,7 @@ class DoDefaultAction {
|
||||
// This template type conversion operator allows DoDefault() to be
|
||||
// used in any function.
|
||||
template <typename F>
|
||||
operator Action<F>() const {
|
||||
return Action<F>(NULL);
|
||||
}
|
||||
operator Action<F>() const { return Action<F>(NULL); }
|
||||
};
|
||||
|
||||
// Implements the Assign action to set a given pointer referent to a
|
||||
@ -769,7 +779,8 @@ template <typename T>
|
||||
class SetErrnoAndReturnAction {
|
||||
public:
|
||||
SetErrnoAndReturnAction(int errno_value, T result)
|
||||
: errno_(errno_value), result_(result) {}
|
||||
: errno_(errno_value),
|
||||
result_(result) {}
|
||||
template <typename Result, typename ArgumentTuple>
|
||||
Result Perform(const ArgumentTuple& /* args */) const {
|
||||
errno = errno_;
|
||||
@ -847,9 +858,7 @@ class InvokeWithoutArgsAction {
|
||||
// Allows InvokeWithoutArgs(f) to be used as any action whose type is
|
||||
// compatible with f.
|
||||
template <typename Result, typename ArgumentTuple>
|
||||
Result Perform(const ArgumentTuple&) {
|
||||
return function_impl_();
|
||||
}
|
||||
Result Perform(const ArgumentTuple&) { return function_impl_(); }
|
||||
|
||||
private:
|
||||
FunctionImpl function_impl_;
|
||||
@ -917,8 +926,8 @@ class IgnoreResultAction {
|
||||
private:
|
||||
// Type OriginalFunction is the same as F except that its return
|
||||
// type is IgnoredValue.
|
||||
typedef
|
||||
typename internal::Function<F>::MakeResultIgnoredValue OriginalFunction;
|
||||
typedef typename internal::Function<F>::MakeResultIgnoredValue
|
||||
OriginalFunction;
|
||||
|
||||
const Action<OriginalFunction> action_;
|
||||
|
||||
@ -946,7 +955,6 @@ class ReferenceWrapper {
|
||||
// Allows a ReferenceWrapper<T> object to be implicitly converted to
|
||||
// a T&.
|
||||
operator T&() const { return *pointer_; }
|
||||
|
||||
private:
|
||||
T* pointer_;
|
||||
};
|
||||
@ -1095,12 +1103,12 @@ inline internal::DoDefaultAction DoDefault() {
|
||||
// Creates an action that sets the variable pointed by the N-th
|
||||
// (0-based) function argument to 'value'.
|
||||
template <size_t N, typename T>
|
||||
PolymorphicAction<internal::SetArgumentPointeeAction<
|
||||
N, T, internal::IsAProtocolMessage<T>::value>>
|
||||
SetArgPointee(const T& x) {
|
||||
return MakePolymorphicAction(
|
||||
internal::SetArgumentPointeeAction<
|
||||
N, T, internal::IsAProtocolMessage<T>::value>(x));
|
||||
PolymorphicAction<
|
||||
internal::SetArgumentPointeeAction<
|
||||
N, T, internal::IsAProtocolMessage<T>::value> >
|
||||
SetArgPointee(const T& x) {
|
||||
return MakePolymorphicAction(internal::SetArgumentPointeeAction<
|
||||
N, T, internal::IsAProtocolMessage<T>::value>(x));
|
||||
}
|
||||
|
||||
#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
|
||||
// this overload from the templated version and emit a compile error.
|
||||
template <size_t N>
|
||||
PolymorphicAction<internal::SetArgumentPointeeAction<N, const char*, false>>
|
||||
SetArgPointee(const char* p) {
|
||||
return MakePolymorphicAction(
|
||||
internal::SetArgumentPointeeAction<N, const char*, false>(p));
|
||||
PolymorphicAction<
|
||||
internal::SetArgumentPointeeAction<N, const char*, false> >
|
||||
SetArgPointee(const char* p) {
|
||||
return MakePolymorphicAction(internal::SetArgumentPointeeAction<
|
||||
N, const char*, false>(p));
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
PolymorphicAction<internal::SetArgumentPointeeAction<N, const wchar_t*, false>>
|
||||
SetArgPointee(const wchar_t* p) {
|
||||
return MakePolymorphicAction(
|
||||
internal::SetArgumentPointeeAction<N, const wchar_t*, false>(p));
|
||||
PolymorphicAction<
|
||||
internal::SetArgumentPointeeAction<N, const wchar_t*, false> >
|
||||
SetArgPointee(const wchar_t* p) {
|
||||
return MakePolymorphicAction(internal::SetArgumentPointeeAction<
|
||||
N, const wchar_t*, false>(p));
|
||||
}
|
||||
#endif
|
||||
|
||||
// The following version is DEPRECATED.
|
||||
template <size_t N, typename T>
|
||||
PolymorphicAction<internal::SetArgumentPointeeAction<
|
||||
N, T, internal::IsAProtocolMessage<T>::value>>
|
||||
SetArgumentPointee(const T& x) {
|
||||
return MakePolymorphicAction(
|
||||
internal::SetArgumentPointeeAction<
|
||||
N, T, internal::IsAProtocolMessage<T>::value>(x));
|
||||
PolymorphicAction<
|
||||
internal::SetArgumentPointeeAction<
|
||||
N, T, internal::IsAProtocolMessage<T>::value> >
|
||||
SetArgumentPointee(const T& x) {
|
||||
return MakePolymorphicAction(internal::SetArgumentPointeeAction<
|
||||
N, T, internal::IsAProtocolMessage<T>::value>(x));
|
||||
}
|
||||
|
||||
// Creates an action that sets a pointer referent to a given value.
|
||||
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));
|
||||
}
|
||||
|
||||
@ -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.
|
||||
template <typename T>
|
||||
PolymorphicAction<internal::SetErrnoAndReturnAction<T>> SetErrnoAndReturn(
|
||||
int errval, T result) {
|
||||
PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
|
||||
SetErrnoAndReturn(int errval, T result) {
|
||||
return MakePolymorphicAction(
|
||||
internal::SetErrnoAndReturnAction<T>(errval, result));
|
||||
}
|
||||
@ -1154,8 +1164,8 @@ PolymorphicAction<internal::SetErrnoAndReturnAction<T>> SetErrnoAndReturn(
|
||||
|
||||
// Creates an action that invokes 'function_impl' with no argument.
|
||||
template <typename FunctionImpl>
|
||||
PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl>>
|
||||
InvokeWithoutArgs(FunctionImpl function_impl) {
|
||||
PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >
|
||||
InvokeWithoutArgs(FunctionImpl function_impl) {
|
||||
return MakePolymorphicAction(
|
||||
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
|
||||
// with no argument.
|
||||
template <class Class, typename MethodPtr>
|
||||
PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>>
|
||||
InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) {
|
||||
PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> >
|
||||
InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) {
|
||||
return MakePolymorphicAction(
|
||||
internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(obj_ptr,
|
||||
method_ptr));
|
||||
internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(
|
||||
obj_ptr, method_ptr));
|
||||
}
|
||||
|
||||
// Creates an action that performs an_action and throws away its
|
||||
|
||||
@ -38,10 +38,10 @@
|
||||
#ifndef 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 <ostream> // NOLINT
|
||||
#include "gmock/internal/gmock-port.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace testing {
|
||||
|
||||
@ -108,7 +108,7 @@ class GTEST_API_ Cardinality {
|
||||
// cardinality, i.e. exceed the maximum number of allowed calls.
|
||||
bool IsOverSaturatedByCallCount(int call_count) const {
|
||||
return impl_->IsSaturatedByCallCount(call_count) &&
|
||||
!impl_->IsSatisfiedByCallCount(call_count);
|
||||
!impl_->IsSatisfiedByCallCount(call_count);
|
||||
}
|
||||
|
||||
// Describes self to an ostream
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -106,61 +106,59 @@ class NiceMock : public MockClass {
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4>
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4)
|
||||
: MockClass(a1, a2, a3, a4) {
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3,
|
||||
const A4& a4) : MockClass(a1, a2, a3, a4) {
|
||||
::testing::Mock::AllowUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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)
|
||||
: MockClass(a1, a2, a3, a4, a5) {
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
||||
const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
|
||||
::testing::Mock::AllowUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6>
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
|
||||
const A6& a6)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6) {
|
||||
typename A6>
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
||||
const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
|
||||
::testing::Mock::AllowUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7>
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
|
||||
const A6& a6, const A7& a7)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7) {
|
||||
typename A6, typename A7>
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
||||
const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
|
||||
a6, a7) {
|
||||
::testing::Mock::AllowUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7, typename A8>
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5,
|
||||
const A6& a6, const A7& a7, const A8& a8)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8) {
|
||||
typename A6, typename A7, typename A8>
|
||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
|
||||
a2, a3, a4, a5, a6, a7, a8) {
|
||||
::testing::Mock::AllowUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7, typename A8, typename A9>
|
||||
NiceMock(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 A9& a9)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, 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, const A6& a6, const A7& a7, const A8& a8,
|
||||
const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
||||
::testing::Mock::AllowUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
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,
|
||||
const A6& a6, const A7& a7, const A8& a8, const A9& a9,
|
||||
const A10& a10)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, 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, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
|
||||
const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
||||
::testing::Mock::AllowUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
@ -204,63 +202,59 @@ class NaggyMock : public MockClass {
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4>
|
||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4)
|
||||
: MockClass(a1, a2, a3, a4) {
|
||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3,
|
||||
const A4& a4) : MockClass(a1, a2, a3, a4) {
|
||||
::testing::Mock::WarnUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
||||
const A5& a5)
|
||||
: MockClass(a1, a2, a3, a4, a5) {
|
||||
const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
|
||||
::testing::Mock::WarnUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6) {
|
||||
const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
|
||||
::testing::Mock::WarnUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6, const A7& a7)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7) {
|
||||
const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
|
||||
a6, a7) {
|
||||
::testing::Mock::WarnUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8) {
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
|
||||
a2, a3, a4, a5, a6, a7, a8) {
|
||||
::testing::Mock::WarnUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
||||
const A9& a9)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
||||
const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
||||
::testing::Mock::WarnUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
||||
const A9& a9, const A10& a10)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
|
||||
const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
||||
::testing::Mock::WarnUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
@ -304,63 +298,59 @@ class StrictMock : public MockClass {
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4>
|
||||
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4)
|
||||
: MockClass(a1, a2, a3, a4) {
|
||||
StrictMock(const A1& a1, const A2& a2, const A3& a3,
|
||||
const A4& a4) : MockClass(a1, a2, a3, a4) {
|
||||
::testing::Mock::FailUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
||||
const A5& a5)
|
||||
: MockClass(a1, a2, a3, a4, a5) {
|
||||
const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
|
||||
::testing::Mock::FailUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6) {
|
||||
const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
|
||||
::testing::Mock::FailUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6, const A7& a7)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7) {
|
||||
const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
|
||||
a6, a7) {
|
||||
::testing::Mock::FailUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8) {
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
|
||||
a2, a3, a4, a5, a6, a7, a8) {
|
||||
::testing::Mock::FailUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
||||
const A9& a9)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
||||
const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
||||
::testing::Mock::FailUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
|
||||
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,
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
||||
const A9& a9, const A10& a10)
|
||||
: MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
|
||||
const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
||||
::testing::Mock::FailUninterestingCalls(
|
||||
internal::ImplicitCast_<MockClass*>(this));
|
||||
}
|
||||
@ -382,25 +372,25 @@ class StrictMock : public MockClass {
|
||||
// NaggyMock, and StrictMock cannot be nested.
|
||||
|
||||
template <typename MockClass>
|
||||
class NiceMock<NiceMock<MockClass>>;
|
||||
class NiceMock<NiceMock<MockClass> >;
|
||||
template <typename MockClass>
|
||||
class NiceMock<NaggyMock<MockClass>>;
|
||||
class NiceMock<NaggyMock<MockClass> >;
|
||||
template <typename MockClass>
|
||||
class NiceMock<StrictMock<MockClass>>;
|
||||
class NiceMock<StrictMock<MockClass> >;
|
||||
|
||||
template <typename MockClass>
|
||||
class NaggyMock<NiceMock<MockClass>>;
|
||||
class NaggyMock<NiceMock<MockClass> >;
|
||||
template <typename MockClass>
|
||||
class NaggyMock<NaggyMock<MockClass>>;
|
||||
class NaggyMock<NaggyMock<MockClass> >;
|
||||
template <typename MockClass>
|
||||
class NaggyMock<StrictMock<MockClass>>;
|
||||
class NaggyMock<StrictMock<MockClass> >;
|
||||
|
||||
template <typename MockClass>
|
||||
class StrictMock<NiceMock<MockClass>>;
|
||||
class StrictMock<NiceMock<MockClass> >;
|
||||
template <typename MockClass>
|
||||
class StrictMock<NaggyMock<MockClass>>;
|
||||
class StrictMock<NaggyMock<MockClass> >;
|
||||
template <typename MockClass>
|
||||
class StrictMock<StrictMock<MockClass>>;
|
||||
class StrictMock<StrictMock<MockClass> >;
|
||||
|
||||
} // namespace testing
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -76,8 +76,8 @@ class InvokeMethodAction {
|
||||
|
||||
template <typename Result, typename ArgumentTuple>
|
||||
Result Perform(const ArgumentTuple& args) const {
|
||||
return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(obj_ptr_,
|
||||
method_ptr_, args);
|
||||
return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
|
||||
obj_ptr_, method_ptr_, args);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -94,8 +94,9 @@ class InvokeMethodAction {
|
||||
// necessary because Visual Studio deprecates ::std::copy, issuing warning 4996.
|
||||
// However Visual Studio 2010 and later do not honor #pragmas which disable that
|
||||
// warning.
|
||||
template <typename InputIterator, typename OutputIterator>
|
||||
inline OutputIterator CopyElements(InputIterator first, InputIterator last,
|
||||
template<typename InputIterator, typename OutputIterator>
|
||||
inline OutputIterator CopyElements(InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator output) {
|
||||
for (; first != last; ++first, ++output) {
|
||||
*output = *first;
|
||||
@ -110,7 +111,7 @@ inline OutputIterator CopyElements(InputIterator first, InputIterator last,
|
||||
// Creates an action that invokes 'function_impl' with the mock
|
||||
// function's arguments.
|
||||
template <typename FunctionImpl>
|
||||
PolymorphicAction<internal::InvokeAction<FunctionImpl>> Invoke(
|
||||
PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(
|
||||
FunctionImpl function_impl) {
|
||||
return MakePolymorphicAction(
|
||||
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
|
||||
// with the mock function's arguments.
|
||||
template <class Class, typename MethodPtr>
|
||||
PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr>> Invoke(
|
||||
PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
|
||||
Class* obj_ptr, MethodPtr method_ptr) {
|
||||
return MakePolymorphicAction(
|
||||
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 to one that accepts (and ignores) arguments.
|
||||
template <typename InnerAction>
|
||||
inline internal::WithArgsAction<InnerAction> WithoutArgs(
|
||||
const InnerAction& action) {
|
||||
inline internal::WithArgsAction<InnerAction>
|
||||
WithoutArgs(const InnerAction& action) {
|
||||
return internal::WithArgsAction<InnerAction>(action);
|
||||
}
|
||||
|
||||
@ -141,8 +142,8 @@ inline internal::WithArgsAction<InnerAction> WithoutArgs(
|
||||
// multiple arguments. For convenience, we also provide
|
||||
// WithArgs<k>(an_action) (defined below) as a synonym.
|
||||
template <int k, typename InnerAction>
|
||||
inline internal::WithArgsAction<InnerAction, k> WithArg(
|
||||
const InnerAction& action) {
|
||||
inline internal::WithArgsAction<InnerAction, k>
|
||||
WithArg(const InnerAction& 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
|
||||
// we suppress them here.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4100)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
// 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()) {
|
||||
return ::testing::get<k>(args);
|
||||
}
|
||||
|
||||
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
|
||||
// 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)) {
|
||||
*pointer = ::testing::get<k>(args);
|
||||
}
|
||||
|
||||
// Action SaveArgPointee<k>(pointer) saves the value pointed to
|
||||
// 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)) {
|
||||
*pointer = *::testing::get<k>(args);
|
||||
}
|
||||
|
||||
// Action SetArgReferee<k>(value) assigns 'value' to the variable
|
||||
// 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)) {
|
||||
typedef typename ::testing::tuple_element<k, args_type>::type argk_type;
|
||||
// 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
|
||||
// iterator. The action does not take ownership of the elements in the
|
||||
// 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)) {
|
||||
// Visual Studio deprecates ::std::copy, so we use our own copy in that case.
|
||||
#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
|
||||
// function.
|
||||
ACTION_TEMPLATE(DeleteArg, HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
ACTION_TEMPLATE(DeleteArg,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_0_VALUE_PARAMS()) {
|
||||
delete ::testing::get<k>(args);
|
||||
}
|
||||
@ -219,19 +226,19 @@ ACTION_P(ReturnPointee, pointer) { return *pointer; }
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
|
||||
// Suppresses the 'unreachable code' warning that VC generates in opt modes.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push) // Saves the current warning state.
|
||||
#pragma warning(disable : 4702) // Temporarily disables warning 4702.
|
||||
#endif
|
||||
# ifdef _MSC_VER
|
||||
# pragma warning(push) // Saves the current warning state.
|
||||
# pragma warning(disable:4702) // Temporarily disables warning 4702.
|
||||
# endif
|
||||
ACTION_P(Throw, exception) { throw exception; }
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop) // Restores the warning state.
|
||||
#endif
|
||||
# ifdef _MSC_VER
|
||||
# pragma warning(pop) // Restores the warning state.
|
||||
# endif
|
||||
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
#include <vector>
|
||||
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
#include <stdexcept> // NOLINT
|
||||
# include <stdexcept> // NOLINT
|
||||
#endif
|
||||
|
||||
#include "gmock/gmock-actions.h"
|
||||
@ -90,22 +90,19 @@ class ExpectationSet;
|
||||
namespace internal {
|
||||
|
||||
// Implements a mock function.
|
||||
template <typename F>
|
||||
class FunctionMocker;
|
||||
template <typename F> class FunctionMocker;
|
||||
|
||||
// Base class for expectations.
|
||||
class ExpectationBase;
|
||||
|
||||
// Implements an expectation.
|
||||
template <typename F>
|
||||
class TypedExpectation;
|
||||
template <typename F> class TypedExpectation;
|
||||
|
||||
// Helper class for testing the Expectation class template.
|
||||
class ExpectationTester;
|
||||
|
||||
// Base class for function mockers.
|
||||
template <typename F>
|
||||
class FunctionMockerBase;
|
||||
template <typename F> class FunctionMockerBase;
|
||||
|
||||
// Protects the mock object registry (in class Mock), all function
|
||||
// mockers, and all expectations.
|
||||
@ -151,20 +148,23 @@ class GTEST_API_ UntypedFunctionMockerBase {
|
||||
// action fails.
|
||||
// L = *
|
||||
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
|
||||
// the action's result.
|
||||
// L = *
|
||||
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
|
||||
// explicitly expected nor explicitly unexpected) to the given
|
||||
// ostream.
|
||||
virtual void UntypedDescribeUninterestingCall(const void* untyped_args,
|
||||
::std::ostream* os) const
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
|
||||
virtual void UntypedDescribeUninterestingCall(
|
||||
const void* untyped_args,
|
||||
::std::ostream* os) const
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
|
||||
|
||||
// Returns the expectation that matches the given function arguments
|
||||
// (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
|
||||
// expected number.
|
||||
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)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
|
||||
|
||||
// Prints the given function arguments to the ostream.
|
||||
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
|
||||
// method.
|
||||
// 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
|
||||
// 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
|
||||
// called after RegisterOwner() or SetOwnerAndName() has been
|
||||
// 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
|
||||
// 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
|
||||
// arguments. This function can be safely called from multiple
|
||||
// threads concurrently. The caller is responsible for deleting the
|
||||
// result.
|
||||
UntypedActionResultHolderBase* UntypedInvokeWith(const void* untyped_args)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
|
||||
UntypedActionResultHolderBase* UntypedInvokeWith(
|
||||
const void* untyped_args)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
|
||||
|
||||
protected:
|
||||
typedef std::vector<const void*> UntypedOnCallSpecs;
|
||||
|
||||
typedef std::vector<internal::linked_ptr<ExpectationBase>>
|
||||
UntypedExpectations;
|
||||
typedef std::vector<internal::linked_ptr<ExpectationBase> >
|
||||
UntypedExpectations;
|
||||
|
||||
// Returns an Expectation object that references and co-owns exp,
|
||||
// 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
|
||||
// bug in Symbian's C++ compiler (cannot decide between two
|
||||
// overloaded constructors of Matcher<const ArgumentTuple&>).
|
||||
extra_matcher_(A<const ArgumentTuple&>()) {}
|
||||
extra_matcher_(A<const ArgumentTuple&>()) {
|
||||
}
|
||||
|
||||
// Implements the .With() clause.
|
||||
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
|
||||
// made on the given mock object.
|
||||
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
|
||||
// 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);
|
||||
|
||||
// Registers a mock object and a mock method it owns.
|
||||
static void Register(const void* mock_obj,
|
||||
internal::UntypedFunctionMockerBase* mocker)
|
||||
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
|
||||
static void Register(
|
||||
const void* mock_obj,
|
||||
internal::UntypedFunctionMockerBase* mocker)
|
||||
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
|
||||
|
||||
// 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
|
||||
// information helps the user identify which object it is.
|
||||
static void RegisterUseByOnCallOrExpectCall(const void* mock_obj,
|
||||
const char* file, int line)
|
||||
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
|
||||
static void RegisterUseByOnCallOrExpectCall(
|
||||
const void* mock_obj, const char* file, int line)
|
||||
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
|
||||
|
||||
// Unregisters a mock method; removes the owning mock object from
|
||||
// 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);
|
||||
|
||||
// Returns the expectation this object references.
|
||||
const internal::linked_ptr<internal::ExpectationBase>& expectation_base()
|
||||
const {
|
||||
const internal::linked_ptr<internal::ExpectationBase>&
|
||||
expectation_base() const {
|
||||
return expectation_base_;
|
||||
}
|
||||
|
||||
@ -604,6 +612,7 @@ class ExpectationSet {
|
||||
Expectation::Set expectations_;
|
||||
};
|
||||
|
||||
|
||||
// Sequence objects are used by a user to specify the relative order
|
||||
// in which the expectations should match. They are copyable (we rely
|
||||
// on the compiler-defined copy constructor and assignment operator).
|
||||
@ -652,7 +661,6 @@ class GTEST_API_ InSequence {
|
||||
public:
|
||||
InSequence();
|
||||
~InSequence();
|
||||
|
||||
private:
|
||||
bool sequence_created_;
|
||||
|
||||
@ -757,34 +765,40 @@ class GTEST_API_ ExpectationBase {
|
||||
// the current thread.
|
||||
|
||||
// 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.
|
||||
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();
|
||||
return retired_;
|
||||
}
|
||||
|
||||
// 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();
|
||||
retired_ = true;
|
||||
}
|
||||
|
||||
// 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();
|
||||
return cardinality().IsSatisfiedByCallCount(call_count_);
|
||||
}
|
||||
|
||||
// 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();
|
||||
return cardinality().IsSaturatedByCallCount(call_count_);
|
||||
}
|
||||
|
||||
// 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();
|
||||
return cardinality().IsOverSaturatedByCallCount(call_count_);
|
||||
}
|
||||
@ -798,13 +812,15 @@ class GTEST_API_ ExpectationBase {
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
|
||||
|
||||
// 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();
|
||||
return call_count_;
|
||||
}
|
||||
|
||||
// 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();
|
||||
call_count_++;
|
||||
}
|
||||
@ -813,7 +829,8 @@ class GTEST_API_ ExpectationBase {
|
||||
// WillRepeatedly() clauses) against the cardinality if this hasn't
|
||||
// been done before. Prints a warning if there are too many or too
|
||||
// few actions.
|
||||
void CheckActionCountIfNotDone() const GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
void CheckActionCountIfNotDone() const
|
||||
GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
|
||||
friend class ::testing::Sequence;
|
||||
friend class ::testing::internal::ExpectationTester;
|
||||
@ -831,7 +848,7 @@ class GTEST_API_ ExpectationBase {
|
||||
const string source_text_; // The EXPECT_CALL(...) source text.
|
||||
// True iff the cardinality is specified explicitly.
|
||||
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
|
||||
// satisfied before this expectation can be matched) of this
|
||||
// expectation. We use linked_ptr in the set because we want an
|
||||
@ -850,7 +867,7 @@ class GTEST_API_ ExpectationBase {
|
||||
bool retires_on_saturation_;
|
||||
Clause last_clause_;
|
||||
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);
|
||||
}; // class ExpectationBase
|
||||
@ -863,8 +880,9 @@ class TypedExpectation : public ExpectationBase {
|
||||
typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
|
||||
typedef typename Function<F>::Result Result;
|
||||
|
||||
TypedExpectation(FunctionMockerBase<F>* owner, const char* a_file, int a_line,
|
||||
const string& a_source_text, const ArgumentMatcherTuple& m)
|
||||
TypedExpectation(FunctionMockerBase<F>* owner,
|
||||
const char* a_file, int a_line, const string& a_source_text,
|
||||
const ArgumentMatcherTuple& m)
|
||||
: ExpectationBase(a_file, a_line, a_source_text),
|
||||
owner_(owner),
|
||||
matchers_(m),
|
||||
@ -910,7 +928,9 @@ class TypedExpectation : public ExpectationBase {
|
||||
}
|
||||
|
||||
// Implements the .Times() clause.
|
||||
TypedExpectation& Times(int n) { return Times(Exactly(n)); }
|
||||
TypedExpectation& Times(int n) {
|
||||
return Times(Exactly(n));
|
||||
}
|
||||
|
||||
// Implements the .InSequence() clause.
|
||||
TypedExpectation& InSequence(const Sequence& s) {
|
||||
@ -1025,7 +1045,9 @@ class TypedExpectation : public ExpectationBase {
|
||||
|
||||
// Returns the matchers for the arguments as specified inside the
|
||||
// EXPECT_CALL() macro.
|
||||
const ArgumentMatcherTuple& matchers() const { return matchers_; }
|
||||
const ArgumentMatcherTuple& matchers() const {
|
||||
return matchers_;
|
||||
}
|
||||
|
||||
// Returns the matcher specified by the .With() clause.
|
||||
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
|
||||
// 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()
|
||||
// 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
|
||||
// expectation to the given ostream.
|
||||
void ExplainMatchResultTo(const ArgumentTuple& args, ::std::ostream* os) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
void ExplainMatchResultTo(
|
||||
const ArgumentTuple& args,
|
||||
::std::ostream* os) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
g_gmock_mutex.AssertHeld();
|
||||
|
||||
if (is_retired()) {
|
||||
@ -1122,9 +1148,10 @@ class TypedExpectation : public ExpectationBase {
|
||||
}
|
||||
|
||||
// Returns the action that should be taken for the current invocation.
|
||||
const Action<F>& GetCurrentAction(const FunctionMockerBase<F>* mocker,
|
||||
const ArgumentTuple& args) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
const Action<F>& GetCurrentAction(
|
||||
const FunctionMockerBase<F>* mocker,
|
||||
const ArgumentTuple& args) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
g_gmock_mutex.AssertHeld();
|
||||
const int count = call_count();
|
||||
Assert(count >= 1, __FILE__, __LINE__,
|
||||
@ -1139,16 +1166,16 @@ class TypedExpectation : public ExpectationBase {
|
||||
::std::stringstream ss;
|
||||
DescribeLocationTo(&ss);
|
||||
ss << "Actions ran out in " << source_text() << "...\n"
|
||||
<< "Called " << count << " times, but only " << action_count
|
||||
<< " WillOnce()" << (action_count == 1 ? " is" : "s are")
|
||||
<< " specified - ";
|
||||
<< "Called " << count << " times, but only "
|
||||
<< action_count << " WillOnce()"
|
||||
<< (action_count == 1 ? " is" : "s are") << " specified - ";
|
||||
mocker->DescribeDefaultActionTo(args, &ss);
|
||||
Log(kWarning, ss.str(), 1);
|
||||
}
|
||||
|
||||
return count <= action_count
|
||||
? *static_cast<const Action<F>*>(untyped_actions_[count - 1])
|
||||
: repeated_action();
|
||||
return count <= action_count ?
|
||||
*static_cast<const Action<F>*>(untyped_actions_[count - 1]) :
|
||||
repeated_action();
|
||||
}
|
||||
|
||||
// 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
|
||||
// IncrementCallCount(). A return value of NULL means the default
|
||||
// action.
|
||||
const Action<F>* GetActionForArguments(const FunctionMockerBase<F>* mocker,
|
||||
const ArgumentTuple& args,
|
||||
::std::ostream* what,
|
||||
::std::ostream* why)
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
const Action<F>* GetActionForArguments(
|
||||
const FunctionMockerBase<F>* mocker,
|
||||
const ArgumentTuple& args,
|
||||
::std::ostream* what,
|
||||
::std::ostream* why)
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
g_gmock_mutex.AssertHeld();
|
||||
if (IsSaturated()) {
|
||||
// We have an excessive call.
|
||||
@ -1185,7 +1213,7 @@ class TypedExpectation : public ExpectationBase {
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
@ -1218,8 +1246,8 @@ template <typename F>
|
||||
class MockSpec {
|
||||
public:
|
||||
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
|
||||
typedef
|
||||
typename internal::Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
|
||||
typedef typename internal::Function<F>::ArgumentMatcherTuple
|
||||
ArgumentMatcherTuple;
|
||||
|
||||
// Constructs a MockSpec object, given the function mocker object
|
||||
// that the spec is associated with.
|
||||
@ -1228,23 +1256,21 @@ class MockSpec {
|
||||
|
||||
// Adds a new default action spec to the function mocker and returns
|
||||
// the newly created spec.
|
||||
internal::OnCallSpec<F>& InternalDefaultActionSetAt(const char* file,
|
||||
int line, const char* obj,
|
||||
const char* call) {
|
||||
internal::OnCallSpec<F>& InternalDefaultActionSetAt(
|
||||
const char* file, int line, const char* obj, const char* call) {
|
||||
LogWithLocation(internal::kInfo, file, line,
|
||||
string("ON_CALL(") + obj + ", " + call + ") invoked");
|
||||
string("ON_CALL(") + obj + ", " + call + ") invoked");
|
||||
return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
|
||||
}
|
||||
|
||||
// Adds a new expectation spec to the function mocker and returns
|
||||
// the newly created spec.
|
||||
internal::TypedExpectation<F>& InternalExpectedAt(const char* file, int line,
|
||||
const char* obj,
|
||||
const char* call) {
|
||||
internal::TypedExpectation<F>& InternalExpectedAt(
|
||||
const char* file, int line, const char* obj, const char* call) {
|
||||
const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
|
||||
LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
|
||||
return function_mocker_->AddNewExpectation(file, line, source_text,
|
||||
matchers_);
|
||||
return function_mocker_->AddNewExpectation(
|
||||
file, line, source_text, matchers_);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1277,7 +1303,8 @@ class ReferenceOrValueWrapper {
|
||||
public:
|
||||
// Constructs a wrapper from the given value/reference.
|
||||
explicit ReferenceOrValueWrapper(T value)
|
||||
: value_(::testing::internal::move(value)) {}
|
||||
: value_(::testing::internal::move(value)) {
|
||||
}
|
||||
|
||||
// Unwraps and returns the underlying value/reference, exactly as
|
||||
// originally passed. The behavior of calling this more than once on
|
||||
@ -1288,7 +1315,9 @@ class ReferenceOrValueWrapper {
|
||||
// Always returns a const reference (more precisely,
|
||||
// const RemoveReference<T>&). The behavior of calling this after
|
||||
// calling Unwrap on the same object is unspecified.
|
||||
const T& Peek() const { return value_; }
|
||||
const T& Peek() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
T value_;
|
||||
@ -1302,7 +1331,8 @@ class ReferenceOrValueWrapper<T&> {
|
||||
// Workaround for debatable pass-by-reference lint warning (c-library-team
|
||||
// policy precludes NOLINT in this context)
|
||||
typedef T& reference;
|
||||
explicit ReferenceOrValueWrapper(reference ref) : value_ptr_(&ref) {}
|
||||
explicit ReferenceOrValueWrapper(reference ref)
|
||||
: value_ptr_(&ref) {}
|
||||
T& Unwrap() { return *value_ptr_; }
|
||||
const T& Peek() const { return *value_ptr_; }
|
||||
|
||||
@ -1316,9 +1346,9 @@ class ReferenceOrValueWrapper<T&> {
|
||||
// the constructor only.
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push) // Saves the current warning state.
|
||||
#pragma warning(disable : 4355) // Temporarily disables warning 4355.
|
||||
#endif // _MSV_VER
|
||||
# pragma warning(push) // Saves the current warning state.
|
||||
# pragma warning(disable:4355) // Temporarily disables warning 4355.
|
||||
#endif // _MSV_VER
|
||||
|
||||
// C++ treats the void type specially. For example, you cannot define
|
||||
// a void-typed variable or pass a void value to a function.
|
||||
@ -1342,7 +1372,9 @@ template <typename T>
|
||||
class ActionResultHolder : public UntypedActionResultHolderBase {
|
||||
public:
|
||||
// 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.
|
||||
virtual void PrintAsActionResult(::std::ostream* os) const {
|
||||
@ -1358,16 +1390,16 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
|
||||
const FunctionMockerBase<F>* func_mocker,
|
||||
const typename Function<F>::ArgumentTuple& args,
|
||||
const string& call_description) {
|
||||
return new ActionResultHolder(
|
||||
Wrapper(func_mocker->PerformDefaultAction(args, call_description)));
|
||||
return new ActionResultHolder(Wrapper(
|
||||
func_mocker->PerformDefaultAction(args, call_description)));
|
||||
}
|
||||
|
||||
// Performs the given action and returns the result in a new-ed
|
||||
// ActionResultHolder.
|
||||
template <typename F>
|
||||
static ActionResultHolder* PerformAction(
|
||||
const Action<F>& action,
|
||||
const typename Function<F>::ArgumentTuple& args) {
|
||||
static ActionResultHolder*
|
||||
PerformAction(const Action<F>& action,
|
||||
const typename Function<F>::ArgumentTuple& args) {
|
||||
return new ActionResultHolder(Wrapper(action.Perform(args)));
|
||||
}
|
||||
|
||||
@ -1375,7 +1407,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
|
||||
typedef ReferenceOrValueWrapper<T> Wrapper;
|
||||
|
||||
explicit ActionResultHolder(Wrapper result)
|
||||
: result_(::testing::internal::move(result)) {}
|
||||
: result_(::testing::internal::move(result)) {
|
||||
}
|
||||
|
||||
Wrapper result_;
|
||||
|
||||
@ -1386,7 +1419,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
|
||||
template <>
|
||||
class ActionResultHolder<void> : public UntypedActionResultHolderBase {
|
||||
public:
|
||||
void Unwrap() {}
|
||||
void Unwrap() { }
|
||||
|
||||
virtual void PrintAsActionResult(::std::ostream* /* os */) const {}
|
||||
|
||||
@ -1431,7 +1464,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
// The destructor verifies that all expectations on this mock
|
||||
// function have been satisfied. If not, it will report Google Test
|
||||
// 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);
|
||||
VerifyAndClearExpectationsLocked();
|
||||
Mock::UnregisterLocked(this);
|
||||
@ -1441,9 +1475,10 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
// Returns the ON_CALL spec that matches this mock function with the
|
||||
// given arguments; returns NULL if no matching ON_CALL is found.
|
||||
// L = *
|
||||
const OnCallSpec<F>* FindOnCallSpec(const ArgumentTuple& args) const {
|
||||
for (UntypedOnCallSpecs::const_reverse_iterator it =
|
||||
untyped_on_call_specs_.rbegin();
|
||||
const OnCallSpec<F>* FindOnCallSpec(
|
||||
const ArgumentTuple& args) const {
|
||||
for (UntypedOnCallSpecs::const_reverse_iterator it
|
||||
= untyped_on_call_specs_.rbegin();
|
||||
it != untyped_on_call_specs_.rend(); ++it) {
|
||||
const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);
|
||||
if (spec->Matches(args))
|
||||
@ -1462,13 +1497,14 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
// L = *
|
||||
Result PerformDefaultAction(const ArgumentTuple& args,
|
||||
const string& call_description) const {
|
||||
const OnCallSpec<F>* const spec = this->FindOnCallSpec(args);
|
||||
const OnCallSpec<F>* const spec =
|
||||
this->FindOnCallSpec(args);
|
||||
if (spec != NULL) {
|
||||
return spec->GetAction().Perform(args);
|
||||
}
|
||||
const string message = call_description +
|
||||
"\n The mock function has no default action "
|
||||
"set, and its return type has no default value set.";
|
||||
"\n The mock function has no default action "
|
||||
"set, and its return type has no default value set.";
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
if (!DefaultValue<Result>::Exists()) {
|
||||
throw std::runtime_error(message);
|
||||
@ -1523,7 +1559,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
untyped_on_call_specs_.swap(specs_to_delete);
|
||||
|
||||
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) {
|
||||
delete static_cast<const OnCallSpec<F>*>(*it);
|
||||
}
|
||||
@ -1543,16 +1580,17 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
// arguments. This function can be safely called from multiple
|
||||
// threads concurrently.
|
||||
Result InvokeWith(const ArgumentTuple& args)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
scoped_ptr<ResultHolder> holder(
|
||||
DownCast_<ResultHolder*>(this->UntypedInvokeWith(&args)));
|
||||
return holder->Unwrap();
|
||||
}
|
||||
|
||||
// Adds and returns a default action spec for this mock function.
|
||||
OnCallSpec<F>& AddNewOnCallSpec(const char* file, int line,
|
||||
const ArgumentMatcherTuple& m)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
OnCallSpec<F>& AddNewOnCallSpec(
|
||||
const char* file, int line,
|
||||
const ArgumentMatcherTuple& m)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
|
||||
OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);
|
||||
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.
|
||||
TypedExpectation<F>& AddNewExpectation(const char* file, int line,
|
||||
const string& source_text,
|
||||
const ArgumentMatcherTuple& m)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
TypedExpectation<F>& AddNewExpectation(
|
||||
const char* file,
|
||||
int line,
|
||||
const string& source_text,
|
||||
const ArgumentMatcherTuple& m)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
|
||||
TypedExpectation<F>* const expectation =
|
||||
new TypedExpectation<F>(this, file, line, source_text, m);
|
||||
@ -1584,8 +1624,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
MockSpec<F>& current_spec() { return current_spec_; }
|
||||
|
||||
private:
|
||||
template <typename Func>
|
||||
friend class TypedExpectation;
|
||||
template <typename Func> friend class TypedExpectation;
|
||||
|
||||
// Some utilities needed for implementing UntypedInvokeWith().
|
||||
|
||||
@ -1597,9 +1636,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
const OnCallSpec<F>* const spec = FindOnCallSpec(args);
|
||||
|
||||
if (spec == NULL) {
|
||||
*os << (internal::type_equals<Result, void>::value
|
||||
? "returning directly.\n"
|
||||
: "returning default value.\n");
|
||||
*os << (internal::type_equals<Result, void>::value ?
|
||||
"returning directly.\n" :
|
||||
"returning default value.\n");
|
||||
} else {
|
||||
*os << "taking default action specified at:\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
|
||||
// explicitly expected nor explicitly unexpected) to the given
|
||||
// ostream.
|
||||
virtual void UntypedDescribeUninterestingCall(const void* untyped_args,
|
||||
::std::ostream* os) const
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
virtual void UntypedDescribeUninterestingCall(
|
||||
const void* untyped_args,
|
||||
::std::ostream* os) const
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
const ArgumentTuple& args =
|
||||
*static_cast<const ArgumentTuple*>(untyped_args);
|
||||
*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
|
||||
// mock function) and excessive locking could cause a dead lock.
|
||||
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)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
const ArgumentTuple& args =
|
||||
*static_cast<const ArgumentTuple*>(untyped_args);
|
||||
MutexLock l(&g_gmock_mutex);
|
||||
@ -1670,8 +1711,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
|
||||
// Returns the expectation that matches the arguments, or NULL if no
|
||||
// expectation matches them.
|
||||
TypedExpectation<F>* FindMatchingExpectationLocked(const ArgumentTuple& args)
|
||||
const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
TypedExpectation<F>* FindMatchingExpectationLocked(
|
||||
const ArgumentTuple& args) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
g_gmock_mutex.AssertHeld();
|
||||
for (typename UntypedExpectations::const_reverse_iterator it =
|
||||
untyped_expectations_.rbegin();
|
||||
@ -1686,10 +1728,11 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
}
|
||||
|
||||
// Returns a message that the arguments don't match any expectation.
|
||||
void FormatUnexpectedCallMessageLocked(const ArgumentTuple& args,
|
||||
::std::ostream* os,
|
||||
::std::ostream* why) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
void FormatUnexpectedCallMessageLocked(
|
||||
const ArgumentTuple& args,
|
||||
::std::ostream* os,
|
||||
::std::ostream* why) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
g_gmock_mutex.AssertHeld();
|
||||
*os << "\nUnexpected mock function call - ";
|
||||
DescribeDefaultActionTo(args, os);
|
||||
@ -1698,14 +1741,15 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
|
||||
// Prints a list of expectations that have been tried against the
|
||||
// current mock function call.
|
||||
void PrintTriedExpectationsLocked(const ArgumentTuple& args,
|
||||
::std::ostream* why) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
void PrintTriedExpectationsLocked(
|
||||
const ArgumentTuple& args,
|
||||
::std::ostream* why) const
|
||||
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
|
||||
g_gmock_mutex.AssertHeld();
|
||||
const int count = static_cast<int>(untyped_expectations_.size());
|
||||
*why << "Google Mock tried the following " << count << " "
|
||||
<< (count == 1 ? "expectation, but it didn't match"
|
||||
: "expectations, but none matched")
|
||||
<< (count == 1 ? "expectation, but it didn't match" :
|
||||
"expectations, but none matched")
|
||||
<< ":\n";
|
||||
for (int i = 0; i < count; i++) {
|
||||
TypedExpectation<F>* const expectation =
|
||||
@ -1741,8 +1785,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
}; // class FunctionMockerBase
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop) // Restores the warning state.
|
||||
#endif // _MSV_VER
|
||||
# pragma warning(pop) // Restores the warning state.
|
||||
#endif // _MSV_VER
|
||||
|
||||
// Implements methods of FunctionMockerBase.
|
||||
|
||||
@ -1779,9 +1823,7 @@ using internal::MockSpec;
|
||||
// // Expects a call to const MockFoo::Bar().
|
||||
// EXPECT_CALL(Const(foo), Bar());
|
||||
template <typename T>
|
||||
inline const T& Const(const T& x) {
|
||||
return x;
|
||||
}
|
||||
inline const T& Const(const T& x) { return x; }
|
||||
|
||||
// Constructs an Expectation object that references and co-owns exp.
|
||||
inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
|
||||
@ -1794,12 +1836,12 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
|
||||
// See CompilesWithMethodNameExpandedFromMacro tests in
|
||||
// internal/gmock-spec-builders_test.cc for more details.
|
||||
#define GMOCK_ON_CALL_IMPL_(obj, call) \
|
||||
((obj).gmock_##call) \
|
||||
.InternalDefaultActionSetAt(__FILE__, __LINE__, #obj, #call)
|
||||
((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
|
||||
#obj, #call)
|
||||
#define ON_CALL(obj, call) GMOCK_ON_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)
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
|
||||
|
||||
@ -59,8 +59,8 @@
|
||||
#include "gmock/gmock-cardinalities.h"
|
||||
#include "gmock/gmock-generated-actions.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-matchers.h"
|
||||
#include "gmock/gmock-matchers.h"
|
||||
#include "gmock/gmock-more-actions.h"
|
||||
#include "gmock/gmock-more-matchers.h"
|
||||
|
||||
@ -69,78 +69,72 @@ template <typename Tuple>
|
||||
struct MatcherTuple;
|
||||
|
||||
template <>
|
||||
struct MatcherTuple<::testing::tuple<>> {
|
||||
typedef ::testing::tuple<> type;
|
||||
struct MatcherTuple< ::testing::tuple<> > {
|
||||
typedef ::testing::tuple< > type;
|
||||
};
|
||||
|
||||
template <typename A1>
|
||||
struct MatcherTuple<::testing::tuple<A1>> {
|
||||
typedef ::testing::tuple<Matcher<A1>> type;
|
||||
struct MatcherTuple< ::testing::tuple<A1> > {
|
||||
typedef ::testing::tuple<Matcher<A1> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2>
|
||||
struct MatcherTuple<::testing::tuple<A1, A2>> {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>> type;
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3>
|
||||
struct MatcherTuple<::testing::tuple<A1, A2, A3>> {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>> type;
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4>
|
||||
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4>> {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>>
|
||||
type;
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
|
||||
Matcher<A4> > type;
|
||||
};
|
||||
|
||||
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>,
|
||||
Matcher<A5>>
|
||||
type;
|
||||
Matcher<A5> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6>
|
||||
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6>> {
|
||||
typename A6>
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6>>
|
||||
type;
|
||||
Matcher<A5>, Matcher<A6> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7>
|
||||
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6, A7>> {
|
||||
typename A6, typename A7>
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>>
|
||||
type;
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7, typename A8>
|
||||
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8>> {
|
||||
typename A6, typename A7, typename A8>
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>>
|
||||
type;
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7, typename A8, typename A9>
|
||||
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9>> {
|
||||
typename A6, typename A7, typename A8, typename 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>,
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>,
|
||||
Matcher<A9>>
|
||||
type;
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7, typename A8, typename A9, typename A10>
|
||||
struct MatcherTuple<::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, 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> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>,
|
||||
Matcher<A9>, Matcher<A10>>
|
||||
type;
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
|
||||
Matcher<A10> > type;
|
||||
};
|
||||
|
||||
// Template struct Function<F>, where F must be a function type, contains
|
||||
@ -169,7 +163,8 @@ struct Function<R()> {
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
struct Function<R(A1)> : Function<R()> {
|
||||
struct Function<R(A1)>
|
||||
: Function<R()> {
|
||||
typedef A1 Argument1;
|
||||
typedef ::testing::tuple<A1> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
@ -178,7 +173,8 @@ struct Function<R(A1)> : Function<R()> {
|
||||
};
|
||||
|
||||
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 ::testing::tuple<A1, A2> ArgumentTuple;
|
||||
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>
|
||||
struct Function<R(A1, A2, A3)> : Function<R(A1, A2)> {
|
||||
struct Function<R(A1, A2, A3)>
|
||||
: Function<R(A1, A2)> {
|
||||
typedef A3 Argument3;
|
||||
typedef ::testing::tuple<A1, A2, A3> ArgumentTuple;
|
||||
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>
|
||||
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 ::testing::tuple<A1, A2, A3, A4> ArgumentTuple;
|
||||
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,
|
||||
typename A5>
|
||||
struct Function<R(A1, A2, A3, A4, A5)> : Function<R(A1, A2, A3, A4)> {
|
||||
typename A5>
|
||||
struct Function<R(A1, A2, A3, A4, A5)>
|
||||
: Function<R(A1, A2, A3, A4)> {
|
||||
typedef A5 Argument5;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
|
||||
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,
|
||||
typename A5, typename A6>
|
||||
struct Function<R(A1, A2, A3, A4, A5, A6)> : Function<R(A1, A2, A3, A4, A5)> {
|
||||
typename A5, typename A6>
|
||||
struct Function<R(A1, A2, A3, A4, A5, A6)>
|
||||
: Function<R(A1, A2, A3, A4, A5)> {
|
||||
typedef A6 Argument6;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
|
||||
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,
|
||||
typename A5, typename A6, typename A7>
|
||||
typename A5, typename A6, typename A7>
|
||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
|
||||
: Function<R(A1, A2, A3, A4, A5, A6)> {
|
||||
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,
|
||||
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)>
|
||||
: Function<R(A1, A2, A3, A4, A5, A6, A7)> {
|
||||
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,
|
||||
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)>
|
||||
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
|
||||
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 void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
|
||||
A9);
|
||||
A9);
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5, typename A6, typename A7, typename A8, typename A9,
|
||||
typename A10>
|
||||
typename A5, typename A6, typename A7, typename A8, typename A9,
|
||||
typename 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)> {
|
||||
typedef A10 Argument10;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>
|
||||
ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
A10> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
|
||||
A9, A10);
|
||||
A9, A10);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@ -38,8 +38,8 @@
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
||||
|
||||
#include <ostream> // NOLINT
|
||||
#include <stdio.h>
|
||||
#include <ostream> // NOLINT
|
||||
#include <string>
|
||||
|
||||
#include "gmock/internal/gmock-generated-internal-utils.h"
|
||||
@ -67,9 +67,7 @@ struct PointeeOf {
|
||||
};
|
||||
// This specialization is for the raw pointer case.
|
||||
template <typename T>
|
||||
struct PointeeOf<T*> {
|
||||
typedef T type;
|
||||
}; // NOLINT
|
||||
struct PointeeOf<T*> { typedef T type; }; // NOLINT
|
||||
|
||||
// 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.
|
||||
@ -80,9 +78,7 @@ inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
|
||||
}
|
||||
// This overloaded version is for the raw pointer case.
|
||||
template <typename Element>
|
||||
inline Element* GetRawPointer(Element* p) {
|
||||
return p;
|
||||
}
|
||||
inline Element* GetRawPointer(Element* p) { return p; }
|
||||
|
||||
// This comparator allows linked_ptr to be stored in sets.
|
||||
template <typename T>
|
||||
@ -105,7 +101,7 @@ struct LinkedPtrLessThan {
|
||||
(defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
|
||||
// wchar_t is a typedef.
|
||||
#else
|
||||
#define GMOCK_WCHAR_T_IS_NATIVE_ 1
|
||||
# define GMOCK_WCHAR_T_IS_NATIVE_ 1
|
||||
#endif
|
||||
|
||||
// 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
|
||||
#ifdef __GNUC__
|
||||
// signed/unsigned wchar_t are valid types.
|
||||
#define GMOCK_HAS_SIGNED_WCHAR_T_ 1
|
||||
# define GMOCK_HAS_SIGNED_WCHAR_T_ 1
|
||||
#endif
|
||||
|
||||
// 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
|
||||
// when a matcher argument type can be safely converted to another
|
||||
// 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.
|
||||
template <typename T>
|
||||
struct KindOf {
|
||||
template <typename T> struct KindOf {
|
||||
enum { value = kOther }; // The default kind.
|
||||
};
|
||||
|
||||
// This macro declares that the kind of 'type' is 'kind'.
|
||||
#define GMOCK_DECLARE_KIND_(type, kind) \
|
||||
template <> \
|
||||
struct KindOf<type> { \
|
||||
enum { value = kind }; \
|
||||
}
|
||||
template <> struct KindOf<type> { enum { value = kind }; }
|
||||
|
||||
GMOCK_DECLARE_KIND_(bool, kBool);
|
||||
|
||||
@ -148,11 +142,11 @@ GMOCK_DECLARE_KIND_(bool, kBool);
|
||||
GMOCK_DECLARE_KIND_(char, kInteger);
|
||||
GMOCK_DECLARE_KIND_(signed 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_(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
|
||||
|
||||
#if GMOCK_WCHAR_T_IS_NATIVE_
|
||||
@ -171,8 +165,8 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
|
||||
#undef GMOCK_DECLARE_KIND_
|
||||
|
||||
// Evaluates to the kind of 'type'.
|
||||
#define GMOCK_KIND_OF_(type) \
|
||||
static_cast<::testing::internal::TypeKind>( \
|
||||
#define GMOCK_KIND_OF_(type) \
|
||||
static_cast< ::testing::internal::TypeKind>( \
|
||||
::testing::internal::KindOf<type>::value)
|
||||
|
||||
// Evaluates to true iff integer type T is signed.
|
||||
@ -215,13 +209,13 @@ struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
|
||||
template <typename From, typename To>
|
||||
struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
|
||||
: public bool_constant<
|
||||
// When converting from a smaller size to a larger size, we are
|
||||
// fine as long as we are not converting from signed to unsigned.
|
||||
((sizeof(From) < sizeof(To)) &&
|
||||
(!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
|
||||
// When converting between the same size, the signedness must match.
|
||||
((sizeof(From) == sizeof(To)) &&
|
||||
(GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT
|
||||
// When converting from a smaller size to a larger size, we are
|
||||
// fine as long as we are not converting from signed to unsigned.
|
||||
((sizeof(From) < sizeof(To)) &&
|
||||
(!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
|
||||
// When converting between the same size, the signedness must match.
|
||||
((sizeof(From) == sizeof(To)) &&
|
||||
(GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT
|
||||
|
||||
#undef GMOCK_IS_SIGNED_
|
||||
|
||||
@ -244,8 +238,8 @@ struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
|
||||
// Converting a floating-point to another floating-point is lossless
|
||||
// iff the target type is at least as big as the source type.
|
||||
template <typename From, typename To>
|
||||
struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kFloatingPoint,
|
||||
To>
|
||||
struct LosslessArithmeticConvertibleImpl<
|
||||
kFloatingPoint, From, kFloatingPoint, To>
|
||||
: public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
|
||||
|
||||
// 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.
|
||||
template <typename From, typename To>
|
||||
struct LosslessArithmeticConvertible
|
||||
: public LosslessArithmeticConvertibleImpl<GMOCK_KIND_OF_(From), From,
|
||||
GMOCK_KIND_OF_(To), To> {
|
||||
}; // NOLINT
|
||||
: public LosslessArithmeticConvertibleImpl<
|
||||
GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {}; // NOLINT
|
||||
|
||||
// This interface knows how to report a Google Mock failure (either
|
||||
// non-fatal or fatal).
|
||||
class FailureReporterInterface {
|
||||
public:
|
||||
// The type of a failure (either non-fatal or fatal).
|
||||
enum FailureType { kNonfatal, kFatal };
|
||||
enum FailureType {
|
||||
kNonfatal, kFatal
|
||||
};
|
||||
|
||||
virtual ~FailureReporterInterface() {}
|
||||
|
||||
@ -286,8 +281,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter();
|
||||
inline void Assert(bool condition, const char* file, int line,
|
||||
const string& msg) {
|
||||
if (!condition) {
|
||||
GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal, file,
|
||||
line, msg);
|
||||
GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
|
||||
file, line, msg);
|
||||
}
|
||||
}
|
||||
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.
|
||||
enum LogSeverity { kInfo = 0, kWarning = 1 };
|
||||
enum LogSeverity {
|
||||
kInfo = 0,
|
||||
kWarning = 1
|
||||
};
|
||||
|
||||
// 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
|
||||
// function calls will be inlined by the compiler and need to be
|
||||
// conservative.
|
||||
GTEST_API_ void Log(LogSeverity severity, const string& message,
|
||||
GTEST_API_ void Log(LogSeverity severity,
|
||||
const string& message,
|
||||
int stack_frames_to_skip);
|
||||
|
||||
// TODO(wan@google.com): group all type utilities together.
|
||||
@ -338,50 +337,35 @@ GTEST_API_ void Log(LogSeverity severity, const string& message,
|
||||
// Type traits.
|
||||
|
||||
// is_reference<T>::value is non-zero iff T is a reference type.
|
||||
template <typename T>
|
||||
struct is_reference : public false_type {};
|
||||
template <typename T>
|
||||
struct is_reference<T&> : public true_type {};
|
||||
template <typename T> struct is_reference : public false_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.
|
||||
template <typename T1, typename T2>
|
||||
struct type_equals : public false_type {};
|
||||
template <typename T>
|
||||
struct type_equals<T, T> : public true_type {};
|
||||
template <typename T1, typename T2> struct type_equals : public false_type {};
|
||||
template <typename T> struct type_equals<T, T> : public true_type {};
|
||||
|
||||
// remove_reference<T>::type removes the reference from type T, if any.
|
||||
template <typename T>
|
||||
struct remove_reference {
|
||||
typedef T type;
|
||||
}; // NOLINT
|
||||
template <typename T>
|
||||
struct remove_reference<T&> {
|
||||
typedef T type;
|
||||
}; // NOLINT
|
||||
template <typename T> struct remove_reference { 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
|
||||
// other types. Useful for saving a copy of a function argument.
|
||||
template <typename T>
|
||||
struct DecayArray {
|
||||
typedef T type;
|
||||
}; // NOLINT
|
||||
template <typename T, size_t N>
|
||||
struct DecayArray<T[N]> {
|
||||
template <typename T> struct DecayArray { typedef T type; }; // NOLINT
|
||||
template <typename T, size_t N> struct DecayArray<T[N]> {
|
||||
typedef const T* type;
|
||||
};
|
||||
// Sometimes people use arrays whose size is not available at the use site
|
||||
// (e.g. extern const char kNamePrefix[]). This specialization covers that
|
||||
// case.
|
||||
template <typename T>
|
||||
struct DecayArray<T[]> {
|
||||
template <typename T> struct DecayArray<T[]> {
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
// Disable MSVC warnings for infinite recursion, since in this case the
|
||||
// the recursion is unreachable.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4717)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4717)
|
||||
#endif
|
||||
|
||||
// Invalid<T>() is usable as an expression of type T, but will terminate
|
||||
@ -399,7 +383,7 @@ inline T Invalid() {
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// 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) {
|
||||
// Ensures that RawContainer is not a const type.
|
||||
testing::StaticAssertTypeEq<RawContainer,
|
||||
GTEST_REMOVE_CONST_(RawContainer)>();
|
||||
GTEST_REMOVE_CONST_(RawContainer)>();
|
||||
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
|
||||
// represented as a (pointer, size) tuple.
|
||||
template <typename ElementPointer, typename Size>
|
||||
class StlContainerView<::testing::tuple<ElementPointer, Size>> {
|
||||
class StlContainerView< ::testing::tuple<ElementPointer, Size> > {
|
||||
public:
|
||||
typedef GTEST_REMOVE_CONST_(
|
||||
typename internal::PointeeOf<ElementPointer>::type) RawElement;
|
||||
@ -499,8 +483,7 @@ class StlContainerView<::testing::tuple<ElementPointer, Size>> {
|
||||
|
||||
// The following specialization prevents the user from instantiating
|
||||
// StlContainer with a reference type.
|
||||
template <typename T>
|
||||
class StlContainerView<T&>;
|
||||
template <typename T> class StlContainerView<T&>;
|
||||
|
||||
// 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,
|
||||
@ -512,7 +495,7 @@ struct RemoveConstFromKey {
|
||||
|
||||
// Partially specialized to remove constness from std::pair<const K, 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;
|
||||
};
|
||||
|
||||
@ -525,3 +508,4 @@ struct BooleanConstant {};
|
||||
} // namespace testing
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
||||
|
||||
|
||||
@ -40,8 +40,8 @@
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
// Most of the utilities needed for porting Google Mock are also
|
||||
// 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
|
||||
// here, as Google Mock depends on Google Test. Only add a utility
|
||||
// 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-port.h"
|
||||
#include "gmock/internal/custom/gmock-port.h"
|
||||
|
||||
// To avoid conditional compilation everywhere, we make it
|
||||
// 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
|
||||
// required to compile Google Mock.
|
||||
#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
|
||||
|
||||
// Macro for referencing flags. This is public as we want the user to
|
||||
@ -74,17 +74,17 @@
|
||||
// Macros for declaring flags.
|
||||
#define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(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) \
|
||||
extern GTEST_API_ ::std::string GMOCK_FLAG(name)
|
||||
extern GTEST_API_ ::std::string GMOCK_FLAG(name)
|
||||
|
||||
// Macros for defining flags.
|
||||
#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) \
|
||||
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) \
|
||||
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
|
||||
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
|
||||
|
||||
#endif // !defined(GMOCK_DECLARE_bool_)
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
#include <errno.h>
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#include "gmock/internal/gmock-port.h"
|
||||
@ -195,14 +195,14 @@ class Interface {
|
||||
virtual char* StringFromString(char* str) = 0;
|
||||
virtual int IntFromString(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 VoidFromFloat(float n) = 0;
|
||||
virtual void VoidFromDouble(double n) = 0;
|
||||
virtual void VoidFromVector(const std::vector<int>& v) = 0;
|
||||
};
|
||||
|
||||
class Mock : public Interface {
|
||||
class Mock: public Interface {
|
||||
public:
|
||||
Mock() {}
|
||||
|
||||
@ -210,7 +210,7 @@ class Mock : public Interface {
|
||||
MOCK_METHOD1(StringFromString, char*(char* str));
|
||||
MOCK_METHOD1(IntFromString, 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(VoidFromFloat, void(float n));
|
||||
MOCK_METHOD1(VoidFromDouble, void(double n));
|
||||
@ -296,8 +296,8 @@ TEST(LinkTest, TestSetArrayArgument) {
|
||||
char ch = 'x';
|
||||
char ch2 = 'y';
|
||||
|
||||
EXPECT_CALL(mock, VoidFromString(_))
|
||||
.WillOnce(SetArrayArgument<0>(&ch2, &ch2 + 1));
|
||||
EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,
|
||||
&ch2 + 1));
|
||||
mock.VoidFromString(&ch);
|
||||
}
|
||||
|
||||
@ -334,8 +334,8 @@ TEST(LinkTest, TestInvokeWithoutArgs) {
|
||||
|
||||
EXPECT_CALL(mock, VoidFromString(_))
|
||||
.WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
|
||||
.WillOnce(
|
||||
InvokeWithoutArgs(&test_invoke_helper, &InvokeHelper::VoidFromVoid));
|
||||
.WillOnce(InvokeWithoutArgs(&test_invoke_helper,
|
||||
&InvokeHelper::VoidFromVoid));
|
||||
mock.VoidFromString(NULL);
|
||||
mock.VoidFromString(NULL);
|
||||
}
|
||||
@ -419,14 +419,14 @@ TEST(LinkTest, TestThrow) {
|
||||
// is expanded and macro expansion cannot contain #pragma. Therefore
|
||||
// we suppress them here.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4100)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
// Tests the linkage of actions created using ACTION macro.
|
||||
namespace {
|
||||
ACTION(Return1) { return 1; }
|
||||
} // namespace
|
||||
}
|
||||
|
||||
TEST(LinkTest, TestActionMacro) {
|
||||
Mock mock;
|
||||
@ -438,7 +438,7 @@ TEST(LinkTest, TestActionMacro) {
|
||||
// Tests the linkage of actions created using ACTION_P macro.
|
||||
namespace {
|
||||
ACTION_P(ReturnArgument, ret_value) { return ret_value; }
|
||||
} // namespace
|
||||
}
|
||||
|
||||
TEST(LinkTest, TestActionPMacro) {
|
||||
Mock mock;
|
||||
@ -452,10 +452,10 @@ namespace {
|
||||
ACTION_P2(ReturnEqualsEitherOf, first, second) {
|
||||
return arg0 == first || arg0 == second;
|
||||
}
|
||||
} // namespace
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
TEST(LinkTest, TestActionP2Macro) {
|
||||
@ -487,7 +487,8 @@ TEST(LinkTest, TestMatchersEq) {
|
||||
const char* p = "x";
|
||||
|
||||
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.
|
||||
@ -586,7 +587,7 @@ TEST(LinkTest, TestMatcherElementsAre) {
|
||||
// Tests the linkage of the ElementsAreArray matcher.
|
||||
TEST(LinkTest, TestMatcherElementsAreArray) {
|
||||
Mock mock;
|
||||
char arr[] = {'a', 'b'};
|
||||
char arr[] = { 'a', 'b' };
|
||||
|
||||
ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());
|
||||
}
|
||||
|
||||
@ -165,24 +165,24 @@ GTEST_API_ bool InDeathTestChild();
|
||||
// Asserts that a given statement causes the program to exit, with an
|
||||
// integer exit status that satisfies predicate, and emitting error output
|
||||
// that matches regex.
|
||||
#define ASSERT_EXIT(statement, predicate, regex) \
|
||||
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
|
||||
# define ASSERT_EXIT(statement, predicate, regex) \
|
||||
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
|
||||
|
||||
// Like ASSERT_EXIT, but continues on to successive tests in the
|
||||
// test case, if any:
|
||||
#define EXPECT_EXIT(statement, predicate, regex) \
|
||||
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
|
||||
# define EXPECT_EXIT(statement, predicate, regex) \
|
||||
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
|
||||
|
||||
// Asserts that a given statement causes the program to exit, either by
|
||||
// explicitly exiting with a nonzero exit code or being killed by a
|
||||
// signal, and emitting error output that matches regex.
|
||||
#define ASSERT_DEATH(statement, regex) \
|
||||
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
|
||||
# define ASSERT_DEATH(statement, regex) \
|
||||
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
|
||||
|
||||
// Like ASSERT_DEATH, but continues on to successive tests in the
|
||||
// test case, if any:
|
||||
#define EXPECT_DEATH(statement, regex) \
|
||||
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
|
||||
# define EXPECT_DEATH(statement, regex) \
|
||||
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
|
||||
|
||||
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
|
||||
|
||||
@ -191,7 +191,6 @@ class GTEST_API_ ExitedWithCode {
|
||||
public:
|
||||
explicit ExitedWithCode(int exit_code);
|
||||
bool operator()(int exit_status) const;
|
||||
|
||||
private:
|
||||
// No implementation - assignment is unsupported.
|
||||
void operator=(const ExitedWithCode& other);
|
||||
@ -199,18 +198,17 @@ class GTEST_API_ ExitedWithCode {
|
||||
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
|
||||
// given signal.
|
||||
class GTEST_API_ KilledBySignal {
|
||||
public:
|
||||
explicit KilledBySignal(int signum);
|
||||
bool operator()(int exit_status) const;
|
||||
|
||||
private:
|
||||
const int signum_;
|
||||
};
|
||||
#endif // !GTEST_OS_WINDOWS
|
||||
# endif // !GTEST_OS_WINDOWS
|
||||
|
||||
// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
|
||||
// The death testing framework causes this to have interesting semantics,
|
||||
@ -255,21 +253,23 @@ class GTEST_API_ KilledBySignal {
|
||||
// EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
|
||||
// }, "death");
|
||||
//
|
||||
#ifdef NDEBUG
|
||||
# ifdef NDEBUG
|
||||
|
||||
#define EXPECT_DEBUG_DEATH(statement, regex) \
|
||||
# define EXPECT_DEBUG_DEATH(statement, regex) \
|
||||
GTEST_EXECUTE_STATEMENT_(statement, regex)
|
||||
|
||||
#define ASSERT_DEBUG_DEATH(statement, regex) \
|
||||
# define ASSERT_DEBUG_DEATH(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
|
||||
|
||||
// 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
|
||||
// assertions in one test.
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
EXPECT_DEATH(statement, regex)
|
||||
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
ASSERT_DEATH(statement, regex)
|
||||
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
EXPECT_DEATH(statement, regex)
|
||||
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
ASSERT_DEATH(statement, regex)
|
||||
#else
|
||||
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
|
||||
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return )
|
||||
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
|
||||
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
|
||||
@ -105,14 +105,14 @@ class GTEST_API_ Message {
|
||||
#if GTEST_OS_SYMBIAN
|
||||
// Streams a value (either a pointer or not) to this object.
|
||||
template <typename T>
|
||||
inline Message& operator<<(const T& value) {
|
||||
inline Message& operator <<(const T& value) {
|
||||
StreamHelper(typename internal::is_pointer<T>::type(), value);
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
// Streams a non-pointer value to this object.
|
||||
template <typename T>
|
||||
inline Message& operator<<(const T& val) {
|
||||
inline Message& operator <<(const T& val) {
|
||||
// Some libraries overload << for STL containers. These
|
||||
// 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,
|
||||
// overloads of << defined in the global namespace and those
|
||||
// visible via Koenig lookup are both exposed in this function.
|
||||
using ::operator<<;
|
||||
using ::operator <<;
|
||||
*ss_ << val;
|
||||
return *this;
|
||||
}
|
||||
@ -146,7 +146,7 @@ class GTEST_API_ Message {
|
||||
// ensure consistent result across compilers, we always treat NULL
|
||||
// as "(null)".
|
||||
template <typename T>
|
||||
inline Message& operator<<(T* const& pointer) { // NOLINT
|
||||
inline Message& operator <<(T* const& pointer) { // NOLINT
|
||||
if (pointer == NULL) {
|
||||
*ss_ << "(null)";
|
||||
} else {
|
||||
@ -162,29 +162,31 @@ class GTEST_API_ Message {
|
||||
// templatized version above. Without this definition, streaming
|
||||
// endl or other basic IO manipulators to Message will confuse the
|
||||
// compiler.
|
||||
Message& operator<<(BasicNarrowIoManip val) {
|
||||
Message& operator <<(BasicNarrowIoManip val) {
|
||||
*ss_ << val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// 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
|
||||
// using the UTF-8 encoding.
|
||||
Message& operator<<(const wchar_t* wide_c_str);
|
||||
Message& operator<<(wchar_t* wide_c_str);
|
||||
Message& operator <<(const wchar_t* wide_c_str);
|
||||
Message& operator <<(wchar_t* wide_c_str);
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
// Converts the given wide string to a narrow string using the UTF-8
|
||||
// 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
|
||||
|
||||
#if GTEST_HAS_GLOBAL_WSTRING
|
||||
// Converts the given wide string to a narrow string using the UTF-8
|
||||
// encoding, and streams the result to this Message object.
|
||||
Message& operator<<(const ::wstring& wstr);
|
||||
Message& operator <<(const ::wstring& wstr);
|
||||
#endif // GTEST_HAS_GLOBAL_WSTRING
|
||||
|
||||
// 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;
|
||||
|
||||
private:
|
||||
|
||||
#if GTEST_OS_SYMBIAN
|
||||
// These are needed as the Nokia Symbian Compiler cannot decide between
|
||||
// const T& and const T* in a function template. The Nokia compiler _can_
|
||||
@ -212,13 +215,13 @@ class GTEST_API_ Message {
|
||||
const T& value) {
|
||||
// See the comments in Message& operator <<(const T&) above for why
|
||||
// we need this using statement.
|
||||
using ::operator<<;
|
||||
using ::operator <<;
|
||||
*ss_ << value;
|
||||
}
|
||||
#endif // GTEST_OS_SYMBIAN
|
||||
|
||||
// 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
|
||||
// from implementing the assignment operator.
|
||||
@ -226,7 +229,7 @@ class GTEST_API_ Message {
|
||||
};
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user