From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- .../TransferFunctions/RemapPPtrTransferTests.cpp | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Runtime/Serialize/TransferFunctions/RemapPPtrTransferTests.cpp (limited to 'Runtime/Serialize/TransferFunctions/RemapPPtrTransferTests.cpp') diff --git a/Runtime/Serialize/TransferFunctions/RemapPPtrTransferTests.cpp b/Runtime/Serialize/TransferFunctions/RemapPPtrTransferTests.cpp new file mode 100644 index 0000000..ea4710b --- /dev/null +++ b/Runtime/Serialize/TransferFunctions/RemapPPtrTransferTests.cpp @@ -0,0 +1,57 @@ +#include "UnityPrefix.h" +#include "Configuration/UnityConfigure.h" + +#if ENABLE_UNIT_TESTS + +#include "Runtime/Testing/Testing.h" +#include "Runtime/Testing/TestFixtures.h" + +SUITE (RemapPPtrTransferTests) +{ + //------------------------------------------------------------------------- + + DEFINE_TRANSFER_TEST_FIXTURE (DoesNotTouchNonPPtrProperty) + { + UnityStr m_NonPPtrProperty = "test"; + TRANSFER (m_NonPPtrProperty); + CHECK (m_NonPPtrProperty == "test"); + } + + TEST_FIXTURE (DoesNotTouchNonPPtrPropertyTestFixture, Transfer_WithNonPPtrProperty_DoesNotChangeProperty) + { + DoRemapPPtrTransfer (); + } + + //------------------------------------------------------------------------- + + DEFINE_TRANSFER_TEST_FIXTURE (RemapsPPtrProperty) + { + PPtr m_PPtrProperty (1234); + TRANSFER (m_PPtrProperty); + CHECK (m_PPtrProperty.GetInstanceID () == 4321); + } + + TEST_FIXTURE (RemapsPPtrPropertyTestFixture, Transfer_WithPPtrProperty_MapsToNewInstanceID) + { + AddPPtrRemap (1234, 4321); + DoRemapPPtrTransfer (); + } + + //------------------------------------------------------------------------- + + DEFINE_TRANSFER_TEST_FIXTURE (DidReadLastPPtrProperty) + { + PPtr m_PPtrProperty; + TRANSFER (m_PPtrProperty); + CHECK (transfer.DidReadLastPPtrProperty ()); + } + + TEST_FIXTURE (DidReadLastPPtrPropertyTestFixture, DidReadLastPPtrProperty_WithPPtrProperty_IsTrue) + { + DoRemapPPtrTransfer (); + } + +} //TEST + +#endif // ENABLE_UNIT_TESTS + -- cgit v1.1-26-g67d0