25 lines
709 B
C++
25 lines
709 B
C++
#include <Void/Testing/Assert.hpp>
|
|
#include <Void/Testing/Test.hpp>
|
|
#include <Void/TestingMock/MockFunction.hpp>
|
|
|
|
#include <memory>
|
|
|
|
// std::move_only_function support: a unique_ptr-capturing lambda used to
|
|
// fail to compile against std::function. With Phase 2.3.4 the action
|
|
// holder is std::move_only_function, so this works.
|
|
Void::Testing::Test invokes_accepts_unique_ptr_capturing_lambda()
|
|
{
|
|
using namespace Void::TestingMock;
|
|
MockFunction<int(int)> fn{"counter"};
|
|
|
|
auto state = std::make_unique<int>(10);
|
|
|
|
fn.expect(_<int>())
|
|
.invokes(
|
|
[s = std::move(state)](int delta) -> int { return *s + delta; })
|
|
.times(2);
|
|
|
|
Void::Testing::expect_eq(fn(1), 11);
|
|
Void::Testing::expect_eq(fn(5), 15);
|
|
}
|