amoeba commented on code in PR #41018: URL: https://github.com/apache/arrow/pull/41018#discussion_r1556222185
########## cpp/src/arrow/ipc/message_internal_test.cc: ########## @@ -0,0 +1,85 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 <flatbuffers/flatbuffers.h> +#include <gtest/gtest.h> +#include <memory> + +#include "arrow/buffer.h" +#include "arrow/ipc/dictionary.h" +#include "arrow/ipc/metadata_internal.h" +#include "arrow/ipc/options.h" +#include "arrow/memory_pool.h" +#include "arrow/testing/gtest_util.h" +#include "arrow/util/key_value_metadata.h" + +namespace arrow { + +namespace flatbuf = org::apache::arrow::flatbuf; + +namespace ipc { +namespace internal { + +using FBB = flatbuffers::FlatBufferBuilder; + +// GH-40361: Test that Flatbuffer serialization matches a known output +// byte-for-byte. +// +// Our Flatbuffers code should not depend on argument evaluation order as it's +// undefined (https://en.cppreference.com/w/cpp/language/eval_order) and may +// lead to unnecessary platform- or toolchain-specific differences in +// serialization. +TEST(TestMessageInternal, TestByteIdentical) { + FBB fbb; + flatbuffers::Offset<flatbuf::Schema> fb_schema; + DictionaryFieldMapper mapper; + + // Create a simple Schema with just one metadata KVP + auto f0 = field("f0", int64()); + std::vector<std::shared_ptr<Field>> fields = {f0}; + std::shared_ptr<KeyValueMetadata> metadata = + KeyValueMetadata::Make({"my_key"}, {"my_value"}); + auto schema = ::arrow::schema({f0}, metadata); Review Comment: Good point, done in 2e32daaabb79b7b2be7d7a49d6fde9b4de228c3b. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
