34 lines
769 B
C++
34 lines
769 B
C++
#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;
|
|
}
|