From 037952a97981d89c6b1a6d41766e09bcce2e290a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 9 Nov 2022 23:27:18 +0100 Subject: [PATCH] DebugTools: supply two different materials to the "same" test. Otherwise the code could also just return true only if the instances are the exact same location in memory, which is definitely undesired. --- .../DebugTools/Test/CompareMaterialTest.cpp | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/Magnum/DebugTools/Test/CompareMaterialTest.cpp b/src/Magnum/DebugTools/Test/CompareMaterialTest.cpp index 7039da249..70276412f 100644 --- a/src/Magnum/DebugTools/Test/CompareMaterialTest.cpp +++ b/src/Magnum/DebugTools/Test/CompareMaterialTest.cpp @@ -47,21 +47,39 @@ using namespace Math::Literals; const struct { const char* name; - Trade::MaterialData material; + Trade::MaterialData actual; + Trade::MaterialData expected; } SameData[]{ - {"empty", Trade::MaterialData{{}, {}}}, - {"empty with types", Trade::MaterialData{Trade::MaterialType::PbrMetallicRoughness|Trade::MaterialType::PbrClearCoat, {}}}, - {"base attributes", Trade::MaterialData{Trade::MaterialType::Phong, { - {Trade::MaterialAttribute::DiffuseColor, 0x556699aa_rgbaf}, - {Trade::MaterialAttribute::NormalTexture, 5u}, - {"name", "hello"_s}, - }}}, - {"layers", Trade::MaterialData{Trade::MaterialType::PbrMetallicRoughness|Trade::MaterialType::PbrClearCoat, { - {Trade::MaterialAttribute::NormalTexture, 5u}, - {Trade::MaterialLayer::ClearCoat}, - {Trade::MaterialAttribute::LayerFactor, 0.76f}, - {"name", "hello"_s}, - }, {1, 3, 4}}}, + {"empty", + Trade::MaterialData{{}, {}}, + Trade::MaterialData{{}, {}}}, + {"empty with types", + Trade::MaterialData{Trade::MaterialType::PbrMetallicRoughness|Trade::MaterialType::PbrClearCoat, {}}, + Trade::MaterialData{Trade::MaterialType::PbrMetallicRoughness|Trade::MaterialType::PbrClearCoat, {}}}, + {"base attributes", + Trade::MaterialData{Trade::MaterialType::Phong, { + {Trade::MaterialAttribute::DiffuseColor, 0x556699aa_rgbaf}, + {Trade::MaterialAttribute::NormalTexture, 5u}, + {"name", "hello"_s}, + }}, + Trade::MaterialData{Trade::MaterialType::Phong, { + {"name", "hello"_s}, + {Trade::MaterialAttribute::DiffuseColor, 0x556699aa_rgbaf}, + {Trade::MaterialAttribute::NormalTexture, 5u}, + }}}, + {"layers", + Trade::MaterialData{Trade::MaterialType::PbrMetallicRoughness|Trade::MaterialType::PbrClearCoat, { + {Trade::MaterialAttribute::NormalTexture, 5u}, + {Trade::MaterialLayer::ClearCoat}, + {Trade::MaterialAttribute::LayerFactor, 0.76f}, + {"name", "hello"_s}, + }, {1, 3, 4}}, + Trade::MaterialData{Trade::MaterialType::PbrMetallicRoughness|Trade::MaterialType::PbrClearCoat, { + {Trade::MaterialAttribute::NormalTexture, 5u}, + {Trade::MaterialAttribute::LayerFactor, 0.76f}, + {Trade::MaterialLayer::ClearCoat}, + {"name", "hello"_s}, + }, {1, 3, 4}}}, }; const struct { @@ -271,7 +289,7 @@ void CompareMaterialTest::same() { auto&& data = SameData[testCaseInstanceId()]; setTestCaseDescription(data.name); - CORRADE_COMPARE_AS(data.material, data.material, CompareMaterial); + CORRADE_COMPARE_AS(data.actual, data.expected, CompareMaterial); } void CompareMaterialTest::different() {