File indexing completed on 2024-09-22 04:53:11

0001 /*
0002  * SPDX-FileCopyrightText: 2008 Trevor Pounds
0003  * SPDX-License-Identifier: MIT
0004  */
0005 
0006 #ifndef __MOCKITOPP_MATCHER_NOT_HPP__
0007 #define __MOCKITOPP_MATCHER_NOT_HPP__
0008 
0009 #include <mockitopp/matchers/Matcher.hpp>
0010 
0011 namespace mockitopp
0012 {
0013    namespace matcher
0014    {
0015       namespace detail
0016       {
0017          template <typename T>
0018          struct NotT : public Matcher<T>
0019          {
0020             NotT(const Matcher<T>& matcher)
0021                : matcher_(matcher.clone())
0022                {}
0023 
0024             virtual ~NotT()
0025                { delete matcher_; }
0026 
0027             virtual Matcher<T>* clone() const
0028                { return new NotT(*matcher_); }
0029 
0030             virtual bool operator== (typename mockitopp::detail::tr1::add_reference<typename mockitopp::detail::tr1::add_const<T>::type>::type rhs) const
0031                { return !(*matcher_ == rhs); }
0032 
0033             private:
0034 
0035                Matcher<T>* matcher_;
0036          };
0037       } // namespace detail
0038 
0039       template <typename T>
0040       detail::NotT<T> is_not(const Matcher<T>& matcher)
0041          { return detail::NotT<T>(matcher); }
0042    } // namespace matcher
0043 } // namespace mockitopp
0044 
0045 #endif //__MOCKITOPP_MATCHER_EQ_HPP__