Consolidate various to_string implementations for math classes
Signed-off-by: puvvadar <puvvadar@amazon.com>
This commit is contained in:
@@ -665,6 +665,8 @@ namespace UnitTest
|
||||
EXPECT_EQ("20", AZStd::to_string(static_cast<uint32_t>(20)));
|
||||
EXPECT_EQ("20", AZStd::to_string(static_cast<int64_t>(20)));
|
||||
EXPECT_EQ("20", AZStd::to_string(static_cast<uint64_t>(20)));
|
||||
EXPECT_EQ("false", AZStd::to_string(false));
|
||||
EXPECT_EQ("true", AZStd::to_string(true));
|
||||
|
||||
// wstring to string
|
||||
AZStd::string str1;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <AzCore/Math/Matrix4x4.h>
|
||||
#include <AzCore/Math/Quaternion.h>
|
||||
#include <AzCore/Math/Sphere.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/Vector4.h>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
|
||||
#include <AzCore/Math/MathStringConversions.h>
|
||||
#include <AzCore/Math/Aabb.h>
|
||||
#include <AzCore/Math/Color.h>
|
||||
#include <AzCore/Math/Matrix3x3.h>
|
||||
#include <AzCore/Math/Matrix3x4.h>
|
||||
#include <AzCore/Math/Matrix4x4.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Quaternion.h>
|
||||
#include <AzCore/Math/Vector2.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class MathStrings : public AllocatorsTestFixture
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
TEST_F(MathStrings, TestVectorStringConverters)
|
||||
{
|
||||
AZ::Vector2 vec2 = AZ::Vector2::CreateOne();
|
||||
AZ::Vector3 vec3 = AZ::Vector3::CreateOne();
|
||||
AZ::Vector4 vec4 = AZ::Vector4::CreateOne();
|
||||
AZ::Quaternion quat = AZ::Quaternion::CreateIdentity();
|
||||
|
||||
EXPECT_EQ(AZStd::to_string(vec2), "1.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(vec3), "1.00000000,1.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(vec4), "1.00000000,1.00000000,1.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(quat), "0.00000000,0.00000000,0.00000000,1.00000000");
|
||||
}
|
||||
|
||||
TEST_F(MathStrings, TestMatrixStringConverters)
|
||||
{
|
||||
AZ::Matrix3x3 mat33 = AZ::Matrix3x3::CreateIdentity();
|
||||
AZ::Matrix4x4 mat44 = AZ::Matrix4x4::CreateIdentity();
|
||||
AZ::Transform xform = AZ::Transform::CreateIdentity();
|
||||
|
||||
EXPECT_EQ(AZStd::to_string(mat33), "1.00000000,0.00000000,0.00000000\n0.00000000,1.00000000,0.00000000\n0.00000000,0.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(mat44), "1.00000000,0.00000000,0.00000000,0.00000000\n0.00000000,1.00000000,0.00000000,0.00000000\n0.00000000,0.00000000,1.00000000,0.00000000\n0.00000000,0.00000000,0.00000000,1.00000000");
|
||||
EXPECT_EQ(AZStd::to_string(xform), "0.00000000,0.00000000,0.00000000\n0.00000000,0.00000000,0.00000000\n0.00000000,0.00000000,0.00000000\n0.00000000,0.00000000,0.00000000");
|
||||
|
||||
}
|
||||
|
||||
TEST_F(MathStrings, TestAabbStringConverter)
|
||||
{
|
||||
AZ::Aabb aabb = AZ::Aabb::CreateFromMinMaxValues(0.f, 0.f, 0.f, 1.f, 1.f, 1.f);
|
||||
EXPECT_EQ(AZStd::to_string(aabb), "0.00000000,0.00000000,0.00000000\n1.00000000,1.00000000,1.00000000");
|
||||
}
|
||||
|
||||
TEST_F(MathStrings, TestColorStringConverter)
|
||||
{
|
||||
EXPECT_EQ(AZStd::to_string(AZ::Colors::Black), "R:0, G:0, B:0 A:0");
|
||||
}
|
||||
}
|
||||
@@ -140,6 +140,7 @@ set(FILES
|
||||
Math/FrustumPerformanceTests.cpp
|
||||
Math/IntersectionTests.cpp
|
||||
Math/MathIntrinsicsTests.cpp
|
||||
Math/MathStringsTests.cpp
|
||||
Math/MathUtilsTests.cpp
|
||||
Math/Matrix3x3PerformanceTests.cpp
|
||||
Math/Matrix3x3Tests.cpp
|
||||
|
||||
Reference in New Issue
Block a user