/* * 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. * */ #pragma once #include #include #include #include "PythonTraceMessageSink.h" #include "PythonTestingUtility.h" #include #include #include #include #include #include #include namespace UnitTest { ////////////////////////////////////////////////////////////////////////// // test class/structs struct MyCustomType { AZ_TYPE_INFO(MyCustomType, "{E4BE9816-E3E0-49EA-99B0-D72403461548}"); public: AZ::u8 m_data; void SetData(AZ::u8 v) { m_data = v; } AZ::u8 GetData() const { return m_data; } static void Reflect(AZ::ReflectContext* context) { if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) { serializeContext->Class() ->Version(1) ->Field("data", &MyCustomType::m_data) ; } if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) { behaviorContext->Class("MyCustomType") ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation) ->Attribute(AZ::Script::Attributes::Module, "test.pair") ->Method("set_data", &MyCustomType::SetData) ->Method("get_data", &MyCustomType::GetData) ; } } }; } // AZStd::hash specialization for UnitTest::MyCustomType, required by BehaviorContext for AZStd::pair with custom types. template<> struct AZStd::hash { typedef UnitTest::MyCustomType argument_type; typedef AZStd::size_t result_type; constexpr result_type operator()(const argument_type& value) const { return AZStd::hash()(value.m_data); } };