refactor(*): remove FTypeInfo and replace it with the native std::type_info

This commit is contained in:
2022-05-12 23:36:32 +08:00
parent db5ed179c6
commit eeef55e9b4
11 changed files with 229 additions and 528 deletions

View File

@ -1,7 +1,6 @@
#include "Testing/MiscellaneousTesting.h"
#include "Miscellaneous/AssertionMacros.h"
#include "Miscellaneous/TypeInfo.h"
#include "Miscellaneous/Compare.h"
NAMESPACE_REDCRAFT_BEGIN
@ -14,7 +13,6 @@ void TestMiscellaneous()
{
TestAssertionMacros();
TestCompare();
TestTypeInfo();
}
NAMESPACE_UNNAMED_BEGIN
@ -219,35 +217,6 @@ void TestCompare()
always_check(SynthThreeWayCompare(FTestSynth( 0), FTestSynth(-1)) == weak_ordering::greater);
}
NAMESPACE_UNNAMED_BEGIN
template <typename...>
struct TTestTemplateType { };
NAMESPACE_UNNAMED_END
void TestTypeInfo()
{
const FTypeInfo& TempA = Typeid(void);
const FTypeInfo& TempB = Typeid(void);
always_check(TempA == TempB);
always_check(TempA == Typeid(void));
const FTypeInfo& TempC(Typeid(TTestTemplateType<int8, int16>));
const FTypeInfo& TempD = Typeid(TTestTemplateType<int8, int32>);
const FTypeInfo& TempE = TempC;
const FTypeInfo& TempF = TempD;
always_check(TempE != TempF);
always_check((TempE < TempF) == (TempF > TempE));
always_check((TempE > TempF) == (TempF < TempE));
always_check((TempE <= TempF) == (TempF >= TempE));
always_check((TempE >= TempF) == (TempF <= TempE));
always_check((TempE <=> TempF) != 0);
}
NAMESPACE_END(Testing)
NAMESPACE_MODULE_END(Utility)

View File

@ -339,11 +339,13 @@ void TestVariant()
const TVariant<int32> TempRD = TempLC;
auto ReturnRD = MoveTemp(TempRD).Visit<int32>(TestQualifiers);
always_check((TIsSame<int32, decltype(ReturnRD)>::Value));
}
{
always_check(GetTypeHash(TVariant<int32, float>(114)) == GetTypeHash(TVariant<int32, float>(114)));
always_check(GetTypeHash(TVariant<int32, float>(114)) != GetTypeHash(TVariant<int32, float>(514)));
}
{
TVariant<uint8, int16, int32> TempA = Invalid;
TVariant<uint8, int16, int32> TempB = static_cast<int16>(16);
@ -561,6 +563,11 @@ void TestAny()
TempZ = FTracker();
}
{
always_check(GetTypeHash(FAny(114)) == GetTypeHash(FAny(114)));
always_check(GetTypeHash(FAny(114)) != GetTypeHash(FAny(514)));
}
{
FAny TempA = Invalid;
FAny TempB = static_cast<int16>(16);
@ -1087,8 +1094,8 @@ void TestFunction()
always_check(TempC() == 0xEE);
always_check(TempD() == 0xFF);
always_check(TempC.TargetType() == Typeid(FFunctor));
always_check(TempD.TargetType() == Typeid(FFunctor));
always_check(TempC.TargetType() == typeid(FFunctor));
always_check(TempD.TargetType() == typeid(FFunctor));
}
{
@ -1203,7 +1210,7 @@ void TestFunction()
{
TFunction<bool(bool)> Identity = [](bool In) { return In; };
TFunction<bool(bool)> NotIdentity = NotFn(Identity);
always_check(Identity(true));
always_check(NotIdentity(false));
}