test.cpp: Add (nowadays) misisng header, format fixes

这个提交包含在:
2025-11-04 21:49:40 +01:00
父节点 4cfdead5d0
当前提交 a2e3a8ff14

查看文件

@@ -1,6 +1,7 @@
#include "exile.hpp"
#include "assert.h"
#include <map>
#include <algorithm>
std::string sandboxed_reverse(std::string str)
{
@@ -43,18 +44,26 @@ int test_exile_launch_serializer()
{
static_assert(!std::is_trivially_copyable_v<not_trivially_copyable>);
auto serializer = [](const not_trivially_copyable &obj, char *buf, size_t n){
auto serializer = [](const not_trivially_copyable &obj, char *buf, size_t n)
{
serialize_stdstring<std::string>(obj.somecontent, buf, n);
return obj.somecontent.size();
};
auto deserializer = [](const char *buffer, size_t n) {
auto deserializer = [](const char *buffer, size_t n)
{
not_trivially_copyable obj;
obj.somecontent = deserialize_stdstring<std::string>(buffer, n);
return obj;
};
not_trivially_copyable result = exile_launch<not_trivially_copyable>(exile_init_policy(), serializer, deserializer, []() {not_trivially_copyable obj; obj.somecontent = "Just something"; return obj;});
not_trivially_copyable result = exile_launch<not_trivially_copyable>(exile_init_policy(), serializer, deserializer,
[]()
{
not_trivially_copyable obj;
obj.somecontent = "Just something";
return obj;
});
assert(result.somecontent == "Just something");
return 0;