diff --git a/src/Magnum/Trade/MaterialData.cpp b/src/Magnum/Trade/MaterialData.cpp index b939dff43..604d5cbe9 100644 --- a/src/Magnum/Trade/MaterialData.cpp +++ b/src/Magnum/Trade/MaterialData.cpp @@ -233,7 +233,7 @@ MaterialData::MaterialData(const MaterialTypes types, Containers::Array 1) for(std::size_t j = begin + 1; j != end; ++j) { if(_data[j - 1].name() < _data[j].name()) continue; - std::sort(_data + begin, _data + end, [](const MaterialAttributeData& a, const MaterialAttributeData& b) { + std::sort(_data + begin, _data + end, [i](const MaterialAttributeData& a, const MaterialAttributeData& b) { /* Need to check here (instead of in the outer for loop) as we exit the loop right after the sort and thus duplicates that occur after the first non-sorted pair wouldn't get detected. @@ -244,7 +244,7 @@ MaterialData::MaterialData(const MaterialTypes types, Containers::Array attributes{InPlaceInit, { + /* This attribute is in the first layer, so it should not be reported + as duplicated */ + {MaterialAttribute::DoubleSided, true}, + + /* Second layer is empty, this is the third layer (index 2) */ {MaterialAttribute::DoubleSided, true}, {MaterialAttribute::DiffuseTextureCoordinates, 5u}, {"highlightColor", 0x335566ff_rgbaf}, @@ -987,16 +992,16 @@ void MaterialDataTest::constructDuplicateAttribute() { /* Testing that it asserts in all input permutations */ for(std::size_t i = 0; i != testCaseRepeatId(); ++i) - std::next_permutation(attributes.begin(), attributes.end(), [](const MaterialAttributeData& a, const MaterialAttributeData& b) { + std::next_permutation(attributes.begin() + 1, attributes.end(), [](const MaterialAttributeData& a, const MaterialAttributeData& b) { return a.name() < b.name(); }); std::ostringstream out; Error redirectError{&out}; - MaterialData data{{}, std::move(attributes)}; + MaterialData data{{}, std::move(attributes), Containers::array({1, 1, 6})}; /* Because with graceful asserts it doesn't exit on error, the assertion might get printed multiple times */ - CORRADE_COMPARE(Utility::String::partition(out.str(), '\n')[0], "Trade::MaterialData: duplicate attribute DiffuseTextureCoordinates"); + CORRADE_COMPARE(Utility::String::partition(out.str(), '\n')[0], "Trade::MaterialData: duplicate attribute DiffuseTextureCoordinates in layer 2"); } void MaterialDataTest::constructFromImmutableSortedArray() {