Browse Source

MeshTools: better assertion message for interleave().

Print expected and actual count to simplify debugging. Also the phrase
"nothing done." is useless, as nothing is _ever_ done after assertion
failure. Probably remains from the times where that wasn't assertion but
merely harmless warning.
pull/277/head
Vladimír Vondruš 13 years ago
parent
commit
9311d80614
  1. 2
      src/MeshTools/Interleave.h
  2. 2
      src/MeshTools/Test/InterleaveTest.cpp

2
src/MeshTools/Interleave.h

@ -76,7 +76,7 @@ class Interleave {
}
template<class T, class ...U> static typename std::enable_if<!std::is_convertible<T, std::size_t>::value, std::size_t>::type attributeCount(const T& first, const U&... next) {
CORRADE_ASSERT(sizeof...(next) == 0 || attributeCount(next...) == first.size() || attributeCount(next...) == ~std::size_t(0), "MeshTools::interleave(): attribute arrays don't have the same length, nothing done.", 0);
CORRADE_ASSERT(sizeof...(next) == 0 || attributeCount(next...) == first.size() || attributeCount(next...) == ~std::size_t(0), "MeshTools::interleave(): attribute arrays don't have the same length, expected" << first.size() << "but got" << attributeCount(next...), 0);
return first.size();
}

2
src/MeshTools/Test/InterleaveTest.cpp

@ -57,7 +57,7 @@ void InterleaveTest::attributeCount() {
Error::setOutput(&ss);
CORRADE_COMPARE((Implementation::Interleave::attributeCount(std::vector<Byte>{0, 1, 2},
std::vector<Byte>{0, 1, 2, 3, 4, 5})), std::size_t(0));
CORRADE_COMPARE(ss.str(), "MeshTools::interleave(): attribute arrays don't have the same length, nothing done.\n");
CORRADE_COMPARE(ss.str(), "MeshTools::interleave(): attribute arrays don't have the same length, expected 3 but got 6\n");
CORRADE_COMPARE((Implementation::Interleave::attributeCount(std::vector<Byte>{0, 1, 2},
std::vector<Byte>{3, 4, 5})), std::size_t(3));

Loading…
Cancel
Save