blob: 91bd95aa51abb2d3509b87a8802ebd6e7ed0ad7a [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#pragma once
#include <fidl/test/json/cpp/fidl.h>
#include "lib/fidl/cpp/fuzzing/traits.h"
#include "lib/fidl/cpp/internal/header.h"
// For ::std::max_element().
#include <algorithm>
// For uint64_t.
#include <stdint.h>
namespace fuzzing {
using Example_foo_Response = ::fidl::test::json::Example_foo_Response;
using Example_foo_Result = ::fidl::test::json::Example_foo_Result;
template <>
struct MinSize<Example_foo_Response> {
operator size_t() { return MinSize<int64_t>(); }
};
template <>
struct Allocate<Example_foo_Response> {
Example_foo_Response operator()(FuzzInput* src, size_t* size) {
ZX_ASSERT(*size >= MinSize<Example_foo_Response>());
const size_t slack_per_member =
(*size - MinSize<Example_foo_Response>()) / 1;
Example_foo_Response out;
size_t out_size;
out_size = MinSize<int64_t>() + slack_per_member;
out.y = Allocate<int64_t>{}(src, &out_size);
return out;
}
};
template <>
struct MinSize<Example_foo_Result> {
operator size_t() {
size_t sizes[] = {0, MinSize<Example_foo_Response>(), MinSize<uint32_t>()};
return 1 + *std::max_element(sizes, sizes + 2 + 1);
}
};
template <>
struct Allocate<Example_foo_Result> {
static_assert(2 > 0, "xunion must have at least one member");
Example_foo_Result operator()(FuzzInput* src, size_t* size) {
ZX_ASSERT(*size >= MinSize<Example_foo_Result>());
uint8_t selector;
ZX_ASSERT(src->CopyBytes(&selector, 1));
(*size)++;
Example_foo_Result out;
switch (selector % 2) {
case 0: {
out.set_response(Allocate<Example_foo_Response>{}(src, size));
break;
}
case 1: {
out.set_err(Allocate<uint32_t>{}(src, size));
break;
}
}
return out;
}
};
} // namespace fuzzing