Bug fix: correct RTTI for AttributeInvocable (#1004)

* Bug fix: correct RTTI for AttributeInvocable

* Allow test case to crash if RTTI is wrong

* Revert "Allow test case to crash if RTTI is wrong"

Based on PR feedback, this change adds no value to the test and is confusing.

This reverts commit 6c36065c3759d857cc16ab011d09167261181141.

* Remove perhaps confusing comments and add a more to the point comment

Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
yuriy0
2021-06-14 18:29:19 -04:00
committed by GitHub
parent a47b30c708
commit 12c7391bd7
2 changed files with 23 additions and 1 deletions
@@ -2010,6 +2010,28 @@ TEST_F(SerializeBasicTest, BasicTypeTest_Succeed)
}
/*
This test will dynamic cast (azrtti_cast) between incompatible types, which should always result in nullptr.
If this test fails, the RTTI declaration for the relevant type is incorrect.
*/
TEST_F(Serialization, AttributeRTTI)
{
{
AttributeInvocable<AZStd::function<AZStd::string(AZStd::string)>> fn([](AZStd::string x) { return x + x; });
Attribute* fnDownCast = &fn;
auto fnUpCast = azrtti_cast<AttributeInvocable<AZStd::function<int(int)>>*>(fnDownCast);
EXPECT_EQ(fnUpCast, nullptr);
}
{
AttributeFunction<AZStd::string(AZStd::string)> fn([](AZStd::string x) { return x + x; });
Attribute* fnDownCast = &fn;
auto fnUpCast = azrtti_cast<AttributeFunction<int(int)>*>(fnDownCast);
EXPECT_EQ(fnUpCast, nullptr);
}
}
/*
* Deprecation
*/