mirror of
https://github.com/meekrosoft/fff
synced 2026-01-23 08:25:59 +01:00
Add tests to verify std::function works with capturing lambda
Introduce a test that uses a capturing lambda as a custom_fake. Signed-off-by: Yuval Peress <peress@google.com>
This commit is contained in:
29
test/src/fff_test_custom_function_template.cpp
Normal file
29
test/src/fff_test_custom_function_template.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Copyright 2022 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "fff_wrapper.hpp"
|
||||
|
||||
DEFINE_FFF_GLOBALS
|
||||
|
||||
FAKE_VOID_FUNC(do_stuff, int);
|
||||
|
||||
class FFFCustomFakeSuite : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
RESET_FAKE(do_stuff);
|
||||
FFF_RESET_HISTORY();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(FFFCustomFakeSuite, custom_cpp_fake_function)
|
||||
{
|
||||
int x = 0;
|
||||
do_stuff_fake.custom_fake = [&x](int i) {
|
||||
x = i;
|
||||
};
|
||||
do_stuff(5);
|
||||
ASSERT_EQ(5, x);
|
||||
}
|
||||
Reference in New Issue
Block a user