Small updates based on PR feedback.

main
AMZN-koppersr 5 years ago
parent 11b79f567a
commit afcbe4e02b

@ -49,6 +49,9 @@ namespace AZ
//! Note on pointers: The Json Serialization assumes that are always constructed, so a default JSON value of "{}" is interpret as
//! creating a new default instance even if the default value is a null pointer. A JSON Null needs to be explicitly stored in
//! the JSON Document in order to default or explicitly set a pointer to null.
//! Note on pointer memory: Objects created/destroyed by the Json Serialization for pointers require that the AZ_CLASS_ALLOCATOR is
//! declared and the object is created using aznew or memory is allocated using azmalloc. Without these the application may
//! crash if the Json Serialization tries to create or destroy an object pointed to by a pointer.
class JsonSerialization final
{
public:

@ -140,7 +140,7 @@ namespace JsonSerializationTests
ASSERT_NE(nullptr, ptrValue);
EXPECT_EQ(42, *ptrValue);
azfree(ptrValue, AZ::SystemAllocator, sizeof(int), AZStd::alignment_of<int>::value);
azfree(ptrValue, AZ::SystemAllocator, sizeof(int), alignof(int));
}
TEST_F(BaseJsonSerializerTests, ContinueLoading_DefaultToNullPointer_ValueLoadedCorrectly)
@ -155,7 +155,7 @@ namespace JsonSerializationTests
EXPECT_EQ(Processing::Completed, result.GetProcessing());
ASSERT_NE(nullptr, ptrValue);
azfree(ptrValue, AZ::SystemAllocator, sizeof(int), AZStd::alignment_of<int>::value);
azfree(ptrValue, AZ::SystemAllocator, sizeof(int), alignof(int));
}
TEST_F(BaseJsonSerializerTests, ContinueLoading_NullDeletesObject_ValueLoadedCorrectly)
@ -163,7 +163,7 @@ namespace JsonSerializationTests
using namespace AZ::JsonSerializationResult;
rapidjson::Value json(rapidjson::kNullType);
int* ptrValue = reinterpret_cast<int*>(azmalloc(sizeof(int), AZStd::alignment_of<int>::value, AZ::SystemAllocator));
int* ptrValue = reinterpret_cast<int*>(azmalloc(sizeof(int), alignof(int), AZ::SystemAllocator));
ResultCode result = ContinueLoading(&ptrValue, azrtti_typeid<int>(), json, *m_jsonDeserializationContext, Flags::ResolvePointer);

Loading…
Cancel
Save