/* * 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. */ #include #include #include #include #include #include using namespace std; using namespace apache::thrift; using namespace apache::thrift::test; namespace { class F14RoundTripTest : public testing::Test {}; } // namespace // F14Vector* containers have the additional guarantee (over unordered // containers) that iteration order roundtrips. TEST_F(F14RoundTripTest, RoundTrip) { StructWithF14VectorContainers s0; for (size_t i = 0; i < 5; ++i) { s0.m_ref()->emplace(i, i); s0.s_ref()->emplace(i); } const auto serialized = CompactSerializer::serialize(s0); StructWithF14VectorContainers s1; CompactSerializer::deserialize(serialized, s1); auto as_vector = [](const auto& c) { return vector::value_type>( c.begin(), c.end()); }; EXPECT_EQ(as_vector(*s0.m_ref()), as_vector(*s1.m_ref())); EXPECT_EQ(as_vector(*s0.s_ref()), as_vector(*s1.s_ref())); }