|
|
|
@ -295,42 +295,10 @@ TEST_F(StoreTest, delete_test)
|
|
|
|
|
ASSERT_TRUE(mEsmStore.get<RecordType>().getSize() == 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class T, class = std::void_t<>>
|
|
|
|
|
struct HasRecordId : std::false_type
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
|
struct HasRecordId<T, std::void_t<decltype(T::sRecordId)>> : std::true_type
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct RecNameIntChar
|
|
|
|
|
{
|
|
|
|
|
char name[6];
|
|
|
|
|
RecNameIntChar(ESM::RecNameInts recName)
|
|
|
|
|
{
|
|
|
|
|
unsigned int FourCC = recName & ~ESM::sEsm4RecnameFlag; // Removes the flag
|
|
|
|
|
name[0] = FourCC & 0xFF;
|
|
|
|
|
name[1] = (FourCC >> 8) & 0xFF;
|
|
|
|
|
name[2] = (FourCC >> 16) & 0xFF;
|
|
|
|
|
name[3] = (FourCC >> 24) & 0xFF;
|
|
|
|
|
if (ESM::isESM4Rec(recName))
|
|
|
|
|
{
|
|
|
|
|
name[4] = '4';
|
|
|
|
|
name[5] = '\0';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
name[4] = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
static unsigned int hasSameRecordId(const MWWorld::Store<T>& store, ESM::RecNameInts RecName)
|
|
|
|
|
{
|
|
|
|
|
if constexpr (HasRecordId<T>::value)
|
|
|
|
|
if constexpr (MWWorld::HasRecordId<T>::value)
|
|
|
|
|
{
|
|
|
|
|
return T::sRecordId == RecName ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
@ -343,16 +311,15 @@ static unsigned int hasSameRecordId(const MWWorld::Store<T>& store, ESM::RecName
|
|
|
|
|
template <typename T>
|
|
|
|
|
static void testRecNameIntCount(const MWWorld::Store<T>& store, const MWWorld::ESMStore::StoreTuple& stores)
|
|
|
|
|
{
|
|
|
|
|
if constexpr (HasRecordId<T>::value)
|
|
|
|
|
if constexpr (MWWorld::HasRecordId<T>::value)
|
|
|
|
|
{
|
|
|
|
|
const unsigned int recordIdCount
|
|
|
|
|
= std::apply([](auto&&... x) { return (hasSameRecordId(x, T::sRecordId) + ...); }, stores);
|
|
|
|
|
if (recordIdCount != 1)
|
|
|
|
|
{
|
|
|
|
|
std::cout << "The same RecNameInt is used twice ESM::REC_" + std::string(RecNameIntChar(T::sRecordId).name)
|
|
|
|
|
<< std::endl;
|
|
|
|
|
}
|
|
|
|
|
ASSERT_TRUE(recordIdCount == 1);
|
|
|
|
|
std::string RecordIdName(ESM::NAME(T::sRecordId & ~ESM::sEsm4RecnameFlag).toStringView());
|
|
|
|
|
if (ESM::isESM4Rec(T::sRecordId))
|
|
|
|
|
RecordIdName += '4';
|
|
|
|
|
|
|
|
|
|
ASSERT_EQ(recordIdCount, 1) << "The same RecNameInt is used twice ESM::REC_" << RecordIdName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -361,7 +328,7 @@ static void testAllRecNameIntUnique(const MWWorld::ESMStore::StoreTuple& stores)
|
|
|
|
|
std::apply([&stores](auto&&... x) { (testRecNameIntCount(x, stores), ...); }, stores);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(StoreTest, recordId_Unique) // Test that each type has a unique recordId
|
|
|
|
|
TEST_F(StoreTest, eachRecordTypeShouldHaveUniqueRecordId)
|
|
|
|
|
{
|
|
|
|
|
testAllRecNameIntUnique(MWWorld::ESMStore::StoreTuple());
|
|
|
|
|
}
|
|
|
|
|