/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include #include "UserTypes.h" namespace UnitTest { ////////////////////////////////////////////////////////////////////////// // Fixtures // Fixture for non-typed tests template class CompressedPairTest : public AllocatorsFixture { protected: void SetUp() override { AllocatorsFixture::SetUp(); } void TearDown() override { AllocatorsFixture::TearDown(); } }; template class CompressedPairSizeTest : public CompressedPairTest {}; namespace CompressedPairInternal { struct EmptyStruct {}; struct EmptyStructNonDerived {}; struct FinalEmptyStruct final {}; struct DerivedFromEmptyStruct : EmptyStruct { }; struct DerivedWithDataFromEmptyStruct : EmptyStruct { uint32_t m_value{}; }; } template struct CompressedPairTestConfig { using first_type = T1; using second_type = T2; static constexpr size_t max_expected_size = MaxExpectedSize; }; constexpr size_t pairSize = sizeof(AZStd::compressed_pair); using CompressedPairTestConfigs = ::testing::Types< CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig >; TYPED_TEST_CASE(CompressedPairTest, CompressedPairTestConfigs); using CompressedPairSizeTestConfigs = ::testing::Types< CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig , CompressedPairTestConfig >; TYPED_TEST_CASE(CompressedPairSizeTest, CompressedPairSizeTestConfigs); TYPED_TEST(CompressedPairTest, CompressedPairDefaultConstructorSucceeds) { AZStd::compressed_pair testPair; (void)testPair; } TYPED_TEST(CompressedPairTest, CompressedPairFirstElementConstructorSucceeds) { AZStd::compressed_pair testPair(typename TypeParam::first_type{}); (void)testPair; } TYPED_TEST(CompressedPairTest, CompressedPairSecondElementConstructorSucceeds) { AZStd::compressed_pair testPair(AZStd::skip_element_tag{}, typename TypeParam::second_type{}); (void)testPair; } TYPED_TEST(CompressedPairTest, CompressedPairPiecewiseElementConstructorSucceeds) { AZStd::compressed_pair testPair(AZStd::piecewise_construct_t{}, std::tuple<>{}, std::tuple<>{}); (void)testPair; } TYPED_TEST(CompressedPairSizeTest, CompressedPairUsesEmptyBaseOptimizationForClassSize) { static_assert(sizeof(TypeParam) <= TypeParam::max_expected_size, "Compressed Pair is not expected size"); } }