Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gmock_set_arg.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef GMOCK_SET_ARG_H_
20 #define GMOCK_SET_ARG_H_
21 
22 #include <gmock/gmock.h>
23 
24 namespace testing
25 {
26 namespace internal
27 {
28 template <size_t N, typename A, bool kIsProto>
30  public:
31  // Constructs an action that sets the variable pointed to by the
32  // N-th function argument to 'value'.
33  explicit SetArgumentAction(const A& value) : value_(value) {}
34 
35  template <typename Result, typename ArgumentTuple>
36  void Perform(const ArgumentTuple& args) const {
37  CompileAssertTypesEqual<void, Result>();
38  ::std::tr1::get<N>(args) = value_;
39  }
40 
41  private:
42  const A value_;
43 
44  GTEST_DISALLOW_ASSIGN_(SetArgumentAction);
45 };
46 }
47 template <size_t N, typename T>
48 PolymorphicAction<
49  internal::SetArgumentAction<
50  N, T, internal::IsAProtocolMessage<T>::value> >
51 SetArg(const T& x) {
52  return MakePolymorphicAction(internal::SetArgumentAction<
53  N, T, internal::IsAProtocolMessage<T>::value>(x));
54 }
55 }
56 
57 #endif /* GMOCK_SET_ARG_H_ */
Definition: gmock_set_arg.h:29
Definition: dimensions.h:35
PolymorphicAction< internal::SetArgumentAction< N, T, internal::IsAProtocolMessage< T >::value > > SetArg(const T &x)
Definition: gmock_set_arg.h:51
void Perform(const ArgumentTuple &args) const
Definition: gmock_set_arg.h:36
SetArgumentAction(const A &value)
Definition: gmock_set_arg.h:33

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014