/* * Copyright (c) Contributors to the Open 3D Engine Project * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include #include #include #include #include namespace NumericalMethods { void ExpectClose(const VectorVariable& actual, const VectorVariable& expected, double tolerance) { ASSERT_TRUE(actual.GetDimension() == expected.GetDimension()); for (AZ::u32 i = 0; i < actual.GetDimension(); i++) { EXPECT_NEAR(actual[i], expected[i], tolerance); } } void ExpectClose(const AZStd::vector& actual, const AZStd::vector& expected, double tolerance) { ASSERT_TRUE(actual.size() == expected.size()); for (AZ::u32 i = 0; i < actual.size(); i++) { EXPECT_NEAR(actual[i], expected[i], tolerance); } } // Global test environment. class NumericalMethodsTestEnvironment : public AZ::Test::ITestEnvironment { protected: void SetupEnvironment() override; void TeardownEnvironment() override; AZ::ComponentApplication* m_application; AZ::Entity* m_systemEntity; }; void NumericalMethodsTestEnvironment::SetupEnvironment() { #if AZ_TRAIT_UNITTEST_USE_TEST_RUNNER_ENVIRONMENT AZ::EnvironmentInstance inst = AZ::Test::GetPlatform().GetTestRunnerEnvironment(); AZ::Environment::Attach(inst); #endif AZ::AllocatorInstance::Create(); // Create application and descriptor m_application = aznew AZ::ComponentApplication; AZ::ComponentApplication::Descriptor appDesc; appDesc.m_useExistingAllocator = true; // Create system entity AZ::ComponentApplication::StartupParameters startupParams; m_systemEntity = m_application->Create(appDesc, startupParams); AZ_TEST_ASSERT(m_systemEntity); m_systemEntity->AddComponent(aznew AZ::MemoryComponent()); m_systemEntity->Init(); m_systemEntity->Activate(); } void NumericalMethodsTestEnvironment::TeardownEnvironment() { delete m_application; AZ::AllocatorInstance::Destroy(); } } // namespace NumericalMethods AZ_UNIT_TEST_HOOK(new NumericalMethods::NumericalMethodsTestEnvironment);