/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include namespace apache::thrift::test { template Struct gen() { Struct obj; obj.field1_ref().emplace(100, 1); obj.field2_ref().emplace(200, 2); obj.field3_ref().emplace(300, 3); obj.field4_ref().emplace(400, 4); return obj; } template struct Structs; template <> struct Structs { using Struct = Foo; using LazyStruct = LazyFoo; using IndexedStruct = IndexedFoo; }; template <> struct Structs { using Struct = OptionalFoo; using LazyStruct = OptionalLazyFoo; using IndexedStruct = OptionalIndexedFoo; }; template <> struct Structs { using Struct = TerseFoo; using LazyStruct = TerseLazyFoo; using IndexedStruct = IndexedFoo; }; template <> struct Structs { using Struct = TerseOptionalFoo; using LazyStruct = TerseOptionalLazyFoo; using IndexedStruct = OptionalIndexedFoo; }; template <> struct Structs { using Struct = FooNoChecksum; using LazyStruct = LazyFooNoChecksum; using IndexedStruct = IndexedFoo; }; template struct TypeParam : Structs { using Serializer = Serializer_; }; using TypeParams = ::testing::Types< TypeParam, TypeParam, TypeParam, TypeParam, TypeParam, TypeParam, TypeParam, TypeParam, TypeParam, TypeParam>; template struct LazyDeserialization : testing::Test { static auto genStruct() { return gen(); } static auto genLazyStruct() { return gen(); } template static std::string serialize(V&& v) { return T::Serializer::template serialize(std::forward(v)); } template static V deserialize(const std::string& s) { return T::Serializer::template deserialize(s); } template auto deserialize(const std::string& s, V&& v) { return T::Serializer::deserialize(s, std::forward(v)); } }; TYPED_TEST_SUITE(LazyDeserialization, TypeParams); } // namespace apache::thrift::test