1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  *     Copyright 2020-Present Couchbase, Inc.
4  *
5  *   Use of this software is governed by the Business Source License included
6  *   in the file licenses/BSL-Couchbase.txt.  As of the Change Date specified
7  *   in that file, in accordance with the Business Source License, use of this
8  *   software will be governed by the Apache License, Version 2.0, included in
9  *   the file licenses/APL2.txt.
10  */
11 #pragma once
12 
13 #include <folly/portability/GMock.h>
14 
15 #include <functional>
16 
17 // MockFunction.AsStdFunction exists, but due to MB-37860 could not
18 // be used under windows. For now, this serves as a replacement
19 template <class Return, class... Args>
asStdFunction(testing::MockFunction<Return (Args...)> & mockFunction)20 std::function<Return(Args...)> asStdFunction(
21         testing::MockFunction<Return(Args...)>& mockFunction) {
22     return [&mockFunction](Args&&... args) {
23         return mockFunction.Call(std::forward<Args>(args)...);
24     };
25 }