feat(testing-mock): complete P2 M-TESTINGMOCK-01..04 sessions, action-outside-lock, move-only, combinators

This commit is contained in:
faumaray committed 2026-11-27 01:15:36 +03:00
1 parent 86d777eae6
commit 658c21a2fa
8 files changed
+1702 -30

No files matched your search

+6 -1
View File
@@ -292,7 +292,7 @@ if(_has_fsm)
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
endif()
has_modules(_has_net Net Functional Text)
has_modules(_has_net Net Functional Text Time)
if(_has_net)
run_consumer(NetOnly "${install_prefix}" "NetOnly"
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
@@ -300,6 +300,11 @@ if(_has_net)
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
endif()
has_modules(_has_testing_mock TestingMock Testing Functional Core)
if(_has_testing_mock)
run_consumer(TestingMockOnly "${install_prefix}" "TestingMockOnly" ${_no_external_deps})
endif()
# Foundation consumer with Core-formatting bridge and zero external packages.
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Memory Core)
if(_has_foundation)
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 4.0)
project(VoidTestingMockOnlyConsumer LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Void CONFIG REQUIRED COMPONENTS TestingMock)
add_executable(testing_mock_only_consumer main.cpp)
target_link_libraries(testing_mock_only_consumer PRIVATE Void::TestingMock)
enable_testing()
add_test(NAME testing_mock_only_consumer COMMAND testing_mock_only_consumer)
+33
View File
@@ -0,0 +1,33 @@
#include <Void/TestingMock/Matcher.hpp>
#include <Void/TestingMock/MockFunction.hpp>
#include <Void/TestingMock/Session.hpp>
#include <memory>
#include <string>
int main()
{
using namespace Void::TestingMock;
MockSession session;
MockFunction<std::unique_ptr<int>(std::string)> fn{session, "lookup"};
auto exp = fn.try_expect(
AllOf<std::string>(StartsWith<std::string>("k_"),
EndsWith<std::string>("_1")));
if (!exp.has_value()) {
return 1;
}
(*exp)->returns_once(std::make_unique<int>(42));
if (!freeze(session, Concurrency::SingleThread).has_value()) {
return 2;
}
auto out = fn("k_ok_1");
if (!out || *out != 42) {
return 3;
}
auto rep = verify_and_close(session);
if (!rep.has_value() || !rep->ok()) {
return 4;
}
return 0;
}