/* * 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 "IntegerPrimtitiveTestConfig.h" namespace UnitTest { using namespace AzToolsFramework; template struct QtWidgetLimitsFixture : public ToolsApplicationFixture { }; TYPED_TEST_CASE(QtWidgetLimitsFixture, IntegerPrimtitiveTestConfigs); TYPED_TEST(QtWidgetLimitsFixture, MinRange) { switch (AZ::IntegralTypeCompare()) { // Given an LY widget value type of equal signedness and size to QtWidgetValueType case AZ::IntegralTypeDiff::LSignedRSignedEqSize: { // Expect the minimum range of widget type to equal QtWidgetValueType EXPECT_EQ(QtWidgetLimits::Min(), std::numeric_limits::min()); EXPECT_EQ(QtWidgetLimits::Min(), std::numeric_limits::min()); break; } // Given an LY widget type of equal signedness but wider than QtWidgetValueType case AZ::IntegralTypeDiff::LSignedRSignedLWider: { // Expect the minimum range of widget type to be clamped to the range of QtWidgetValueType EXPECT_NE(QtWidgetLimits::Min(), std::numeric_limits::min()); EXPECT_EQ(QtWidgetLimits::Min(), std::numeric_limits::min()); break; } // Given an LY widget type with a minimum range greater than the range of QtWidgetValueType case AZ::IntegralTypeDiff::LSignedRSignedRWider: case AZ::IntegralTypeDiff::LUnsignedRSignedLWider: case AZ::IntegralTypeDiff::LUnsignedRSignedEqSize: case AZ::IntegralTypeDiff::LUnsignedRSignedRWider: { // Expect the minimum range of widget type to be greater than the minimum range of QtWidgetValueType EXPECT_EQ(QtWidgetLimits::Min(), std::numeric_limits::min()); EXPECT_NE(QtWidgetLimits::Min(), std::numeric_limits::min()); break; } default: FAIL(); } } TYPED_TEST(QtWidgetLimitsFixture, MaxRange) { switch (AZ::IntegralTypeCompare()) { // Given an LY widget value type of equal signedness and size to QtWidgetValueType case AZ::IntegralTypeDiff::LSignedRSignedEqSize: { // Expect the maximum range of widget type to equal QtWidgetValueType EXPECT_EQ(QtWidgetLimits::Max(), std::numeric_limits::max()); EXPECT_EQ(QtWidgetLimits::Max(), std::numeric_limits::max()); break; } // Given an LY widget type with a maximum range greater than the range of QtWidgetValueType case AZ::IntegralTypeDiff::LSignedRSignedLWider: case AZ::IntegralTypeDiff::LUnsignedRSignedLWider: case AZ::IntegralTypeDiff::LUnsignedRSignedEqSize: { // Expect the maximum range of widget type to be clamped to the range of QtWidgetValueType EXPECT_NE(QtWidgetLimits::Max(), std::numeric_limits::max()); EXPECT_EQ(QtWidgetLimits::Max(), std::numeric_limits::max()); break; } // Given an LY widget type with a maximum range less than the range of QtWidgetValueType case AZ::IntegralTypeDiff::LUnsignedRSignedRWider: case AZ::IntegralTypeDiff::LSignedRSignedRWider: { // Expect the maximum range of widget type to be less than the minimum range of QtWidgetValueType EXPECT_EQ(QtWidgetLimits::Max(), std::numeric_limits::max()); EXPECT_NE(QtWidgetLimits::Max(), std::numeric_limits::max()); break; } default: FAIL(); } } } // namespace UnitTest