chromium/third_party/perfetto/src/protozero/test/cppgen_conformance_unittest.cc

/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * 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 <limits>
#include <memory>
#include <vector>

#include "perfetto/protozero/message_handle.h"
#include "perfetto/protozero/packed_repeated_fields.h"
#include "test/gtest_and_gmock.h"

// Autogenerated headers in out/*/gen/
#include "src/protozero/test/example_proto/library.gen.h"
#include "src/protozero/test/example_proto/other_package/test_messages.gen.h"
#include "src/protozero/test/example_proto/subpackage/test_messages.gen.h"
#include "src/protozero/test/example_proto/test_messages.gen.h"
#include "src/protozero/test/example_proto/test_messages.pb.h"

// Generated by the cppgen compiler.
namespace pbtest = protozero::test::protos::gen;
namespace pbtest_subpackage = protozero::test::protos::subpackage::gen;
namespace pbtest_otherpackage = other_package::gen;

// Generated by the official protobuf compiler.
namespace pbgold = protozero::test::protos;
namespace pbgold_subpackage = protozero::test::protos::subpackage;
namespace pbgold_other_package = other_package;

namespace protozero {
namespace {

ElementsAreArray;

// The two functions below are templated because they are re-used both on the
// libprotobuf and protozero versions to check both libproto -> zero and
// zero -> libproto compatibility.
template <typename T>
void SetTestingFields(T* msg) {}

template <typename T>
void CheckTestingFields(const T& msg) {}

TEST(ProtoCppConformanceTest, GenEncode_GoldDecode) {}

TEST(ProtoCppConformanceTest, GoldEncode_GenDecode) {}

TEST(ProtoCppConformanceTest, GenEncode_GenDecode) {}

TEST(ProtoCppConformanceTest, NestedMessages) {}

// Tests that unknown fields are preserved when re-serializing. This test uses
// the messages NestedA and NestedA_V2, where NestedA_V2 mimics a future
// extension of NestedA. It starts filling the V2 version, than decodes it with
// V1, then re-encodes V1 and decodes with V2 and finally check that all the V2
// original fields have been preserved.
TEST(ProtoCppConformanceTest, PreserveUnknownFields) {}

// Checks that unset fields aren't zero-initialized in the decode -> re-encode
// process.
TEST(ProtoCppConformanceTest, DontDefaultInitialize) {}

// Tests serialization and deserialization of packed encoding fields.
TEST(ProtoCppConformanceTest, PackedRepeatedFields) {}

TEST(ProtoCppConformanceTest, DifferentPackages) {}
}  // namespace
}  // namespace protozero