Browse Source

Trade: test handling of MeshData and SceneData over 4 GB.

Passes for SceneData but fails for MeshData due to 32-bit types used by
accident. The two also have a vastly different calculations in the range
checks, should unify that first.
pull/617/head
Vladimír Vondruš 3 years ago
parent
commit
0679cccdf3
  1. 33
      src/Magnum/Trade/Test/MeshDataTest.cpp
  2. 34
      src/Magnum/Trade/Test/SceneDataTest.cpp

33
src/Magnum/Trade/Test/MeshDataTest.cpp

@ -114,6 +114,11 @@ struct MeshDataTest: TestSuite::Tester {
void constructIndexlessNotOwned();
void constructAttributelessNotOwned();
#ifndef CORRADE_TARGET_32BIT
void constructIndicesOver4GB();
void constructAttributeOver4GB();
#endif
void constructIndexDataButNotIndexed();
void constructAttributelessImplicitVertexCount();
void constructIndicesNotContained();
@ -299,6 +304,11 @@ MeshDataTest::MeshDataTest() {
&MeshDataTest::constructAttributelessNotOwned},
Containers::arraySize(SingleNotOwnedData));
#ifndef CORRADE_TARGET_32BIT
addTests({&MeshDataTest::constructIndicesOver4GB,
&MeshDataTest::constructAttributeOver4GB});
#endif
addTests({&MeshDataTest::constructIndexDataButNotIndexed,
&MeshDataTest::constructAttributelessImplicitVertexCount,
&MeshDataTest::constructIndicesNotContained,
@ -2245,6 +2255,29 @@ void MeshDataTest::constructAttributelessNotOwned() {
CORRADE_COMPARE(data.attributeCount(), 0);
}
#ifndef CORRADE_TARGET_32BIT
void MeshDataTest::constructIndicesOver4GB() {
/* For some reason 2500 doesn't trigger an assertion, 3000 does */
Containers::ArrayView<UnsignedInt> indexData{reinterpret_cast<UnsignedInt*>(0xdeadbeef), 3000ull*1000*1000};
MeshIndexData indices{indexData};
MeshData data{MeshPrimitive::Triangles, {}, indexData, indices, 5};
CORRADE_COMPARE(data.indices().data(), indexData.begin());
CORRADE_COMPARE(data.indices<UnsignedInt>().size(), indexData.size());
}
void MeshDataTest::constructAttributeOver4GB() {
/* For some reason 2500 doesn't trigger an assertion, 3000 does */
Containers::ArrayView<UnsignedInt> vertexData{reinterpret_cast<UnsignedInt*>(0xdeadbeef), 3000ull*1000*1000};
MeshData data{MeshPrimitive::Triangles, {}, vertexData, {
MeshAttributeData{meshAttributeCustom(15), vertexData}
}};
CORRADE_COMPARE(data.attribute(0).data(), vertexData.begin());
CORRADE_COMPARE(data.attribute<UnsignedInt>(0).size(), vertexData.size());
}
#endif
void MeshDataTest::constructIndexDataButNotIndexed() {
CORRADE_SKIP_IF_NO_ASSERT();

34
src/Magnum/Trade/Test/SceneDataTest.cpp

@ -139,6 +139,11 @@ struct SceneDataTest: TestSuite::Tester {
void constructDeprecatedBoth2DAnd3D();
#endif
#ifndef CORRADE_TARGET_32BIT
void constructMappingOver4GB();
void constructFieldOver4GB();
#endif
void constructDuplicateField();
void constructDuplicateCustomField();
void constructInconsistentMappingType();
@ -489,6 +494,11 @@ SceneDataTest::SceneDataTest() {
addTests({&SceneDataTest::constructDeprecatedBoth2DAnd3D});
#endif
#ifndef CORRADE_TARGET_32BIT
addTests({&SceneDataTest::constructMappingOver4GB,
&SceneDataTest::constructFieldOver4GB});
#endif
addTests({&SceneDataTest::constructDuplicateField,
&SceneDataTest::constructDuplicateCustomField,
&SceneDataTest::constructInconsistentMappingType,
@ -3533,6 +3543,30 @@ void SceneDataTest::constructDeprecatedBoth2DAnd3D() {
}
#endif
#ifndef CORRADE_TARGET_32BIT
void SceneDataTest::constructMappingOver4GB() {
Containers::ArrayView<UnsignedInt> mappingData{reinterpret_cast<UnsignedInt*>(0xdeadbeef), 3000ull*1000*1000};
Containers::StridedArrayView1D<UnsignedByte> fieldData{mappingData, reinterpret_cast<UnsignedByte*>(mappingData.data()), 3000ull*1000*1000, 0};
SceneData data{SceneMappingType::UnsignedInt, 1, {}, mappingData, {
SceneFieldData{sceneFieldCustom(15), mappingData, fieldData},
}};
CORRADE_COMPARE(data.mapping(0).data(), mappingData.begin());
CORRADE_COMPARE(data.mapping<UnsignedInt>(0).size(), mappingData.size());
}
void SceneDataTest::constructFieldOver4GB() {
Containers::ArrayView<UnsignedInt> fieldData{reinterpret_cast<UnsignedInt*>(0xdeadbeef), 3000ull*1000*1000};
Containers::StridedArrayView1D<UnsignedByte> mappingData{fieldData, reinterpret_cast<UnsignedByte*>(fieldData.data()), 3000ull*1000*1000, 0};
SceneData data{SceneMappingType::UnsignedByte, 1, {}, fieldData, {
SceneFieldData{sceneFieldCustom(15), mappingData, fieldData},
}};
CORRADE_COMPARE(data.field(0).data(), fieldData.begin());
CORRADE_COMPARE(data.field<UnsignedInt>(0).size(), fieldData.size());
}
#endif
void SceneDataTest::constructDuplicateField() {
CORRADE_SKIP_IF_NO_ASSERT();

Loading…
Cancel
Save