Browse Source

Test: remove all use of <sstream> for Debug output testing.

Compared to Corrade, the improvement in compile time is about a minute
cumulative across all cores, or about 8 seconds on an 8-core system (~2
minutes before, ~1:52 after). Not bad at all. And this is with a
deprecated build, the non-deprecated build is 1:48 -> 1:41.
pull/659/head
Vladimír Vondruš 1 year ago
parent
commit
cc608dba42
  1. 67
      src/Magnum/Animation/Test/InterpolationTest.cpp
  2. 12
      src/Magnum/Animation/Test/PlayerTest.cpp
  3. 8
      src/Magnum/Animation/Test/TrackViewTest.cpp
  4. 51
      src/Magnum/Audio/Test/AbstractImporterTest.cpp
  5. 7
      src/Magnum/Audio/Test/BufferFormatTest.cpp
  6. 6
      src/Magnum/Audio/Test/ContextALTest.cpp
  7. 8
      src/Magnum/Audio/Test/ContextTest.cpp
  8. 11
      src/Magnum/Audio/Test/RendererTest.cpp
  9. 11
      src/Magnum/Audio/Test/SourceTest.cpp
  10. 324
      src/Magnum/DebugTools/Test/CompareImageTest.cpp
  11. 11
      src/Magnum/DebugTools/Test/CompareMaterialTest.cpp
  12. 59
      src/Magnum/DebugTools/Test/FrameProfilerTest.cpp
  13. 32
      src/Magnum/DebugTools/Test/ScreenshotGLTest.cpp
  14. 27
      src/Magnum/DebugTools/Test/TextureImageGLTest.cpp
  15. 35
      src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp
  16. 51
      src/Magnum/GL/Test/AbstractTextureGLTest.cpp
  17. 93
      src/Magnum/GL/Test/AttributeTest.cpp
  18. 16
      src/Magnum/GL/Test/BufferImageGLTest.cpp
  19. 11
      src/Magnum/GL/Test/BufferTest.cpp
  20. 13
      src/Magnum/GL/Test/ContextGLTest.cpp
  21. 48
      src/Magnum/GL/Test/ContextTest.cpp
  22. 66
      src/Magnum/GL/Test/CubeMapTextureGLTest.cpp
  23. 8
      src/Magnum/GL/Test/DebugOutputGLTest.cpp
  24. 39
      src/Magnum/GL/Test/DebugOutputTest.cpp
  25. 7
      src/Magnum/GL/Test/DefaultFramebufferTest.cpp
  26. 10
      src/Magnum/GL/Test/FramebufferGLTest.cpp
  27. 7
      src/Magnum/GL/Test/FramebufferTest.cpp
  28. 118
      src/Magnum/GL/Test/MeshGLTest.cpp
  29. 39
      src/Magnum/GL/Test/MeshTest.cpp
  30. 99
      src/Magnum/GL/Test/PixelFormatTest.cpp
  31. 15
      src/Magnum/GL/Test/RendererTest.cpp
  32. 43
      src/Magnum/GL/Test/SamplerTest.cpp
  33. 35
      src/Magnum/GL/Test/ShaderGLTest.cpp
  34. 7
      src/Magnum/GL/Test/ShaderTest.cpp
  35. 15
      src/Magnum/GL/Test/VersionTest.cpp
  36. 15
      src/Magnum/MaterialTools/Test/FilterTest.cpp
  37. 7
      src/Magnum/MaterialTools/Test/MergeTest.cpp
  38. 15
      src/Magnum/MaterialTools/Test/PhongToPbrMetallicRoughnessTest.cpp
  39. 7
      src/Magnum/MaterialTools/Test/RemoveDuplicatesTest.cpp
  40. 43
      src/Magnum/Math/Test/AngleTest.cpp
  41. 9
      src/Magnum/Math/Test/BezierTest.cpp
  42. 11
      src/Magnum/Math/Test/BitVectorTest.cpp
  43. 6
      src/Magnum/Math/Test/ColorBatchTest.cpp
  44. 79
      src/Magnum/Math/Test/ColorTest.cpp
  45. 31
      src/Magnum/Math/Test/ComplexTest.cpp
  46. 2
      src/Magnum/Math/Test/ConfigurationValueTest.cpp
  47. 53
      src/Magnum/Math/Test/CubicHermiteTest.cpp
  48. 7
      src/Magnum/Math/Test/DistanceTest.cpp
  49. 21
      src/Magnum/Math/Test/DualComplexTest.cpp
  50. 31
      src/Magnum/Math/Test/DualQuaternionTest.cpp
  51. 11
      src/Magnum/Math/Test/DualTest.cpp
  52. 12
      src/Magnum/Math/Test/FrustumTest.cpp
  53. 19
      src/Magnum/Math/Test/FunctionsTest.cpp
  54. 15
      src/Magnum/Math/Test/HalfTest.cpp
  55. 7
      src/Magnum/Math/Test/IntersectionTest.cpp
  56. 36
      src/Magnum/Math/Test/Matrix3Test.cpp
  57. 40
      src/Magnum/Math/Test/Matrix4Test.cpp
  58. 22
      src/Magnum/Math/Test/MatrixTest.cpp
  59. 15
      src/Magnum/Math/Test/PackingBatchTest.cpp
  60. 63
      src/Magnum/Math/Test/QuaternionTest.cpp
  61. 14
      src/Magnum/Math/Test/RangeTest.cpp
  62. 21
      src/Magnum/Math/Test/RectangularMatrixTest.cpp
  63. 19
      src/Magnum/Math/Test/TimeTest.cpp
  64. 10
      src/Magnum/Math/Test/Vector2Test.cpp
  65. 10
      src/Magnum/Math/Test/Vector3Test.cpp
  66. 10
      src/Magnum/Math/Test/Vector4Test.cpp
  67. 33
      src/Magnum/Math/Test/VectorTest.cpp
  68. 9
      src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp
  69. 55
      src/Magnum/MeshTools/Test/CombineTest.cpp
  70. 52
      src/Magnum/MeshTools/Test/CompileGLTest.cpp
  71. 10
      src/Magnum/MeshTools/Test/CompileLinesGLTest.cpp
  72. 28
      src/Magnum/MeshTools/Test/CompressIndicesTest.cpp
  73. 40
      src/Magnum/MeshTools/Test/ConcatenateTest.cpp
  74. 7
      src/Magnum/MeshTools/Test/CopyTest.cpp
  75. 51
      src/Magnum/MeshTools/Test/DuplicateTest.cpp
  76. 15
      src/Magnum/MeshTools/Test/FilterTest.cpp
  77. 17
      src/Magnum/MeshTools/Test/FlipNormalsTest.cpp
  78. 100
      src/Magnum/MeshTools/Test/GenerateIndicesTest.cpp
  79. 15
      src/Magnum/MeshTools/Test/GenerateLinesTest.cpp
  80. 32
      src/Magnum/MeshTools/Test/GenerateNormalsTest.cpp
  81. 58
      src/Magnum/MeshTools/Test/InterleaveTest.cpp
  82. 63
      src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp
  83. 15
      src/Magnum/MeshTools/Test/SubdivideTest.cpp
  84. 103
      src/Magnum/MeshTools/Test/TransformTest.cpp
  85. 49
      src/Magnum/SceneGraph/Test/AnimableTest.cpp
  86. 11
      src/Magnum/SceneGraph/Test/DualComplexTransformationTest.cpp
  87. 15
      src/Magnum/SceneGraph/Test/DualQuaternionTransformationTest.cpp
  88. 23
      src/Magnum/SceneGraph/Test/ObjectTest.cpp
  89. 15
      src/Magnum/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp
  90. 17
      src/Magnum/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp
  91. 9
      src/Magnum/SceneGraph/Test/TranslationTransformationTest.cpp
  92. 16
      src/Magnum/SceneTools/Test/CombineTest.cpp
  93. 8
      src/Magnum/SceneTools/Test/CopyTest.cpp
  94. 35
      src/Magnum/SceneTools/Test/FilterTest.cpp
  95. 15
      src/Magnum/SceneTools/Test/FlattenMeshHierarchyTest.cpp
  96. 47
      src/Magnum/SceneTools/Test/HierarchyTest.cpp
  97. 25
      src/Magnum/SceneTools/Test/MapTest.cpp
  98. 58
      src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp
  99. 365
      src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp
  100. 7
      src/Magnum/ShaderTools/Test/StageTest.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

67
src/Magnum/Animation/Test/InterpolationTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Animation/Easing.h"
#include "Magnum/Animation/Interpolation.h"
@ -225,12 +224,12 @@ void InterpolationTest::interpolatorFor() {
void InterpolationTest::interpolatorForInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<Float>(Interpolation::Spline);
Animation::interpolatorFor<Float>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Spline\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -245,12 +244,12 @@ void InterpolationTest::interpolatorForBool() {
void InterpolationTest::interpolatorForBoolInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<bool>(Interpolation::Custom);
Animation::interpolatorFor<bool>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -265,12 +264,12 @@ void InterpolationTest::interpolatorForBitVector() {
void InterpolationTest::interpolatorForBitVectorInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<Math::BitVector<4>>(Interpolation::Custom);
Animation::interpolatorFor<Math::BitVector<4>>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -289,12 +288,12 @@ void InterpolationTest::interpolatorForComplex() {
void InterpolationTest::interpolatorForComplexInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<Complex>(Interpolation::Custom);
Animation::interpolatorFor<Complex>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -313,12 +312,12 @@ void InterpolationTest::interpolatorForQuaternion() {
void InterpolationTest::interpolatorForQuaternionInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<Quaternion>(Interpolation::Spline);
Animation::interpolatorFor<Quaternion>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Spline\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -337,12 +336,12 @@ void InterpolationTest::interpolatorForDualQuaternion() {
void InterpolationTest::interpolatorForDualQuaternionInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<DualQuaternion>(Interpolation::Custom);
Animation::interpolatorFor<DualQuaternion>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -358,12 +357,12 @@ void InterpolationTest::interpolatorForCubicHermiteScalar() {
void InterpolationTest::interpolatorForCubicHermiteScalarInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<CubicHermite1D>(Interpolation::Custom);
Animation::interpolatorFor<CubicHermite1D>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -379,12 +378,12 @@ void InterpolationTest::interpolatorForCubicHermiteVector() {
void InterpolationTest::interpolatorForCubicHermiteVectorInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<CubicHermite2D>(Interpolation::Custom);
Animation::interpolatorFor<CubicHermite2D>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -400,12 +399,12 @@ void InterpolationTest::interpolatorForCubicHermiteComplex() {
void InterpolationTest::interpolatorForCubicHermiteComplexInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<CubicHermiteComplex>(Interpolation::Custom);
Animation::interpolatorFor<CubicHermiteComplex>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -427,12 +426,12 @@ void InterpolationTest::interpolatorForCubicHermiteQuaternion() {
void InterpolationTest::interpolatorForCubicHermiteQuaternionInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Animation::interpolatorFor<CubicHermiteQuaternion>(Interpolation::Custom);
Animation::interpolatorFor<CubicHermiteQuaternion>(Interpolation(0xde));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
}
@ -544,7 +543,7 @@ void InterpolationTest::interpolateStrictIntegerKey() {
void InterpolationTest::interpolateError() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
{
@ -552,14 +551,14 @@ void InterpolationTest::interpolateError() {
Animation::interpolate<Float, Float>(Keys, nullptr, Extrapolation::Extrapolated, Extrapolation::Extrapolated, Math::lerp, 0.0f, hint);
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolate(): keys and values don't have the same size\n");
}
void InterpolationTest::interpolateStrictError() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
{
@ -575,7 +574,7 @@ void InterpolationTest::interpolateStrictError() {
Math::lerp, 0.0f, hint);
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Animation::interpolateStrict(): at least two keyframes required\n"
"Animation::interpolateStrict(): keys and values don't have the same size\n");
}
@ -629,31 +628,31 @@ void InterpolationTest::unpackEaseClamped() {
}
void InterpolationTest::debugInterpolation() {
std::ostringstream out;
Containers::String out;
Debug{&out} << Interpolation::Custom << Interpolation(0xde);
CORRADE_COMPARE(out.str(), "Animation::Interpolation::Custom Animation::Interpolation(0xde)\n");
CORRADE_COMPARE(out, "Animation::Interpolation::Custom Animation::Interpolation(0xde)\n");
}
void InterpolationTest::debugInterpolationPacked() {
std::ostringstream out;
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << Interpolation::Custom << Debug::packed << Interpolation(0xde) << Interpolation::Constant;
CORRADE_COMPARE(out.str(), "Custom 0xde Animation::Interpolation::Constant\n");
CORRADE_COMPARE(out, "Custom 0xde Animation::Interpolation::Constant\n");
}
void InterpolationTest::debugExtrapolation() {
std::ostringstream out;
Containers::String out;
Debug{&out} << Extrapolation::DefaultConstructed << Extrapolation(0xde);
CORRADE_COMPARE(out.str(), "Animation::Extrapolation::DefaultConstructed Animation::Extrapolation(0xde)\n");
CORRADE_COMPARE(out, "Animation::Extrapolation::DefaultConstructed Animation::Extrapolation(0xde)\n");
}
void InterpolationTest::debugExtrapolationPacked() {
std::ostringstream out;
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << Extrapolation::DefaultConstructed << Debug::packed << Extrapolation(0xde) << Extrapolation::Constant;
CORRADE_COMPARE(out.str(), "DefaultConstructed 0xde Animation::Extrapolation::Constant\n");
CORRADE_COMPARE(out, "DefaultConstructed 0xde Animation::Extrapolation::Constant\n");
}

12
src/Magnum/Animation/Test/PlayerTest.cpp

@ -24,13 +24,13 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Player is std::pair-free */
#include "Magnum/Animation/Player.h"
@ -329,7 +329,7 @@ void PlayerTest::setDurationReplace() {
void PlayerTest::trackInvalidIndex() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Float value;
@ -340,7 +340,7 @@ void PlayerTest::trackInvalidIndex() {
player.track(1);
CORRADE_COMPARE(out.str(), "Animation::Player::track(): index out of range\n");
CORRADE_COMPARE(out, "Animation::Player::track(): index out of range\n");
}
void PlayerTest::advanceNotRunning() {
@ -1400,10 +1400,10 @@ void PlayerTest::runFor100YearsChrono() {
}
void PlayerTest::debugState() {
std::ostringstream out;
Containers::String out;
Debug{&out} << State::Playing << State(0xde);
CORRADE_COMPARE(out.str(), "Animation::State::Playing Animation::State(0xde)\n");
CORRADE_COMPARE(out, "Animation::State::Playing Animation::State(0xde)\n");
}
}}}}

8
src/Magnum/Animation/Test/TrackViewTest.cpp

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stream-free */
#include <Corrade/Utility/DebugStl.h> /** @todo remove once TrackView is std::pair-free */
#include "Magnum/Animation/Track.h"
#include "Magnum/Math/Half.h"
@ -571,10 +571,10 @@ void TrackViewTest::constructInconsistentViewSize() {
Float keys[2]{};
Vector3 values[3]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
TrackView<Float, Vector3>{keys, values, Math::select};
CORRADE_COMPARE(out.str(), "Animation::TrackView: expected key and value view to have the same size but got 2 and 3\n");
CORRADE_COMPARE(out, "Animation::TrackView: expected key and value view to have the same size but got 2 and 3\n");
}
void TrackViewTest::constructCopyStorage() {

51
src/Magnum/Audio/Test/AbstractImporterTest.cpp

@ -24,14 +24,13 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <string> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h>
#include "Magnum/Audio/AbstractImporter.h"
@ -187,13 +186,13 @@ void AbstractImporterTest::openFileAsDataNotFound() {
bool _opened = false;
} importer;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_VERIFY(!importer.openFile("nonexistent.bin"));
CORRADE_VERIFY(!importer.isOpened());
/* There's an error from Path::read() before */
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"\nAudio::AbstractImporter::openFile(): cannot open file nonexistent.bin\n",
TestSuite::Compare::StringHasSuffix);
}
@ -211,11 +210,11 @@ void AbstractImporterTest::openFileNotImplemented() {
Containers::Array<char> doData() override { return nullptr; }
} importer;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_VERIFY(!importer.openFile("file.dat"));
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::openFile(): not implemented\n");
CORRADE_COMPARE(out, "Audio::AbstractImporter::openFile(): not implemented\n");
}
void AbstractImporterTest::openDataNotSupported() {
@ -231,11 +230,11 @@ void AbstractImporterTest::openDataNotSupported() {
Containers::Array<char> doData() override { return nullptr; }
} importer;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_VERIFY(!importer.openData(nullptr));
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::openData(): feature not supported\n");
CORRADE_COMPARE(out, "Audio::AbstractImporter::openData(): feature not supported\n");
}
void AbstractImporterTest::openDataNotImplemented() {
@ -251,11 +250,11 @@ void AbstractImporterTest::openDataNotImplemented() {
Containers::Array<char> doData() override { return nullptr; }
} importer;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_VERIFY(!importer.openData(nullptr));
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::openData(): feature advertised but not implemented\n");
CORRADE_COMPARE(out, "Audio::AbstractImporter::openData(): feature advertised but not implemented\n");
}
void AbstractImporterTest::format() {
@ -285,11 +284,11 @@ void AbstractImporterTest::formatNoFile() {
Containers::Array<char> doData() override { return nullptr; }
} importer;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
importer.format();
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::format(): no file opened\n");
CORRADE_COMPARE(out, "Audio::AbstractImporter::format(): no file opened\n");
}
void AbstractImporterTest::frequency() {
@ -319,11 +318,11 @@ void AbstractImporterTest::frequencyNoFile() {
Containers::Array<char> doData() override { return nullptr; }
} importer;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
importer.frequency();
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::frequency(): no file opened\n");
CORRADE_COMPARE(out, "Audio::AbstractImporter::frequency(): no file opened\n");
}
void AbstractImporterTest::data() {
@ -357,11 +356,11 @@ void AbstractImporterTest::dataNoFile() {
Containers::Array<char> doData() override { return nullptr; }
} importer;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
importer.data();
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::data(): no file opened\n");
CORRADE_COMPARE(out, "Audio::AbstractImporter::data(): no file opened\n");
}
void AbstractImporterTest::dataCustomDeleter() {
@ -379,39 +378,39 @@ void AbstractImporterTest::dataCustomDeleter() {
}
} importer;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
importer.data();
CORRADE_COMPARE(out.str(), "Audio::AbstractImporter::data(): implementation is not allowed to use a custom Array deleter\n");
CORRADE_COMPARE(out, "Audio::AbstractImporter::data(): implementation is not allowed to use a custom Array deleter\n");
}
void AbstractImporterTest::debugFeature() {
std::ostringstream out;
Containers::String out;
Debug{&out} << ImporterFeature::OpenData << ImporterFeature(0xf0);
CORRADE_COMPARE(out.str(), "Audio::ImporterFeature::OpenData Audio::ImporterFeature(0xf0)\n");
CORRADE_COMPARE(out, "Audio::ImporterFeature::OpenData Audio::ImporterFeature(0xf0)\n");
}
void AbstractImporterTest::debugFeaturePacked() {
std::ostringstream out;
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ImporterFeature::OpenData << Debug::packed << ImporterFeature(0xf0) << ImporterFeature::OpenData;
CORRADE_COMPARE(out.str(), "OpenData 0xf0 Audio::ImporterFeature::OpenData\n");
CORRADE_COMPARE(out, "OpenData 0xf0 Audio::ImporterFeature::OpenData\n");
}
void AbstractImporterTest::debugFeatures() {
std::ostringstream out;
Containers::String out;
Debug{&out} << (ImporterFeature::OpenData|ImporterFeature(0xf0)) << ImporterFeatures{};
CORRADE_COMPARE(out.str(), "Audio::ImporterFeature::OpenData|Audio::ImporterFeature(0xf0) Audio::ImporterFeatures{}\n");
CORRADE_COMPARE(out, "Audio::ImporterFeature::OpenData|Audio::ImporterFeature(0xf0) Audio::ImporterFeatures{}\n");
}
void AbstractImporterTest::debugFeaturesPacked() {
std::ostringstream out;
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (ImporterFeature::OpenData|ImporterFeature(0xf0)) << Debug::packed << ImporterFeatures{} << ImporterFeature::OpenData;
CORRADE_COMPARE(out.str(), "OpenData|0xf0 {} Audio::ImporterFeature::OpenData\n");
CORRADE_COMPARE(out, "OpenData|0xf0 {} Audio::ImporterFeature::OpenData\n");
}
}}}}

7
src/Magnum/Audio/Test/BufferFormatTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Audio/BufferFormat.h"
@ -43,9 +42,9 @@ BufferFormatTest::BufferFormatTest() {
}
void BufferFormatTest::debugFormat() {
std::ostringstream out;
Containers::String out;
Debug(&out) << BufferFormat::Stereo16 << BufferFormat(0xdead);
CORRADE_COMPARE(out.str(), "Audio::BufferFormat::Stereo16 Audio::BufferFormat(0xdead)\n");
CORRADE_COMPARE(out, "Audio::BufferFormat::Stereo16 Audio::BufferFormat(0xdead)\n");
}
}}}}

6
src/Magnum/Audio/Test/ContextALTest.cpp

@ -25,10 +25,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
@ -194,11 +194,11 @@ void ContextALTest::quietLog() {
const char* argv[] = { "", "--magnum-log", testCaseInstanceId() ? "quiet" : "default" };
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
/* MSVC 2015 and 2017 needs the int cast otherwise C2398 */
Context context{int(Containers::arraySize(argv)), argv};
CORRADE_COMPARE(out.str().empty(), bool(testCaseInstanceId()));
CORRADE_COMPARE(!out, bool(testCaseInstanceId()));
}
void ContextALTest::ignoreUnrelatedOptions() {

8
src/Magnum/Audio/Test/ContextTest.cpp

@ -26,11 +26,9 @@
*/
#include <set>
#include <sstream>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Audio/Context.h"
@ -103,9 +101,9 @@ void ContextTest::extensions() {
}
void ContextTest::debugHrtfStatus() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Context::HrtfStatus::Denied << Context::HrtfStatus(0xdead);
CORRADE_COMPARE(out.str(), "Audio::Context::HrtfStatus::Denied Audio::Context::HrtfStatus(0xdead)\n");
CORRADE_COMPARE(out, "Audio::Context::HrtfStatus::Denied Audio::Context::HrtfStatus(0xdead)\n");
}
}}}}

11
src/Magnum/Audio/Test/RendererTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Magnum.h"
#include "Magnum/Audio/Renderer.h"
@ -46,15 +45,15 @@ RendererTest::RendererTest() {
}
void RendererTest::debugError() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Renderer::Error::InvalidOperation << Renderer::Error(0xdead);
CORRADE_COMPARE(out.str(), "Audio::Renderer::Error::InvalidOperation Audio::Renderer::Error(0xdead)\n");
CORRADE_COMPARE(out, "Audio::Renderer::Error::InvalidOperation Audio::Renderer::Error(0xdead)\n");
}
void RendererTest::debugDistanceModel() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Renderer::DistanceModel::Inverse << Renderer::DistanceModel(0xdead);
CORRADE_COMPARE(out.str(), "Audio::Renderer::DistanceModel::Inverse Audio::Renderer::DistanceModel(0xdead)\n");
CORRADE_COMPARE(out, "Audio::Renderer::DistanceModel::Inverse Audio::Renderer::DistanceModel(0xdead)\n");
}
}}}}

11
src/Magnum/Audio/Test/SourceTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Audio/Source.h"
@ -45,15 +44,15 @@ SourceTest::SourceTest() {
}
void SourceTest::debugState() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Source::State::Playing << Source::State(0xdead);
CORRADE_COMPARE(out.str(), "Audio::Source::State::Playing Audio::Source::State(0xdead)\n");
CORRADE_COMPARE(out, "Audio::Source::State::Playing Audio::Source::State(0xdead)\n");
}
void SourceTest::debugType() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Source::Type::Streaming << Source::Type(0xdead);
CORRADE_COMPARE(out.str(), "Audio::Source::Type::Streaming Audio::Source::Type(0xdead)\n");
CORRADE_COMPARE(out, "Audio::Source::Type::Streaming Audio::Source::Type(0xdead)\n");
}
}}}}

324
src/Magnum/DebugTools/Test/CompareImageTest.cpp

@ -24,19 +24,16 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo drop once Debug is stream-free */
#include <Corrade/Containers/Triple.h>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/File.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Path.h>
#include <Corrade/Utility/String.h> /* replaceFirst() */
@ -294,37 +291,37 @@ const ImageView2D ExpectedRed{PixelFormat::R32F, {3, 3}, ExpectedRedData};
void CompareImageTest::formatUnknown() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
ImageView2D image{PixelStorage{}, PixelFormat(0xdead), 0, 0, {}};
Implementation::calculateImageDelta(image.format(), image.pixels(), image);
CORRADE_COMPARE(out.str(), "DebugTools::CompareImage: unknown format PixelFormat(0xdead)\n");
CORRADE_COMPARE(out, "DebugTools::CompareImage: unknown format PixelFormat(0xdead)\n");
}
void CompareImageTest::formatPackedDepthStencil() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
ImageView2D image{PixelFormat::Depth24UnormStencil8UI, {}};
Implementation::calculateImageDelta(image.format(), image.pixels(), image);
CORRADE_COMPARE(out.str(), "DebugTools::CompareImage: packed depth/stencil formats are not supported yet\n");
CORRADE_COMPARE(out, "DebugTools::CompareImage: packed depth/stencil formats are not supported yet\n");
}
void CompareImageTest::formatImplementationSpecific() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
ImageView2D image{PixelStorage{}, pixelFormatWrap(0xdead), 0, 0, {}};
Implementation::calculateImageDelta(image.format(), image.pixels(), image);
CORRADE_COMPARE(out.str(), "DebugTools::CompareImage: can't compare implementation-specific pixel formats\n");
CORRADE_COMPARE(out, "DebugTools::CompareImage: can't compare implementation-specific pixel formats\n");
}
void CompareImageTest::calculateDelta() {
@ -459,17 +456,20 @@ void CompareImageTest::calculateDeltaSpecials3() {
}
void CompareImageTest::deltaImage() {
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Containers::Array<Float> delta{32*32};
for(std::int_fast32_t x = 0; x != 32; ++x)
for(std::int_fast32_t y = 0; y != 32; ++y)
delta[y*32 + x] = Vector2{Float(x), Float(y)}.length()/Vector2{32.0f}.length();
Implementation::printDeltaImage(d, delta, {32, 32}, 1.0f, 0.0f, 0.0f);
CORRADE_COMPARE(out.str(),
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug d{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printDeltaImage(d, delta, {32, 32}, 1.0f, 0.0f, 0.0f);
}
CORRADE_COMPARE(out,
" |$$$$$$$$$$0000000888888DDDDNNNNM|\n"
" |ZZZZZZZ$$$$$$$$0000008888DDDDNNN|\n"
" |ZZZZZZZZZZZZZ$$$$$$00008888DDDDN|\n"
@ -489,16 +489,19 @@ void CompareImageTest::deltaImage() {
}
void CompareImageTest::deltaImageScaling() {
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Containers::Array<Float> delta{65*40};
for(std::int_fast32_t x = 0; x != 65; ++x)
for(std::int_fast32_t y = 0; y != 40; ++y)
delta[y*65 + x] = Vector2{Float(x), Float(y)}.length()/Vector2{65.0f, 40.0f}.length();
Implementation::printDeltaImage(d, delta, {65, 40}, 1.0f, 0.0f, 0.0f);
CORRADE_COMPARE(out.str(),
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug d{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printDeltaImage(d, delta, {65, 40}, 1.0f, 0.0f, 0.0f);
}
CORRADE_COMPARE(out,
" |777777IIIIIIZZZZ$$$0000888DDDNNMM|\n"
" |????777777IIIIZZZZ$$$000888DDDNNN|\n"
" |?????????7777IIIIZZZ$$$00888DDDNN|\n"
@ -520,12 +523,16 @@ void CompareImageTest::deltaImageColors() {
Implementation::printDeltaImage(out, DeltaRed, {3, 3}, 2.0f, 0.5f, 0.2f);
}
std::ostringstream out;
Debug dc{&out, Debug::Flag::DisableColors};
Implementation::printDeltaImage(dc, DeltaRed, {3, 3}, 2.0f, 0.5f, 0.2f);
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug dc{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printDeltaImage(dc, DeltaRed, {3, 3}, 2.0f, 0.5f, 0.2f);
}
/* Yes, there is half of the rows (2 instead of 3) in order to roughly
preserve image ratio */
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
" |.7 |\n"
" |: ,|");
}
@ -539,12 +546,16 @@ void CompareImageTest::deltaImageSpecials() {
nan, inf, 0.0f,
nan, inf, 0.0f};
std::ostringstream out;
Debug dc{&out, Debug::Flag::DisableColors};
Implementation::printDeltaImage(dc, delta, {3, 4}, 3.0f, 0.0f, 0.0f);
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug dc{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printDeltaImage(dc, delta, {3, 4}, 3.0f, 0.0f, 0.0f);
}
/* Should show the max value for NaN and infs and the usual things
otherwise */
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
" |MM |\n"
" |~M8|");
}
@ -556,11 +567,14 @@ void CompareImageTest::pixelDelta() {
Implementation::printPixelDeltas(out, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 10);
}
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 10);
CORRADE_COMPARE(out.str(), "\n"
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug d{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 10);
}
CORRADE_COMPARE(out, "\n"
" Pixels above max/mean threshold:\n"
" [1,2] Vector(1), expected Vector(0) (Δ = 1)\n"
" [0,0] Vector(0.3), expected Vector(0.65) (Δ = 0.35)\n"
@ -569,19 +583,25 @@ void CompareImageTest::pixelDelta() {
}
void CompareImageTest::pixelDeltaEmpty() {
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 1.0f, 1.0f, 10);
CORRADE_COMPARE(out.str(), "");
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug d{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 1.0f, 1.0f, 10);
}
CORRADE_COMPARE(out, "");
}
void CompareImageTest::pixelDeltaOverflow() {
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 3);
CORRADE_COMPARE(out.str(), "\n"
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug d{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 3);
}
CORRADE_COMPARE(out, "\n"
" Top 3 out of 4 pixels above max/mean threshold:\n"
" [1,2] Vector(1), expected Vector(0) (Δ = 1)\n"
" [0,0] Vector(0.3), expected Vector(0.65) (Δ = 0.35)\n"
@ -607,11 +627,14 @@ const ImageView2D ActualHalf{PixelFormat::RG16F, {2, 2}, ActualHalfData};
const ImageView2D ExpectedHalf{PixelFormat::RG16F, {2, 2}, ExpectedHalfData};
void CompareImageTest::pixelDeltaHalf() {
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Implementation::printPixelDeltas(d, DeltaHalf, ActualHalf.format(), ActualHalf.pixels(), ExpectedHalf.pixels(), 0.5f, 0.1f, 10);
CORRADE_COMPARE(out.str(), "\n"
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug d{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printPixelDeltas(d, DeltaHalf, ActualHalf.format(), ActualHalf.pixels(), ExpectedHalf.pixels(), 0.5f, 0.1f, 10);
}
CORRADE_COMPARE(out, "\n"
" Pixels above max/mean threshold:\n"
" [0,0] Vector(0.3, 1), expected Vector(0.6499, 1) (Δ = 0.175)\n"
" [1,0] Vector(0.8999, 0.8999), expected Vector(0.6001, 0.9102) (Δ = 0.155)\n"
@ -619,14 +642,17 @@ void CompareImageTest::pixelDeltaHalf() {
}
void CompareImageTest::pixelDeltaSpecials() {
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Implementation::printPixelDeltas(d, DeltaSpecials, ActualSpecials.format(), ActualSpecials.pixels(), ExpectedSpecials.pixels(), 1.5f, 0.5f, 10);
/* The string gets fully written only on destruction or with a newline at
the end */
Containers::String out;
{
Debug d{&out, Debug::Flag::DisableColors|Debug::Flag::NoNewlineAtTheEnd};
Implementation::printPixelDeltas(d, DeltaSpecials, ActualSpecials.format(), ActualSpecials.pixels(), ExpectedSpecials.pixels(), 1.5f, 0.5f, 10);
}
/* MSVC before version 2019 16.10(11?) prints -nan(ind) instead of ±nan.
But only sometimes. */
#if defined(CORRADE_TARGET_MSVC) && _MSC_VER < 1929 && !defined(CORRADE_TARGET_CLANG_CL)
CORRADE_COMPARE(out.str(), "\n"
CORRADE_COMPARE(out, "\n"
" Pixels above max/mean threshold:\n"
" [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n"
" [3,0] Vector(0.3), expected Vector(-nan(ind)) (Δ = -nan(ind))\n"
@ -635,7 +661,7 @@ void CompareImageTest::pixelDeltaSpecials() {
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)");
#else
CORRADE_COMPARE(out.str(), "\n"
CORRADE_COMPARE(out, "\n"
" Pixels above max/mean threshold:\n"
" [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n"
" [3,0] Vector(0.3), expected Vector(nan) (Δ = nan)\n"
@ -647,7 +673,7 @@ void CompareImageTest::pixelDeltaSpecials() {
}
void CompareImageTest::compareDifferentSize() {
std::stringstream out;
Containers::String out;
char data[8*5];
ImageView2D a{PixelFormat::RG8UI, {3, 4}, data};
@ -662,11 +688,11 @@ void CompareImageTest::compareDifferentSize() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Images a and b have different size, actual Vector(3, 4) but Vector(3, 5) expected.\n");
CORRADE_COMPARE(out, "Images a and b have different size, actual Vector(3, 4) but Vector(3, 5) expected.\n");
}
void CompareImageTest::compareDifferentFormat() {
std::stringstream out;
Containers::String out;
char data[16*12];
ImageView2D a{PixelFormat::RGBA32F, {3, 4}, data};
@ -681,7 +707,7 @@ void CompareImageTest::compareDifferentFormat() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Images a and b have different format, actual PixelFormat::RGBA32F but PixelFormat::RGB32F expected.\n");
CORRADE_COMPARE(out, "Images a and b have different format, actual PixelFormat::RGBA32F but PixelFormat::RGB32F expected.\n");
}
void CompareImageTest::compareSameZeroThreshold() {
@ -697,7 +723,7 @@ void CompareImageTest::compareSameZeroThreshold() {
}
void CompareImageTest::compareAboveThresholds() {
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f};
@ -708,7 +734,7 @@ void CompareImageTest::compareAboveThresholds() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have both max and mean delta above threshold, actual 39/18.5 but at most 20/10 expected. Delta image:\n"
" |?M|\n"
" Pixels above max/mean threshold:\n"
@ -718,7 +744,7 @@ void CompareImageTest::compareAboveThresholds() {
}
void CompareImageTest::compareAboveMaxThreshold() {
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{30.0f, 20.0f};
@ -729,7 +755,7 @@ void CompareImageTest::compareAboveMaxThreshold() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have max delta above threshold, actual 39 but at most 30 expected. Mean delta 18.5 is within threshold 20. Delta image:\n"
" |?M|\n"
" Pixels above max/mean threshold:\n"
@ -737,7 +763,7 @@ void CompareImageTest::compareAboveMaxThreshold() {
}
void CompareImageTest::compareAboveMeanThreshold() {
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{50.0f, 18.0f};
@ -748,7 +774,7 @@ void CompareImageTest::compareAboveMeanThreshold() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have mean delta above threshold, actual 18.5 but at most 18 expected. Max delta 39 is within threshold 50. Delta image:\n"
" |?M|\n"
" Pixels above max/mean threshold:\n"
@ -757,7 +783,7 @@ void CompareImageTest::compareAboveMeanThreshold() {
}
void CompareImageTest::compareNonZeroThreshold() {
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f};
@ -768,7 +794,7 @@ void CompareImageTest::compareNonZeroThreshold() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have deltas 39/18.5 below threshold 40/20. Delta image:\n"
" |?M|\n"
" Pixels above max/mean threshold:\n"
@ -776,7 +802,7 @@ void CompareImageTest::compareNonZeroThreshold() {
}
void CompareImageTest::compareSpecials() {
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{1.5f, 0.5f};
@ -789,7 +815,7 @@ void CompareImageTest::compareSpecials() {
/* clang-cl prints -nan(ind) instead of ±nan, but differently than MSVC */
#ifdef CORRADE_TARGET_CLANG_CL
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have both max and mean delta above threshold, actual 3.1/-nan(ind) but at most 1.5/0.5 expected. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -806,7 +832,7 @@ void CompareImageTest::compareSpecials() {
#elif defined(CORRADE_TARGET_MSVC)
#if _MSC_VER < 1929
#ifdef _M_X64
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have both max and mean delta above threshold, actual 3.1/-nan(ind) but at most 1.5/0.5 expected. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -817,7 +843,7 @@ void CompareImageTest::compareSpecials() {
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#else
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have both max and mean delta above threshold, actual 3.1/nan but at most 1.5/0.5 expected. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -829,7 +855,7 @@ void CompareImageTest::compareSpecials() {
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#endif
#else
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have both max and mean delta above threshold, actual 3.1/-nan(ind) but at most 1.5/0.5 expected. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -857,9 +883,9 @@ void CompareImageTest::compareSpecials() {
" [1,0] Vector(0.3), expected Vector(-inf) (Δ = inf)\n"
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n";
if(out.str() == expectedPositive)
CORRADE_COMPARE(out.str(), expectedPositive);
else CORRADE_COMPARE(out.str(),
if(out == expectedPositive)
CORRADE_COMPARE(out, expectedPositive);
else CORRADE_COMPARE(out,
"Images a and b have both max and mean delta above threshold, actual 3.1/-nan but at most 1.5/0.5 expected. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -873,7 +899,7 @@ void CompareImageTest::compareSpecials() {
}
void CompareImageTest::compareSpecialsMeanOnly() {
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{15.0f, 0.5f};
@ -886,7 +912,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
/* clang-cl prints -nan(ind) instead of ±nan, but differently than MSVC */
#ifdef CORRADE_TARGET_CLANG_CL
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have mean delta above threshold, actual -nan(ind) but at most 0.5 expected. Max delta 3.1 is within threshold 15. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -903,7 +929,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
#elif defined(CORRADE_TARGET_MSVC)
#if _MSC_VER < 1929
#ifdef _M_X64
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have mean delta above threshold, actual -nan(ind) but at most 0.5 expected. Max delta 3.1 is within threshold 15. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -914,7 +940,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#else
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have mean delta above threshold, actual nan but at most 0.5 expected. Max delta 3.1 is within threshold 15. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -926,7 +952,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#endif
#else
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have mean delta above threshold, actual -nan(ind) but at most 0.5 expected. Max delta 3.1 is within threshold 15. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -954,9 +980,9 @@ void CompareImageTest::compareSpecialsMeanOnly() {
" [1,0] Vector(0.3), expected Vector(-inf) (Δ = inf)\n"
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n";
if(out.str() == expectedPositive)
CORRADE_COMPARE(out.str(), expectedPositive);
else CORRADE_COMPARE(out.str(),
if(out == expectedPositive)
CORRADE_COMPARE(out, expectedPositive);
else CORRADE_COMPARE(out,
"Images a and b have mean delta above threshold, actual -nan but at most 0.5 expected. Max delta 3.1 is within threshold 15. Delta image:\n"
" |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n"
@ -972,7 +998,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
void CompareImageTest::compareSpecialsDisallowedThreshold() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
{
Error redirectError{&out};
@ -980,7 +1006,7 @@ void CompareImageTest::compareSpecialsDisallowedThreshold() {
TestSuite::Comparator<CompareImage> b{0.3f, Constants::nan()};
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::CompareImage: thresholds can't be NaN or infinity\n"
"DebugTools::CompareImage: thresholds can't be NaN or infinity\n");
}
@ -1035,7 +1061,7 @@ void CompareImageTest::imageNonZeroDelta() {
/* This will produce output if --verbose is specified */
CORRADE_COMPARE_WITH(ActualRgb, ExpectedRgb, (CompareImage{40.0f, 20.0f}));
std::ostringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f};
@ -1046,14 +1072,14 @@ void CompareImageTest::imageNonZeroDelta() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareVerbose);
CORRADE_COMPARE(out, ImageCompareVerbose);
}
void CompareImageTest::imageNonZeroDeltaNoPixels() {
/* This will produce output if --verbose is specified */
CORRADE_COMPARE_WITH(ActualRgb, ExpectedRgb, (CompareImage{40.0f, 40.0f}));
std::ostringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{40.0f, 40.0f};
@ -1066,13 +1092,13 @@ void CompareImageTest::imageNonZeroDeltaNoPixels() {
/* No pixel list written as there are no outliers. Testing this just once
since all other combinations (image/file/pixels) use the same codepath. */
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Images a and b have deltas 39/18.5 below threshold 40/40. Delta image:\n"
" |?M|\n");
}
void CompareImageTest::imageError() {
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f};
@ -1083,7 +1109,7 @@ void CompareImageTest::imageError() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareError);
CORRADE_COMPARE(out, ImageCompareError);
}
void CompareImageTest::imageFileZeroDelta() {
@ -1120,7 +1146,7 @@ void CompareImageTest::imageFileNonZeroDelta() {
CORRADE_COMPARE_WITH(actualFilename, expectedFilename,
(CompareImageFile{*_importerManager, 40.0f, 20.0f}));
std::ostringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f};
@ -1131,7 +1157,7 @@ void CompareImageTest::imageFileNonZeroDelta() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareVerbose);
CORRADE_COMPARE(out, ImageCompareVerbose);
}
void CompareImageTest::imageFileError() {
@ -1139,7 +1165,7 @@ void CompareImageTest::imageFileError() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out;
Containers::String out;
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that
@ -1158,7 +1184,7 @@ void CompareImageTest::imageFileError() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareError);
CORRADE_COMPARE(out, ImageCompareError);
/* Create the output dir if it doesn't exist, but avoid stale files making
false positives */
@ -1172,7 +1198,7 @@ void CompareImageTest::imageFileError() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{
out.str({});
out = {};
Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
}
@ -1180,7 +1206,7 @@ void CompareImageTest::imageFileError() {
/* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same
file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename));
CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
}
@ -1190,7 +1216,7 @@ void CompareImageTest::imageFilePluginLoadFailed() {
if(manager.loadState("AnyImageImporter") != PluginManager::LoadState::NotFound)
CORRADE_SKIP("AnyImageImporter plugin found, can't test.");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImageFile> compare{&manager, nullptr, 20.0f, 10.0f};
@ -1208,7 +1234,7 @@ void CompareImageTest::imageFilePluginLoadFailed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "AnyImageImporter plugin could not be loaded.\n");
CORRADE_COMPARE(out, "AnyImageImporter plugin could not be loaded.\n");
}
void CompareImageTest::imageFileActualLoadFailed() {
@ -1216,7 +1242,7 @@ void CompareImageTest::imageFileActualLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, nullptr, 20.0f, 10.0f};
@ -1233,7 +1259,7 @@ void CompareImageTest::imageFileActualLoadFailed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Actual image a (nonexistent.tga) could not be loaded.\n");
CORRADE_COMPARE(out, "Actual image a (nonexistent.tga) could not be loaded.\n");
}
void CompareImageTest::imageFileExpectedLoadFailed() {
@ -1241,7 +1267,7 @@ void CompareImageTest::imageFileExpectedLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out;
Containers::String out;
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that
@ -1258,7 +1284,7 @@ void CompareImageTest::imageFileExpectedLoadFailed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Expected image b (nonexistent.tga) could not be loaded.\n");
CORRADE_COMPARE(out, "Expected image b (nonexistent.tga) could not be loaded.\n");
/* Create the output dir if it doesn't exist, but avoid stale files making
false positives */
@ -1272,7 +1298,7 @@ void CompareImageTest::imageFileExpectedLoadFailed() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{
out.str({});
out = {};
Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
}
@ -1280,7 +1306,7 @@ void CompareImageTest::imageFileExpectedLoadFailed() {
/* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same
file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename));
CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
}
@ -1291,7 +1317,7 @@ void CompareImageTest::imageFileActualIsCompressed() {
manager.load("DdsImporter") < PluginManager::LoadState::Loaded)
CORRADE_SKIP("AnyImageImporter or DdsImporter plugins can't be loaded.");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImageFile> compare{&manager, nullptr, 20.0f, 10.0f};
@ -1309,7 +1335,7 @@ void CompareImageTest::imageFileActualIsCompressed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(Utility::String::replaceFirst(out.str(), DEBUGTOOLS_TEST_DIR, "..."), "Actual image a (.../CompareImageCompressed.dds) is compressed, comparison not possible.\n");
CORRADE_COMPARE(Utility::String::replaceFirst(out, DEBUGTOOLS_TEST_DIR, "..."), "Actual image a (.../CompareImageCompressed.dds) is compressed, comparison not possible.\n");
}
void CompareImageTest::imageFileExpectedIsCompressed() {
@ -1318,7 +1344,7 @@ void CompareImageTest::imageFileExpectedIsCompressed() {
manager.load("DdsImporter") < PluginManager::LoadState::Loaded)
CORRADE_SKIP("AnyImageImporter or DdsImporter plugins can't be loaded.");
std::stringstream out;
Containers::String out;
TestSuite::Comparator<CompareImageFile> compare{&manager, nullptr, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that
@ -1385,7 +1411,7 @@ void CompareImageTest::imageToFileNonZeroDelta() {
CORRADE_COMPARE_WITH(ActualRgb, expectedFilename,
(CompareImageToFile{*_importerManager, 40.0f, 20.0f}));
std::ostringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f};
@ -1396,7 +1422,7 @@ void CompareImageTest::imageToFileNonZeroDelta() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareVerbose);
CORRADE_COMPARE(out, ImageCompareVerbose);
}
void CompareImageTest::imageToFileError() {
@ -1404,7 +1430,7 @@ void CompareImageTest::imageToFileError() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out;
Containers::String out;
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that
@ -1422,7 +1448,7 @@ void CompareImageTest::imageToFileError() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareError);
CORRADE_COMPARE(out, ImageCompareError);
/* Create the output dir if it doesn't exist, but avoid stale files making
false positives */
@ -1436,7 +1462,7 @@ void CompareImageTest::imageToFileError() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{
out.str({});
out = {};
Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
}
@ -1444,7 +1470,7 @@ void CompareImageTest::imageToFileError() {
/* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same
file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename));
CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
}
@ -1454,7 +1480,7 @@ void CompareImageTest::imageToFilePluginLoadFailed() {
if(manager.loadState("AnyImageImporter") != PluginManager::LoadState::NotFound)
CORRADE_SKIP("AnyImageImporter plugin found, can't test.");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImageToFile> compare{&manager, nullptr, 20.0f, 10.0f};
@ -1471,7 +1497,7 @@ void CompareImageTest::imageToFilePluginLoadFailed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "AnyImageImporter plugin could not be loaded.\n");
CORRADE_COMPARE(out, "AnyImageImporter plugin could not be loaded.\n");
}
void CompareImageTest::imageToFileExpectedLoadFailed() {
@ -1479,7 +1505,7 @@ void CompareImageTest::imageToFileExpectedLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out;
Containers::String out;
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb, "nonexistent.tga");
@ -1491,7 +1517,7 @@ void CompareImageTest::imageToFileExpectedLoadFailed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Expected image b (nonexistent.tga) could not be loaded.\n");
CORRADE_COMPARE(out, "Expected image b (nonexistent.tga) could not be loaded.\n");
/* Create the output dir if it doesn't exist, but avoid stale files making
false positives */
@ -1505,7 +1531,7 @@ void CompareImageTest::imageToFileExpectedLoadFailed() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{
out.str({});
out = {};
Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
}
@ -1513,7 +1539,7 @@ void CompareImageTest::imageToFileExpectedLoadFailed() {
/* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same
file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename));
CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
}
@ -1524,7 +1550,7 @@ void CompareImageTest::imageToFileExpectedIsCompressed() {
manager.load("DdsImporter") < PluginManager::LoadState::Loaded)
CORRADE_SKIP("AnyImageImporter or DdsImporter plugins can't be loaded.");
std::stringstream out;
Containers::String out;
TestSuite::Comparator<CompareImageToFile> compare{&manager, nullptr, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that
@ -1541,7 +1567,7 @@ void CompareImageTest::imageToFileExpectedIsCompressed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(Utility::String::replaceFirst(out.str(), DEBUGTOOLS_TEST_DIR, "..."),
CORRADE_COMPARE(Utility::String::replaceFirst(out, DEBUGTOOLS_TEST_DIR, "..."),
"Expected image b (.../CompareImageCompressed.dds) is compressed, comparison not possible.\n");
/* Create the output dir if it doesn't exist, but avoid stale files making
@ -1592,7 +1618,7 @@ void CompareImageTest::fileToImageNonZeroDelta() {
CORRADE_COMPARE_WITH(actualFilename, ExpectedRgb,
(CompareFileToImage{*_importerManager, 40.0f, 20.0f}));
std::ostringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 40.0f, 20.0f};
@ -1603,7 +1629,7 @@ void CompareImageTest::fileToImageNonZeroDelta() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareVerbose);
CORRADE_COMPARE(out, ImageCompareVerbose);
}
void CompareImageTest::fileToImageError() {
@ -1611,7 +1637,7 @@ void CompareImageTest::fileToImageError() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 20.0f, 10.0f};
@ -1627,7 +1653,7 @@ void CompareImageTest::fileToImageError() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareError);
CORRADE_COMPARE(out, ImageCompareError);
}
void CompareImageTest::fileToImagePluginLoadFailed() {
@ -1635,7 +1661,7 @@ void CompareImageTest::fileToImagePluginLoadFailed() {
if(manager.loadState("AnyImageImporter") != PluginManager::LoadState::NotFound)
CORRADE_SKIP("AnyImageImporter plugin found, can't test.");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareFileToImage> compare{&manager, 20.0f, 10.0f};
@ -1651,7 +1677,7 @@ void CompareImageTest::fileToImagePluginLoadFailed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "AnyImageImporter plugin could not be loaded.\n");
CORRADE_COMPARE(out, "AnyImageImporter plugin could not be loaded.\n");
}
void CompareImageTest::fileToImageActualLoadFailed() {
@ -1659,7 +1685,7 @@ void CompareImageTest::fileToImageActualLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 20.0f, 10.0f};
@ -1670,7 +1696,7 @@ void CompareImageTest::fileToImageActualLoadFailed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Actual image a (nonexistent.tga) could not be loaded.\n");
CORRADE_COMPARE(out, "Actual image a (nonexistent.tga) could not be loaded.\n");
}
void CompareImageTest::fileToImageActualIsCompressed() {
@ -1679,7 +1705,7 @@ void CompareImageTest::fileToImageActualIsCompressed() {
manager.load("DdsImporter") < PluginManager::LoadState::Loaded)
CORRADE_SKIP("AnyImageImporter or DdsImporter plugins can't be loaded.");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareFileToImage> compare{&manager, 20.0f, 10.0f};
@ -1695,7 +1721,7 @@ void CompareImageTest::fileToImageActualIsCompressed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(Utility::String::replaceFirst(out.str(), DEBUGTOOLS_TEST_DIR, "..."),
CORRADE_COMPARE(Utility::String::replaceFirst(out, DEBUGTOOLS_TEST_DIR, "..."),
"Actual image a (.../CompareImageCompressed.dds) is compressed, comparison not possible.\n");
}
@ -1906,7 +1932,7 @@ void CompareImageTest::pixelsToImageNonZeroDelta() {
CORRADE_COMPARE_WITH(ActualRgb.pixels<Color3ub>(),
ExpectedRgb, (CompareImage{40.0f, 20.0f}));
std::ostringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f};
@ -1917,11 +1943,11 @@ void CompareImageTest::pixelsToImageNonZeroDelta() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareVerbose);
CORRADE_COMPARE(out, ImageCompareVerbose);
}
void CompareImageTest::pixelsToImageDifferentFormat() {
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{{}, {}};
@ -1933,13 +1959,13 @@ void CompareImageTest::pixelsToImageDifferentFormat() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Images a and b have different format, actual PixelFormat::RGB8I but PixelFormat::RGB8Unorm expected.\n");
CORRADE_COMPARE(out, "Images a and b have different format, actual PixelFormat::RGB8I but PixelFormat::RGB8Unorm expected.\n");
}
void CompareImageTest::pixelsToImageError() {
/* Same as imageError(), but taking pixels instead */
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f};
@ -1951,7 +1977,7 @@ void CompareImageTest::pixelsToImageError() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareError);
CORRADE_COMPARE(out, ImageCompareError);
}
template<class T> void CompareImageTest::pixelsToFileZeroDelta() {
@ -2006,7 +2032,7 @@ void CompareImageTest::pixelsToFileNonZeroDelta() {
expectedFilename,
(CompareImageToFile{*_importerManager, 40.0f, 20.0f}));
std::ostringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f};
@ -2017,7 +2043,7 @@ void CompareImageTest::pixelsToFileNonZeroDelta() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareVerbose);
CORRADE_COMPARE(out, ImageCompareVerbose);
}
void CompareImageTest::pixelsToFileDifferentFormat() {
@ -2031,7 +2057,7 @@ void CompareImageTest::pixelsToFileDifferentFormat() {
views. */
Containers::String expectedFilename = Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga");
std::stringstream out;
Containers::String out;
{
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, {}, {}};
@ -2044,7 +2070,7 @@ void CompareImageTest::pixelsToFileDifferentFormat() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Images a and b have different format, actual PixelFormat::RGB8Snorm but PixelFormat::RGB8Unorm expected.\n");
CORRADE_COMPARE(out, "Images a and b have different format, actual PixelFormat::RGB8Snorm but PixelFormat::RGB8Unorm expected.\n");
}
void CompareImageTest::pixelsToFileError() {
@ -2060,7 +2086,7 @@ void CompareImageTest::pixelsToFileError() {
views. */
Containers::String expectedFilename = Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga");
std::stringstream out;
Containers::String out;
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
/* Vector3ub gets matched to PixelFormat::R8UI initially, but once the
@ -2076,7 +2102,7 @@ void CompareImageTest::pixelsToFileError() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), ImageCompareError);
CORRADE_COMPARE(out, ImageCompareError);
/* Create the output dir if it doesn't exist, but avoid stale files making
false positives */
@ -2090,7 +2116,7 @@ void CompareImageTest::pixelsToFileError() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{
out.str({});
out = {};
Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
}
@ -2098,7 +2124,7 @@ void CompareImageTest::pixelsToFileError() {
/* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same
file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename));
CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
}
@ -2110,7 +2136,7 @@ void CompareImageTest::pixelsToFileExpectedLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out;
Containers::String out;
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb.pixels<Color3ub>(), "nonexistent.tga");
@ -2122,7 +2148,7 @@ void CompareImageTest::pixelsToFileExpectedLoadFailed() {
compare.printMessage(flags, d, "a", "b");
}
CORRADE_COMPARE(out.str(), "Expected image b (nonexistent.tga) could not be loaded.\n");
CORRADE_COMPARE(out, "Expected image b (nonexistent.tga) could not be loaded.\n");
/* Create the output dir if it doesn't exist, but avoid stale files making
false positives */
@ -2136,7 +2162,7 @@ void CompareImageTest::pixelsToFileExpectedLoadFailed() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{
out.str({});
out = {};
Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
}
@ -2144,7 +2170,7 @@ void CompareImageTest::pixelsToFileExpectedLoadFailed() {
/* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same
file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename));
CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
}

11
src/Magnum/DebugTools/Test/CompareMaterialTest.cpp

@ -24,10 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/DebugTools/CompareMaterial.h"
#include "Magnum/Math/Color.h"
@ -353,12 +352,12 @@ void CompareMaterialTest::different() {
compare.printMessage(flags, out, "a", "b");
}
std::ostringstream out;
Containers::String out;
{
Debug dc{&out, Debug::Flag::DisableColors};
compare.printMessage(flags, dc, "a", "b");
}
CORRADE_COMPARE(out.str(), data.message);
CORRADE_COMPARE(out, data.message);
}
void CompareMaterialTest::differentReverse() {
@ -375,12 +374,12 @@ void CompareMaterialTest::differentReverse() {
compare.printMessage(flags, out, "b", "a");
}
std::ostringstream out;
Containers::String out;
{
Debug dc{&out, Debug::Flag::DisableColors};
compare.printMessage(flags, dc, "b", "a");
}
CORRADE_COMPARE(out.str(), data.messageReverse);
CORRADE_COMPARE(out, data.messageReverse);
}
}}}}

59
src/Magnum/DebugTools/Test/FrameProfilerTest.cpp

@ -24,12 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/ConfigurationGroup.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Configuration is std::string-free */
#include <Corrade/Utility/System.h>
#include "Magnum/DebugTools/FrameProfiler.h"
@ -781,32 +780,32 @@ void FrameProfilerTest::move() {
void FrameProfilerTest::delayZero() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
FrameProfiler::Measurement{"", FrameProfiler::Units::Count, 0,
nullptr, nullptr, nullptr, nullptr};
CORRADE_COMPARE(out.str(), "DebugTools::FrameProfiler::Measurement: delay can't be zero\n");
CORRADE_COMPARE(out, "DebugTools::FrameProfiler::Measurement: delay can't be zero\n");
}
void FrameProfilerTest::frameCountZero() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
FrameProfiler{{}, 0};
CORRADE_COMPARE(out.str(), "DebugTools::FrameProfiler::setup(): max frame count can't be zero\n");
CORRADE_COMPARE(out, "DebugTools::FrameProfiler::setup(): max frame count can't be zero\n");
}
void FrameProfilerTest::delayTooLittleFrames() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
FrameProfiler profiler{{
FrameProfiler::Measurement{"", FrameProfiler::Units::Count, 3,
nullptr, nullptr, nullptr, nullptr}
}, 2};
CORRADE_COMPARE(out.str(), "DebugTools::FrameProfiler::setup(): max delay 3 is larger than max frame count 2\n");
CORRADE_COMPARE(out, "DebugTools::FrameProfiler::setup(): max delay 3 is larger than max frame count 2\n");
}
void FrameProfilerTest::startStopFrameUnexpected() {
@ -814,7 +813,7 @@ void FrameProfilerTest::startStopFrameUnexpected() {
FrameProfiler profiler;
std::ostringstream out;
Containers::String out;
{
Error redirectError{&out};
profiler.endFrame();
@ -824,7 +823,7 @@ void FrameProfilerTest::startStopFrameUnexpected() {
Error redirectError{&out};
profiler.beginFrame();
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::endFrame(): expected begin of frame\n"
"DebugTools::FrameProfiler::beginFrame(): expected end of frame\n");
}
@ -839,14 +838,14 @@ void FrameProfilerTest::measurementOutOfRange() {
nullptr, nullptr, nullptr}
}, 1};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
profiler.measurementName(2);
profiler.measurementUnits(2);
profiler.measurementDelay(2);
profiler.measurementData(2, 0);
profiler.measurementMean(2);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementName(): index 2 out of range for 2 measurements\n"
"DebugTools::FrameProfiler::measurementUnits(): index 2 out of range for 2 measurements\n"
"DebugTools::FrameProfiler::measurementDelay(): index 2 out of range for 2 measurements\n"
@ -870,10 +869,10 @@ void FrameProfilerTest::frameOutOfRange() {
profiler.beginFrame();
profiler.endFrame();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
profiler.measurementData(0, 3);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementData(): frame 3 out of range for max 3 frames\n");
}
@ -889,10 +888,10 @@ void FrameProfilerTest::dataNotAvailableYet() {
/* Empty state */
{
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
profiler.measurementData(0, 0);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementData(): frame 0 of measurement 0 not available yet (delay 3, 0 frames measured so far)\n");
}
@ -910,12 +909,12 @@ void FrameProfilerTest::dataNotAvailableYet() {
profiler.measurementData(0, 0);
profiler.measurementData(0, 1);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
profiler.measurementData(0, 2);
profiler.measurementData(0, 3);
profiler.measurementData(0, 4);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementData(): frame 2 of measurement 0 not available yet (delay 3, 4 frames measured so far)\n"
"DebugTools::FrameProfiler::measurementData(): frame 3 of measurement 0 not available yet (delay 3, 4 frames measured so far)\n"
"DebugTools::FrameProfiler::measurementData(): frame 4 of measurement 0 not available yet (delay 3, 4 frames measured so far)\n");
@ -933,10 +932,10 @@ void FrameProfilerTest::dataNotAvailableYet() {
profiler.measurementData(0, 2);
profiler.measurementData(0, 3);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
profiler.measurementData(0, 4);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementData(): frame 4 of measurement 0 not available yet (delay 3, 6 frames measured so far)\n");
}
}
@ -957,10 +956,10 @@ void FrameProfilerTest::meanNotAvailableYet() {
CORRADE_COMPARE(profiler.measuredFrameCount(), 1);
CORRADE_VERIFY(!profiler.isMeasurementAvailable(0));
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
profiler.measurementMean(0);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementMean(): measurement data available after 2 more frames\n");
}
@ -1160,13 +1159,13 @@ void FrameProfilerTest::glNotEnabled() {
FrameProfilerGL profiler{{}, 5};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
profiler.isMeasurementAvailable(FrameProfilerGL::Value::CpuDuration);
profiler.frameTimeMean();
profiler.cpuDurationMean();
profiler.gpuDurationMean();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"DebugTools::FrameProfilerGL::isMeasurementAvailable(): DebugTools::FrameProfilerGL::Value::CpuDuration not enabled\n"
"DebugTools::FrameProfilerGL::frameTimeMean(): not enabled\n"
"DebugTools::FrameProfilerGL::cpuDurationMean(): not enabled\n"
@ -1175,25 +1174,25 @@ void FrameProfilerTest::glNotEnabled() {
#endif
void FrameProfilerTest::debugUnits() {
std::ostringstream out;
Containers::String out;
Debug{&out} << FrameProfiler::Units::Nanoseconds << FrameProfiler::Units(0xf0);
CORRADE_COMPARE(out.str(), "DebugTools::FrameProfiler::Units::Nanoseconds DebugTools::FrameProfiler::Units(0xf0)\n");
CORRADE_COMPARE(out, "DebugTools::FrameProfiler::Units::Nanoseconds DebugTools::FrameProfiler::Units(0xf0)\n");
}
#ifdef MAGNUM_TARGET_GL
void FrameProfilerTest::debugGLValue() {
std::ostringstream out;
Containers::String out;
Debug{&out} << FrameProfilerGL::Value::GpuDuration << FrameProfilerGL::Value(0xfff0);
CORRADE_COMPARE(out.str(), "DebugTools::FrameProfilerGL::Value::GpuDuration DebugTools::FrameProfilerGL::Value(0xfff0)\n");
CORRADE_COMPARE(out, "DebugTools::FrameProfilerGL::Value::GpuDuration DebugTools::FrameProfilerGL::Value(0xfff0)\n");
}
void FrameProfilerTest::debugGLValues() {
std::ostringstream out;
Containers::String out;
Debug{&out} << (FrameProfilerGL::Value::CpuDuration|FrameProfilerGL::Value::FrameTime) << FrameProfilerGL::Values{};
CORRADE_COMPARE(out.str(), "DebugTools::FrameProfilerGL::Value::FrameTime|DebugTools::FrameProfilerGL::Value::CpuDuration DebugTools::FrameProfilerGL::Values{}\n");
CORRADE_COMPARE(out, "DebugTools::FrameProfilerGL::Value::FrameTime|DebugTools::FrameProfilerGL::Value::CpuDuration DebugTools::FrameProfilerGL::Values{}\n");
}
void FrameProfilerTest::configurationGLValue() {

32
src/Magnum/DebugTools/Test/ScreenshotGLTest.cpp

@ -24,12 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/String.h>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Path.h>
#include "Magnum/ImageView.h"
@ -130,7 +128,7 @@ void ScreenshotGLTest::rgba8() {
else
CORRADE_VERIFY(Utility::Path::make(SCREENSHOTTEST_SAVE_DIR));
std::ostringstream out;
Containers::String out;
bool succeeded;
{
#ifndef MAGNUM_TARGET_WEBGL
@ -145,8 +143,8 @@ void ScreenshotGLTest::rgba8() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(succeeded);
CORRADE_COMPARE(out.str(),
Utility::formatString("DebugTools::screenshot(): saved a PixelFormat::RGBA8Unorm image of size Vector(4, 3) to {}\n", file));
CORRADE_COMPARE(out,
Utility::format("DebugTools::screenshot(): saved a PixelFormat::RGBA8Unorm image of size Vector(4, 3) to {}\n", file));
if(!(_importerManager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) ||
!(_importerManager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
@ -187,7 +185,7 @@ void ScreenshotGLTest::r8() {
else
CORRADE_VERIFY(Utility::Path::make(SCREENSHOTTEST_SAVE_DIR));
std::ostringstream out;
Containers::String out;
bool succeeded;
{
#ifndef MAGNUM_TARGET_WEBGL
@ -207,8 +205,8 @@ void ScreenshotGLTest::r8() {
CORRADE_EXPECT_FAIL_IF(framebuffer.implementationColorReadFormat() != GL::PixelFormat::Red,
"Implementation-defined color read format is not single-channel.");
CORRADE_COMPARE(out.str(),
Utility::formatString("DebugTools::screenshot(): saved a PixelFormat::R8Unorm image of size Vector(4, 3) to {}\n", file));
CORRADE_COMPARE(out,
Utility::format("DebugTools::screenshot(): saved a PixelFormat::R8Unorm image of size Vector(4, 3) to {}\n", file));
if(!(_importerManager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) ||
!(_importerManager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
@ -234,7 +232,7 @@ void ScreenshotGLTest::unknownFormat() {
framebuffer.implementationColorReadType() == GL::PixelType::UnsignedByte)
CORRADE_SKIP("The framebuffer read format is RGBA8, can't test.");
std::ostringstream out;
Containers::String out;
bool succeeded;
{
Error redirectOutput{&out};
@ -245,9 +243,9 @@ void ScreenshotGLTest::unknownFormat() {
CORRADE_VERIFY(!succeeded);
if(framebuffer.implementationColorReadFormat() == GL::PixelFormat::RGBA)
CORRADE_COMPARE(out.str(), "DebugTools::screenshot(): can't map {GL::PixelFormat::RGBA, GL::PixelType::UnsignedShort565} to a generic pixel format\n");
CORRADE_COMPARE(out, "DebugTools::screenshot(): can't map {GL::PixelFormat::RGBA, GL::PixelType::UnsignedShort565} to a generic pixel format\n");
else
CORRADE_COMPARE(out.str(), "DebugTools::screenshot(): can't map {GL::PixelFormat::RGB, GL::PixelType::UnsignedShort565} to a generic pixel format\n");
CORRADE_COMPARE(out, "DebugTools::screenshot(): can't map {GL::PixelFormat::RGB, GL::PixelType::UnsignedShort565} to a generic pixel format\n");
}
void ScreenshotGLTest::pluginLoadFailed() {
@ -271,7 +269,7 @@ void ScreenshotGLTest::pluginLoadFailed() {
CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete);
std::ostringstream out;
Containers::String out;
bool succeeded;
{
Error redirectOutput{&out};
@ -281,9 +279,9 @@ void ScreenshotGLTest::pluginLoadFailed() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(!succeeded);
#ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT
CORRADE_COMPARE(out.str(), "PluginManager::Manager::load(): plugin AnyImageConverter is not static and was not found in nowhere\n");
CORRADE_COMPARE(out, "PluginManager::Manager::load(): plugin AnyImageConverter is not static and was not found in nowhere\n");
#else
CORRADE_COMPARE(out.str(), "PluginManager::Manager::load(): plugin AnyImageConverter was not found\n");
CORRADE_COMPARE(out, "PluginManager::Manager::load(): plugin AnyImageConverter was not found\n");
#endif
}
@ -307,7 +305,7 @@ void ScreenshotGLTest::saveFailed() {
CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete);
std::ostringstream out;
Containers::String out;
bool succeeded;
{
Error redirectOutput{&out};
@ -316,7 +314,7 @@ void ScreenshotGLTest::saveFailed() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(!succeeded);
CORRADE_COMPARE(out.str(), "Trade::AnyImageConverter::convertToFile(): cannot determine the format of image.poo for a 2D image\n");
CORRADE_COMPARE(out, "Trade::AnyImageConverter::convertToFile(): cannot determine the format of image.poo for a 2D image\n");
}
}}}}

27
src/Magnum/DebugTools/Test/TextureImageGLTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h"
#include "Magnum/ImageView.h"
@ -143,15 +142,15 @@ void TextureImageGLTest::subImage2DNotReadable() {
texture.setImage(0, GL::TextureFormat::RGB9E5, ImageView2D{GL::PixelFormat::RGB, GL::PixelType::UnsignedInt5999Rev, Vector2i{2}, Data2D});
#endif
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */
textureSubImage(texture, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(out.str(), "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
#else
CORRADE_COMPARE(out.str(), "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::IncompleteAttachment\n");
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::IncompleteAttachment\n");
#endif
}
@ -186,15 +185,15 @@ void TextureImageGLTest::subImage2DBufferNotReadable() {
GL::Texture2D texture;
texture.setImage(0, GL::TextureFormat::RGB9E5, ImageView2D{GL::PixelFormat::RGB, GL::PixelType::UnsignedInt5999Rev, Vector2i{2}, Data2D});
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */
textureSubImage(texture, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead);
MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(out.str(), "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
#else
CORRADE_COMPARE(out.str(), "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::IncompleteAttachment\n");
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::IncompleteAttachment\n");
#endif
}
#endif
@ -272,15 +271,15 @@ void TextureImageGLTest::subImageCubeNotReadable() {
.setImage(GL::CubeMapCoordinate::PositiveZ, 0, format, view)
.setImage(GL::CubeMapCoordinate::NegativeZ, 0, format, view);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */
textureSubImage(texture, GL::CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(out.str(), "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
#else
CORRADE_COMPARE(out.str(), "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::IncompleteAttachment\n");
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::IncompleteAttachment\n");
#endif
}
@ -330,15 +329,15 @@ void TextureImageGLTest::subImageCubeBufferNotReadable() {
.setImage(GL::CubeMapCoordinate::PositiveZ, 0, format, view)
.setImage(GL::CubeMapCoordinate::NegativeZ, 0, format, view);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */
textureSubImage(texture, GL::CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead);
MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(out.str(), "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::Unsupported\n");
#else
CORRADE_COMPARE(out.str(), "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::IncompleteAttachment\n");
CORRADE_COMPARE(out, "DebugTools::textureSubImage(): texture format not framebuffer-readable: GL::Framebuffer::Status::IncompleteAttachment\n");
#endif
}
#endif

35
src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp

@ -25,16 +25,13 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/StringStl.h> /* StringHasPrefix / StringHasSuffix */
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Resource.h>
#include <Corrade/Utility/System.h>
@ -630,7 +627,7 @@ void AbstractShaderProgramGLTest::linkFailure() {
/* And thus linking as well, saying something like "error: linking with
uncompiled/unspecialized shader" */
std::ostringstream out;
Containers::String out;
{
Error redirectError{&out};
CORRADE_VERIFY(!program.link());
@ -640,12 +637,12 @@ void AbstractShaderProgramGLTest::linkFailure() {
CORRADE_VERIFY(program.isLinkFinished());
/* There's a driver-specific message after */
CORRADE_COMPARE_AS(out.str(), "GL::AbstractShaderProgram::link(): linking failed with the following message:",
CORRADE_COMPARE_AS(out, "GL::AbstractShaderProgram::link(): linking failed with the following message:",
TestSuite::Compare::StringHasPrefix);
/* No stray \0 should be anywhere */
CORRADE_COMPARE_AS(out.str(), "\0"_s, TestSuite::Compare::StringNotContains);
CORRADE_COMPARE_AS(out, "\0"_s, TestSuite::Compare::StringNotContains);
/* The message should end with a newline */
CORRADE_COMPARE_AS(out.str(), "\n"_s, TestSuite::Compare::StringHasSuffix);
CORRADE_COMPARE_AS(out, "\n"_s, TestSuite::Compare::StringHasSuffix);
}
void AbstractShaderProgramGLTest::linkFailureAsync() {
@ -672,7 +669,7 @@ void AbstractShaderProgramGLTest::linkFailureAsync() {
program.attachShaders({shader});
/* The link submission should not print anything ... */
std::ostringstream out;
Containers::String out;
{
Error redirectError{&out};
program.submitLink();
@ -681,7 +678,7 @@ void AbstractShaderProgramGLTest::linkFailureAsync() {
while(!program.isLinkFinished())
Utility::System::sleep(100);
CORRADE_VERIFY(out.str().empty());
CORRADE_COMPARE(out, "");
/* ... only the final check should. In this case it's "error: linking with
uncompiled/unspecialized shader" as well, but if the shaders would be
@ -692,7 +689,7 @@ void AbstractShaderProgramGLTest::linkFailureAsync() {
CORRADE_VERIFY(!program.checkLink({}));
}
CORRADE_VERIFY(program.isLinkFinished());
CORRADE_COMPARE_AS(out.str(), "GL::AbstractShaderProgram::link(): linking failed with the following message:",
CORRADE_COMPARE_AS(out, "GL::AbstractShaderProgram::link(): linking failed with the following message:",
TestSuite::Compare::StringHasPrefix);
/* Not testing presence of \0 etc., as that's tested well enough in
@ -735,26 +732,26 @@ void AbstractShaderProgramGLTest::linkFailureAsyncShaderList() {
/* The link submission should not print anything ... */
{
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
program.submitLink();
CORRADE_VERIFY(out.str().empty());
CORRADE_COMPARE(out, "");
}
/* ... only the final check should. Vertex shader should be fine, but
fragment should fail. */
std::ostringstream out;
Containers::String out;
{
Error redirectError{&out};
CORRADE_VERIFY(!program.checkLink({vert, frag}));
}
CORRADE_COMPARE_AS(out.str(), "GL::Shader::compile(): compilation of fragment shader failed with the following message:",
CORRADE_COMPARE_AS(out, "GL::Shader::compile(): compilation of fragment shader failed with the following message:",
TestSuite::Compare::StringHasPrefix);
/* The linker error (which would most probably say something like "error:
linking with uncompiled/unspecialized shader") should not be even
printed */
CORRADE_COMPARE_AS(out.str(), "GL::AbstractShaderProgram::link(): linking failed with the following message:",
CORRADE_COMPARE_AS(out, "GL::AbstractShaderProgram::link(): linking failed with the following message:",
TestSuite::Compare::StringNotContains);
}
@ -876,10 +873,10 @@ void AbstractShaderProgramGLTest::uniformNotFound() {
program.attachShaders({vert, frag});
CORRADE_VERIFY(program.link());
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
program.uniformLocation("nonexistent");
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram: location of uniform 'nonexistent' cannot be retrieved\n");
}
@ -1174,10 +1171,10 @@ void AbstractShaderProgramGLTest::uniformBlockIndexNotFound() {
program.attachShaders({vert, frag});
CORRADE_VERIFY(program.link());
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
program.uniformBlockIndex("nonexistent");
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram: index of uniform block 'nonexistent' cannot be retrieved\n");
}

51
src/Magnum/GL/Test/AbstractTextureGLTest.cpp

@ -24,8 +24,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Containers/String.h>
#include "Magnum/ImageView.h"
#include "Magnum/GL/Context.h"
@ -132,10 +131,10 @@ void AbstractTextureGLTest::imageQueryViewNullptr() {
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, {nullptr, 2*2*4}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.image(0, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::image(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::image(): image view is nullptr\n");
}
void AbstractTextureGLTest::imageQueryViewBadSize() {
@ -149,10 +148,10 @@ void AbstractTextureGLTest::imageQueryViewBadSize() {
char data[2*4];
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2, 1}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.image(0, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::image(): expected image view size Vector(2, 2) but got Vector(2, 1)\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::image(): expected image view size Vector(2, 2) but got Vector(2, 1)\n");
}
void AbstractTextureGLTest::subImageQueryViewNullptr() {
@ -165,10 +164,10 @@ void AbstractTextureGLTest::subImageQueryViewNullptr() {
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, {nullptr, 2*2*4}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.subImage(0, {{}, Vector2i{2}}, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::subImage(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::subImage(): image view is nullptr\n");
}
void AbstractTextureGLTest::subImageQueryViewBadSize() {
@ -185,10 +184,10 @@ void AbstractTextureGLTest::subImageQueryViewBadSize() {
char data[2*4];
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2, 1}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.subImage(0, {{}, Vector2i{2}}, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::subImage(): expected image view size Vector(2, 2) but got Vector(2, 1)\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::subImage(): expected image view size Vector(2, 2) but got Vector(2, 1)\n");
}
void AbstractTextureGLTest::compressedImageQueryViewNullptr() {
@ -204,10 +203,10 @@ void AbstractTextureGLTest::compressedImageQueryViewNullptr() {
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, {nullptr, 16}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::compressedImage(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::compressedImage(): image view is nullptr\n");
}
void AbstractTextureGLTest::compressedImageQueryViewBadSize() {
@ -224,10 +223,10 @@ void AbstractTextureGLTest::compressedImageQueryViewBadSize() {
char data[2*16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4, 8}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::compressedImage(): expected image view size Vector(4, 4) but got Vector(4, 8)\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::compressedImage(): expected image view size Vector(4, 4) but got Vector(4, 8)\n");
}
void AbstractTextureGLTest::compressedImageQueryViewBadDataSize() {
@ -244,10 +243,10 @@ void AbstractTextureGLTest::compressedImageQueryViewBadDataSize() {
char data[16 - 1];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::compressedImage(): expected image view data size 16 bytes but got 15\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::compressedImage(): expected image view data size 16 bytes but got 15\n");
}
void AbstractTextureGLTest::compressedImageQueryViewBadFormat() {
@ -264,10 +263,10 @@ void AbstractTextureGLTest::compressedImageQueryViewBadFormat() {
char data[16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector2i{4}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
}
void AbstractTextureGLTest::compressedSubImageQueryViewNullptr() {
@ -287,10 +286,10 @@ void AbstractTextureGLTest::compressedSubImageQueryViewNullptr() {
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, {nullptr, 16}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedSubImage(0, {{}, Vector2i{4}}, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::compressedSubImage(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::compressedSubImage(): image view is nullptr\n");
}
void AbstractTextureGLTest::compressedSubImageQueryViewBadSize() {
@ -311,10 +310,10 @@ void AbstractTextureGLTest::compressedSubImageQueryViewBadSize() {
char data[2*16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4, 8}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedSubImage(0, {{}, Vector2i{4}}, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::compressedSubImage(): expected image view size Vector(4, 4) but got Vector(4, 8)\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::compressedSubImage(): expected image view size Vector(4, 4) but got Vector(4, 8)\n");
}
void AbstractTextureGLTest::compressedSubImageQueryViewBadDataSize() {
@ -335,10 +334,10 @@ void AbstractTextureGLTest::compressedSubImageQueryViewBadDataSize() {
char data[16 - 1];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedSubImage(0, {{}, Vector2i{4}}, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::compressedSubImage(): expected image view data size 16 bytes but got 15\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::compressedSubImage(): expected image view data size 16 bytes but got 15\n");
}
void AbstractTextureGLTest::compressedSubImageQueryViewBadFormat() {
@ -359,10 +358,10 @@ void AbstractTextureGLTest::compressedSubImageQueryViewBadFormat() {
char data[16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector2i{4}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedSubImage(0, {{}, Vector2i{4}}, image);
CORRADE_COMPARE(out.str(), "GL::AbstractTexture::compressedSubImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
CORRADE_COMPARE(out, "GL::AbstractTexture::compressedSubImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
}
#endif

93
src/Magnum/GL/Test/AttributeTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/VertexFormat.h"
#include "Magnum/GL/Attribute.h"
@ -1109,11 +1108,11 @@ void AttributeTest::attributeFromGenericFormatEnableNormalized() {
void AttributeTest::attributeFromGenericFormatUnexpectedForNormalizedKind() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DynamicAttribute{DynamicAttribute::Kind::GenericNormalized, 3,
VertexFormat::Int};
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::DynamicAttribute: can't use VertexFormat::Int for a normalized attribute\n");
}
@ -1121,13 +1120,13 @@ void AttributeTest::attributeFromGenericFormatUnexpectedForNormalizedKind() {
void AttributeTest::attributeFromGenericFormatUnexpectedForIntegralKind() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DynamicAttribute{DynamicAttribute::Kind::Integral, 3,
VertexFormat::Vector2bNormalized};
DynamicAttribute{DynamicAttribute::Kind::Integral, 3,
VertexFormat::Vector3};
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::DynamicAttribute: can't use VertexFormat::Vector2bNormalized for a GL::DynamicAttribute::Kind::Integral attribute\n"
"GL::DynamicAttribute: can't use VertexFormat::Vector3 for an integral attribute\n");
}
@ -1137,11 +1136,11 @@ void AttributeTest::attributeFromGenericFormatUnexpectedForIntegralKind() {
void AttributeTest::attributeFromGenericFormatUnexpectedForLongKind() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DynamicAttribute{DynamicAttribute::Kind::Long, 3,
VertexFormat::UnsignedShortNormalized};
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::DynamicAttribute: can't use VertexFormat::UnsignedShortNormalized for a GL::DynamicAttribute::Kind::Long attribute\n");
}
#endif
@ -1149,20 +1148,20 @@ void AttributeTest::attributeFromGenericFormatUnexpectedForLongKind() {
void AttributeTest::attributeFromGenericFormatTooManyVectors() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DynamicAttribute{Attribute<7, Vector2>{}, VertexFormat::Matrix2x2};
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::DynamicAttribute: can't use VertexFormat::Matrix2x2 for a 1-vector attribute\n");
}
void AttributeTest::attributeFromGenericFormatTooManyComponents() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DynamicAttribute{Attribute<7, Vector2>{}, VertexFormat::Vector3};
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::DynamicAttribute: can't use VertexFormat::Vector3 for a 2-component attribute\n");
}
@ -1170,10 +1169,10 @@ void AttributeTest::attributeFromGenericFormatNotAvailable() {
#ifndef MAGNUM_TARGET_GLES
CORRADE_SKIP("All attribute formats available on desktop GL.");
#else
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DynamicAttribute{Attribute<7, Vector2>{}, VertexFormat::Vector3d};
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::DynamicAttribute: VertexFormat::Vector3d isn't available on this target\n");
#endif
}
@ -1219,79 +1218,79 @@ void AttributeTest::hasVertexFormat() {
void AttributeTest::debugComponents1() {
typedef Attribute<3, Float> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::Components::One << Attribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::Components::One GL::Attribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::Components::One GL::Attribute::Components(0xdead)\n");
}
void AttributeTest::debugComponents2() {
typedef Attribute<3, Vector2> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::Components::Two << Attribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::Components::Two GL::Attribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::Components::Two GL::Attribute::Components(0xdead)\n");
}
void AttributeTest::debugComponents3() {
typedef Attribute<3, Vector3> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::Components::Three << Attribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::Components::Three GL::Attribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::Components::Three GL::Attribute::Components(0xdead)\n");
}
#ifndef MAGNUM_TARGET_GLES2
void AttributeTest::debugComponents4() {
typedef Attribute<3, Vector4i> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::Components::Four << Attribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::Components::Four GL::Attribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::Components::Four GL::Attribute::Components(0xdead)\n");
}
#endif
void AttributeTest::debugComponentsMatrix2() {
typedef Attribute<3, Matrix2x2> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::Components::Two << Attribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::Components::Two GL::Attribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::Components::Two GL::Attribute::Components(0xdead)\n");
}
void AttributeTest::debugComponentsMatrix3() {
typedef Attribute<3, Matrix3> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::Components::Three << Attribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::Components::Three GL::Attribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::Components::Three GL::Attribute::Components(0xdead)\n");
}
void AttributeTest::debugComponentsMatrix4() {
typedef Attribute<3, Matrix4> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::Components::Four << Attribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::Components::Four GL::Attribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::Components::Four GL::Attribute::Components(0xdead)\n");
}
void AttributeTest::debugComponentsVector4() {
typedef Attribute<3, Vector4> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::Components::Three << Attribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::Components::Three GL::Attribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::Components::Three GL::Attribute::Components(0xdead)\n");
}
void AttributeTest::debugDataTypeFloat() {
typedef Attribute<3, Float> Attribute;
std::ostringstream out;
Containers::String out;
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
Debug{&out} << Attribute::DataType::Half << Attribute::DataType(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Half GL::Attribute::DataType(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::DataType::Half GL::Attribute::DataType(0xdead)\n");
#else
Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n");
#endif
}
@ -1299,9 +1298,9 @@ void AttributeTest::debugDataTypeFloat() {
void AttributeTest::debugDataTypeInt() {
typedef Attribute<3, Int> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::DataType::Short << Attribute::DataType(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Short GL::Attribute::DataType(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::DataType::Short GL::Attribute::DataType(0xdead)\n");
}
#endif
@ -1309,44 +1308,44 @@ void AttributeTest::debugDataTypeInt() {
void AttributeTest::debugDataTypeDouble() {
typedef Attribute<3, Double> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::DataType::Double << Attribute::DataType(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Double GL::Attribute::DataType(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::DataType::Double GL::Attribute::DataType(0xdead)\n");
}
#endif
void AttributeTest::debugDataTypeVector3() {
typedef Attribute<3, Vector3> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n");
}
void AttributeTest::debugDataTypeVector4() {
typedef Attribute<3, Vector4> Attribute;
std::ostringstream out;
Containers::String out;
Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead);
CORRADE_COMPARE(out.str(), "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n");
CORRADE_COMPARE(out, "GL::Attribute::DataType::Float GL::Attribute::DataType(0xdead)\n");
}
void AttributeTest::debugDynamicKind() {
std::ostringstream out;
Containers::String out;
Debug{&out} << DynamicAttribute::Kind::GenericNormalized << DynamicAttribute::Kind(0xfe);
CORRADE_COMPARE(out.str(), "GL::DynamicAttribute::Kind::GenericNormalized GL::DynamicAttribute::Kind(0xfe)\n");
CORRADE_COMPARE(out, "GL::DynamicAttribute::Kind::GenericNormalized GL::DynamicAttribute::Kind(0xfe)\n");
}
void AttributeTest::debugDynamicComponents() {
std::ostringstream out;
Containers::String out;
Debug{&out} << DynamicAttribute::Components::Three << DynamicAttribute::Components(0xdead);
CORRADE_COMPARE(out.str(), "GL::DynamicAttribute::Components::Three GL::DynamicAttribute::Components(0xdead)\n");
CORRADE_COMPARE(out, "GL::DynamicAttribute::Components::Three GL::DynamicAttribute::Components(0xdead)\n");
}
void AttributeTest::debugDynamicDataType() {
std::ostringstream out;
Containers::String out;
Debug{&out} << DynamicAttribute::DataType::Float << DynamicAttribute::DataType(0xdead);
CORRADE_COMPARE(out.str(), "GL::DynamicAttribute::DataType::Float GL::DynamicAttribute::DataType(0xdead)\n");
CORRADE_COMPARE(out, "GL::DynamicAttribute::DataType::Float GL::DynamicAttribute::DataType(0xdead)\n");
}
}}}}

16
src/Magnum/GL/Test/BufferImageGLTest.cpp

@ -24,10 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once dataProperties() std::pair is gone */
#include "Magnum/PixelFormat.h"
#include "Magnum/GL/BufferImage.h"
@ -333,12 +333,12 @@ void BufferImageGLTest::constructBufferCompressedGeneric() {
void BufferImageGLTest::constructInvalidSize() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* Doesn't consider alignment */
BufferImage2D{Magnum::PixelFormat::RGB8Unorm, {1, 3}, Containers::Array<char>{3*3}, BufferUsage::StaticDraw};
CORRADE_COMPARE(out.str(), "GL::BufferImage::BufferImage(): data too small, got 9 but expected at least 12 bytes\n");
CORRADE_COMPARE(out, "GL::BufferImage::BufferImage(): data too small, got 9 but expected at least 12 bytes\n");
}
void BufferImageGLTest::constructCompressedInvalidSize() {
@ -346,17 +346,17 @@ void BufferImageGLTest::constructCompressedInvalidSize() {
/* Too small for given format */
{
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CompressedBufferImage2D{Magnum::CompressedPixelFormat::Bc2RGBAUnorm, {4, 4}, Containers::Array<char>{2}, BufferUsage::StaticDraw};
CORRADE_COMPARE(out.str(), "GL::CompressedBufferImage::CompressedBufferImage(): data too small, got 2 but expected at least 4 bytes\n");
CORRADE_COMPARE(out, "GL::CompressedBufferImage::CompressedBufferImage(): data too small, got 2 but expected at least 4 bytes\n");
/* Size should be rounded up even if the image size is not full block */
} {
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CompressedBufferImage2D{Magnum::CompressedPixelFormat::Bc2RGBAUnorm, {2, 2}, Containers::Array<char>{2}, BufferUsage::StaticDraw};
CORRADE_COMPARE(out.str(), "GL::CompressedBufferImage::CompressedBufferImage(): data too small, got 2 but expected at least 4 bytes\n");
CORRADE_COMPARE(out, "GL::CompressedBufferImage::CompressedBufferImage(): data too small, got 2 but expected at least 4 bytes\n");
}
}

11
src/Magnum/GL/Test/BufferTest.cpp

@ -25,9 +25,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Buffer.h"
@ -72,16 +71,16 @@ void BufferTest::constructCopy() {
}
void BufferTest::debugTargetHint() {
std::ostringstream out;
Containers::String out;
Debug{&out} << Buffer::TargetHint::Array << Buffer::TargetHint(0xdead);
CORRADE_COMPARE(out.str(), "GL::Buffer::TargetHint::Array GL::Buffer::TargetHint(0xdead)\n");
CORRADE_COMPARE(out, "GL::Buffer::TargetHint::Array GL::Buffer::TargetHint(0xdead)\n");
}
#ifndef MAGNUM_TARGET_GLES2
void BufferTest::debugTarget() {
std::ostringstream out;
Containers::String out;
Debug{&out} << Buffer::Target::Uniform << Buffer::Target(0xdead);
CORRADE_COMPARE(out.str(), "GL::Buffer::Target::Uniform GL::Buffer::Target(0xdead)\n");
CORRADE_COMPARE(out, "GL::Buffer::Target::Uniform GL::Buffer::Target(0xdead)\n");
}
#endif

13
src/Magnum/GL/Test/ContextGLTest.cpp

@ -25,7 +25,6 @@
*/
#include <algorithm> /* std::find() */
#include <sstream>
#include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/StringIterable.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once Debug is stream-free */
@ -267,7 +266,7 @@ void ContextGLTest::constructConfiguration() {
if(data.needsExtensionMissing && Context::current().isExtensionSupported(*data.needsExtensionMissing))
CORRADE_SKIP(data.needsExtensionMissing->string() << "is supported.");
std::ostringstream out;
Containers::String out;
{
Context* current = &Context::current();
Context::makeCurrent(nullptr);
@ -282,11 +281,11 @@ void ContextGLTest::constructConfiguration() {
}
if(!data.logShouldContain.isEmpty())
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
data.logShouldContain,
TestSuite::Compare::StringContains);
if(!data.logShouldNotContain.isEmpty())
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
data.logShouldNotContain,
TestSuite::Compare::StringNotContains);
}
@ -329,7 +328,7 @@ void ContextGLTest::constructMove() {
/* The context is still not created here either */
CORRADE_VERIFY(!Context::hasCurrent());
std::ostringstream out;
Containers::String out;
{
Debug redirectOut{&out};
b.create(Context::Configuration{}
@ -340,11 +339,11 @@ void ContextGLTest::constructMove() {
.addDisabledExtensions(data.disabledExtensions));
}
if(!data.logShouldContain.isEmpty())
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
data.logShouldContain,
TestSuite::Compare::StringContains);
if(!data.logShouldNotContain.isEmpty())
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
data.logShouldNotContain,
TestSuite::Compare::StringNotContains);

48
src/Magnum/GL/Test/ContextTest.cpp

@ -25,12 +25,10 @@
*/
#include <set>
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
@ -233,11 +231,11 @@ void ContextTest::configurationConstructUnknownWorkaround() {
/* Unknown workarounds should get ignored -- we're storing views on
internally known workaround strings to avoid allocations so there's no
other way */
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
configuration.addDisabledWorkarounds({"all-drivers-are-shit"});
CORRADE_VERIFY(configuration.disabledWorkarounds().isEmpty());
CORRADE_COMPARE(out.str(), "GL::Context::Configuration::addDisabledWorkarounds(): unknown workaround all-drivers-are-shit\n");
CORRADE_COMPARE(out, "GL::Context::Configuration::addDisabledWorkarounds(): unknown workaround all-drivers-are-shit\n");
}
void ContextTest::configurationConstructCopy() {
@ -457,9 +455,9 @@ void ContextTest::debugFlag() {
#ifdef MAGNUM_TARGET_WEBGL
CORRADE_SKIP("No context flags on Emscripten yet.");
#else
std::ostringstream out;
Containers::String out;
Debug(&out) << Context::Flag::Debug << Context::Flag(0xdead);
CORRADE_COMPARE(out.str(), "GL::Context::Flag::Debug GL::Context::Flag(0xdead)\n");
CORRADE_COMPARE(out, "GL::Context::Flag::Debug GL::Context::Flag(0xdead)\n");
#endif
}
@ -467,10 +465,10 @@ void ContextTest::debugFlagPacked() {
#ifdef MAGNUM_TARGET_WEBGL
CORRADE_SKIP("No context flags on Emscripten yet.");
#else
std::ostringstream out;
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << Context::Flag::Debug << Debug::packed << Context::Flag(0xdead) << Context::Flag::NoError;
CORRADE_COMPARE(out.str(), "Debug 0xdead GL::Context::Flag::NoError\n");
CORRADE_COMPARE(out, "Debug 0xdead GL::Context::Flag::NoError\n");
#endif
}
@ -478,9 +476,9 @@ void ContextTest::debugFlags() {
#ifdef MAGNUM_TARGET_WEBGL
CORRADE_SKIP("No context flags on Emscripten yet.");
#else
std::ostringstream out;
Containers::String out;
Debug{&out} << (Context::Flag::Debug|Context::Flag::NoError|Context::Flag(0xded0)) << Context::Flags{};
CORRADE_COMPARE(out.str(), "GL::Context::Flag::Debug|GL::Context::Flag::NoError|GL::Context::Flag(0xded0) GL::Context::Flags{}\n");
CORRADE_COMPARE(out, "GL::Context::Flag::Debug|GL::Context::Flag::NoError|GL::Context::Flag(0xded0) GL::Context::Flags{}\n");
#endif
}
@ -488,56 +486,56 @@ void ContextTest::debugFlagsPacked() {
#ifdef MAGNUM_TARGET_WEBGL
CORRADE_SKIP("No context flags on Emscripten yet.");
#else
std::ostringstream out;
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (Context::Flag::Debug|Context::Flag::NoError|Context::Flag(0xded0)) << Debug::packed << Context::Flags{} << (Context::Flag::Debug|Context::Flag::NoError);
CORRADE_COMPARE(out.str(), "Debug|NoError|0xded0 {} GL::Context::Flag::Debug|GL::Context::Flag::NoError\n");
CORRADE_COMPARE(out, "Debug|NoError|0xded0 {} GL::Context::Flag::Debug|GL::Context::Flag::NoError\n");
#endif
}
void ContextTest::debugDetectedDriver() {
std::ostringstream out;
Containers::String out;
#ifndef MAGNUM_TARGET_WEBGL
Debug{&out} << Context::DetectedDriver::Amd << Context::DetectedDriver(0xdead);
CORRADE_COMPARE(out.str(), "GL::Context::DetectedDriver::Amd GL::Context::DetectedDriver(0xdead)\n");
CORRADE_COMPARE(out, "GL::Context::DetectedDriver::Amd GL::Context::DetectedDriver(0xdead)\n");
#else
Debug{&out} << Context::DetectedDriver::Angle << Context::DetectedDriver(0xdead);
CORRADE_COMPARE(out.str(), "GL::Context::DetectedDriver::Angle GL::Context::DetectedDriver(0xdead)\n");
CORRADE_COMPARE(out, "GL::Context::DetectedDriver::Angle GL::Context::DetectedDriver(0xdead)\n");
#endif
}
void ContextTest::debugDetectedDriverPacked() {
std::ostringstream out;
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
#ifndef MAGNUM_TARGET_WEBGL
Debug{&out} << Debug::packed << Context::DetectedDriver::Amd << Debug::packed << Context::DetectedDriver(0xdead) << Context::DetectedDriver::NVidia;
CORRADE_COMPARE(out.str(), "Amd 0xdead GL::Context::DetectedDriver::NVidia\n");
CORRADE_COMPARE(out, "Amd 0xdead GL::Context::DetectedDriver::NVidia\n");
#else
Debug{&out} << Debug::packed << Context::DetectedDriver::Angle << Debug::packed << Context::DetectedDriver(0xdead) << Context::DetectedDriver::Angle;
CORRADE_COMPARE(out.str(), "Angle 0xdead GL::Context::DetectedDriver::Angle\n");
CORRADE_COMPARE(out, "Angle 0xdead GL::Context::DetectedDriver::Angle\n");
#endif
}
void ContextTest::debugDetectedDrivers() {
std::ostringstream out;
Containers::String out;
#ifndef MAGNUM_TARGET_WEBGL
Debug{&out} << (Context::DetectedDriver::Amd|Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00)) << Context::DetectedDrivers{};
CORRADE_COMPARE(out.str(), "GL::Context::DetectedDriver::Amd|GL::Context::DetectedDriver::Mesa|GL::Context::DetectedDriver(0xde00) GL::Context::DetectedDrivers{}\n");
CORRADE_COMPARE(out, "GL::Context::DetectedDriver::Amd|GL::Context::DetectedDriver::Mesa|GL::Context::DetectedDriver(0xde00) GL::Context::DetectedDrivers{}\n");
#else
Debug{&out} << (Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00)) << Context::DetectedDrivers{};
CORRADE_COMPARE(out.str(), "GL::Context::DetectedDriver::Angle|GL::Context::DetectedDriver(0xde00) GL::Context::DetectedDrivers{}\n");
CORRADE_COMPARE(out, "GL::Context::DetectedDriver::Angle|GL::Context::DetectedDriver(0xde00) GL::Context::DetectedDrivers{}\n");
#endif
}
void ContextTest::debugDetectedDriversPacked() {
std::ostringstream out;
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
#ifndef MAGNUM_TARGET_WEBGL
Debug{&out} << Debug::packed << (Context::DetectedDriver::Amd|Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00)) << Debug::packed << Context::DetectedDrivers{} << (Context::DetectedDriver::Amd|Context::DetectedDriver::Mesa);
CORRADE_COMPARE(out.str(), "Amd|Mesa|0xde00 {} GL::Context::DetectedDriver::Amd|GL::Context::DetectedDriver::Mesa\n");
CORRADE_COMPARE(out, "Amd|Mesa|0xde00 {} GL::Context::DetectedDriver::Amd|GL::Context::DetectedDriver::Mesa\n");
#else
Debug{&out} << Debug::packed << (Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00)) << Debug::packed << Context::DetectedDrivers{} << (Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00));
CORRADE_COMPARE(out.str(), "Angle|0xde00 {} GL::Context::DetectedDriver::Angle|GL::Context::DetectedDriver(0xde00)\n");
CORRADE_COMPARE(out, "Angle|0xde00 {} GL::Context::DetectedDriver::Angle|GL::Context::DetectedDriver(0xde00)\n");
#endif
}

66
src/Magnum/GL/Test/CubeMapTextureGLTest.cpp

@ -24,9 +24,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h"
#include "Magnum/ImageView.h"
@ -1051,10 +1049,10 @@ void CubeMapTextureGLTest::imageQueryViewNullptr() {
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte,
Vector2i{2}, {nullptr, 2*2*4}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.image(CubeMapCoordinate::PositiveY, 0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::image(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::image(): image view is nullptr\n");
}
void CubeMapTextureGLTest::imageQueryViewBadSize() {
@ -1069,10 +1067,10 @@ void CubeMapTextureGLTest::imageQueryViewBadSize() {
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte,
{2, 1}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.image(CubeMapCoordinate::PositiveY, 0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::image(): expected image view size Vector(2, 2) but got Vector(2, 1)\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::image(): expected image view size Vector(2, 2) but got Vector(2, 1)\n");
}
#endif
@ -1413,10 +1411,10 @@ void CubeMapTextureGLTest::compressedImageQueryViewNullptr() {
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, {nullptr, 16}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(CubeMapCoordinate::PositiveX, 0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedImage(): image view is nullptr\n");
}
void CubeMapTextureGLTest::compressedImageQueryViewBadSize() {
@ -1433,10 +1431,10 @@ void CubeMapTextureGLTest::compressedImageQueryViewBadSize() {
char data[2*16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4, 8}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(CubeMapCoordinate::PositiveX, 0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view size Vector(4, 4) but got Vector(4, 8)\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedImage(): expected image view size Vector(4, 4) but got Vector(4, 8)\n");
}
void CubeMapTextureGLTest::compressedImageQueryViewBadDataSize() {
@ -1453,10 +1451,10 @@ void CubeMapTextureGLTest::compressedImageQueryViewBadDataSize() {
char data[16 - 1];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(CubeMapCoordinate::PositiveX, 0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view data size 16 bytes but got 15\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedImage(): expected image view data size 16 bytes but got 15\n");
}
void CubeMapTextureGLTest::compressedImageQueryViewBadFormat() {
@ -1473,10 +1471,10 @@ void CubeMapTextureGLTest::compressedImageQueryViewBadFormat() {
char data[16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector2i{4}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(CubeMapCoordinate::PositiveX, 0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
}
#endif
@ -1770,10 +1768,10 @@ void CubeMapTextureGLTest::compressedSubImageQueryViewNullptr() {
MutableCompressedImageView3D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4, 4, 1}, {nullptr, 16}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedSubImage(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedSubImage(): image view is nullptr\n");
}
void CubeMapTextureGLTest::compressedSubImageQueryViewBadSize() {
@ -1790,10 +1788,10 @@ void CubeMapTextureGLTest::compressedSubImageQueryViewBadSize() {
char data[2*16];
MutableCompressedImageView3D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4, 4, 2}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedSubImage(): expected image view size Vector(4, 4, 1) but got Vector(4, 4, 2)\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedSubImage(): expected image view size Vector(4, 4, 1) but got Vector(4, 4, 2)\n");
}
void CubeMapTextureGLTest::compressedSubImageQueryViewBadDataSize() {
@ -1810,10 +1808,10 @@ void CubeMapTextureGLTest::compressedSubImageQueryViewBadDataSize() {
char data[16 - 1];
MutableCompressedImageView3D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4, 4, 1}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedSubImage(): expected image view data size 16 bytes but got 15\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedSubImage(): expected image view data size 16 bytes but got 15\n");
}
void CubeMapTextureGLTest::compressedSubImageQueryViewBadFormat() {
@ -1830,10 +1828,10 @@ void CubeMapTextureGLTest::compressedSubImageQueryViewBadFormat() {
char data[16];
MutableCompressedImageView3D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector3i{4, 4, 1}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedSubImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedSubImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
}
void CubeMapTextureGLTest::compressedSubImageQueryBuffer() {
@ -1979,10 +1977,10 @@ void CubeMapTextureGLTest::image3DQueryViewNullptr() {
MutableImageView3D image{PixelFormat::RGBA, PixelType::UnsignedByte,
{2, 2, 6}, {nullptr, 2*2*6*4}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.image(0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::image(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::image(): image view is nullptr\n");
}
void CubeMapTextureGLTest::image3DQueryViewBadSize() {
@ -1997,10 +1995,10 @@ void CubeMapTextureGLTest::image3DQueryViewBadSize() {
MutableImageView3D image{PixelFormat::RGBA, PixelType::UnsignedByte,
{2, 1, 6}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.image(0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::image(): expected image view size Vector(2, 2, 6) but got Vector(2, 1, 6)\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::image(): expected image view size Vector(2, 2, 6) but got Vector(2, 1, 6)\n");
}
#endif
@ -2178,10 +2176,10 @@ void CubeMapTextureGLTest::compressedImage3DQueryViewNullptr() {
MutableCompressedImageView3D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4, 4, 6}, {nullptr, 16*6}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedImage(): image view is nullptr\n");
}
void CubeMapTextureGLTest::compressedImage3DQueryViewBadSize() {
@ -2198,10 +2196,10 @@ void CubeMapTextureGLTest::compressedImage3DQueryViewBadSize() {
char data[2*6*16];
MutableCompressedImageView3D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4, 8, 6}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view size Vector(4, 4, 6) but got Vector(4, 8, 6)\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedImage(): expected image view size Vector(4, 4, 6) but got Vector(4, 8, 6)\n");
}
void CubeMapTextureGLTest::compressedImage3DQueryViewBadDataSize() {
@ -2218,10 +2216,10 @@ void CubeMapTextureGLTest::compressedImage3DQueryViewBadDataSize() {
char data[16*6 - 1];
MutableCompressedImageView3D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4, 4, 6}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view data size 96 bytes but got 95\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedImage(): expected image view data size 96 bytes but got 95\n");
}
void CubeMapTextureGLTest::compressedImage3DQueryViewBadFormat() {
@ -2238,10 +2236,10 @@ void CubeMapTextureGLTest::compressedImage3DQueryViewBadFormat() {
char data[6*16];
MutableCompressedImageView3D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector3i{4, 4, 6}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
texture.compressedImage(0, image);
CORRADE_COMPARE(out.str(), "GL::CubeMapTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
CORRADE_COMPARE(out, "GL::CubeMapTexture::compressedImage(): expected image view format GL::CompressedPixelFormat::RGBAS3tcDxt3 but got GL::CompressedPixelFormat::RGBAS3tcDxt1\n");
}
#endif

8
src/Magnum/GL/Test/DebugOutputGLTest.cpp

@ -24,10 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <sstream> /** @todo remove once the DebugOutput internals are stream-free */
#include <Corrade/Containers/StringView.h>
#include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stream-free */
#include <Corrade/Utility/DebugStl.h> /** @todo remove once the DebugOutput internals are stream-free */
#include "Magnum/GL/Context.h"
#include "Magnum/GL/DebugOutput.h"
@ -137,7 +137,7 @@ void DebugOutputGLTest::setCallbackDeprecated() {
DebugOutput::setDefaultCallback();
}};
std::ostringstream out;
Containers::String out;
CORRADE_IGNORE_DEPRECATED_PUSH
DebugOutput::setCallback([](DebugOutput::Source source, DebugOutput::Type type, UnsignedInt id, DebugOutput::Severity severity, const std::string& string, const void* userPtr) {
Implementation::defaultDebugCallback(source, type, id, severity, string, static_cast<std::ostringstream*>(const_cast<void*>(userPtr)));
@ -148,7 +148,7 @@ void DebugOutputGLTest::setCallbackDeprecated() {
1337, DebugOutput::Severity::High, "Hello from OpenGL command stream!");
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Debug output: high severity application marker (1337): Hello from OpenGL command stream!\n");
}
#endif

39
src/Magnum/GL/Test/DebugOutputTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/DebugOutput.h"
@ -57,39 +56,39 @@ DebugOutputTest::DebugOutputTest() {
}
void DebugOutputTest::debugSource() {
std::ostringstream o;
Debug(&o) << DebugOutput::Source::ShaderCompiler << DebugOutput::Source(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugOutput::Source::ShaderCompiler GL::DebugOutput::Source(0xdead)\n");
Containers::String out;
Debug{&out} << DebugOutput::Source::ShaderCompiler << DebugOutput::Source(0xdead);
CORRADE_COMPARE(out, "GL::DebugOutput::Source::ShaderCompiler GL::DebugOutput::Source(0xdead)\n");
}
void DebugOutputTest::debugType() {
std::ostringstream o;
Debug(&o) << DebugOutput::Type::PushGroup << DebugOutput::Type(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugOutput::Type::PushGroup GL::DebugOutput::Type(0xdead)\n");
Containers::String out;
Debug{&out} << DebugOutput::Type::PushGroup << DebugOutput::Type(0xdead);
CORRADE_COMPARE(out, "GL::DebugOutput::Type::PushGroup GL::DebugOutput::Type(0xdead)\n");
}
void DebugOutputTest::debugSeverity() {
std::ostringstream o;
Debug(&o) << DebugOutput::Severity::Notification << DebugOutput::Severity(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugOutput::Severity::Notification GL::DebugOutput::Severity(0xdead)\n");
Containers::String out;
Debug{&out} << DebugOutput::Severity::Notification << DebugOutput::Severity(0xdead);
CORRADE_COMPARE(out, "GL::DebugOutput::Severity::Notification GL::DebugOutput::Severity(0xdead)\n");
}
void DebugOutputTest::debugMessageSource() {
std::ostringstream o;
Debug(&o) << DebugMessage::Source::Application << DebugMessage::Source(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugMessage::Source::Application GL::DebugMessage::Source(0xdead)\n");
Containers::String out;
Debug{&out} << DebugMessage::Source::Application << DebugMessage::Source(0xdead);
CORRADE_COMPARE(out, "GL::DebugMessage::Source::Application GL::DebugMessage::Source(0xdead)\n");
}
void DebugOutputTest::debugMessageType() {
std::ostringstream o;
Debug(&o) << DebugMessage::Type::DeprecatedBehavior << DebugMessage::Type(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugMessage::Type::DeprecatedBehavior GL::DebugMessage::Type(0xdead)\n");
Containers::String out;
Debug{&out} << DebugMessage::Type::DeprecatedBehavior << DebugMessage::Type(0xdead);
CORRADE_COMPARE(out, "GL::DebugMessage::Type::DeprecatedBehavior GL::DebugMessage::Type(0xdead)\n");
}
void DebugOutputTest::debugGroupSource() {
std::ostringstream o;
Debug(&o) << DebugGroup::Source::ThirdParty << DebugGroup::Source(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugGroup::Source::ThirdParty GL::DebugGroup::Source(0xdead)\n");
Containers::String out;
Debug{&out} << DebugGroup::Source::ThirdParty << DebugGroup::Source(0xdead);
CORRADE_COMPARE(out, "GL::DebugGroup::Source::ThirdParty GL::DebugGroup::Source(0xdead)\n");
}
}}}}

7
src/Magnum/GL/Test/DefaultFramebufferTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/DefaultFramebuffer.h"
@ -43,10 +42,10 @@ DefaultFramebufferTest::DefaultFramebufferTest() {
}
void DefaultFramebufferTest::debugStatus() {
std::ostringstream out;
Containers::String out;
Debug(&out) << DefaultFramebuffer::Status::Complete << DefaultFramebuffer::Status(0xdead);
CORRADE_COMPARE(out.str(), "GL::DefaultFramebuffer::Status::Complete GL::DefaultFramebuffer::Status(0xdead)\n");
CORRADE_COMPARE(out, "GL::DefaultFramebuffer::Status::Complete GL::DefaultFramebuffer::Status(0xdead)\n");
}
}}}}

10
src/Magnum/GL/Test/FramebufferGLTest.cpp

@ -25,9 +25,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h"
#include "Magnum/ImageView.h"
@ -1715,10 +1713,10 @@ void FramebufferGLTest::readViewNullptr() {
MutableImageView2D view{DataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, {8, 16}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
framebuffer.read({{}, {8, 16}}, view);
CORRADE_COMPARE(out.str(), "GL::AbstractFramebuffer::read(): image view is nullptr\n");
CORRADE_COMPARE(out, "GL::AbstractFramebuffer::read(): image view is nullptr\n");
}
void FramebufferGLTest::readViewBadSize() {
@ -1742,10 +1740,10 @@ void FramebufferGLTest::readViewBadSize() {
char data[(DataOffset + 8*15)*sizeof(Color4ub)]{};
MutableImageView2D view{DataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, {8, 15}, data};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
framebuffer.read({{}, {8, 16}}, view);
CORRADE_COMPARE(out.str(), "GL::AbstractFramebuffer::read(): expected image view size Vector(8, 16) but got Vector(8, 15)\n");
CORRADE_COMPARE(out, "GL::AbstractFramebuffer::read(): expected image view size Vector(8, 16) but got Vector(8, 15)\n");
}
#ifndef MAGNUM_TARGET_GLES2

7
src/Magnum/GL/Test/FramebufferTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Framebuffer.h"
@ -64,10 +63,10 @@ void FramebufferTest::constructCopy() {
}
void FramebufferTest::debugStatus() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Framebuffer::Status::IncompleteMissingAttachment << Framebuffer::Status(0xdead);
CORRADE_COMPARE(out.str(), "GL::Framebuffer::Status::IncompleteMissingAttachment GL::Framebuffer::Status(0xdead)\n");
CORRADE_COMPARE(out, "GL::Framebuffer::Status::IncompleteMissingAttachment GL::Framebuffer::Status(0xdead)\n");
}
}}}}

118
src/Magnum/GL/Test/MeshGLTest.cpp

@ -25,14 +25,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include "Magnum/Image.h"
#include "Magnum/Mesh.h"
@ -2278,12 +2276,12 @@ void MeshGLTest::addVertexBufferMovedOutInstance() {
Buffer buffer{NoCreate};
Mesh mesh;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
mesh.addVertexBuffer(buffer, 0, Attribute<0, Float>{});
CORRADE_COMPARE(out.str(), "GL::Mesh::addVertexBuffer(): empty or moved-out Buffer instance was passed\n");
CORRADE_COMPARE(out, "GL::Mesh::addVertexBuffer(): empty or moved-out Buffer instance was passed\n");
}
void MeshGLTest::addVertexBufferTransferOwnwership() {
@ -2599,12 +2597,12 @@ void MeshGLTest::setIndexBufferMovedOutInstance() {
Buffer buffer{NoCreate};
Mesh mesh;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
mesh.setIndexBuffer(buffer, 0, MeshIndexType::UnsignedByte);
CORRADE_COMPARE(out.str(), "GL::Mesh::setIndexBuffer(): empty or moved-out Buffer instance was passed\n");
CORRADE_COMPARE(out, "GL::Mesh::setIndexBuffer(): empty or moved-out Buffer instance was passed\n");
}
template<class T> void MeshGLTest::setIndexBufferTransferOwnership() {
@ -2721,12 +2719,12 @@ void MeshGLTest::indexTypeSetIndexOffsetNotIndexed() {
Mesh mesh;
MeshView view{mesh};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
mesh.indexType();
mesh.setIndexOffset(3);
view.setIndexOffset(3);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::Mesh::indexType(): mesh is not indexed\n"
"GL::Mesh::setIndexOffset(): mesh is not indexed\n"
"GL::MeshView::setIndexOffset(): mesh is not indexed\n");
@ -3086,13 +3084,13 @@ void MeshGLTest::setBaseVertexNoExtensionAvailable() {
.setBaseVertex(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultipleShader{}.draw(mesh);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for indexed mesh draw with base vertex specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for indexed mesh draw with base vertex specification\n");
#else
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): indexed mesh draw with base vertex specification possible only since WebGL 2.0\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): indexed mesh draw with base vertex specification possible only since WebGL 2.0\n");
#endif
}
@ -3122,13 +3120,13 @@ void MeshGLTest::setBaseVertexRangeNoExtensionAvailable() {
.setBaseVertex(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort, 0, 2);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultipleShader{}.draw(mesh);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for indexed mesh draw with base vertex specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for indexed mesh draw with base vertex specification\n");
#else
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): indexed mesh draw with base vertex specification possible only since WebGL 2.0\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): indexed mesh draw with base vertex specification possible only since WebGL 2.0\n");
#endif
}
#endif
@ -3242,10 +3240,10 @@ void MeshGLTest::setInstanceCountBaseInstanceNoExtensionAvailable() {
.setInstanceCount(2)
.setBaseInstance(1);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultipleShader{}.draw(mesh);
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for instanced mesh draw with base instance specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for instanced mesh draw with base instance specification\n");
}
#endif
#endif
@ -3367,10 +3365,10 @@ void MeshGLTest::setInstanceCountIndexedBaseInstanceNoExtensionAvailable() {
.setBaseInstance(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultipleShader{}.draw(mesh);
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh draw with base instance specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh draw with base instance specification\n");
}
#endif
#endif
@ -3457,13 +3455,13 @@ void MeshGLTest::setInstanceCountIndexedBaseVertexNoExtensionAvailable() {
.setBaseVertex(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultipleShader{}.draw(mesh);
#ifndef MAGNUM_TARGET_GLES2
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh draw with base vertex specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh draw with base vertex specification\n");
#else
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): instanced indexed mesh draw with base vertex specification possible only since OpenGL ES 3.0\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): instanced indexed mesh draw with base vertex specification possible only since OpenGL ES 3.0\n");
#endif
}
#endif
@ -3535,13 +3533,13 @@ void MeshGLTest::setInstanceCountIndexedBaseVertexBaseInstanceNoExtensionAvailab
.setBaseInstance(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultipleShader{}.draw(mesh);
#ifndef MAGNUM_TARGET_GLES2
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh draw with base vertex and base instance specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh draw with base vertex and base instance specification\n");
#else
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): instanced indexed mesh draw with base vertex specification possible only since OpenGL 3.0\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): instanced indexed mesh draw with base vertex specification possible only since OpenGL 3.0\n");
#endif
}
#endif
@ -4474,11 +4472,11 @@ void MeshGLTest::multiDrawWrongVertexOffsetSize() {
UnsignedInt counts[3]{};
UnsignedInt vertexOffsets[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, vertexOffsets, nullptr);
shader.draw(mesh, counts, nullptr, nullptr);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 0\n");
}
@ -4493,11 +4491,11 @@ void MeshGLTest::multiDrawIndexedWrongVertexOffsetSize() {
UnsignedInt vertexOffsets[2]{};
UnsignedInt indexOffsets[3]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, vertexOffsets, indexOffsets);
/* Omitting vertex offsets altogether is okay */
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 2\n");
}
@ -4510,11 +4508,11 @@ void MeshGLTest::multiDrawIndexedWrongIndexOffsetSize() {
UnsignedInt counts[3]{};
UnsignedInt indexOffsets[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, nullptr, indexOffsets);
shader.draw(mesh, counts, nullptr, nullptr);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): expected 3 index offset items but got 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 index offset items but got 0\n");
}
@ -4555,13 +4553,13 @@ void MeshGLTest::multiDrawIndexedBaseVertexNoExtensionAvailable() {
UnsignedInt vertexOffsets[]{0};
UnsignedInt indexOffsets[]{0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultiDrawShader{}.draw(mesh, counts, vertexOffsets, indexOffsets);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for indexed mesh multi-draw with base vertex specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for indexed mesh multi-draw with base vertex specification\n");
#else
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): indexed mesh multi-draw with base vertex specification possible only since WebGL 2.0\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): indexed mesh multi-draw with base vertex specification possible only since WebGL 2.0\n");
#endif
}
@ -4600,13 +4598,13 @@ void MeshGLTest::multiDrawIndexedViewsBaseVertexNoExtensionAvailable() {
UnsignedInt vertexOffsets[]{1};
UnsignedInt indexOffsets[]{0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultiDrawShader{}.draw(mesh, counts, vertexOffsets, indexOffsets);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for indexed mesh multi-draw with base vertex specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for indexed mesh multi-draw with base vertex specification\n");
#else
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): indexed mesh multi-draw with base vertex specification possible only since WebGL 2.0\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): indexed mesh multi-draw with base vertex specification possible only since WebGL 2.0\n");
#endif
}
#endif
@ -4619,10 +4617,10 @@ void MeshGLTest::multiDrawViewsInstanced() {
view.setCount(3)
.setInstanceCount(2);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultiDrawShader{}.draw({view, view});
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): cannot multi-draw instanced meshes\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): cannot multi-draw instanced meshes\n");
}
void MeshGLTest::multiDrawViewsDifferentMeshes() {
@ -4631,10 +4629,10 @@ void MeshGLTest::multiDrawViewsDifferentMeshes() {
Mesh a, b;
MeshView viewA{a}, viewB{b};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultiDrawShader{}.draw({viewA, viewB});
CORRADE_COMPARE(out.str(), Utility::formatString("GL::AbstractShaderProgram::draw(): all meshes must be views of the same original mesh, expected 0x{:x} but got 0x{:x} at index 1\n", reinterpret_cast<std::uintptr_t>(&a), reinterpret_cast<std::uintptr_t>(&b)));
CORRADE_COMPARE(out, Utility::format("GL::AbstractShaderProgram::draw(): all meshes must be views of the same original mesh, expected 0x{:x} but got 0x{:x} at index 1\n", reinterpret_cast<std::uintptr_t>(&a), reinterpret_cast<std::uintptr_t>(&b)));
}
#ifdef MAGNUM_TARGET_GLES
@ -5125,11 +5123,11 @@ void MeshGLTest::multiDrawInstancedWrongInstanceCountSize() {
UnsignedInt counts[3]{};
UnsignedInt instanceCounts[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, nullptr, nullptr);
shader.draw(mesh, counts, nullptr, nullptr, nullptr);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): expected 3 instance count items but got 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 instance count items but got 0\n");
}
@ -5143,11 +5141,11 @@ void MeshGLTest::multiDrawInstancedWrongVertexOffsetSize() {
UnsignedInt instanceCounts[3]{};
UnsignedInt vertexOffsets[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, vertexOffsets, nullptr);
shader.draw(mesh, counts, instanceCounts, nullptr, nullptr);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 0\n");
}
@ -5163,11 +5161,11 @@ void MeshGLTest::multiDrawInstancedWrongInstanceOffsetSize() {
UnsignedInt vertexOffsets[3]{};
UnsignedInt instanceOffsets[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, vertexOffsets, nullptr, instanceOffsets);
/* Omitting vertex offsets altogether is okay */
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): expected 3 instance offset items but got 2\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): expected 3 instance offset items but got 2\n");
}
#endif
@ -5180,11 +5178,11 @@ void MeshGLTest::multiDrawInstancedIndexedWrongInstanceCountSize() {
UnsignedInt counts[3]{};
UnsignedInt instanceCounts[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, nullptr, nullptr);
shader.draw(mesh, counts, nullptr, nullptr, nullptr);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): expected 3 instance count items but got 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 instance count items but got 0\n");
}
@ -5200,11 +5198,11 @@ void MeshGLTest::multiDrawInstancedIndexedWrongVertexOffsetSize() {
UnsignedInt vertexOffsets[2]{};
UnsignedInt indexOffsets[3]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, vertexOffsets, indexOffsets);
/* Omitting vertex offsets altogether is okay */
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 2\n");
}
@ -5218,11 +5216,11 @@ void MeshGLTest::multiDrawInstancedIndexedWrongIndexOffsetSize() {
UnsignedInt instanceCounts[3]{};
UnsignedInt indexOffsets[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, nullptr, indexOffsets);
shader.draw(mesh, counts, instanceCounts, nullptr, nullptr);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): expected 3 index offset items but got 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 index offset items but got 0\n");
}
@ -5239,11 +5237,11 @@ void MeshGLTest::multiDrawInstancedIndexedWrongInstanceOffsetSize() {
UnsignedInt indexOffsets[3]{};
UnsignedInt instanceOffsets[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, nullptr, indexOffsets, instanceOffsets);
/* Omitting instance offsets altogether is okay */
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): expected 3 instance offset items but got 2\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): expected 3 instance offset items but got 2\n");
}
void MeshGLTest::multiDrawInstancedBaseVertexNoExtensionAvailable() {
@ -5269,13 +5267,13 @@ void MeshGLTest::multiDrawInstancedBaseVertexNoExtensionAvailable() {
UnsignedInt vertexOffsets[]{0};
UnsignedInt indexOffsets[]{0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultiDrawInstancedShader{}.draw(mesh, counts, instanceCounts, vertexOffsets, indexOffsets);
#ifndef MAGNUM_TARGET_GLES2
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh multi-draw with base vertex and base instance specification\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh multi-draw with base vertex and base instance specification\n");
#else
CORRADE_COMPARE(out.str(), "GL::AbstractShaderProgram::draw(): instanced indexed mesh multi-draw with base vertex specification possible only since OpenGL ES 3.0 and WebGL 2.0\n");
CORRADE_COMPARE(out, "GL::AbstractShaderProgram::draw(): instanced indexed mesh multi-draw with base vertex specification possible only since OpenGL ES 3.0 and WebGL 2.0\n");
#endif
}
@ -5304,11 +5302,11 @@ void MeshGLTest::multiDrawInstancedBaseInstanceNoExtensionAvailable() {
UnsignedInt indexOffsets[]{0};
UnsignedInt instanceOffsets[]{0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MultiDrawInstancedShader{}.draw(nonIndexed, counts, instanceCounts, vertexOffsets, nullptr, instanceOffsets);
MultiDrawInstancedShader{}.draw(indexed, counts, instanceCounts, nullptr, indexOffsets, instanceOffsets);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): no extension available for instanced mesh multi-draw with base instance specification\n"
"GL::AbstractShaderProgram::draw(): no extension available for instanced indexed mesh multi-draw with base vertex and base instance specification\n");
}

39
src/Magnum/GL/Test/MeshTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Mesh.h"
#include "Magnum/GL/AbstractShaderProgram.h"
@ -142,25 +141,25 @@ struct Shader: AbstractShaderProgram {
void MeshTest::drawCountNotSet() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Shader{NoCreate}.draw(Mesh{NoCreate});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): Mesh::setCount() was never called, probably a mistake?\n");
}
void MeshTest::drawViewCountNotSet() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Mesh mesh{NoCreate};
Shader{NoCreate}.draw(MeshView{mesh});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): MeshView::setCount() was never called, probably a mistake?\n");
}
@ -206,21 +205,21 @@ void MeshTest::mapPrimitiveImplementationSpecific() {
void MeshTest::mapPrimitiveUnsupported() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
meshPrimitive(Magnum::MeshPrimitive::Instances);
CORRADE_COMPARE(out.str(), "GL::meshPrimitive(): unsupported primitive MeshPrimitive::Instances\n");
CORRADE_COMPARE(out, "GL::meshPrimitive(): unsupported primitive MeshPrimitive::Instances\n");
}
void MeshTest::mapPrimitiveInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
meshPrimitive(Magnum::MeshPrimitive{});
meshPrimitive(Magnum::MeshPrimitive(0x12));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::meshPrimitive(): invalid primitive MeshPrimitive(0x0)\n"
"GL::meshPrimitive(): invalid primitive MeshPrimitive(0x12)\n");
}
@ -261,12 +260,12 @@ void MeshTest::mapIndexTypeImplementationSpecific() {
void MeshTest::mapIndexTypeInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
meshIndexType(Magnum::MeshIndexType(0x0));
meshIndexType(Magnum::MeshIndexType(0x12));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::meshIndexType(): invalid type MeshIndexType(0x0)\n"
"GL::meshIndexType(): invalid type MeshIndexType(0x12)\n");
}
@ -280,25 +279,25 @@ void MeshTest::indexTypeSize() {
void MeshTest::indexTypeSizeInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
meshIndexTypeSize(MeshIndexType{});
meshIndexTypeSize(MeshIndexType(0xbadcafe));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::meshIndexTypeSize(): invalid type GL::MeshIndexType(0x0)\n"
"GL::meshIndexTypeSize(): invalid type GL::MeshIndexType(0xbadcafe)\n");
}
void MeshTest::debugPrimitive() {
std::ostringstream o;
Debug(&o) << MeshPrimitive::TriangleFan << MeshPrimitive(0xdead);
CORRADE_COMPARE(o.str(), "GL::MeshPrimitive::TriangleFan GL::MeshPrimitive(0xdead)\n");
Containers::String out;
Debug{&out} << MeshPrimitive::TriangleFan << MeshPrimitive(0xdead);
CORRADE_COMPARE(out, "GL::MeshPrimitive::TriangleFan GL::MeshPrimitive(0xdead)\n");
}
void MeshTest::debugIndexType() {
std::ostringstream o;
Debug(&o) << MeshIndexType::UnsignedShort << MeshIndexType(0xdead);
CORRADE_COMPARE(o.str(), "GL::MeshIndexType::UnsignedShort GL::MeshIndexType(0xdead)\n");
Containers::String out;
Debug{&out} << MeshIndexType::UnsignedShort << MeshIndexType(0xdead);
CORRADE_COMPARE(out, "GL::MeshIndexType::UnsignedShort GL::MeshIndexType(0xdead)\n");
}
}}}}

99
src/Magnum/GL/Test/PixelFormatTest.cpp

@ -24,10 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/PixelFormat.h"
#include "Magnum/GL/PixelFormat.h"
@ -217,12 +216,12 @@ void PixelFormatTest::mapFormatTypeTextureFormat() {
CORRADE_COMPARE(pixelType(Magnum::PixelFormat::format), Magnum::GL::PixelType::expectedType); \
CORRADE_COMPARE(genericPixelFormat(Magnum::GL::PixelFormat::expectedFormat, Magnum::GL::PixelType::expectedType), Magnum::PixelFormat::format); \
CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \
std::ostringstream out; \
Containers::String out; \
{ /* Redirected otherwise graceful assert would abort */ \
Error redirectError{&out}; \
textureFormat(Magnum::PixelFormat::format); \
} \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out; \
++nextHandled; \
continue; \
}
@ -238,12 +237,12 @@ void PixelFormatTest::mapFormatTypeTextureFormat() {
CORRADE_COMPARE(pixelFormat(Magnum::PixelFormat::format), Magnum::GL::PixelFormat::expectedFormat); \
CORRADE_COMPARE(pixelType(Magnum::PixelFormat::format), Magnum::GL::PixelType::expectedType); \
CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \
std::ostringstream out; \
Containers::String out; \
{ /* Redirected otherwise graceful assert would abort */ \
Error redirectError{&out}; \
textureFormat(Magnum::PixelFormat::format); \
} \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out; \
++nextHandled; \
continue; \
}
@ -253,14 +252,14 @@ void PixelFormatTest::mapFormatTypeTextureFormat() {
CORRADE_COMPARE(firstUnhandled, 0xffff); \
CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::format)); \
CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \
std::ostringstream out; \
Containers::String out; \
{ /* Redirected otherwise graceful assert would abort */ \
Error redirectError{&out}; \
pixelFormat(Magnum::PixelFormat::format); \
pixelType(Magnum::PixelFormat::format); \
textureFormat(Magnum::PixelFormat::format); \
} \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out; \
++nextHandled; \
continue; \
}
@ -295,26 +294,26 @@ void PixelFormatTest::mapFormatUnsupported() {
#ifndef MAGNUM_TARGET_GLES2
CORRADE_SKIP("All pixel formats are supported on ES3+.");
#else
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::RGB16UI));
pixelFormat(Magnum::PixelFormat::RGB16UI);
CORRADE_COMPARE(out.str(), "GL::pixelFormat(): format PixelFormat::RGB16UI is not supported on this target\n");
CORRADE_COMPARE(out, "GL::pixelFormat(): format PixelFormat::RGB16UI is not supported on this target\n");
#endif
}
void PixelFormatTest::mapFormatInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
hasPixelFormat(Magnum::PixelFormat{});
hasPixelFormat(Magnum::PixelFormat(0x123));
pixelFormat(Magnum::PixelFormat{});
pixelFormat(Magnum::PixelFormat(0x123));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::hasPixelFormat(): invalid format PixelFormat(0x0)\n"
"GL::hasPixelFormat(): invalid format PixelFormat(0x123)\n"
"GL::pixelFormat(): invalid format PixelFormat(0x0)\n"
@ -329,11 +328,11 @@ void PixelFormatTest::mapTypeImplementationSpecific() {
void PixelFormatTest::mapTypeImplementationSpecificZero() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
pixelType(Magnum::pixelFormatWrap(PixelFormat::RGBA));
CORRADE_COMPARE(out.str(), "GL::pixelType(): format is implementation-specific, but no additional type specifier was passed\n");
CORRADE_COMPARE(out, "GL::pixelType(): format is implementation-specific, but no additional type specifier was passed\n");
}
void PixelFormatTest::mapTypeUnsupported() {
@ -344,21 +343,21 @@ void PixelFormatTest::mapTypeUnsupported() {
#else
CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::RGBA16UI));
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
pixelType(Magnum::PixelFormat::RGB16UI);
CORRADE_COMPARE(out.str(), "GL::pixelType(): format PixelFormat::RGB16UI is not supported on this target\n");
CORRADE_COMPARE(out, "GL::pixelType(): format PixelFormat::RGB16UI is not supported on this target\n");
#endif
}
void PixelFormatTest::mapTypeInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
pixelType(Magnum::PixelFormat{});
pixelType(Magnum::PixelFormat(0x123));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::pixelType(): invalid format PixelFormat(0x0)\n"
"GL::pixelType(): invalid format PixelFormat(0x123)\n");
}
@ -366,11 +365,11 @@ void PixelFormatTest::mapTypeInvalid() {
void PixelFormatTest::mapTextureFormatImplementationSpecific() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
hasTextureFormat(Magnum::pixelFormatWrap(PixelFormat::RGBA));
textureFormat(Magnum::pixelFormatWrap(PixelFormat::RGBA));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::hasTextureFormat(): cannot map an implementation-specific pixel format to an OpenGL texture format\n"
"GL::textureFormat(): cannot map an implementation-specific pixel format to an OpenGL texture format\n");
}
@ -381,31 +380,31 @@ void PixelFormatTest::mapTextureFormatUnsupported() {
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2)
CORRADE_SKIP("All pixel formats are supported on ES3+.");
#elif defined(MAGNUM_TARGET_GLES2)
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
textureFormat(Magnum::PixelFormat::Depth32F);
CORRADE_COMPARE(out.str(), "GL::textureFormat(): format PixelFormat::Depth32F is not supported on this target\n");
CORRADE_COMPARE(out, "GL::textureFormat(): format PixelFormat::Depth32F is not supported on this target\n");
#else
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
textureFormat(Magnum::PixelFormat::Depth16UnormStencil8UI);
CORRADE_COMPARE(out.str(), "GL::textureFormat(): format PixelFormat::Depth16UnormStencil8UI is not supported on this target\n");
CORRADE_COMPARE(out, "GL::textureFormat(): format PixelFormat::Depth16UnormStencil8UI is not supported on this target\n");
#endif
}
void PixelFormatTest::mapTextureFormatInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
hasTextureFormat(Magnum::PixelFormat{});
hasTextureFormat(Magnum::PixelFormat(0x123));
textureFormat(Magnum::PixelFormat{});
textureFormat(Magnum::PixelFormat(0x123));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::hasTextureFormat(): invalid format PixelFormat(0x0)\n"
"GL::hasTextureFormat(): invalid format PixelFormat(0x123)\n"
"GL::textureFormat(): invalid format PixelFormat(0x0)\n"
@ -443,10 +442,10 @@ void PixelFormatTest::size() {
void PixelFormatTest::sizeInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
pixelFormatSize(PixelFormat::DepthStencil, PixelType::Float);
CORRADE_COMPARE(out.str(), "GL::pixelFormatSize(): invalid GL::PixelType::Float specified for GL::PixelFormat::DepthStencil\n");
CORRADE_COMPARE(out, "GL::pixelFormatSize(): invalid GL::PixelType::Float specified for GL::PixelFormat::DepthStencil\n");
}
void PixelFormatTest::mapCompressedFormatTextureFormat() {
@ -507,13 +506,13 @@ void PixelFormatTest::mapCompressedFormatTextureFormat() {
CORRADE_COMPARE(firstUnhandled, 0xffff); \
CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::format)); \
CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::format)); \
std::ostringstream out; \
Containers::String out; \
{ /* Redirected otherwise graceful assert would abort */ \
Error redirectError{&out}; \
compressedPixelFormat(Magnum::CompressedPixelFormat::format); \
textureFormat(Magnum::CompressedPixelFormat::format); \
} \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out; \
++nextHandled; \
continue; \
}
@ -547,17 +546,17 @@ void PixelFormatTest::mapCompressedFormatUnsupported() {
#ifdef MAGNUM_TARGET_GLES2
CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm));
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compressedPixelFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm);
CORRADE_COMPARE(out.str(), "GL::compressedPixelFormat(): format CompressedPixelFormat::Astc3x3x3RGBAUnorm is not supported on this target\n");
CORRADE_COMPARE(out, "GL::compressedPixelFormat(): format CompressedPixelFormat::Astc3x3x3RGBAUnorm is not supported on this target\n");
#elif !defined(MAGNUM_TARGET_GLES)
CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm));
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compressedPixelFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm);
CORRADE_COMPARE(out.str(), "GL::compressedPixelFormat(): format CompressedPixelFormat::PvrtcRGB2bppUnorm is not supported on this target\n");
CORRADE_COMPARE(out, "GL::compressedPixelFormat(): format CompressedPixelFormat::PvrtcRGB2bppUnorm is not supported on this target\n");
#else
CORRADE_SKIP("All compressed pixel formats are supported on ES3.");
#endif
@ -566,14 +565,14 @@ void PixelFormatTest::mapCompressedFormatUnsupported() {
void PixelFormatTest::mapCompressedFormatInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
hasCompressedPixelFormat(Magnum::CompressedPixelFormat{});
hasCompressedPixelFormat(Magnum::CompressedPixelFormat(0x123));
compressedPixelFormat(Magnum::CompressedPixelFormat{});
compressedPixelFormat(Magnum::CompressedPixelFormat(0x123));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::hasCompressedPixelFormat(): invalid format CompressedPixelFormat(0x0)\n"
"GL::hasCompressedPixelFormat(): invalid format CompressedPixelFormat(0x123)\n"
"GL::compressedPixelFormat(): invalid format CompressedPixelFormat(0x0)\n"
@ -592,17 +591,17 @@ void PixelFormatTest::mapCompressedTextureFormatUnsupported() {
#ifdef MAGNUM_TARGET_GLES2
CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm));
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
textureFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm);
CORRADE_COMPARE(out.str(), "GL::textureFormat(): format CompressedPixelFormat::Astc3x3x3RGBAUnorm is not supported on this target\n");
CORRADE_COMPARE(out, "GL::textureFormat(): format CompressedPixelFormat::Astc3x3x3RGBAUnorm is not supported on this target\n");
#elif !defined(MAGNUM_TARGET_GLES)
CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm));
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
textureFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm);
CORRADE_COMPARE(out.str(), "GL::textureFormat(): format CompressedPixelFormat::PvrtcRGB2bppUnorm is not supported on this target\n");
CORRADE_COMPARE(out, "GL::textureFormat(): format CompressedPixelFormat::PvrtcRGB2bppUnorm is not supported on this target\n");
#else
CORRADE_SKIP("All compressed pixel formats are supported on ES3.");
#endif
@ -611,14 +610,14 @@ void PixelFormatTest::mapCompressedTextureFormatUnsupported() {
void PixelFormatTest::mapCompressedTextureFormatInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
hasTextureFormat(Magnum::CompressedPixelFormat{});
hasTextureFormat(Magnum::CompressedPixelFormat(0x123));
textureFormat(Magnum::CompressedPixelFormat{});
textureFormat(Magnum::CompressedPixelFormat(0x123));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::hasTextureFormat(): invalid format CompressedPixelFormat(0x0)\n"
"GL::hasTextureFormat(): invalid format CompressedPixelFormat(0x123)\n"
"GL::textureFormat(): invalid format CompressedPixelFormat(0x0)\n"
@ -637,31 +636,31 @@ void PixelFormatTest::mapGenericCompressedFormatUnsupported() {
}
void PixelFormatTest::debugPixelFormat() {
std::ostringstream out;
Containers::String out;
Debug(&out) << PixelFormat::RGBA << PixelFormat(0xdead);
CORRADE_COMPARE(out.str(), "GL::PixelFormat::RGBA GL::PixelFormat(0xdead)\n");
CORRADE_COMPARE(out, "GL::PixelFormat::RGBA GL::PixelFormat(0xdead)\n");
}
void PixelFormatTest::debugPixelType() {
std::ostringstream out;
Containers::String out;
Debug(&out) << PixelType::UnsignedByte << PixelType(0xdead);
CORRADE_COMPARE(out.str(), "GL::PixelType::UnsignedByte GL::PixelType(0xdead)\n");
CORRADE_COMPARE(out, "GL::PixelType::UnsignedByte GL::PixelType(0xdead)\n");
}
void PixelFormatTest::debugCompressedPixelFormat() {
std::ostringstream out;
Containers::String out;
Debug{&out} << CompressedPixelFormat::RGBS3tcDxt1 << CompressedPixelFormat(0xdead);
CORRADE_COMPARE(out.str(), "GL::CompressedPixelFormat::RGBS3tcDxt1 GL::CompressedPixelFormat(0xdead)\n");
CORRADE_COMPARE(out, "GL::CompressedPixelFormat::RGBS3tcDxt1 GL::CompressedPixelFormat(0xdead)\n");
}
void PixelFormatTest::debugTextureFormat() {
std::ostringstream out;
Containers::String out;
Debug(&out) << TextureFormat::DepthComponent << TextureFormat(0xdead);
CORRADE_COMPARE(out.str(), "GL::TextureFormat::DepthComponent GL::TextureFormat(0xdead)\n");
CORRADE_COMPARE(out, "GL::TextureFormat::DepthComponent GL::TextureFormat(0xdead)\n");
}
}}}}

15
src/Magnum/GL/Test/RendererTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Renderer.h"
@ -52,25 +51,25 @@ RendererTest::RendererTest() {
}
void RendererTest::debugError() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Renderer::Error::InvalidOperation << Renderer::Error(0xdead);
CORRADE_COMPARE(out.str(), "GL::Renderer::Error::InvalidOperation GL::Renderer::Error(0xdead)\n");
CORRADE_COMPARE(out, "GL::Renderer::Error::InvalidOperation GL::Renderer::Error(0xdead)\n");
}
#ifndef MAGNUM_TARGET_WEBGL
void RendererTest::debugResetNotificationStrategy() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Renderer::ResetNotificationStrategy::LoseContextOnReset << Renderer::ResetNotificationStrategy(0xdead);
CORRADE_COMPARE(out.str(), "GL::Renderer::ResetNotificationStrategy::LoseContextOnReset GL::Renderer::ResetNotificationStrategy(0xdead)\n");
CORRADE_COMPARE(out, "GL::Renderer::ResetNotificationStrategy::LoseContextOnReset GL::Renderer::ResetNotificationStrategy(0xdead)\n");
}
void RendererTest::debugGraphicsResetStatus() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Renderer::GraphicsResetStatus::GuiltyContextReset << Renderer::GraphicsResetStatus(0xdead);
CORRADE_COMPARE(out.str(), "GL::Renderer::GraphicsResetStatus::GuiltyContextReset GL::Renderer::GraphicsResetStatus(0xdead)\n");
CORRADE_COMPARE(out, "GL::Renderer::GraphicsResetStatus::GuiltyContextReset GL::Renderer::GraphicsResetStatus(0xdead)\n");
}
#endif

43
src/Magnum/GL/Test/SamplerTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Sampler.h"
#include "Magnum/GL/Sampler.h"
@ -88,11 +87,11 @@ void SamplerTest::mapFilter() {
void SamplerTest::mapFilterInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
samplerFilter(Magnum::SamplerFilter(0x123));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::samplerFilter(): invalid filter SamplerFilter(0x123)\n");
}
@ -105,11 +104,11 @@ void SamplerTest::mapMipmap() {
void SamplerTest::mapMipmapInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
samplerMipmap(Magnum::SamplerMipmap(0x123));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::samplerMipmap(): invalid mode SamplerMipmap(0x123)\n");
}
@ -141,12 +140,12 @@ void SamplerTest::mapWrappingVector() {
void SamplerTest::mapWrappingInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
hasSamplerWrapping(Magnum::SamplerWrapping(0x123));
samplerWrapping(Magnum::SamplerWrapping(0x123));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::hasSamplerWrapping(): invalid wrapping SamplerWrapping(0x123)\n"
"GL::samplerWrapping(): invalid wrapping SamplerWrapping(0x123)\n");
}
@ -157,59 +156,59 @@ void SamplerTest::mapWrappingUnsupported() {
#else
CORRADE_VERIFY(!hasSamplerWrapping(Magnum::SamplerWrapping::MirrorClampToEdge));
std::ostringstream out;
Containers::String out;
{
Error redirectError{&out};
samplerWrapping(Magnum::SamplerWrapping::MirrorClampToEdge);
}
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"GL::samplerWrapping(): wrapping SamplerWrapping::MirrorClampToEdge is not supported on this target\n");
#endif
}
void SamplerTest::debugFilter() {
std::ostringstream out;
Containers::String out;
Debug(&out) << SamplerFilter::Linear << SamplerFilter(0xdead);
CORRADE_COMPARE(out.str(), "GL::SamplerFilter::Linear GL::SamplerFilter(0xdead)\n");
CORRADE_COMPARE(out, "GL::SamplerFilter::Linear GL::SamplerFilter(0xdead)\n");
}
void SamplerTest::debugMipmap() {
std::ostringstream out;
Containers::String out;
Debug(&out) << SamplerMipmap::Base << SamplerMipmap(0xdead);
CORRADE_COMPARE(out.str(), "GL::SamplerMipmap::Base GL::SamplerMipmap(0xdead)\n");
CORRADE_COMPARE(out, "GL::SamplerMipmap::Base GL::SamplerMipmap(0xdead)\n");
}
void SamplerTest::debugWrapping() {
std::ostringstream out;
Containers::String out;
Debug(&out) << SamplerWrapping::ClampToEdge << SamplerWrapping(0xdead);
CORRADE_COMPARE(out.str(), "GL::SamplerWrapping::ClampToEdge GL::SamplerWrapping(0xdead)\n");
CORRADE_COMPARE(out, "GL::SamplerWrapping::ClampToEdge GL::SamplerWrapping(0xdead)\n");
}
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void SamplerTest::debugCompareMode() {
std::ostringstream out;
Containers::String out;
Debug(&out) << SamplerCompareMode::CompareRefToTexture << SamplerCompareMode(0xdead);
CORRADE_COMPARE(out.str(), "GL::SamplerCompareMode::CompareRefToTexture GL::SamplerCompareMode(0xdead)\n");
CORRADE_COMPARE(out, "GL::SamplerCompareMode::CompareRefToTexture GL::SamplerCompareMode(0xdead)\n");
}
void SamplerTest::debugCompareFunction() {
std::ostringstream out;
Containers::String out;
Debug(&out) << SamplerCompareFunction::GreaterOrEqual << SamplerCompareFunction(0xdead);
CORRADE_COMPARE(out.str(), "GL::SamplerCompareFunction::GreaterOrEqual GL::SamplerCompareFunction(0xdead)\n");
CORRADE_COMPARE(out, "GL::SamplerCompareFunction::GreaterOrEqual GL::SamplerCompareFunction(0xdead)\n");
}
#endif
#ifndef MAGNUM_TARGET_GLES
void SamplerTest::debugDepthStencilMode() {
std::ostringstream out;
Containers::String out;
Debug(&out) << SamplerDepthStencilMode::StencilIndex << SamplerDepthStencilMode(0xdead);
CORRADE_COMPARE(out.str(), "GL::SamplerDepthStencilMode::StencilIndex GL::SamplerDepthStencilMode(0xdead)\n");
CORRADE_COMPARE(out, "GL::SamplerDepthStencilMode::StencilIndex GL::SamplerDepthStencilMode(0xdead)\n");
}
#endif

35
src/Magnum/GL/Test/ShaderGLTest.cpp

@ -25,14 +25,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h>
#include <Corrade/Containers/StringStl.h> /* StringHasPrefix / StringHasSuffix */
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/System.h>
#include <Corrade/Utility/Path.h>
@ -399,11 +396,11 @@ void ShaderGLTest::addFileNonexistent() {
Shader shader(Version::GLES200, Shader::Type::Fragment);
#endif
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
shader.addFile("nonexistent");
/* There's an error message from Path::read() before */
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"\nGL::Shader::addFile(): can't read nonexistent\n",
TestSuite::Compare::StringHasSuffix);
}
@ -467,7 +464,7 @@ void ShaderGLTest::compileFailure() {
/* First line is 1, so 175 newlines means the error is on line 176 */
shader.addSource("void main() {" + "\n"_s*175 + "someOutputVariable = ERROR_ERROR();\n}\n");
std::ostringstream out;
Containers::String out;
{
Error redirectError{&out};
CORRADE_VERIFY(!shader.compile());
@ -475,33 +472,33 @@ void ShaderGLTest::compileFailure() {
CORRADE_VERIFY(shader.isCompileFinished());
/* There's a driver-specific message after */
CORRADE_COMPARE_AS(out.str(), "GL::Shader::compile(): compilation of vertex shader failed with the following message:",
CORRADE_COMPARE_AS(out, "GL::Shader::compile(): compilation of vertex shader failed with the following message:",
TestSuite::Compare::StringHasPrefix);
/* The error message should contain the correct source number */
CORRADE_COMPARE_AS(out.str(), "11", TestSuite::Compare::StringNotContains);
CORRADE_COMPARE_AS(out, "11", TestSuite::Compare::StringNotContains);
{
#ifndef MAGNUM_TARGET_WEBGL
/* Fixed in 23.1.4, https://gitlab.freedesktop.org/mesa/mesa/-/commit/d5ff432d7d08c8bb644594ccf28b83be4b521ffe
Since I don't have any builtin way to compare version strings yet,
XFAILing only optionally, if it actually doesn't contain the
string. */
CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & Context::DetectedDriver::Mesa && !Containers::StringView{out.str()}.contains("12"),
CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & Context::DetectedDriver::Mesa && !out.contains("12"),
"Mesa reports source number only in some cases.");
#endif
CORRADE_COMPARE_AS(out.str(), "12", TestSuite::Compare::StringContains);
CORRADE_COMPARE_AS(out, "12", TestSuite::Compare::StringContains);
}
CORRADE_COMPARE_AS(out.str(), "13", TestSuite::Compare::StringNotContains);
CORRADE_COMPARE_AS(out, "13", TestSuite::Compare::StringNotContains);
/* The error message should contain the correct line number */
CORRADE_COMPARE_AS(out.str(), "175", TestSuite::Compare::StringNotContains);
CORRADE_COMPARE_AS(out.str(), "176", TestSuite::Compare::StringContains);
CORRADE_COMPARE_AS(out.str(), "177", TestSuite::Compare::StringNotContains);
CORRADE_COMPARE_AS(out, "175", TestSuite::Compare::StringNotContains);
CORRADE_COMPARE_AS(out, "176", TestSuite::Compare::StringContains);
CORRADE_COMPARE_AS(out, "177", TestSuite::Compare::StringNotContains);
/* No stray \0 should be anywhere */
CORRADE_COMPARE_AS(out.str(), "\0"_s, TestSuite::Compare::StringNotContains);
CORRADE_COMPARE_AS(out, "\0"_s, TestSuite::Compare::StringNotContains);
/* The message should end with a newline */
CORRADE_COMPARE_AS(out.str(), "\n"_s, TestSuite::Compare::StringHasSuffix);
CORRADE_COMPARE_AS(out, "\n"_s, TestSuite::Compare::StringHasSuffix);
}
void ShaderGLTest::compileFailureAsync() {
@ -521,7 +518,7 @@ void ShaderGLTest::compileFailureAsync() {
shader.addSource("[fu] bleh error #:! stuff\n");
/* The compile submission should not print anything ... */
std::ostringstream out;
Containers::String out;
{
Error redirectError{&out};
shader.submitCompile();
@ -530,7 +527,7 @@ void ShaderGLTest::compileFailureAsync() {
while(!shader.isCompileFinished())
Utility::System::sleep(100);
CORRADE_VERIFY(out.str().empty());
CORRADE_COMPARE(out, "");
/* ... only the final check should */
{
@ -538,7 +535,7 @@ void ShaderGLTest::compileFailureAsync() {
CORRADE_VERIFY(!shader.checkCompile());
}
CORRADE_VERIFY(shader.isCompileFinished());
CORRADE_COMPARE_AS(out.str(), "GL::Shader::compile(): compilation of fragment shader failed with the following message:",
CORRADE_COMPARE_AS(out, "GL::Shader::compile(): compilation of fragment shader failed with the following message:",
TestSuite::Compare::StringHasPrefix);
/* Not testing presence of \0 etc., as that's tested well enough in

7
src/Magnum/GL/Test/ShaderTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Shader.h"
@ -62,10 +61,10 @@ void ShaderTest::constructCopy() {
}
void ShaderTest::debugType() {
std::ostringstream out;
Containers::String out;
Debug(&out) << Shader::Type::Fragment << Shader::Type(0xdead);
CORRADE_COMPARE(out.str(), "GL::Shader::Type::Fragment GL::Shader::Type(0xdead)\n");
CORRADE_COMPARE(out, "GL::Shader::Type::Fragment GL::Shader::Type(0xdead)\n");
}
}}}}

15
src/Magnum/GL/Test/VersionTest.cpp

@ -24,10 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Version.h"
@ -103,7 +102,7 @@ void VersionTest::compare() {
}
void VersionTest::debug() {
std::ostringstream out;
Containers::String out;
#ifndef MAGNUM_TARGET_GLES
Debug(&out) << Version::GL210 << Version(0xdead);
@ -112,20 +111,20 @@ void VersionTest::debug() {
#endif
#ifdef MAGNUM_TARGET_WEBGL
CORRADE_COMPARE(out.str(), "WebGL 1.0 Invalid(0xdead)\n");
CORRADE_COMPARE(out, "WebGL 1.0 Invalid(0xdead)\n");
#elif defined(MAGNUM_TARGET_GLES)
CORRADE_COMPARE(out.str(), "OpenGL ES 2.0 Invalid(0xdead)\n");
CORRADE_COMPARE(out, "OpenGL ES 2.0 Invalid(0xdead)\n");
#else
CORRADE_COMPARE(out.str(), "OpenGL 2.1 Invalid(0xdead)\n");
CORRADE_COMPARE(out, "OpenGL 2.1 Invalid(0xdead)\n");
#endif
}
#ifndef MAGNUM_TARGET_GLES
void VersionTest::debugES() {
std::ostringstream out;
Containers::String out;
Debug{&out} << Version::GLES310;
CORRADE_COMPARE(out.str(), "OpenGL ES 3.1\n");
CORRADE_COMPARE(out, "OpenGL ES 3.1\n");
}
#endif

15
src/Magnum/MaterialTools/Test/FilterTest.cpp

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/BitArray.h>
#include <Corrade/Containers/BitArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/DebugTools/CompareMaterial.h"
#include "Magnum/MaterialTools/Filter.h"
@ -162,10 +161,10 @@ void FilterTest::attributesWrongBitCount() {
}, {2, 4}};
Containers::BitArrayView attributesToKeep{nullptr, 0, 5};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
filterAttributes(material, attributesToKeep);
CORRADE_COMPARE(out.str(), "MaterialTools::filterAttributes(): expected 4 bits but got 5\n");
CORRADE_COMPARE(out, "MaterialTools::filterAttributes(): expected 4 bits but got 5\n");
}
void FilterTest::layers() {
@ -253,10 +252,10 @@ void FilterTest::layersWrongBitCount() {
}, {2, 4}};
Containers::BitArrayView layersToKeep{nullptr, 0, 3};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
filterLayers(material, layersToKeep);
CORRADE_COMPARE(out.str(), "MaterialTools::filterLayers(): expected 2 bits but got 3\n");
CORRADE_COMPARE(out, "MaterialTools::filterLayers(): expected 2 bits but got 3\n");
}
void FilterTest::attributesLayers() {
@ -356,11 +355,11 @@ void FilterTest::attributesLayersWrongBitCount() {
Containers::BitArrayView attributesToKeep{nullptr, 0, 5};
Containers::BitArrayView layersToKeep{nullptr, 0, 3};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
filterAttributesLayers(material, attributesToKeep, layersToKeep.prefix(2));
filterAttributesLayers(material, attributesToKeep.prefix(4), layersToKeep);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MaterialTools::filterAttributesLayers(): expected 4 attribute bits but got 5\n"
"MaterialTools::filterAttributesLayers(): expected 2 layer bits but got 3\n");
}

7
src/Magnum/MaterialTools/Test/MergeTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/DebugTools/CompareMaterial.h"
#include "Magnum/Math/Color.h"
@ -306,13 +305,13 @@ void MergeTest::conflictsFail() {
}, {2, 3}};
/* Verify that it fails in all variants */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_VERIFY(!merge(a, b));
CORRADE_VERIFY(!merge(b, a));
CORRADE_VERIFY(!merge(a, c, MergeConflicts::KeepFirstIfSameType));
CORRADE_VERIFY(!merge(c, a, MergeConflicts::KeepFirstIfSameType));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MaterialTools::merge(): conflicting attribute RoughnessTexture in layer 0\n"
"MaterialTools::merge(): conflicting attribute RoughnessTexture in layer 0\n"
"MaterialTools::merge(): conflicting type Trade::MaterialAttributeType::Float vs String of attribute customAttribute in layer 1\n"

15
src/Magnum/MaterialTools/Test/PhongToPbrMetallicRoughnessTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stream-free */
#include "Magnum/DebugTools/CompareMaterial.h"
#include "Magnum/MaterialTools/PhongToPbrMetallicRoughness.h"
@ -278,35 +277,35 @@ void PhongToPbrMetallicRoughnessTest::convert() {
auto&& data = ConvertData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Warning redirectWarning{&out};
Containers::Optional<Trade::MaterialData> actual = phongToPbrMetallicRoughness(data.material, data.flags);
CORRADE_VERIFY(actual);
CORRADE_COMPARE_AS(*actual, data.expected, DebugTools::CompareMaterial);
CORRADE_COMPARE(out.str(), "");
CORRADE_COMPARE(out, "");
}
void PhongToPbrMetallicRoughnessTest::warning() {
auto&& data = WarningData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Containers::Optional<Trade::MaterialData> actual = phongToPbrMetallicRoughness(data.material, data.flags);
CORRADE_VERIFY(actual);
CORRADE_COMPARE_AS(*actual, data.expected, DebugTools::CompareMaterial);
CORRADE_COMPARE(out.str(), data.message);
CORRADE_COMPARE(out, data.message);
}
void PhongToPbrMetallicRoughnessTest::fail() {
auto&& data = FailData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_VERIFY(!phongToPbrMetallicRoughness(data.material, data.flags));
CORRADE_COMPARE(out.str(), data.message);
CORRADE_COMPARE(out, data.message);
}
}}}}

7
src/Magnum/MaterialTools/Test/RemoveDuplicatesTest.cpp

@ -24,12 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream> /** @todo remove once Debug is stream-free */
#include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stream-free */
#include "Magnum/DebugTools/CompareMaterial.h"
#include "Magnum/Math/Color.h"
@ -648,11 +647,11 @@ void RemoveDuplicatesTest::invalidSize() {
};
UnsignedInt mapping[3];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
removeDuplicatesInto(data, mapping);
removeDuplicatesInPlaceInto(data, mapping);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MaterialTools::removeDuplicatesInto(): bad output size, expected 2 but got 3\n"
"MaterialTools::removeDuplicatesInPlaceInto(): bad output size, expected 2 but got 3\n");
}

43
src/Magnum/Math/Test/AngleTest.cpp

@ -24,14 +24,13 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Corrade/Containers/String.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include <Corrade/Utility/TweakableParser.h>
#endif
@ -341,43 +340,43 @@ void AngleTest::conversion() {
}
void AngleTest::debugDeg() {
std::ostringstream o;
Containers::String out;
Debug(&o) << 90.0_degf;
CORRADE_COMPARE(o.str(), "Deg(90)\n");
Debug{&out} << 90.0_degf;
CORRADE_COMPARE(out, "Deg(90)\n");
/* Verify that this compiles */
o.str({});
Debug(&o) << 56.0_degf - 34.0_degf;
CORRADE_COMPARE(o.str(), "Deg(22)\n");
out = {};
Debug{&out} << 56.0_degf - 34.0_degf;
CORRADE_COMPARE(out, "Deg(22)\n");
}
void AngleTest::debugDegPacked() {
std::ostringstream out;
Containers::String out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << 90.0_degf << 45.0_degf;
CORRADE_COMPARE(out.str(), "90 Deg(45)\n");
CORRADE_COMPARE(out, "90 Deg(45)\n");
}
void AngleTest::debugRad() {
std::ostringstream o;
Containers::String out;
Debug(&o) << 1.5708_radf;
CORRADE_COMPARE(o.str(), "Rad(1.5708)\n");
Debug{&out} << 1.5708_radf;
CORRADE_COMPARE(out, "Rad(1.5708)\n");
/* Verify that this compiles */
o.str({});
Debug(&o) << 1.5708_radf - 3.1416_radf;
CORRADE_COMPARE(o.str(), "Rad(-1.5708)\n");
out = {};
Debug{&out} << 1.5708_radf - 3.1416_radf;
CORRADE_COMPARE(out, "Rad(-1.5708)\n");
}
void AngleTest::debugRadPacked() {
std::ostringstream out;
Containers::String out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << 1.5708_radf << 3.1416_radf;
CORRADE_COMPARE(out.str(), "1.5708 Rad(3.1416)\n");
CORRADE_COMPARE(out, "1.5708 Rad(3.1416)\n");
}
#if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
@ -395,11 +394,11 @@ template<class T> void AngleTest::tweakableError() {
setTestCaseTemplateName(TweakableTraits<T>::name());
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<T>::parse(Utility::format(data.data, TweakableTraits<T>::literal())).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, TweakableTraits<T>::literal()));
CORRADE_COMPARE(out, Utility::format(data.error, TweakableTraits<T>::literal()));
CORRADE_COMPARE(state, data.state);
}
#endif

9
src/Magnum/Math/Test/BezierTest.cpp

@ -25,9 +25,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Bezier.h"
#include "Magnum/Math/CubicHermite.h"
@ -337,9 +338,9 @@ void BezierTest::strictWeakOrdering() {
}
void BezierTest::debug() {
std::ostringstream out;
Containers::String out;
Debug(&out) << CubicBezier2D{Vector2{0.0f, 1.0f}, Vector2{1.5f, -0.3f}, Vector2{2.1f, 0.5f}, Vector2{0.0f, 2.0f}};
CORRADE_COMPARE(out.str(), "Bezier({0, 1}, {1.5, -0.3}, {2.1, 0.5}, {0, 2})\n");
CORRADE_COMPARE(out, "Bezier({0, 1}, {1.5, -0.3}, {2.1, 0.5}, {0, 2})\n");
}
}}}}

11
src/Magnum/Math/Test/BitVectorTest.cpp

@ -24,9 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/BitVector.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -373,12 +374,12 @@ void BitVectorTest::strictWeakOrdering() {
}
void BitVectorTest::debug() {
std::ostringstream o;
Containers::String out;
/* 0b00100101 0b01010011 0b010 */
Debug(&o) << BitVector19(0x25, 0x53, 0x02);
Debug{&out} << BitVector19(0x25, 0x53, 0x02);
CORRADE_COMPARE(o.str(), "BitVector(0b00100101, 0b01010011, 0b010)\n");
CORRADE_COMPARE(out, "BitVector(0b00100101, 0b01010011, 0b010)\n");
}
}}}}

6
src/Magnum/Math/Test/ColorBatchTest.cpp

@ -24,7 +24,6 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StridedArrayView.h>
@ -32,7 +31,6 @@
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stram-free */
#include <Corrade/Utility/Path.h>
#include "Magnum/ImageView.h"
@ -369,11 +367,11 @@ void ColorBatchTest::yFlipInvalidLastDimension() {
it's enough to test just some */
char data[32];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
yFlipBc3InPlace(Containers::stridedArrayView(data).expanded<0>(Containers::Size3D{1, 4, 8}));
yFlipBc1InPlace(Containers::stridedArrayView(data).expanded<0>(Containers::Size3D{1, 2, 16}).every({1, 1, 2}));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::yFlipBc3InPlace(): expected last dimension to be 16 bytes but got 8\n"
"Math::yFlipBc1InPlace(): last dimension is not contiguous\n");
}

79
src/Magnum/Math/Test/ColorTest.cpp

@ -24,13 +24,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Corrade/Containers/String.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Tweakable.h>
#endif
@ -1246,28 +1245,28 @@ void ColorTest::swizzleType() {
}
void ColorTest::debug() {
std::ostringstream o;
Debug(&o) << Color3(0.5f, 0.75f, 1.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 0.75, 1)\n");
Containers::String out;
Debug{&out} << Color3(0.5f, 0.75f, 1.0f);
CORRADE_COMPARE(out, "Vector(0.5, 0.75, 1)\n");
o.str({});
Debug(&o) << Color4(0.5f, 0.75f, 0.0f, 1.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 0.75, 0, 1)\n");
out = {};
Debug{&out} << Color4(0.5f, 0.75f, 0.0f, 1.0f);
CORRADE_COMPARE(out, "Vector(0.5, 0.75, 0, 1)\n");
}
void ColorTest::debugUb() {
std::ostringstream o;
Debug(&o) << 0x123456_rgb << 0x789abc_rgb;
CORRADE_COMPARE(o.str(), "#123456 #789abc\n");
Containers::String out;
Debug{&out} << 0x123456_rgb << 0x789abc_rgb;
CORRADE_COMPARE(out, "#123456 #789abc\n");
o.str({});
Debug(&o) << 0x12345678_rgba << 0x90abcdef_rgba;
CORRADE_COMPARE(o.str(), "#12345678 #90abcdef\n");
out = {};
Debug{&out} << 0x12345678_rgba << 0x90abcdef_rgba;
CORRADE_COMPARE(out, "#12345678 #90abcdef\n");
/* The Hex flag shouldn't affect this at all */
o.str({});
Debug{&o, Debug::Flag::Hex} << 0x789abc_rgb << 0x12345678_rgba;
CORRADE_COMPARE(o.str(), "#789abc #12345678\n");
out = {};
Debug{&out, Debug::Flag::Hex} << 0x789abc_rgb << 0x12345678_rgba;
CORRADE_COMPARE(out, "#789abc #12345678\n");
}
void ColorTest::debugUbColor() {
@ -1284,12 +1283,12 @@ void ColorTest::debugUbColor() {
<< 0x3bd26799_rgba << 0x3bd267cc_rgba << 0x3bd267ff_rgba;
/* It should work just for the immediately following value */
std::ostringstream out;
Containers::String out;
Debug{&out}
<< Debug::color << 0x3bd267_rgb
<< Debug::color << 0x2f83cc99_rgba
<< 0x3bd267_rgb << 0x2f83cc99_rgba;
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"\033[38;2;59;210;103m\033[48;2;59;210;103m██\033[0m "
"\033[38;2;47;131;204m▒▒\033[0m #3bd267 #2f83cc99\n");
}
@ -1308,18 +1307,18 @@ void ColorTest::debugUbColorColorsDisabled() {
<< 0x3bd26799_rgba << 0x3bd267cc_rgba << 0x3bd267ff_rgba;
/* It should work just for the immediately following value */
std::ostringstream out;
Containers::String out;
Debug{&out, Debug::Flag::DisableColors}
<< Debug::color << 0x2f83cc_rgb
<< Debug::color << 0x2f83cc99_rgba
<< 0x2f83cc_rgb << 0x2f83cc99_rgba;
CORRADE_COMPARE(out.str(), "▓▓ ▒▒ #2f83cc #2f83cc99\n");
CORRADE_COMPARE(out, "▓▓ ▒▒ #2f83cc #2f83cc99\n");
}
void ColorTest::debugHsv() {
std::ostringstream out;
Containers::String out;
Debug{&out} << ColorHsv(135.0_degf, 0.75f, 0.3f);
CORRADE_COMPARE(out.str(), "ColorHsv(Deg(135), 0.75, 0.3)\n");
CORRADE_COMPARE(out, "ColorHsv(Deg(135), 0.75, 0.3)\n");
}
#if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
@ -1399,11 +1398,11 @@ void ColorTest::tweakableErrorRgb() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Color3ub>::parse(Utility::format(data.data, "ff3366", "rgb")).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, "ff3366", "rgb", ""));
CORRADE_COMPARE(out, Utility::format(data.error, "ff3366", "rgb", ""));
CORRADE_COMPARE(state, data.state);
}
@ -1411,11 +1410,11 @@ void ColorTest::tweakableErrorSrgb() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Vector3ub>::parse(Utility::format(data.data, "ff3366", "srgb")).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, "ff3366", "rgb", "s"));
CORRADE_COMPARE(out, Utility::format(data.error, "ff3366", "rgb", "s"));
CORRADE_COMPARE(state, data.state);
}
@ -1423,11 +1422,11 @@ void ColorTest::tweakableErrorRgba() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Color4ub>::parse(Utility::format(data.data, "ff3366aa", "rgba")).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, "ff3366aa", "rgba", ""));
CORRADE_COMPARE(out, Utility::format(data.error, "ff3366aa", "rgba", ""));
CORRADE_COMPARE(state, data.state);
}
@ -1435,11 +1434,11 @@ void ColorTest::tweakableErrorSrgba() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Vector4ub>::parse(Utility::format(data.data, "ff3366aa", "srgba")).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, "ff3366aa", "rgba", "s"));
CORRADE_COMPARE(out, Utility::format(data.error, "ff3366aa", "rgba", "s"));
CORRADE_COMPARE(state, data.state);
}
@ -1447,11 +1446,11 @@ void ColorTest::tweakableErrorRgbf() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Color3>::parse(Utility::format(data.data, "ff3366", "rgbf")).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, "ff3366", "rgbf", ""));
CORRADE_COMPARE(out, Utility::format(data.error, "ff3366", "rgbf", ""));
CORRADE_COMPARE(state, data.state);
}
@ -1459,11 +1458,11 @@ void ColorTest::tweakableErrorSrgbf() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Color3>::parse(Utility::format(data.data, "ff3366", "srgbf")).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, "ff3366", "rgbf", "s"));
CORRADE_COMPARE(out, Utility::format(data.error, "ff3366", "rgbf", "s"));
CORRADE_COMPARE(state, data.state);
}
@ -1471,11 +1470,11 @@ void ColorTest::tweakableErrorRgbaf() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Color4>::parse(Utility::format(data.data, "ff3366aa", "rgbaf")).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, "ff3366aa", "rgbaf", ""));
CORRADE_COMPARE(out, Utility::format(data.error, "ff3366aa", "rgbaf", ""));
CORRADE_COMPARE(state, data.state);
}
@ -1483,11 +1482,11 @@ void ColorTest::tweakableErrorSrgbaf() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Color4>::parse(Utility::format(data.data, "ff3366aa", "srgbaf")).first();
CORRADE_COMPARE(out.str(), Utility::formatString(data.error, "ff3366aa", "rgbaf", "s"));
CORRADE_COMPARE(out, Utility::format(data.error, "ff3366aa", "rgbaf", "s"));
CORRADE_COMPARE(state, data.state);
}
#endif

31
src/Magnum/Math/Test/ComplexTest.cpp

@ -24,9 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Complex.h"
#include "Magnum/Math/Matrix3.h"
@ -439,11 +440,11 @@ void ComplexTest::invertedNormalized() {
void ComplexTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
(Complex(-0.6f, 0.8f)*2).invertedNormalized();
CORRADE_COMPARE(out.str(), "Math::Complex::invertedNormalized(): Complex(-1.2, 1.6) is not normalized\n");
CORRADE_COMPARE(out, "Math::Complex::invertedNormalized(): Complex(-1.2, 1.6) is not normalized\n");
}
void ComplexTest::angle() {
@ -478,11 +479,11 @@ void ComplexTest::angleNormalizedButOver1() {
void ComplexTest::angleNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Math::angle(Complex(1.5f, -2.0f).normalized(), {-4.0f, 3.5f});
Math::angle({1.5f, -2.0f}, Complex(-4.0f, 3.5f).normalized());
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::angle(): complex numbers Complex(0.6, -0.8) and Complex(-4, 3.5) are not normalized\n"
"Math::angle(): complex numbers Complex(1.5, -2) and Complex(-0.752577, 0.658505) are not normalized\n");
}
@ -518,7 +519,7 @@ void ComplexTest::matrix() {
void ComplexTest::matrixNotRotation() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* Shear, using rotationShear() instead of rotationScaling() as that isn't
supposed to "fix" the shear */
@ -528,7 +529,7 @@ void ComplexTest::matrixNotRotation() {
supposed to "fix" the reflection either */
Complex::fromMatrix((Matrix3::scaling({-1.0f, 1.0f})*
Matrix3::rotation(45.0_degf)).rotation());
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Complex::fromMatrix(): the matrix is not a rotation:\n"
"Matrix(0.894427, -0.894427,\n"
" 0.447214, 0.447214)\n"
@ -553,13 +554,13 @@ void ComplexTest::lerp() {
void ComplexTest::lerpNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Complex a;
Math::lerp(a*3.0f, a, 0.35f);
Math::lerp(a, a*-3.0f, 0.35f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::lerp(): complex numbers Complex(3, 0) and Complex(1, 0) are not normalized\n"
"Math::lerp(): complex numbers Complex(1, 0) and Complex(-3, -0) are not normalized\n");
}
@ -581,13 +582,13 @@ void ComplexTest::slerp() {
void ComplexTest::slerpNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Complex a;
Math::slerp(a*3.0f, a, 0.35f);
Math::slerp(a, a*-3.0f, 0.35f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::slerp(): complex numbers Complex(3, 0) and Complex(1, 0) are not normalized\n"
"Math::slerp(): complex numbers Complex(1, 0) and Complex(-3, -0) are not normalized\n");
}
@ -618,10 +619,10 @@ void ComplexTest::strictWeakOrdering() {
}
void ComplexTest::debug() {
std::ostringstream o;
Containers::String out;
Debug(&o) << Complex(2.5f, -7.5f);
CORRADE_COMPARE(o.str(), "Complex(2.5, -7.5)\n");
Debug{&out} << Complex(2.5f, -7.5f);
CORRADE_COMPARE(out, "Complex(2.5, -7.5)\n");
}
}}}}

2
src/Magnum/Math/Test/ConfigurationValueTest.cpp

@ -26,7 +26,7 @@
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/Configuration.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Configuration is std::string-free */
#include "Magnum/Math/ConfigurationValue.h"

53
src/Magnum/Math/Test/CubicHermiteTest.cpp

@ -24,9 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Bezier.h"
#include "Magnum/Math/CubicHermite.h"
@ -892,7 +893,7 @@ void CubicHermiteTest::lerpComplex() {
void CubicHermiteTest::lerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* This one should not assert as the default constructor should create
@ -903,7 +904,7 @@ void CubicHermiteTest::lerpComplexNotNormalized() {
CubicHermiteComplex a{{}, Complex{}*2.0f, {}};
Math::lerp({}, a, 0.3f);
Math::lerp(a, {}, 0.3f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::lerp(): complex numbers Complex(1, 0) and Complex(2, 0) are not normalized\n"
"Math::lerp(): complex numbers Complex(2, 0) and Complex(1, 0) are not normalized\n");
}
@ -935,7 +936,7 @@ void CubicHermiteTest::lerpQuaternion() {
void CubicHermiteTest::lerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* This one should not assert as the default constructor should create
@ -946,7 +947,7 @@ void CubicHermiteTest::lerpQuaternionNotNormalized() {
CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}};
Math::lerp({}, a, 0.3f);
Math::lerp(a, {}, 0.3f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::lerp(): quaternions Quaternion({0, 0, 0}, 1) and Quaternion({0, 0, 0}, 2) are not normalized\n"
"Math::lerp(): quaternions Quaternion({0, 0, 0}, 2) and Quaternion({0, 0, 0}, 1) are not normalized\n");
}
@ -977,7 +978,7 @@ void CubicHermiteTest::lerpQuaternionShortestPath() {
void CubicHermiteTest::lerpQuaternionShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* This one should not assert as the default constructor should create
@ -989,7 +990,7 @@ void CubicHermiteTest::lerpQuaternionShortestPathNotNormalized() {
Math::lerpShortestPath({}, a, 0.3f);
Math::lerpShortestPath(a, {}, 0.3f);
/* lerpShortestPath() is calling lerp(), so the message is from there */
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::lerp(): quaternions Quaternion({0, 0, 0}, 1) and Quaternion({0, 0, 0}, 2) are not normalized\n"
"Math::lerp(): quaternions Quaternion({0, 0, 0}, 2) and Quaternion({0, 0, 0}, 1) are not normalized\n");
}
@ -1015,7 +1016,7 @@ void CubicHermiteTest::slerpComplex() {
void CubicHermiteTest::slerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* This one should not assert as the default constructor should create
@ -1026,7 +1027,7 @@ void CubicHermiteTest::slerpComplexNotNormalized() {
CubicHermiteComplex a{{}, Complex{}*2.0f, {}};
Math::slerp({}, a, 0.3f);
Math::slerp(a, {}, 0.3f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::slerp(): complex numbers Complex(1, 0) and Complex(2, 0) are not normalized\n"
"Math::slerp(): complex numbers Complex(2, 0) and Complex(1, 0) are not normalized\n");
}
@ -1058,7 +1059,7 @@ void CubicHermiteTest::slerpQuaternion() {
void CubicHermiteTest::slerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* This one should not assert as the default constructor should create
@ -1069,7 +1070,7 @@ void CubicHermiteTest::slerpQuaternionNotNormalized() {
CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}};
Math::slerp({}, a, 0.3f);
Math::slerp(a, {}, 0.3f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::slerp(): quaternions Quaternion({0, 0, 0}, 1) and Quaternion({0, 0, 0}, 2) are not normalized\n"
"Math::slerp(): quaternions Quaternion({0, 0, 0}, 2) and Quaternion({0, 0, 0}, 1) are not normalized\n");
}
@ -1101,7 +1102,7 @@ void CubicHermiteTest::slerpQuaternionShortestPath() {
void CubicHermiteTest::slerpQuaternionShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* This one should not assert as the default constructor should create
@ -1112,7 +1113,7 @@ void CubicHermiteTest::slerpQuaternionShortestPathNotNormalized() {
CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}};
Math::slerpShortestPath({}, a, 0.3f);
Math::slerpShortestPath(a, {}, 0.3f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::slerpShortestPath(): quaternions Quaternion({0, 0, 0}, 1) and Quaternion({0, 0, 0}, 2) are not normalized\n"
"Math::slerpShortestPath(): quaternions Quaternion({0, 0, 0}, 2) and Quaternion({0, 0, 0}, 1) are not normalized\n");
}
@ -1175,7 +1176,7 @@ void CubicHermiteTest::splerpComplex() {
void CubicHermiteTest::splerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* This one should not assert as the default constructor should create
@ -1186,7 +1187,7 @@ void CubicHermiteTest::splerpComplexNotNormalized() {
CubicHermiteComplex a{{}, Complex{}*2.0f, {}};
Math::splerp({}, a, 0.3f);
Math::splerp(a, {}, 0.3f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::splerp(): complex spline points Complex(1, 0) and Complex(2, 0) are not normalized\n"
"Math::splerp(): complex spline points Complex(2, 0) and Complex(1, 0) are not normalized\n");
}
@ -1214,7 +1215,7 @@ void CubicHermiteTest::splerpQuaternion() {
void CubicHermiteTest::splerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* This one should not assert as the default constructor should create
@ -1225,7 +1226,7 @@ void CubicHermiteTest::splerpQuaternionNotNormalized() {
CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}};
Math::splerp({}, a, 0.3f);
Math::splerp(a, {}, 0.3f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::splerp(): quaternion spline points Quaternion({0, 0, 0}, 1) and Quaternion({0, 0, 0}, 2) are not normalized\n"
"Math::splerp(): quaternion spline points Quaternion({0, 0, 0}, 2) and Quaternion({0, 0, 0}, 1) are not normalized\n");
}
@ -1250,30 +1251,30 @@ void CubicHermiteTest::strictWeakOrdering() {
}
void CubicHermiteTest::debugScalar() {
std::ostringstream out;
Containers::String out;
Debug{&out} << CubicHermite1D{2.0f, 3.0f, -1.0f};
CORRADE_COMPARE(out.str(), "CubicHermite(2, 3, -1)\n");
CORRADE_COMPARE(out, "CubicHermite(2, 3, -1)\n");
}
void CubicHermiteTest::debugVector() {
std::ostringstream out;
Containers::String out;
Debug{&out} << CubicHermite2D{{2.0f, 1.5f}, {3.0f, 0.1f}, {-1.0f, 0.0f}};
CORRADE_COMPARE(out.str(), "CubicHermite(Vector(2, 1.5), Vector(3, 0.1), Vector(-1, 0))\n");
CORRADE_COMPARE(out, "CubicHermite(Vector(2, 1.5), Vector(3, 0.1), Vector(-1, 0))\n");
}
void CubicHermiteTest::debugComplex() {
std::ostringstream out;
Containers::String out;
Debug{&out} << CubicHermiteComplex{{2.0f, 1.5f}, {3.0f, 0.1f}, {-1.0f, 0.0f}};
CORRADE_COMPARE(out.str(), "CubicHermite(Complex(2, 1.5), Complex(3, 0.1), Complex(-1, 0))\n");
CORRADE_COMPARE(out, "CubicHermite(Complex(2, 1.5), Complex(3, 0.1), Complex(-1, 0))\n");
}
void CubicHermiteTest::debugQuaternion() {
std::ostringstream out;
Containers::String out;
Debug{&out} << CubicHermiteQuaternion{
{{2.0f, 1.5f, 0.3f}, 1.1f},
{{3.0f, 0.1f, 2.3f}, 0.7f},
{{-1.0f, 0.0f, 0.3f}, 0.4f}};
CORRADE_COMPARE(out.str(), "CubicHermite(Quaternion({2, 1.5, 0.3}, 1.1), Quaternion({3, 0.1, 2.3}, 0.7), Quaternion({-1, 0, 0.3}, 0.4))\n");
CORRADE_COMPARE(out, "CubicHermite(Quaternion({2, 1.5, 0.3}, 1.1), Quaternion({3, 0.1, 2.3}, 0.7), Quaternion({-1, 0, 0.3}, 0.4))\n");
}
}}}}

7
src/Magnum/Math/Test/DistanceTest.cpp

@ -25,9 +25,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Constants.h"
#include "Magnum/Math/Distance.h"
@ -237,12 +236,12 @@ void DistanceTest::pointPlaneNormalized() {
void DistanceTest::pointPlaneNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Vector4 invalidPlane{2.0f, 2.0f, 2.0f, 0.0f};
Distance::pointPlaneNormalized({}, invalidPlane);
CORRADE_COMPARE(out.str(), "Math::Distance::pointPlaneNormalized(): plane normal Vector(2, 2, 2) is not normalized\n");
CORRADE_COMPARE(out, "Math::Distance::pointPlaneNormalized(): plane normal Vector(2, 2, 2) is not normalized\n");
}
}}}}

21
src/Magnum/Math/Test/DualComplexTest.cpp

@ -25,9 +25,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/DualComplex.h"
#include "Magnum/Math/DualQuaternion.h"
@ -406,11 +407,11 @@ void DualComplexTest::invertedNormalized() {
void DualComplexTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DualComplex({-1.0f, -2.5f}, {}).invertedNormalized();
CORRADE_COMPARE(out.str(), "Math::Complex::invertedNormalized(): Complex(-1, -2.5) is not normalized\n");
CORRADE_COMPARE(out, "Math::Complex::invertedNormalized(): Complex(-1, -2.5) is not normalized\n");
}
void DualComplexTest::rotation() {
@ -468,11 +469,11 @@ void DualComplexTest::matrix() {
void DualComplexTest::matrixNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream o;
Error redirectError{&o};
Containers::String out;
Error redirectError{&out};
DualComplex::fromMatrix(Matrix3::rotation(23.0_degf)*Matrix3::translation({2.0f, 3.0f})*2);
CORRADE_COMPARE(o.str(),
CORRADE_COMPARE(out,
"Math::DualComplex::fromMatrix(): the matrix doesn't represent rigid transformation:\n"
"Matrix(1.84101, -0.781462, 1.33763,\n"
" 0.781462, 1.84101, 7.08595,\n"
@ -522,10 +523,10 @@ void DualComplexTest::strictWeakOrdering() {
}
void DualComplexTest::debug() {
std::ostringstream o;
Containers::String out;
Debug(&o) << DualComplex({-1.0f, -2.5f}, {-3.0f, -7.5f});
CORRADE_COMPARE(o.str(), "DualComplex({-1, -2.5}, {-3, -7.5})\n");
Debug{&out} << DualComplex({-1.0f, -2.5f}, {-3.0f, -7.5f});
CORRADE_COMPARE(out, "DualComplex({-1, -2.5}, {-3, -7.5})\n");
}
}}}}

31
src/Magnum/Math/Test/DualQuaternionTest.cpp

@ -25,9 +25,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/DualQuaternion.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -443,11 +444,11 @@ void DualQuaternionTest::invertedNormalized() {
void DualQuaternionTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DualQuaternion({{ 1.0f, 2.0f, 3.0f}, -4.0f}, {{ 2.5f, -3.1f, 3.3f}, 2.0f}).invertedNormalized();
CORRADE_COMPARE(out.str(), "Math::DualQuaternion::invertedNormalized(): DualQuaternion({{1, 2, 3}, -4}, {{2.5, -3.1, 3.3}, 2}) is not normalized\n");
CORRADE_COMPARE(out, "Math::DualQuaternion::invertedNormalized(): DualQuaternion({{1, 2, 3}, -4}, {{2.5, -3.1, 3.3}, 2}) is not normalized\n");
}
void DualQuaternionTest::rotation() {
@ -471,11 +472,11 @@ void DualQuaternionTest::rotation() {
void DualQuaternionTest::rotationNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DualQuaternion::rotation(120.0_degf, Vector3(2.0f));
CORRADE_COMPARE(out.str(), "Math::Quaternion::rotation(): axis Vector(2, 2, 2) is not normalized\n");
CORRADE_COMPARE(out, "Math::Quaternion::rotation(): axis Vector(2, 2, 2) is not normalized\n");
}
void DualQuaternionTest::translation() {
@ -525,11 +526,11 @@ void DualQuaternionTest::matrix() {
void DualQuaternionTest::matrixNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DualQuaternion::fromMatrix(Matrix4::rotationX(23.0_degf)*Matrix4::translation({-1.0f, 2.0f, 3.0f})*2);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::DualQuaternion::fromMatrix(): the matrix doesn't represent a rigid transformation:\n"
"Matrix(2, 0, 0, -2,\n"
" 0, 1.84101, -0.781462, 1.33763,\n"
@ -562,13 +563,13 @@ void DualQuaternionTest::transformVectorNormalized() {
void DualQuaternionTest::transformVectorNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion a = Quaternion::rotation(23.0_degf, Vector3::xAxis());
(a*2).transformVectorNormalized({});
/* Delegates to quaternion, so the assert prints Quaternion */
CORRADE_COMPARE(out.str(), "Math::Quaternion::transformVectorNormalized(): Quaternion({0.398736, 0, 0}, 1.95985) is not normalized\n");
CORRADE_COMPARE(out, "Math::Quaternion::transformVectorNormalized(): Quaternion({0.398736, 0, 0}, 1.95985) is not normalized\n");
}
void DualQuaternionTest::transformPoint() {
@ -606,12 +607,12 @@ void DualQuaternionTest::transformPointNormalized() {
void DualQuaternionTest::transformPointNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
DualQuaternion a = DualQuaternion::translation({-1.0f, 2.0f, 3.0f})*DualQuaternion::rotation(23.0_degf, Vector3::xAxis());
(a*Dual(2)).transformPointNormalized({});
CORRADE_COMPARE(out.str(), "Math::DualQuaternion::transformPointNormalized(): DualQuaternion({{0.398736, 0, 0}, 1.95985}, {{-0.979925, 2.55795, 2.54104}, 0.199368}) is not normalized\n");
CORRADE_COMPARE(out, "Math::DualQuaternion::transformPointNormalized(): DualQuaternion({{0.398736, 0, 0}, 1.95985}, {{-0.979925, 2.55795, 2.54104}, 0.199368}) is not normalized\n");
}
void DualQuaternionTest::sclerp() {
@ -726,10 +727,10 @@ void DualQuaternionTest::strictWeakOrdering() {
}
void DualQuaternionTest::debug() {
std::ostringstream o;
Containers::String out;
Debug(&o) << DualQuaternion({{1.0f, 2.0f, 3.0f}, -4.0f}, {{0.5f, -3.1f, 3.3f}, 2.0f});
CORRADE_COMPARE(o.str(), "DualQuaternion({{1, 2, 3}, -4}, {{0.5, -3.1, 3.3}, 2})\n");
Debug{&out} << DualQuaternion({{1.0f, 2.0f, 3.0f}, -4.0f}, {{0.5f, -3.1f, 3.3f}, 2.0f});
CORRADE_COMPARE(out, "DualQuaternion({{1, 2, 3}, -4}, {{0.5, -3.1, 3.3}, 2})\n");
}
}}}}

11
src/Magnum/Math/Test/DualTest.cpp

@ -24,9 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Dual.h"
#include "Magnum/Math/Quaternion.h"
@ -385,10 +386,10 @@ void DualTest::subclass() {
}
void DualTest::debug() {
std::ostringstream o;
Containers::String out;
Debug(&o) << Dual(2.5f, -0.3f);
CORRADE_COMPARE(o.str(), "Dual(2.5, -0.3)\n");
Debug{&out} << Dual(2.5f, -0.3f);
CORRADE_COMPARE(out, "Dual(2.5, -0.3)\n");
}
}}}}

12
src/Magnum/Math/Test/FrustumTest.cpp

@ -25,11 +25,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Frustum.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -358,11 +358,11 @@ void FrustumTest::dataOutOfRange() {
Frustum a;
constexpr Frustum ca;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
a[6];
ca[6];
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Frustum::operator[](): index 6 out of range\n"
"Math::Frustum::operator[](): index 6 out of range\n");
}
@ -452,9 +452,9 @@ void FrustumTest::debug() {
{-7.0f, 8.0f, -9.0f, 0.5f},
{ 7.0f, -8.0f, 9.0f, 0.6f}};
std::ostringstream out;
Containers::String out;
Debug{&out} << frustum;
CORRADE_COMPARE(out.str(), "Frustum({-1, 2, -3, 0.1},\n"
CORRADE_COMPARE(out, "Frustum({-1, 2, -3, 0.1},\n"
" {1, -2, 3, 0.2},\n"
" {-4, 5, -6, 0.3},\n"
" {4, -5, 6, 0.4},\n"

19
src/Magnum/Math/Test/FunctionsTest.cpp

@ -25,9 +25,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Functions.h"
#include "Magnum/Math/Time.h"
@ -345,19 +344,19 @@ void FunctionsTest::binomialCoefficient() {
void FunctionsTest::binomialCoefficientInvalidInput() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Math::binomialCoefficient(15, 16);
CORRADE_COMPARE(out.str(), "Math::binomialCoefficient(): k can't be greater than n in (15 choose 16)\n");
CORRADE_COMPARE(out, "Math::binomialCoefficient(): k can't be greater than n in (15 choose 16)\n");
}
void FunctionsTest::binomialCoefficientOverflow() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Math::binomialCoefficient(63, 31);
CORRADE_COMPARE(out.str(), "Math::binomialCoefficient(): overflow for (63 choose 31)\n");
CORRADE_COMPARE(out, "Math::binomialCoefficient(): overflow for (63 choose 31)\n");
}
void FunctionsTest::fmod() {
@ -590,10 +589,10 @@ void FunctionsTest::reflect() {
void FunctionsTest::reflectNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Math::reflect(Vector3{}, Vector3{1.0f});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::reflect(): normal Vector(1, 1, 1) is not normalized\n");
}
@ -617,10 +616,10 @@ void FunctionsTest::refract() {
void FunctionsTest::refractNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Math::refract(Vector3{}, Vector3{1.0f}, 0.0f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::refract(): vectors Vector(0, 0, 0) and Vector(1, 1, 1) are not normalized\n");
}

15
src/Magnum/Math/Test/HalfTest.cpp

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <cstring>
#include <sstream>
#include <new>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Corrade/Utility/Tweakable.h>
#endif
@ -624,14 +623,14 @@ void HalfTest::literal() {
}
void HalfTest::debug() {
std::ostringstream out;
Containers::String out;
Debug{&out} << -36.41_h << Half{Constants::inf()}
<< Math::Vector3<Half>{3.14159_h, -1.4142_h, 1.618_h};
#ifdef CORRADE_TARGET_MSVC
CORRADE_COMPARE(out.str(), "-36.41 inf Vector(3.141, -1.414, 1.618)\n");
CORRADE_COMPARE(out, "-36.41 inf Vector(3.141, -1.414, 1.618)\n");
#else
CORRADE_COMPARE(out.str(), "-36.41 inf Vector(3.141, -1.414, 1.618)\n");
CORRADE_COMPARE(out, "-36.41 inf Vector(3.141, -1.414, 1.618)\n");
#endif
}
@ -648,11 +647,11 @@ void HalfTest::tweakableError() {
auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name);
std::ostringstream out;
Containers::String out;
Warning redirectWarning{&out};
Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Half>::parse(data.data).first();
CORRADE_COMPARE(out.str(), data.error);
CORRADE_COMPARE(out, data.error);
CORRADE_COMPARE(state, data.state);
}
#endif

7
src/Magnum/Math/Test/IntersectionTest.cpp

@ -26,9 +26,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Intersection.h"
@ -460,11 +459,11 @@ void IntersectionTest::sphereConeView() {
void IntersectionTest::sphereConeViewNotRigid() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_VERIFY(!Intersection::sphereConeView({}, 1.0f, Matrix4{ZeroInit}, {}));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Intersection::sphereConeView(): coneView does not represent a rigid transformation:\n"
"Matrix(0, 0, 0, 0,\n"
" 0, 0, 0, 0,\n"

36
src/Magnum/Math/Test/Matrix3Test.cpp

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Matrix3.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -483,11 +483,11 @@ void Matrix3Test::reflection() {
void Matrix3Test::reflectionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Matrix3::reflection({-1.0f, 2.0f});
CORRADE_COMPARE(out.str(), "Math::Matrix3::reflection(): normal Vector(-1, 2) is not normalized\n");
CORRADE_COMPARE(out, "Math::Matrix3::reflection(): normal Vector(-1, 2) is not normalized\n");
}
void Matrix3Test::reflectionIsScaling() {
@ -611,7 +611,7 @@ void Matrix3Test::rotationPart() {
void Matrix3Test::rotationPartNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* Test both non-orthogonality and "unnormalizable" scaling */
@ -619,7 +619,7 @@ void Matrix3Test::rotationPartNotOrthogonal() {
Matrix3::scaling(Vector2::yScale(0.0f)).rotation();
#ifdef CORRADE_TARGET_MSVC
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0.83205,\n"
" 0, 0.5547)\n"
@ -639,9 +639,9 @@ void Matrix3Test::rotationPartNotOrthogonal() {
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, nan,\n"
" 0, nan)\n";
if(out.str() == expectedPositive)
CORRADE_COMPARE(out.str(), expectedPositive);
else CORRADE_COMPARE(out.str(),
if(out == expectedPositive)
CORRADE_COMPARE(out, expectedPositive);
else CORRADE_COMPARE(out,
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0.83205,\n"
" 0, 0.5547)\n"
@ -663,7 +663,7 @@ void Matrix3Test::rotationNormalizedPart() {
void Matrix3Test::rotationNormalizedPartNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Matrix3 a({1.0f, 0.0f, 8.0f},
@ -671,7 +671,7 @@ void Matrix3Test::rotationNormalizedPartNotOrthogonal() {
{7.0f, -1.0f, 8.0f});
a.rotationNormalized();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Matrix3::rotationNormalized(): the rotation part is not orthogonal:\n"
"Matrix(1, 1,\n"
" 0, 0.1)\n");
@ -725,10 +725,10 @@ void Matrix3Test::uniformScalingPart() {
void Matrix3Test::uniformScalingPartNotUniform() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Matrix3::scaling(Vector2::yScale(3.0f)).uniformScaling();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Matrix3::uniformScaling(): the matrix doesn't have uniform scaling:\n"
"Matrix(1, 0,\n"
" 0, 3)\n");
@ -771,11 +771,11 @@ void Matrix3Test::invertedRigid() {
void Matrix3Test::invertedRigidNotRigid() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
(Matrix3::rotation(60.0_degf)*2.0f).invertedRigid();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Matrix3::invertedRigid(): the matrix doesn't represent a rigid transformation:\n"
"Matrix(1, -1.73205, 0,\n"
" 1.73205, 1, 0,\n"
@ -811,9 +811,9 @@ void Matrix3Test::debug() {
{4.0f, 4.0f, 7.0f},
{7.0f, -1.0f, 8.0f});
std::ostringstream o;
Debug(&o) << m;
CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7,\n"
Containers::String out;
Debug{&out} << m;
CORRADE_COMPARE(out, "Matrix(3, 4, 7,\n"
" 5, 4, -1,\n"
" 8, 7, 8)\n");
}

40
src/Magnum/Math/Test/Matrix4Test.cpp

@ -24,10 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Matrix4.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -552,11 +552,11 @@ void Matrix4Test::rotation() {
void Matrix4Test::rotationNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Matrix4::rotation(-74.0_degf, {-1.0f, 2.0f, 2.0f});
CORRADE_COMPARE(out.str(), "Math::Matrix4::rotation(): axis Vector(-1, 2, 2) is not normalized\n");
CORRADE_COMPARE(out, "Math::Matrix4::rotation(): axis Vector(-1, 2, 2) is not normalized\n");
}
void Matrix4Test::rotationX() {
@ -602,11 +602,11 @@ void Matrix4Test::reflection() {
void Matrix4Test::reflectionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Matrix4::reflection({-1.0f, 2.0f, 2.0f});
CORRADE_COMPARE(out.str(), "Math::Matrix4::reflection(): normal Vector(-1, 2, 2) is not normalized\n");
CORRADE_COMPARE(out, "Math::Matrix4::reflection(): normal Vector(-1, 2, 2) is not normalized\n");
}
void Matrix4Test::reflectionIsScaling() {
@ -864,7 +864,7 @@ void Matrix4Test::rotationPart() {
void Matrix4Test::rotationPartNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* Test both non-orthogonality and "unnormalizable" scaling */
@ -872,7 +872,7 @@ void Matrix4Test::rotationPartNotOrthogonal() {
Matrix4::scaling(Vector3::yScale(0.0f)).rotation();
#ifdef CORRADE_TARGET_MSVC
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0, 0.83205,\n"
" 0, 1, 0,\n"
@ -896,9 +896,9 @@ void Matrix4Test::rotationPartNotOrthogonal() {
"Matrix(1, nan, 0,\n"
" 0, nan, 0,\n"
" 0, nan, 1)\n";
if(out.str() == expectedPositive)
CORRADE_COMPARE(out.str(), expectedPositive);
else CORRADE_COMPARE(out.str(),
if(out == expectedPositive)
CORRADE_COMPARE(out, expectedPositive);
else CORRADE_COMPARE(out,
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0, 0.83205,\n"
" 0, 1, 0,\n"
@ -924,7 +924,7 @@ void Matrix4Test::rotationNormalizedPart() {
void Matrix4Test::rotationNormalizedPartNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Matrix4 a({0.0f, 0.0f, 1.0f, 4.0f},
@ -932,7 +932,7 @@ void Matrix4Test::rotationNormalizedPartNotOrthogonal() {
{0.0f, -1.0f, 0.1f, 0.0f},
{9.0f, 4.0f, 5.0f, 9.0f});
a.rotationNormalized();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Matrix4::rotationNormalized(): the rotation part is not orthogonal:\n"
"Matrix(0, 1, 0,\n"
" 0, 0, -1,\n"
@ -987,9 +987,9 @@ void Matrix4Test::uniformScalingPart() {
void Matrix4Test::uniformScalingPartNotUniform() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out}; Matrix4::scaling(Vector3::yScale(3.0f)).uniformScaling();
CORRADE_COMPARE(out.str(), "Math::Matrix4::uniformScaling(): the matrix doesn't have uniform scaling:\n"
CORRADE_COMPARE(out, "Math::Matrix4::uniformScaling(): the matrix doesn't have uniform scaling:\n"
"Matrix(1, 0, 0,\n"
" 0, 3, 0,\n"
" 0, 0, 1)\n");
@ -1176,11 +1176,11 @@ void Matrix4Test::invertedRigid() {
void Matrix4Test::invertedRigidNotRigid() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
(Matrix4::rotationX(-60.0_degf)*2.0f).invertedRigid();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Matrix4::invertedRigid(): the matrix doesn't represent a rigid transformation:\n"
"Matrix(2, 0, 0, 0,\n"
" 0, 1, 1.73205, 0,\n"
@ -1225,9 +1225,9 @@ void Matrix4Test::debug() {
{7.0f, -1.0f, 8.0f, 0.0f},
{9.0f, 4.0f, 5.0f, 9.0f});
std::ostringstream o;
Debug(&o) << m;
CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7, 9,\n"
Containers::String out;
Debug{&out} << m;
CORRADE_COMPARE(out, "Matrix(3, 4, 7, 9,\n"
" 5, 4, -1, 4,\n"
" 8, 7, 8, 5,\n"
" 4, 3, 0, 9)\n");

22
src/Magnum/Math/Test/MatrixTest.cpp

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Matrix.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -536,14 +536,14 @@ void MatrixTest::invertedOrthogonal() {
void MatrixTest::invertedOrthogonalNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream o;
Error redirectError{&o};
Containers::String out;
Error redirectError{&out};
Matrix3x3 a(Vector3(Constants::sqrt3()/2.0f, 0.5f, 0.0f),
Vector3(-0.5f, Constants::sqrt3()/2.0f, 0.0f),
Vector3(0.0f, 0.0f, 1.0f));
(a*2).invertedOrthogonal();
CORRADE_COMPARE(o.str(),
CORRADE_COMPARE(out,
"Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal:\n"
"Matrix(1.73205, -1, 0,\n"
" 1, 1.73205, 0,\n"
@ -631,16 +631,16 @@ void MatrixTest::debug() {
Vector4(7.0f, -1.0f, 8.0f, 0.0f),
Vector4(9.0f, 4.0f, 5.0f, 9.0f));
std::ostringstream o;
Debug(&o) << m;
CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7, 9,\n"
Containers::String out;
Debug{&out} << m;
CORRADE_COMPARE(out, "Matrix(3, 4, 7, 9,\n"
" 5, 4, -1, 4,\n"
" 8, 7, 8, 5,\n"
" 4, 3, 0, 9)\n");
o.str({});
Debug(&o) << "a" << Matrix4x4() << "b" << Matrix4x4();
CORRADE_COMPARE(o.str(), "a Matrix(1, 0, 0, 0,\n"
out = {};
Debug{&out} << "a" << Matrix4x4() << "b" << Matrix4x4();
CORRADE_COMPARE(out, "a Matrix(1, 0, 0, 0,\n"
" 0, 1, 0, 0,\n"
" 0, 0, 1, 0,\n"
" 0, 0, 0, 1) b Matrix(1, 0, 0, 0,\n"

15
src/Magnum/Math/Test/PackingBatchTest.cpp

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Packing.h"
@ -674,7 +673,7 @@ template<class T> void PackingBatchTest::assertionsPackUnpack() {
auto dstNotContiguous = Containers::arrayCast<2, Float>(
Containers::arrayView(resultNonContiguous)).every({1, 2});
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
unpackInto(src, dstWrongCount);
unpackInto(src, dstWrongVectorSize);
@ -684,7 +683,7 @@ template<class T> void PackingBatchTest::assertionsPackUnpack() {
packInto(dstWrongVectorSize, src);
packInto(dstNotContiguous, src);
packInto(dst, srcNonContiguous);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::unpackInto(): wrong destination size, got {1, 2} but expected {2, 2}\n"
"Math::unpackInto(): wrong destination size, got {2, 3} but expected {2, 2}\n"
"Math::unpackInto(): second destination view dimension is not contiguous\n"
@ -718,7 +717,7 @@ void PackingBatchTest::assertionsPackUnpackHalf() {
auto dstNotContiguous = Containers::arrayCast<2, Float>(
Containers::arrayView(resultNonContiguous)).every({1, 2});
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
unpackHalfInto(src, dstWrongCount);
unpackHalfInto(src, dstWrongVectorSize);
@ -728,7 +727,7 @@ void PackingBatchTest::assertionsPackUnpackHalf() {
packHalfInto(dstWrongVectorSize, src);
packHalfInto(dstNotContiguous, src);
packHalfInto(dst, srcNonContiguous);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::unpackHalfInto(): wrong destination size, got {1, 2} but expected {2, 2}\n"
"Math::unpackHalfInto(): wrong destination size, got {2, 3} but expected {2, 2}\n"
"Math::unpackHalfInto(): second destination view dimension is not contiguous\n"
@ -758,7 +757,7 @@ template<class U, class T> void PackingBatchTest::assertionsCast() {
auto dstNotContiguous = Containers::arrayCast<2, U>(
Containers::arrayView(resultNonContiguous)).every({1, 2});
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
castInto(src, dstWrongCount);
castInto(src, dstWrongVectorSize);
@ -766,7 +765,7 @@ template<class U, class T> void PackingBatchTest::assertionsCast() {
castInto(dstWrongCount, src);
castInto(dstWrongVectorSize, src);
castInto(dstNotContiguous, src);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::castInto(): wrong destination size, got {1, 2} but expected {2, 2}\n"
"Math::castInto(): wrong destination size, got {2, 3} but expected {2, 2}\n"
"Math::castInto(): second destination view dimension is not contiguous\n"

63
src/Magnum/Math/Test/QuaternionTest.cpp

@ -24,10 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Functions.h"
#include "Magnum/Math/Matrix4.h"
@ -395,13 +396,13 @@ void QuaternionTest::axisAngle() {
void QuaternionTest::axisAngleNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion a = Quaternion::rotation(23.0_degf, {0.6f, -0.8f, 0.0f})*2;
a.angle();
a.axis();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Quaternion::angle(): Quaternion({0.239242, -0.318989, 0}, 1.95985) is not normalized\n"
"Math::Quaternion::axis(): Quaternion({0.239242, -0.318989, 0}, 1.95985) is not normalized\n");
}
@ -498,11 +499,11 @@ void QuaternionTest::invertedNormalized() {
void QuaternionTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion{{1.0f, 3.0f, -2.0f}, -4.0f}.invertedNormalized();
CORRADE_COMPARE(out.str(), "Math::Quaternion::invertedNormalized(): Quaternion({1, 3, -2}, -4) is not normalized\n");
CORRADE_COMPARE(out, "Math::Quaternion::invertedNormalized(): Quaternion({1, 3, -2}, -4) is not normalized\n");
}
void QuaternionTest::rotation() {
@ -528,11 +529,11 @@ void QuaternionTest::rotation() {
void QuaternionTest::rotationNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion::rotation(-74.0_degf, {-1.0f, 2.0f, 2.0f});
CORRADE_COMPARE(out.str(), "Math::Quaternion::rotation(): axis Vector(-1, 2, 2) is not normalized\n");
CORRADE_COMPARE(out, "Math::Quaternion::rotation(): axis Vector(-1, 2, 2) is not normalized\n");
}
void QuaternionTest::rotationFromTwoVectors() {
@ -599,12 +600,12 @@ void QuaternionTest::rotationFromTwoVectors() {
void QuaternionTest::rotationFromTwoVectorsNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion::rotation({2.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f});
Quaternion::rotation({1.0f, 0.0f, 0.0f}, {0.0f, 2.0f, 0.0f});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Quaternion::rotation(): vectors Vector(2, 0, 0) and Vector(0, 1, 0) are not normalized\n"
"Math::Quaternion::rotation(): vectors Vector(1, 0, 0) and Vector(0, 2, 0) are not normalized\n");
}
@ -619,10 +620,10 @@ void QuaternionTest::reflection() {
void QuaternionTest::reflectionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion::reflection({-1.0f, 2.0f, 2.0f});
CORRADE_COMPARE(out.str(), "Math::Quaternion::reflection(): normal Vector(-1, 2, 2) is not normalized\n");
CORRADE_COMPARE(out, "Math::Quaternion::reflection(): normal Vector(-1, 2, 2) is not normalized\n");
}
void QuaternionTest::angle() {
@ -666,13 +667,13 @@ void QuaternionTest::angleNormalizedButOver1() {
void QuaternionTest::angleNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Math::halfAngle(Quaternion{{1.0f, 2.0f, -3.0f}, -4.0f}.normalized(), {{4.0f, -3.0f, 2.0f}, -1.0f});
Math::halfAngle({{1.0f, 2.0f, -3.0f}, -4.0f}, Quaternion{{4.0f, -3.0f, 2.0f}, -1.0f}.normalized());
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::halfAngle(): quaternions Quaternion({0.182574, 0.365148, -0.547723}, -0.730297) and Quaternion({4, -3, 2}, -1) are not normalized\n"
"Math::halfAngle(): quaternions Quaternion({1, 2, -3}, -4) and Quaternion({0.730297, -0.547723, 0.365148}, -0.182574) are not normalized\n");
}
@ -729,7 +730,7 @@ void QuaternionTest::matrix() {
void QuaternionTest::matrixNotRotation() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* Shear, using rotationShear() instead of rotationScaling() as that isn't
supposed to "fix" the shear */
@ -739,7 +740,7 @@ void QuaternionTest::matrixNotRotation() {
supposed to "fix" the reflection either */
Quaternion::fromMatrix((Matrix4::scaling({-1.0f, 1.0f, 1.0f})*
Matrix4::rotationZ(45.0_degf)).rotation());
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Quaternion::fromMatrix(): the matrix is not a rotation:\n"
"Matrix(0.894427, -0.894427, 0,\n"
" 0.447214, 0.447214, 0,\n"
@ -773,11 +774,11 @@ void QuaternionTest::euler() {
void QuaternionTest::eulerNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion{{1.0f, 3.0f, -2.0f}, -4.0f}.toEuler();
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::Quaternion::toEuler(): Quaternion({1, 3, -2}, -4) is not normalized\n");
}
@ -810,13 +811,13 @@ void QuaternionTest::lerp2D() {
void QuaternionTest::lerpNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion a;
Math::lerp(a*3.0f, a, 0.35f);
Math::lerp(a, a*-3.0f, 0.35f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::lerp(): quaternions Quaternion({0, 0, 0}, 3) and Quaternion({0, 0, 0}, 1) are not normalized\n"
"Math::lerp(): quaternions Quaternion({0, 0, 0}, 1) and Quaternion({-0, -0, -0}, -3) are not normalized\n");
}
@ -842,14 +843,14 @@ void QuaternionTest::lerpShortestPath() {
void QuaternionTest::lerpShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion a;
Math::lerpShortestPath(a*3.0f, a, 0.35f);
Math::lerpShortestPath(a, a*-3.0f, 0.35f);
/* lerpShortestPath() is calling lerp(), so the message is from there */
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::lerp(): quaternions Quaternion({0, 0, 0}, 3) and Quaternion({0, 0, 0}, 1) are not normalized\n"
"Math::lerp(): quaternions Quaternion({-0, -0, -0}, -1) and Quaternion({-0, -0, -0}, -3) are not normalized\n");
}
@ -927,13 +928,13 @@ void QuaternionTest::slerpNormalizedButOver1() {
void QuaternionTest::slerpNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion a;
Math::slerp(a*3.0f, a, 0.35f);
Math::slerp(a, a*-3.0f, 0.35f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::slerp(): quaternions Quaternion({0, 0, 0}, 3) and Quaternion({0, 0, 0}, 1) are not normalized\n"
"Math::slerp(): quaternions Quaternion({0, 0, 0}, 1) and Quaternion({-0, -0, -0}, -3) are not normalized\n");
}
@ -988,13 +989,13 @@ template<class T> void QuaternionTest::slerpShortestPathLinearFallbackIsNormaliz
void QuaternionTest::slerpShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion a;
Math::slerpShortestPath(a*3.0f, a, 0.35f);
Math::slerpShortestPath(a, a*-3.0f, 0.35f);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::slerpShortestPath(): quaternions Quaternion({0, 0, 0}, 3) and Quaternion({0, 0, 0}, 1) are not normalized\n"
"Math::slerpShortestPath(): quaternions Quaternion({0, 0, 0}, 1) and Quaternion({-0, -0, -0}, -3) are not normalized\n");
}
@ -1022,12 +1023,12 @@ void QuaternionTest::transformVectorNormalized() {
void QuaternionTest::transformVectorNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Quaternion a = Quaternion::rotation(23.0_degf, Vector3::xAxis());
(a*2).transformVectorNormalized({});
CORRADE_COMPARE(out.str(), "Math::Quaternion::transformVectorNormalized(): Quaternion({0.398736, 0, 0}, 1.95985) is not normalized\n");
CORRADE_COMPARE(out, "Math::Quaternion::transformVectorNormalized(): Quaternion({0.398736, 0, 0}, 1.95985) is not normalized\n");
}
void QuaternionTest::reflectVector() {
@ -1066,10 +1067,10 @@ void QuaternionTest::strictWeakOrdering() {
}
void QuaternionTest::debug() {
std::ostringstream o;
Containers::String out;
Debug(&o) << Quaternion({1.0f, 2.0f, 3.0f}, -4.0f);
CORRADE_COMPARE(o.str(), "Quaternion({1, 2, 3}, -4)\n");
Debug{&out} << Quaternion({1.0f, 2.0f, 3.0f}, -4.0f);
CORRADE_COMPARE(out, "Quaternion({1, 2, 3}, -4)\n");
}
}}}}

14
src/Magnum/Math/Test/RangeTest.cpp

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/FunctionsBatch.h"
#include "Magnum/Math/Range.h"
@ -1009,17 +1009,17 @@ void RangeTest::subclass() {
}
void RangeTest::debug() {
std::ostringstream o;
Debug(&o) << Range2Di({34, 23}, {47, 30});
Containers::String out;
Debug{&out} << Range2Di({34, 23}, {47, 30});
CORRADE_COMPARE(o.str(), "Range({34, 23}, {47, 30})\n");
CORRADE_COMPARE(out, "Range({34, 23}, {47, 30})\n");
}
void RangeTest::debugPacked() {
std::ostringstream out;
Containers::String out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << Range2Di{{34, 23}, {47, 30}} << Range2Di{};
CORRADE_COMPARE(out.str(), "{{34, 23}, {47, 30}} Range({0, 0}, {0, 0})\n");
CORRADE_COMPARE(out, "{{34, 23}, {47, 30}} Range({0, 0}, {0, 0})\n");
}
}}}}

21
src/Magnum/Math/Test/RectangularMatrixTest.cpp

@ -24,9 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/RectangularMatrix.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -988,16 +989,16 @@ void RectangularMatrixTest::debug() {
Vector4(4.0f, 4.0f, 7.0f, 3.0f),
Vector4(7.0f, -1.0f, 8.0f, 0.0f));
std::ostringstream o;
Debug(&o) << m;
CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7,\n"
Containers::String out;
Debug{&out} << m;
CORRADE_COMPARE(out, "Matrix(3, 4, 7,\n"
" 5, 4, -1,\n"
" 8, 7, 8,\n"
" 4, 3, 0)\n");
o.str({});
Debug(&o) << "a" << Matrix3x4() << "b" << RectangularMatrix<4, 3, Byte>();
CORRADE_COMPARE(o.str(), "a Matrix(0, 0, 0,\n"
out = {};
Debug{&out} << "a" << Matrix3x4() << "b" << RectangularMatrix<4, 3, Byte>();
CORRADE_COMPARE(out, "a Matrix(0, 0, 0,\n"
" 0, 0, 0,\n"
" 0, 0, 0,\n"
" 0, 0, 0) b Matrix(0, 0, 0, 0,\n"
@ -1010,10 +1011,10 @@ void RectangularMatrixTest::debugPacked() {
Vector4(4.0f, 4.0f, 7.0f, 3.0f),
Vector4(7.0f, -1.0f, 8.0f, 0.0f));
std::ostringstream out;
Containers::String out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << m << Matrix2x2{};
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"{3, 4, 7,\n"
" 5, 4, -1,\n"
" 8, 7, 8,\n"

19
src/Magnum/Math/Test/TimeTest.cpp

@ -25,9 +25,8 @@
*/
#include <new>
#include <sstream> /** @todo remove once Debug is STL-free */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is STL-free */
#include "Magnum/Math/Time.h"
@ -405,37 +404,37 @@ void TimeTest::nanosecondFloatScaling() {
}
void TimeTest::debugNanoseconds() {
std::ostringstream out;
Containers::String out;
/* Also verify that the second expression compiles (it's the Unit type,
not Nanoseconds) */
Debug{&out} << 987654321987654321_nsec << 15.0_sec - 7.5_sec;
CORRADE_COMPARE(out.str(), "Nanoseconds(987654321987654321) Nanoseconds(7500000000)\n");
CORRADE_COMPARE(out, "Nanoseconds(987654321987654321) Nanoseconds(7500000000)\n");
}
void TimeTest::debugNanosecondsPacked() {
std::ostringstream out;
Containers::String out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << 15.0_sec << 45.0_sec;
CORRADE_COMPARE(out.str(), "15000000000 Nanoseconds(45000000000)\n");
CORRADE_COMPARE(out, "15000000000 Nanoseconds(45000000000)\n");
}
void TimeTest::debugSeconds() {
std::ostringstream out;
Containers::String out;
/* Also verify that the second expression compiles (it's the Unit type,
not Nanoseconds) */
Debug{&out} << Seconds{123.45_sec} << Seconds{15.0_sec} - Seconds{7.5_sec};
CORRADE_COMPARE(out.str(), "Seconds(123.45) Seconds(7.5)\n");
CORRADE_COMPARE(out, "Seconds(123.45) Seconds(7.5)\n");
}
void TimeTest::debugSecondsPacked() {
std::ostringstream out;
Containers::String out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << Seconds{123.45_sec} << Seconds{45.0_sec};
CORRADE_COMPARE(out.str(), "123.45 Seconds(45)\n");
CORRADE_COMPARE(out, "123.45 Seconds(45)\n");
}
}}}}

10
src/Magnum/Math/Test/Vector2Test.cpp

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector3.h" /* Vector3 used in Vector2Test::cross() */
#include "Magnum/Math/StrictWeakOrdering.h"
@ -363,9 +363,9 @@ void Vector2Test::swizzleType() {
}
void Vector2Test::debug() {
std::ostringstream o;
Debug(&o) << Vector2(0.5f, 15.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 15)\n");
Containers::String out;
Debug{&out} << Vector2(0.5f, 15.0f);
CORRADE_COMPARE(out, "Vector(0.5, 15)\n");
}
}}}}

10
src/Magnum/Math/Test/Vector3Test.cpp

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector3.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -388,9 +388,9 @@ void Vector3Test::swizzleType() {
}
void Vector3Test::debug() {
std::ostringstream o;
Debug(&o) << Vector3(0.5f, 15.0f, 1.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1)\n");
Containers::String out;
Debug{&out} << Vector3(0.5f, 15.0f, 1.0f);
CORRADE_COMPARE(out, "Vector(0.5, 15, 1)\n");
}
}}}}

10
src/Magnum/Math/Test/Vector4Test.cpp

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector4.h"
#include "Magnum/Math/StrictWeakOrdering.h"
@ -430,9 +430,9 @@ void Vector4Test::swizzleType() {
}
void Vector4Test::debug() {
std::ostringstream o;
Debug(&o) << Vector4(0.5f, 15.0f, 1.0f, 1.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n");
Containers::String out;
Debug{&out} << Vector4(0.5f, 15.0f, 1.0f, 1.0f);
CORRADE_COMPARE(out, "Vector(0.5, 15, 1, 1)\n");
}
}}}}

33
src/Magnum/Math/Test/VectorTest.cpp

@ -24,10 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <new>
#include <Corrade/Containers/ArrayView.h> /* arraySize() */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Half.h"
#include "Magnum/Math/Vector.h"
@ -839,10 +840,10 @@ void VectorTest::projectedOntoNormalizedNotNormalized() {
Vector3 vector(1.0f, 2.0f, 3.0f);
Vector3 line(1.0f, -1.0f, 0.5f);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
vector.projectedOntoNormalized(line);
CORRADE_COMPARE(out.str(), "Math::Vector::projectedOntoNormalized(): line Vector(1, -1, 0.5) is not normalized\n");
CORRADE_COMPARE(out, "Math::Vector::projectedOntoNormalized(): line Vector(1, -1, 0.5) is not normalized\n");
}
void VectorTest::flipped() {
@ -881,12 +882,12 @@ void VectorTest::angleNormalizedButOver1() {
void VectorTest::angleNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Math::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), {1.0f, -2.0f, 3.0f});
Math::angle({2.0f, 3.0f, 4.0f}, Vector3(1.0f, -2.0f, 3.0f).normalized());
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Math::angle(): vectors Vector(0.371391, 0.557086, 0.742781) and Vector(1, -2, 3) are not normalized\n"
"Math::angle(): vectors Vector(2, 3, 4) and Vector(0.267261, -0.534522, 0.801784) are not normalized\n");
}
@ -1382,28 +1383,28 @@ void VectorTest::strictWeakOrdering() {
}
void VectorTest::debug() {
std::ostringstream o;
Debug(&o) << Vector4(0.5f, 15.0f, 1.0f, 1.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n");
Containers::String out;
Debug{&out} << Vector4(0.5f, 15.0f, 1.0f, 1.0f);
CORRADE_COMPARE(out, "Vector(0.5, 15, 1, 1)\n");
o.str({});
Debug(&o) << "a" << Vector4() << "b" << Vector4();
CORRADE_COMPARE(o.str(), "a Vector(0, 0, 0, 0) b Vector(0, 0, 0, 0)\n");
out = {};
Debug{&out} << "a" << Vector4() << "b" << Vector4();
CORRADE_COMPARE(out, "a Vector(0, 0, 0, 0) b Vector(0, 0, 0, 0)\n");
}
void VectorTest::debugPacked() {
std::ostringstream out;
Containers::String out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << Vector4(0.5f, 15.0f, 1.0f, 1.0f) << Vector4();
CORRADE_COMPARE(out.str(), "{0.5, 15, 1, 1} Vector(0, 0, 0, 0)\n");
CORRADE_COMPARE(out, "{0.5, 15, 1, 1} Vector(0, 0, 0, 0)\n");
}
void VectorTest::debugPropagateFlags() {
std::ostringstream out;
Containers::String out;
/* The modifier shouldn't become persistent for values after. The nospace
modifier shouldn't get propagated. */
Debug{&out} << ">" << Debug::nospace << Debug::hex << Vector2i(0xab, 0xcd) << Vector2i(12, 13);
CORRADE_COMPARE(out.str(), ">Vector(0xab, 0xcd) Vector(12, 13)\n");
CORRADE_COMPARE(out, ">Vector(0xab, 0xcd) Vector(12, 13)\n");
}
}}}}

9
src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp

@ -25,9 +25,8 @@
*/
#include <functional>
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#define _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS
@ -54,13 +53,13 @@ CORRADE_IGNORE_DEPRECATED_PUSH
void CombineIndexedArraysTest::wrongIndexCount() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream ss;
Error redirectError{&ss};
Containers::String out;
Error redirectError{&out};
std::vector<UnsignedInt> a{0, 1, 0};
std::vector<UnsignedInt> b{3, 4};
std::vector<UnsignedInt> result = combineIndexArrays({a, b});
CORRADE_COMPARE(ss.str(), "MeshTools::combineIndexArrays(): the arrays don't have the same size\n");
CORRADE_COMPARE(out, "MeshTools::combineIndexArrays(): the arrays don't have the same size\n");
}
void CombineIndexedArraysTest::indexArrays() {

55
src/Magnum/MeshTools/Test/CombineTest.cpp

@ -24,12 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h"
#include "Magnum/MeshTools/Combine.h"
@ -191,10 +190,10 @@ void CombineTest::indexedAttributesSingleMesh() {
void CombineTest::indexedAttributesNoMeshes() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineIndexedAttributes({});
CORRADE_COMPARE(out.str(), "MeshTools::combineIndexedAttributes(): no meshes passed\n");
CORRADE_COMPARE(out, "MeshTools::combineIndexedAttributes(): no meshes passed\n");
}
void CombineTest::indexedAttributesNotIndexed() {
@ -207,10 +206,10 @@ void CombineTest::indexedAttributesNotIndexed() {
{}, indices, Trade::MeshIndexData{indices}, 1};
Trade::MeshData c{MeshPrimitive::Lines, 1};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineIndexedAttributes({a, b, c});
CORRADE_COMPARE(out.str(), "MeshTools::combineIndexedAttributes(): data 2 is not indexed\n");
CORRADE_COMPARE(out, "MeshTools::combineIndexedAttributes(): data 2 is not indexed\n");
}
void CombineTest::indexedAttributesDifferentPrimitive() {
@ -222,10 +221,10 @@ void CombineTest::indexedAttributesDifferentPrimitive() {
Trade::MeshData b{MeshPrimitive::Points,
{}, indices, Trade::MeshIndexData{indices}, 1};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineIndexedAttributes({a, b});
CORRADE_COMPARE(out.str(), "MeshTools::combineIndexedAttributes(): data 1 is MeshPrimitive::Points but expected MeshPrimitive::Lines\n");
CORRADE_COMPARE(out, "MeshTools::combineIndexedAttributes(): data 1 is MeshPrimitive::Points but expected MeshPrimitive::Lines\n");
}
void CombineTest::indexedAttributesDifferentIndexCount() {
@ -240,10 +239,10 @@ void CombineTest::indexedAttributesDifferentIndexCount() {
{}, indices,
Trade::MeshIndexData{Containers::arrayView(indices).prefix(4)}, 1};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineIndexedAttributes({a, b, c});
CORRADE_COMPARE(out.str(), "MeshTools::combineIndexedAttributes(): data 2 has 4 indices but expected 5\n");
CORRADE_COMPARE(out, "MeshTools::combineIndexedAttributes(): data 2 has 4 indices but expected 5\n");
}
void CombineTest::indexedAttributesImplementationSpecificIndexType() {
@ -260,10 +259,10 @@ void CombineTest::indexedAttributesImplementationSpecificIndexType() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineIndexedAttributes({a, b});
CORRADE_COMPARE(out.str(), "MeshTools::combineIndexedAttributes(): data 1 has an implementation-specific index type 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::combineIndexedAttributes(): data 1 has an implementation-specific index type 0xcaca\n");
}
void CombineTest::indexedAttributesImplementationSpecificVertexFormat() {
@ -283,10 +282,10 @@ void CombineTest::indexedAttributesImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::meshAttributeCustom(3), vertexFormatWrap(0xcaca), nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineIndexedAttributes({a, b});
CORRADE_COMPARE(out.str(), "MeshTools::combineIndexedAttributes(): attribute 2 of mesh 1 has an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::combineIndexedAttributes(): attribute 2 of mesh 1 has an implementation-specific format 0xcaca\n");
}
void CombineTest::faceAttributes() {
@ -416,10 +415,10 @@ void CombineTest::faceAttributesMeshNotIndexed() {
const Trade::MeshData mesh{MeshPrimitive::Triangles, 3};
const Trade::MeshData faceAttributes{MeshPrimitive::Faces, 0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFaceAttributes(mesh, faceAttributes);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::combineFaceAttributes(): vertex mesh is not indexed\n");
}
@ -434,11 +433,11 @@ void CombineTest::faceAttributesUnexpectedPrimitive() {
const Trade::MeshData faceA{MeshPrimitive::Instances, 0};
const Trade::MeshData faceB{MeshPrimitive::Faces, 0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFaceAttributes(a, faceA);
combineFaceAttributes(b, faceB);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::combineFaceAttributes(): expected a MeshPrimitive::Triangles mesh and a MeshPrimitive::Faces mesh but got MeshPrimitive::Triangles and MeshPrimitive::Instances\n"
"MeshTools::combineFaceAttributes(): expected a MeshPrimitive::Triangles mesh and a MeshPrimitive::Faces mesh but got MeshPrimitive::Lines and MeshPrimitive::Faces\n");
}
@ -451,10 +450,10 @@ void CombineTest::faceAttributesUnexpectedFaceCount() {
{}, indices, Trade::MeshIndexData{indices}, 1};
const Trade::MeshData faceAttributes{MeshPrimitive::Faces, 2};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFaceAttributes(mesh, faceAttributes);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::combineFaceAttributes(): expected 1 face entries for 3 indices but got 2\n");
}
@ -483,11 +482,11 @@ void CombineTest::faceAttributesImplementationSpecificIndexType() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFaceAttributes(triangles, facesImplementationSpecific);
combineFaceAttributes(trianglesImplementationSpecific, faces);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::combineFaceAttributes(): face mesh has an implementation-specific index type 0xcaca\n"
"MeshTools::combineFaceAttributes(): vertex mesh has an implementation-specific index type 0xcaca\n");
}
@ -523,11 +522,11 @@ void CombineTest::faceAttributesImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Tangent, vertexFormatWrap(0xcaca), nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFaceAttributes(triangles, facesImplementationSpecific);
combineFaceAttributes(trianglesImplementationSpecific, faces);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::combineFaceAttributes(): attribute 2 of mesh 1 has an implementation-specific format 0xcaca\n"
"MeshTools::combineFaceAttributes(): attribute 2 of mesh 0 has an implementation-specific format 0xcaca\n");
}
@ -555,17 +554,17 @@ void CombineTest::faceAttributesFacesNotInterleaved() {
Containers::arrayView(faceData[0].id)}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFaceAttributes(mesh, faceAttributes);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::combineFaceAttributes(): face attributes are not interleaved\n");
}
void CombineTest::faceAttributesFaceAttributeOffsetOnly() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFaceAttributes(Trade::MeshData{MeshPrimitive::Triangles, 0}, {
Trade::MeshAttributeData{Trade::MeshAttribute::ObjectId,
@ -573,7 +572,7 @@ void CombineTest::faceAttributesFaceAttributeOffsetOnly() {
Trade::MeshAttributeData{Trade::MeshAttribute::Color,
VertexFormat::Vector4, 0, 5, 16}
});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::combineFaceAttributes(): face attribute 1 is offset-only\n");
}

52
src/Magnum/MeshTools/Test/CompileGLTest.cpp

@ -25,15 +25,13 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Path.h>
#include "Magnum/Image.h"
@ -1355,12 +1353,12 @@ void CompileGLTest::skinning() {
CORRADE_COMPARE(jointCount.second(), data.expectedSecondaryJointCount);
GL::Mesh mesh{NoCreate};
std::ostringstream out;
Containers::String out;
{
Warning redirectWarning{&out};
mesh = compile(meshData);
}
CORRADE_COMPARE(out.str(), data.expectedMessage);
CORRADE_COMPARE(out, data.expectedMessage);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -1499,13 +1497,13 @@ void CompileGLTest::conflictingAttributes() {
GL::Mesh mesh{NoCreate};
std::ostringstream out;
Containers::String out;
{
Warning redirectWarning{&out};
mesh = compile(meshData);
}
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(out.str(), Utility::formatString("MeshTools::compile(): {}\n", data.expectedMessage));
CORRADE_COMPARE(out, Utility::format("MeshTools::compile(): {}\n", data.expectedMessage));
if(!(_manager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) ||
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
@ -1562,10 +1560,10 @@ void CompileGLTest::unsupportedIndexStride() {
{}, indices, Trade::MeshIndexData{Containers::stridedArrayView(indices).every(2)},
1};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compile(data);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compile(): MeshIndexType::UnsignedShort with stride of 4 bytes isn't supported by OpenGL\n");
}
@ -1583,13 +1581,13 @@ void CompileGLTest::morphTargetAttributes() {
Containers::arrayView(vertexData), 26},
}};
std::ostringstream out;
Containers::String out;
Warning redirectError{&out};
if(instanceData.flags)
compile(data, instanceData.flags);
else
compile(data);
CORRADE_COMPARE(out.str(), instanceData.flags ? "" :
CORRADE_COMPARE(out, instanceData.flags ? "" :
"MeshTools::compile(): ignoring 2 morph target attributes\n");
}
@ -1602,13 +1600,13 @@ void CompileGLTest::customAttribute() {
VertexFormat::Short, nullptr}
}};
std::ostringstream out;
Containers::String out;
Warning redirectError{&out};
if(instanceData.flags)
compile(data, instanceData.flags);
else
compile(data);
CORRADE_COMPARE(out.str(), instanceData.flags ? "" :
CORRADE_COMPARE(out, instanceData.flags ? "" :
"MeshTools::compile(): ignoring unknown/unsupported attribute Trade::MeshAttribute::Custom(115)\n");
}
@ -1624,14 +1622,14 @@ void CompileGLTest::unsupportedAttribute() {
VertexFormat::UnsignedByte, nullptr}
}};
std::ostringstream out;
Containers::String out;
Warning redirectError{&out};
if(instanceData.flags)
compile(data, instanceData.flags);
else
compile(data);
/* Warns always, regardless of the flag */
CORRADE_COMPARE(out.str(), "MeshTools::compile(): ignoring unknown/unsupported attribute Trade::MeshAttribute::ObjectId\n");
CORRADE_COMPARE(out, "MeshTools::compile(): ignoring unknown/unsupported attribute Trade::MeshAttribute::ObjectId\n");
#endif
}
@ -1648,11 +1646,11 @@ void CompileGLTest::unsupportedAttributeStride() {
Containers::stridedArrayView(data).flipped<0>()}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compile(zero);
compile(negative);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compile(): Trade::MeshAttribute::Position stride of 0 bytes isn't supported by OpenGL\n"
"MeshTools::compile(): Trade::MeshAttribute::Normal stride of -12 bytes isn't supported by OpenGL\n");
}
@ -1666,13 +1664,13 @@ void CompileGLTest::implementationSpecificAttributeFormat() {
vertexFormatWrap(0xdead), nullptr}
}};
std::ostringstream out;
Containers::String out;
Warning redirectError{&out};
if(instanceData.flags)
compile(data, instanceData.flags);
else
compile(data);
CORRADE_COMPARE(out.str(), instanceData.flags ? "" :
CORRADE_COMPARE(out, instanceData.flags ? "" :
"MeshTools::compile(): ignoring attribute Trade::MeshAttribute::Position with an implementation-specific format 0xdead\n");
}
@ -1681,10 +1679,10 @@ void CompileGLTest::generateNormalsNoPosition() {
Trade::MeshData data{MeshPrimitive::Triangles, 1};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compile(data, CompileFlag::GenerateFlatNormals);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compile(): the mesh has no positions, can't generate normals\n");
}
@ -1696,10 +1694,10 @@ void CompileGLTest::generateNormals2DPosition() {
VertexFormat::Vector2, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compile(data, CompileFlag::GenerateFlatNormals);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compile(): can't generate normals for VertexFormat::Vector2 positions\n");
}
@ -1713,10 +1711,10 @@ void CompileGLTest::generateNormalsNoFloats() {
VertexFormat::Vector3h, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compile(data, CompileFlag::GenerateFlatNormals);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compile(): can't generate normals into VertexFormat::Vector3h\n");
}
@ -1815,11 +1813,11 @@ void CompileGLTest::externalBuffersInvalid() {
compile(data, GL::Buffer{NoCreate}, GL::Buffer{}); /* this is okay */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compile(data, GL::Buffer{NoCreate}, GL::Buffer{NoCreate});
compile(indexedData, GL::Buffer{NoCreate}, GL::Buffer{});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compile(): invalid external buffer(s)\n"
"MeshTools::compile(): invalid external buffer(s)\n");
}

10
src/Magnum/MeshTools/Test/CompileLinesGLTest.cpp

@ -24,12 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h>
#include "Magnum/Image.h"
@ -301,7 +299,7 @@ void CompileLinesGLTest::conflictingAttributes() {
Trade::MeshAttributeData{data.attribute, data.format, vertices.slice(&Vertex::extra)},
}});
std::ostringstream out;
Containers::String out;
GL::Mesh mesh{NoCreate};
{
Warning redirectWarning{&out};
@ -319,7 +317,7 @@ void CompileLinesGLTest::conflictingAttributes() {
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileLinesTestFiles/miter.tga"),
(DebugTools::CompareImageToFile{_manager}));
CORRADE_COMPARE(out.str(), data.expected);
CORRADE_COMPARE(out, data.expected);
}
void CompileLinesGLTest::emptyMesh() {
@ -337,7 +335,7 @@ void CompileLinesGLTest::notGeneratedLineMesh() {
Vector3 positions[3]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compileLines(Trade::MeshData{MeshPrimitive::Lines, {}, positions, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::stridedArrayView(positions)}
@ -345,7 +343,7 @@ void CompileLinesGLTest::notGeneratedLineMesh() {
compileLines(Trade::MeshData{MeshPrimitive::Triangles, {}, positions, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::stridedArrayView(positions)}
}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compileLines(): the mesh wasn't produced with generateLines()\n"
"MeshTools::compileLines(): the mesh wasn't produced with generateLines()\n");
}

28
src/Magnum/MeshTools/Test/CompressIndicesTest.cpp

@ -24,13 +24,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Endianness.h>
#include "Magnum/Math/Vector3.h"
@ -38,6 +37,7 @@
#include "Magnum/Trade/MeshData.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <tuple>
#include <vector>
#endif
@ -218,10 +218,10 @@ void CompressIndicesTest::compressErasedNonContiguous() {
const char indices[6*4]{};
std::stringstream out;
Containers::String out;
Error redirectError{&out};
compressIndices(Containers::StridedArrayView2D<const char>{indices, {6, 2}, {4, 2}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compressIndices(): second view dimension is not contiguous\n");
}
@ -230,10 +230,10 @@ void CompressIndicesTest::compressErasedWrongIndexSize() {
const char indices[6*3]{};
std::stringstream out;
Containers::String out;
Error redirectError{&out};
compressIndices(Containers::StridedArrayView2D<const char>{indices, {6, 3}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compressIndices(): expected index type size 1, 2 or 4 but got 3\n");
}
@ -346,11 +346,11 @@ void CompressIndicesTest::compressMeshDataNonIndexed() {
Trade::MeshData mesh{MeshPrimitive::TriangleFan, 5};
/* Test both r-value and l-value overload */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compressIndices(mesh);
compressIndices(Utility::move(mesh));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compressIndices(): mesh data not indexed\n"
"MeshTools::compressIndices(): mesh data not indexed\n");
}
@ -362,11 +362,11 @@ void CompressIndicesTest::compressMeshDataImplementationSpecificIndexType() {
nullptr, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::StridedArrayView1D<const void>{}}, 1};
/* Test both r-value and l-value overload */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compressIndices(mesh);
compressIndices(Utility::move(mesh));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compressIndices(): mesh has an implementation-specific index type 0xcaca\n"
"MeshTools::compressIndices(): mesh has an implementation-specific index type 0xcaca\n");
}
@ -378,10 +378,10 @@ void CompressIndicesTest::compressMeshDataImplementationSpecificAtLeastIndexType
Trade::MeshData mesh{MeshPrimitive::Points,
{}, indices, Trade::MeshIndexData{indices}, 1};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compressIndices(mesh, meshIndexTypeWrap(0xcaca));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::compressIndices(): can't compress to an implementation-specific index type 0xcaca\n");
}
@ -394,10 +394,10 @@ void CompressIndicesTest::compressAsShort() {
Containers::arrayView<UnsignedShort>({123, 456}),
TestSuite::Compare::Container);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
compressIndicesAs<UnsignedShort>({65536});
CORRADE_COMPARE(out.str(), "MeshTools::compressIndicesAs(): type too small to represent value 65536\n");
CORRADE_COMPARE(out, "MeshTools::compressIndicesAs(): type too small to represent value 65536\n");
CORRADE_IGNORE_DEPRECATED_POP
}
#endif

40
src/Magnum/MeshTools/Test/ConcatenateTest.cpp

@ -24,13 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove when Debug is stream-free */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h"
#include "Magnum/MeshTools/Concatenate.h"
@ -462,10 +460,10 @@ void ConcatenateTest::concatenateOne() {
void ConcatenateTest::concatenateNone() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenate({});
CORRADE_COMPARE(out.str(), "MeshTools::concatenate(): expected at least one mesh\n");
CORRADE_COMPARE(out, "MeshTools::concatenate(): expected at least one mesh\n");
}
void ConcatenateTest::concatenateInto() {
@ -641,11 +639,11 @@ void ConcatenateTest::concatenateUnsupportedPrimitive() {
Trade::MeshData a{MeshPrimitive::TriangleStrip, 0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenate({a});
MeshTools::concatenateInto(a, {a});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::concatenate(): MeshPrimitive::TriangleStrip is not supported, turn it into a plain indexed mesh first\n"
"MeshTools::concatenateInto(): MeshPrimitive::TriangleStrip is not supported, turn it into a plain indexed mesh first\n");
}
@ -657,11 +655,11 @@ void ConcatenateTest::concatenateInconsistentPrimitive() {
Trade::MeshData a{MeshPrimitive::Triangles, 0};
Trade::MeshData b{MeshPrimitive::Lines, 0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenate({a, a, b});
MeshTools::concatenateInto(a, {a, b});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::concatenate(): expected MeshPrimitive::Triangles but got MeshPrimitive::Lines in mesh 2\n"
"MeshTools::concatenateInto(): expected MeshPrimitive::Triangles but got MeshPrimitive::Lines in mesh 1\n");
}
@ -685,11 +683,11 @@ void ConcatenateTest::concatenateInconsistentAttributeFormat() {
VertexFormat::Vector3usNormalized, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenate({a, a, a, a, b});
MeshTools::concatenateInto(a, {a, a, a, b});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::concatenate(): expected VertexFormat::Vector3ubNormalized for attribute 2 (Trade::MeshAttribute::Color) but got VertexFormat::Vector3usNormalized in mesh 4 attribute 1\n"
"MeshTools::concatenateInto(): expected VertexFormat::Vector3ubNormalized for attribute 2 (Trade::MeshAttribute::Color) but got VertexFormat::Vector3usNormalized in mesh 3 attribute 1\n");
}
@ -723,13 +721,13 @@ void ConcatenateTest::concatenateInconsistentArrayAttribute() {
VertexFormat::ByteNormalized, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenate({a, a, a, a, b});
MeshTools::concatenate({b, b, b, b, a});
MeshTools::concatenateInto(a2, {a, a, a, b});
MeshTools::concatenateInto(b, {b, b, b, a});
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"MeshTools::concatenate(): attribute 2 (Trade::MeshAttribute::Custom(42)) is an array but attribute 1 in mesh 4 isn't\n"
"MeshTools::concatenate(): attribute 1 (Trade::MeshAttribute::Custom(42)) isn't an array but attribute 2 in mesh 4 is\n"
"MeshTools::concatenateInto(): attribute 2 (Trade::MeshAttribute::Custom(42)) is an array but attribute 1 in mesh 3 isn't\n"
@ -760,11 +758,11 @@ void ConcatenateTest::concatenateTooLargeAttributeArraySize() {
concatenate() above) */
MeshTools::concatenate({b, a});
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenate({a, a, a, a, b});
MeshTools::concatenateInto(a, {a, a, a, b});
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"MeshTools::concatenate(): expected array size 4 or less for attribute 2 (Trade::MeshAttribute::Custom(42)) but got 5 in mesh 4 attribute 1\n"
"MeshTools::concatenateInto(): expected array size 4 or less for attribute 2 (Trade::MeshAttribute::Custom(42)) but got 5 in mesh 3 attribute 1\n",
TestSuite::Compare::String);
@ -795,11 +793,11 @@ void ConcatenateTest::concatenateImplementationSpecificIndexType() {
a tightly-packed 32bit buffer */
MeshTools::concatenateInto(bDestination, {a});
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenate({a, b});
MeshTools::concatenateInto(a, {b});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::concatenate(): mesh 1 has an implementation-specific index type 0xcaca\n"
"MeshTools::concatenateInto(): mesh 0 has an implementation-specific index type 0xcaca\n");
}
@ -823,11 +821,11 @@ void ConcatenateTest::concatenateImplementationSpecificVertexFormat() {
VertexFormat::Vector3, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenate({a, b});
MeshTools::concatenateInto(a, {b});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::concatenate(): attribute 2 of the first mesh has an implementation-specific format 0xcaca\n"
"MeshTools::concatenateInto(): attribute 2 of the destination mesh has an implementation-specific format 0xcaca\n");
}
@ -837,10 +835,10 @@ void ConcatenateTest::concatenateIntoNoMeshes() {
Trade::MeshData destination{MeshPrimitive::Triangles, 0};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::concatenateInto(destination, {});
CORRADE_COMPARE(out.str(), "MeshTools::concatenateInto(): no meshes passed\n");
CORRADE_COMPARE(out, "MeshTools::concatenateInto(): no meshes passed\n");
}
}}}}

7
src/Magnum/MeshTools/Test/CopyTest.cpp

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h"
#include "Magnum/MeshTools/Copy.h"
@ -497,10 +496,10 @@ void CopyTest::mutableReferenceNotMutable() {
CORRADE_COMPARE(cube.indexDataFlags(), Trade::DataFlag::Global);
CORRADE_COMPARE(cube.vertexDataFlags(), Trade::DataFlag::Global);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::mutableReference(cube);
CORRADE_COMPARE(out.str(), "MeshTools::mutableReference(): data not mutable\n");
CORRADE_COMPARE(out, "MeshTools::mutableReference(): data not mutable\n");
}
}}}}

51
src/Magnum/MeshTools/Test/DuplicateTest.cpp

@ -24,10 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/Magnum.h"
@ -121,11 +120,11 @@ void DuplicateTest::duplicateOutOfRange() {
constexpr UnsignedByte indices[]{1, 1, 0, 4, 2, 2};
constexpr Int data[]{-7, 35, 12, -18};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicate<UnsignedByte, Int>(indices, data);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::duplicateInto(): index 4 out of range for 4 elements\n");
}
@ -156,11 +155,11 @@ void DuplicateTest::duplicateIntoWrongSize() {
constexpr Int data[]{-7, 35, 12, -18};
Int output[5];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicateInto<UnsignedByte, Int>(indices, data, output);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::duplicateInto(): index array and output size don't match, expected 6 but got 5\n");
}
@ -187,14 +186,14 @@ void DuplicateTest::duplicateIntoErasedWrongTypeSize() {
constexpr Int data[]{-7, 35, 12, -18};
Short output[6];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicateInto(
Containers::stridedArrayView(indices),
Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)),
Containers::arrayCast<2, char>(Containers::stridedArrayView(output)));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::duplicateInto(): input and output type size doesn't match, expected 4 but got 2\n");
}
@ -205,7 +204,7 @@ void DuplicateTest::duplicateIntoErasedNonContiguous() {
constexpr Int data[]{-7, 35, 12, -18};
Short output[6];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicateInto(
@ -216,7 +215,7 @@ void DuplicateTest::duplicateIntoErasedNonContiguous() {
Containers::stridedArrayView(indices),
Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)),
Containers::arrayCast<2, char>(Containers::stridedArrayView(output)).every({1, 2}));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::duplicateInto(): second data view dimension is not contiguous\n"
"MeshTools::duplicateInto(): second output view dimension is not contiguous\n");
}
@ -244,14 +243,14 @@ void DuplicateTest::duplicateErasedIndicesIntoErasedWrongTypeSize() {
constexpr Int data[]{-7, 35, 12, -18};
Short output[6];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicateInto(
Containers::StridedArrayView2D<const char>{indices, {6, 3}}.every(2),
Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)),
Containers::arrayCast<2, char>(Containers::stridedArrayView(output)));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::duplicateInto(): expected index type size 1, 2 or 4 but got 3\n");
}
@ -262,14 +261,14 @@ void DuplicateTest::duplicateErasedIndicesIntoErasedNonContiguous() {
constexpr Int data[]{-7, 35, 12, -18};
Short output[6];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicateInto(
Containers::StridedArrayView2D<const char>{indices, {3, 3}, {6, 2}},
Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)).every({1, 2}),
Containers::arrayCast<2, char>(Containers::stridedArrayView(output)));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::duplicateInto(): second index view dimension is not contiguous\n");
}
@ -318,10 +317,10 @@ template<class T> void DuplicateTest::duplicateMeshData() {
void DuplicateTest::duplicateMeshDataNotIndexed() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicate(Trade::MeshData{MeshPrimitive::Points, 0});
CORRADE_COMPARE(out.str(), "MeshTools::duplicate(): mesh data not indexed\n");
CORRADE_COMPARE(out, "MeshTools::duplicate(): mesh data not indexed\n");
}
void DuplicateTest::duplicateMeshDataImplementationSpecificIndexType() {
@ -334,10 +333,10 @@ void DuplicateTest::duplicateMeshDataImplementationSpecificIndexType() {
VertexFormat::Vector3, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicate(a);
CORRADE_COMPARE(out.str(), "MeshTools::duplicate(): mesh has an implementation-specific index type 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::duplicate(): mesh has an implementation-specific index type 0xcaca\n");
}
void DuplicateTest::duplicateMeshDataImplementationSpecificVertexFormat() {
@ -354,10 +353,10 @@ void DuplicateTest::duplicateMeshDataImplementationSpecificVertexFormat() {
vertexFormatWrap(0xcaca), nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicate(a);
CORRADE_COMPARE(out.str(), "MeshTools::duplicate(): attribute 2 has an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::duplicate(): attribute 2 has an implementation-specific format 0xcaca\n");
}
void DuplicateTest::duplicateMeshDataExtra() {
@ -436,13 +435,13 @@ void DuplicateTest::duplicateMeshDataExtraWrongCount() {
}};
const Vector3 normals[]{Vector3::xAxis(), Vector3::yAxis()};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicate(data, {
Trade::MeshAttributeData{10},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, Containers::arrayView(normals)}
});
CORRADE_COMPARE(out.str(), "MeshTools::duplicate(): extra attribute 1 expected to have 3 items but got 2\n");
CORRADE_COMPARE(out, "MeshTools::duplicate(): extra attribute 1 expected to have 3 items but got 2\n");
}
void DuplicateTest::duplicateMeshDataExtraOffsetOnly() {
@ -452,13 +451,13 @@ void DuplicateTest::duplicateMeshDataExtraOffsetOnly() {
Trade::MeshData data{MeshPrimitive::TriangleFan,
{}, indices, Trade::MeshIndexData{indices}, 3};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicate(data, {
Trade::MeshAttributeData{10},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, VertexFormat::Vector3, 3, 5, 14}
});
CORRADE_COMPARE(out.str(), "MeshTools::duplicate(): extra attribute 1 is offset-only\n");
CORRADE_COMPARE(out, "MeshTools::duplicate(): extra attribute 1 is offset-only\n");
}
void DuplicateTest::duplicateMeshDataExtraImplementationSpecificVertexFormat() {
@ -471,7 +470,7 @@ void DuplicateTest::duplicateMeshDataExtraImplementationSpecificVertexFormat() {
VertexFormat::Vector3, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::duplicate(a, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position,
@ -479,7 +478,7 @@ void DuplicateTest::duplicateMeshDataExtraImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Color,
vertexFormatWrap(0xcaca), nullptr}
});
CORRADE_COMPARE(out.str(), "MeshTools::duplicate(): extra attribute 1 has an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::duplicate(): extra attribute 1 has an implementation-specific format 0xcaca\n");
}
void DuplicateTest::duplicateMeshDataNoAttributes() {

15
src/Magnum/MeshTools/Test/FilterTest.cpp

@ -24,12 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/BitArray.h>
#include <Corrade/Containers/BitArrayView.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector4.h"
#include "Magnum/MeshTools/Filter.h"
@ -305,10 +304,10 @@ void FilterTest::attributesWrongBitCount() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, Containers::stridedArrayView(vertices).slice(&Vertex::textureCoordinates1)}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
filterAttributes(mesh, Containers::BitArray{ValueInit, 3});
CORRADE_COMPARE(out.str(), "MeshTools::filterAttributes(): expected 2 bits but got 3\n");
CORRADE_COMPARE(out, "MeshTools::filterAttributes(): expected 2 bits but got 3\n");
}
void FilterTest::onlyAttributes() {
@ -526,12 +525,12 @@ void FilterTest::onlyAttributeIdsOutOfRange() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, Containers::stridedArrayView(vertices).slice(&Vertex::textureCoordinates1)}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_IGNORE_DEPRECATED_PUSH
filterOnlyAttributes(mesh, {0, 0, 2});
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out.str(), "MeshTools::filterOnlyAttributes(): index 2 out of range for 2 attributes\n");
CORRADE_COMPARE(out, "MeshTools::filterOnlyAttributes(): index 2 out of range for 2 attributes\n");
}
void FilterTest::onlyAttributeIdsNoIndexData() {
@ -810,12 +809,12 @@ void FilterTest::exceptAttributeIdsOutOfRange() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, Containers::stridedArrayView(vertices).slice(&Vertex::textureCoordinates1)}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_IGNORE_DEPRECATED_PUSH
filterExceptAttributes(mesh, {0, 0, 2});
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out.str(), "MeshTools::filterExceptAttributes(): index 2 out of range for 2 attributes\n");
CORRADE_COMPARE(out, "MeshTools::filterExceptAttributes(): index 2 out of range for 2 attributes\n");
}
void FilterTest::exceptAttributeIdsNoIndexData() {

17
src/Magnum/MeshTools/Test/FlipNormalsTest.cpp

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector3.h"
#include "Magnum/MeshTools/FlipNormals.h"
@ -74,13 +73,13 @@ FlipNormalsTest::FlipNormalsTest() {
void FlipNormalsTest::wrongIndexCount() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream ss;
Error redirectError{&ss};
Containers::String out;
Error redirectError{&out};
UnsignedByte indices[2];
flipFaceWindingInPlace(Containers::stridedArrayView(indices));
CORRADE_COMPARE(ss.str(), "MeshTools::flipNormals(): index count is not divisible by 3!\n");
CORRADE_COMPARE(out, "MeshTools::flipNormals(): index count is not divisible by 3!\n");
}
template<class T> void FlipNormalsTest::flipFaceWinding() {
@ -110,10 +109,10 @@ void FlipNormalsTest::flipFaceWindingErasedNonContiguous() {
char indices[6*4]{};
std::stringstream out;
Containers::String out;
Error redirectError{&out};
flipFaceWindingInPlace(Containers::StridedArrayView2D<char>{indices, {6, 2}, {4, 2}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::flipFaceWindingInPlace(): second index view dimension is not contiguous\n");
}
@ -122,10 +121,10 @@ void FlipNormalsTest::flipFaceWindingErasedWrongIndexSize() {
char indices[6*3]{};
std::stringstream out;
Containers::String out;
Error redirectError{&out};
flipFaceWindingInPlace(Containers::StridedArrayView2D<char>{indices, {6, 3}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::flipFaceWindingInPlace(): expected index type size 1, 2 or 4 but got 3\n");
}

100
src/Magnum/MeshTools/Test/GenerateIndicesTest.cpp

@ -24,15 +24,13 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once Debug is stream-free */
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include "Magnum/Math/Matrix4.h"
#include "Magnum/MeshTools/GenerateIndices.h"
@ -338,14 +336,14 @@ void GenerateIndicesTest::primitiveCount() {
void GenerateIndicesTest::primitiveCountInvalidVertexCount() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::primitiveCount(MeshPrimitive::LineLoop, 1);
MeshTools::primitiveCount(MeshPrimitive::TriangleStrip, 1);
MeshTools::primitiveCount(MeshPrimitive::TriangleFan, 2);
MeshTools::primitiveCount(MeshPrimitive::Lines, 7);
MeshTools::primitiveCount(MeshPrimitive::Triangles, 14);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::primitiveCount(): expected either zero or at least 2 elements for MeshPrimitive::LineLoop, got 1\n"
"MeshTools::primitiveCount(): expected either zero or at least 3 elements for MeshPrimitive::TriangleStrip, got 1\n"
"MeshTools::primitiveCount(): expected either zero or at least 3 elements for MeshPrimitive::TriangleFan, got 2\n"
@ -356,10 +354,10 @@ void GenerateIndicesTest::primitiveCountInvalidVertexCount() {
void GenerateIndicesTest::primitiveCountInvalidPrimitive() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::primitiveCount(MeshPrimitive(0xdead), 2);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::primitiveCount(): invalid primitive MeshPrimitive(0xdead)\n");
}
@ -509,11 +507,11 @@ void GenerateIndicesTest::generateLineStripIndicesWrongVertexCount() {
UnsignedShort indices[1];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateLineStripIndices(1);
MeshTools::generateLineStripIndices(indices);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateLineStripIndicesInto(): expected either zero or at least two vertices, got 1\n"
"MeshTools::generateLineStripIndicesInto(): expected either zero or at least two indices, got 1\n");
}
@ -524,13 +522,13 @@ void GenerateIndicesTest::generateLineStripIndicesIntoWrongSize() {
UnsignedByte indices[5];
UnsignedInt output[7];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateLineStripIndicesInto(0, output);
MeshTools::generateLineStripIndicesInto(Containers::arrayView(indices).prefix(0), output);
MeshTools::generateLineStripIndicesInto(5, output);
MeshTools::generateLineStripIndicesInto(indices, output);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateLineStripIndicesInto(): bad output size, expected 0 but got 7\n"
"MeshTools::generateLineStripIndicesInto(): bad output size, expected 0 but got 7\n"
"MeshTools::generateLineStripIndicesInto(): bad output size, expected 8 but got 7\n"
@ -542,11 +540,11 @@ void GenerateIndicesTest::generateLineStripIndicesIndexed2DInvalid() {
char indices[3*4];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateLineStripIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2}));
MeshTools::generateLineStripIndices(Containers::StridedArrayView2D<char>{indices, {4, 3}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateLineStripIndicesInto(): second index view dimension is not contiguous\n"
"MeshTools::generateLineStripIndicesInto(): expected index type size 1, 2 or 4 but got 3\n");
}
@ -688,11 +686,11 @@ void GenerateIndicesTest::generateLineLoopIndicesWrongVertexCount() {
UnsignedInt indices[1];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateLineLoopIndices(1);
MeshTools::generateLineLoopIndices(indices);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateLineLoopIndicesInto(): expected either zero or at least two vertices, got 1\n"
"MeshTools::generateLineLoopIndicesInto(): expected either zero or at least two indices, got 1\n");
}
@ -703,13 +701,13 @@ void GenerateIndicesTest::generateLineLoopIndicesIntoWrongSize() {
UnsignedShort indices[5];
UnsignedInt output[9];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateLineLoopIndicesInto(0, output);
MeshTools::generateLineLoopIndicesInto(Containers::arrayView(indices).prefix(0), output);
MeshTools::generateLineLoopIndicesInto(5, output);
MeshTools::generateLineLoopIndicesInto(indices, output);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateLineLoopIndicesInto(): bad output size, expected 0 but got 9\n"
"MeshTools::generateLineLoopIndicesInto(): bad output size, expected 0 but got 9\n"
"MeshTools::generateLineLoopIndicesInto(): bad output size, expected 10 but got 9\n"
@ -721,11 +719,11 @@ void GenerateIndicesTest::generateLineLoopIndicesIndexed2DInvalid() {
char indices[3*4];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateLineLoopIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2}));
MeshTools::generateLineLoopIndices(Containers::StridedArrayView2D<char>{indices, {4, 3}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateLineLoopIndicesInto(): second index view dimension is not contiguous\n"
"MeshTools::generateLineLoopIndicesInto(): expected index type size 1, 2 or 4 but got 3\n");
}
@ -864,11 +862,11 @@ void GenerateIndicesTest::generateTriangleStripIndicesWrongVertexCount() {
UnsignedByte indices[2];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateTriangleStripIndices(2);
MeshTools::generateTriangleStripIndices(indices);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateTriangleStripIndicesInto(): expected either zero or at least three vertices, got 2\n"
"MeshTools::generateTriangleStripIndicesInto(): expected either zero or at least three indices, got 2\n");
}
@ -879,13 +877,13 @@ void GenerateIndicesTest::generateTriangleStripIndicesIntoWrongSize() {
UnsignedInt indices[5];
UnsignedInt output[8];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateTriangleStripIndicesInto(0, output);
MeshTools::generateTriangleStripIndicesInto(Containers::arrayView(indices).prefix(0), output);
MeshTools::generateTriangleStripIndicesInto(5, output);
MeshTools::generateTriangleStripIndicesInto(indices, output);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateTriangleStripIndicesInto(): bad output size, expected 0 but got 8\n"
"MeshTools::generateTriangleStripIndicesInto(): bad output size, expected 0 but got 8\n"
"MeshTools::generateTriangleStripIndicesInto(): bad output size, expected 9 but got 8\n"
@ -897,11 +895,11 @@ void GenerateIndicesTest::generateTriangleStripIndicesIndexed2DInvalid() {
char indices[3*4];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateTriangleStripIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2}));
MeshTools::generateTriangleStripIndices(Containers::StridedArrayView2D<char>{indices, {4, 3}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateTriangleStripIndicesInto(): second index view dimension is not contiguous\n"
"MeshTools::generateTriangleStripIndicesInto(): expected index type size 1, 2 or 4 but got 3\n");
}
@ -1041,11 +1039,11 @@ void GenerateIndicesTest::generateTriangleFanIndicesWrongVertexCount() {
UnsignedInt indices[2];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateTriangleFanIndices(2);
MeshTools::generateTriangleFanIndices(indices);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateTriangleFanIndicesInto(): expected either zero or at least three vertices, got 2\n"
"MeshTools::generateTriangleFanIndicesInto(): expected either zero or at least three indices, got 2\n");
}
@ -1056,13 +1054,13 @@ void GenerateIndicesTest::generateTriangleFanIndicesIntoWrongSize() {
UnsignedInt indices[5];
UnsignedInt output[8];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateTriangleFanIndicesInto(0, output);
MeshTools::generateTriangleFanIndicesInto(Containers::arrayView(indices).prefix(0), output);
MeshTools::generateTriangleFanIndicesInto(5, output);
MeshTools::generateTriangleFanIndicesInto(indices, output);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateTriangleFanIndicesInto(): bad output size, expected 0 but got 8\n"
"MeshTools::generateTriangleFanIndicesInto(): bad output size, expected 0 but got 8\n"
"MeshTools::generateTriangleFanIndicesInto(): bad output size, expected 9 but got 8\n"
@ -1074,11 +1072,11 @@ void GenerateIndicesTest::generateTriangleFanIndicesIndexed2DInvalid() {
char indices[3*4];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateTriangleFanIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2}));
MeshTools::generateTriangleFanIndices(Containers::StridedArrayView2D<char>{indices, {4, 3}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateTriangleFanIndicesInto(): second index view dimension is not contiguous\n"
"MeshTools::generateTriangleFanIndicesInto(): expected index type size 1, 2 or 4 but got 3\n");
}
@ -1207,10 +1205,10 @@ void GenerateIndicesTest::generateQuadIndicesWrongIndexCount() {
UnsignedInt quads[13];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateQuadIndices({}, quads);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateQuadIndicesInto(): quad index count 13 not divisible by 4\n");
}
@ -1220,10 +1218,10 @@ void GenerateIndicesTest::generateQuadIndicesIndexOutOfRange() {
UnsignedInt quads[]{5, 4, 6, 7};
Vector3 positions[7];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateQuadIndices(positions, quads);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateQuadIndicesInto(): index 7 out of range for 7 elements\n");
}
@ -1233,19 +1231,19 @@ void GenerateIndicesTest::generateQuadIndicesIntoWrongSize() {
UnsignedInt quads[12];
UnsignedInt output[19];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::generateQuadIndicesInto({}, quads, output);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateQuadIndicesInto(): bad output size, expected 18 but got 19\n");
}
void GenerateIndicesTest::generateIndicesMeshData() {
auto&& data = MeshDataData[testCaseInstanceId()];
{
std::ostringstream out;
Containers::String out;
Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive;
setTestCaseDescription(out.str());
setTestCaseDescription(out);
}
const struct Vertex {
@ -1302,9 +1300,9 @@ template<class T> void GenerateIndicesTest::generateIndicesMeshDataIndexed() {
auto&& data = MeshDataData[testCaseInstanceId()];
setTestCaseTemplateName(Math::TypeTraits<T>::name());
{
std::ostringstream out;
Containers::String out;
Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive;
setTestCaseDescription(out.str());
setTestCaseDescription(out);
}
const struct Vertex {
@ -1364,9 +1362,9 @@ template<class T> void GenerateIndicesTest::generateIndicesMeshDataIndexed() {
void GenerateIndicesTest::generateIndicesMeshDataEmpty() {
auto&& data = MeshDataData[testCaseInstanceId()];
{
std::ostringstream out;
Containers::String out;
Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive;
setTestCaseDescription(out.str());
setTestCaseDescription(out);
}
/* Similar to generateIndicesMeshData(), just with 0 vertices. Verifying it
@ -1604,19 +1602,19 @@ void GenerateIndicesTest::generateIndicesMeshDataTrivialIndexedMoveDifferentInde
void GenerateIndicesTest::generateIndicesMeshDataInvalidVertexCount() {
auto&& data = MeshDataInvalidVertexCountData[testCaseInstanceId()];
std::ostringstream primitiveName;
Containers::String primitiveName;
Debug{&primitiveName, Debug::Flag::NoNewlineAtTheEnd} << data.primitive;
setTestCaseDescription(primitiveName.str());
setTestCaseDescription(primitiveName);
CORRADE_SKIP_IF_NO_ASSERT();
Trade::MeshData mesh{data.primitive, data.invalidVertexCount};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
generateIndices(mesh);
CORRADE_COMPARE(out.str(), Utility::formatString(
"MeshTools::generateIndices(): expected either zero or at least {} vertices for {}, got {}\n", data.expectedVertexCount, primitiveName.str(), data.invalidVertexCount));
CORRADE_COMPARE(out, Utility::format(
"MeshTools::generateIndices(): expected either zero or at least {} vertices for {}, got {}\n", data.expectedVertexCount, primitiveName, data.invalidVertexCount));
}
void GenerateIndicesTest::generateIndicesMeshDataImplementationSpecificIndexType() {
@ -1626,10 +1624,10 @@ void GenerateIndicesTest::generateIndicesMeshDataImplementationSpecificIndexType
nullptr, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::StridedArrayView1D<const void>{}},
nullptr, {}, 3};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
generateIndices(a);
CORRADE_COMPARE(out.str(), "MeshTools::generateIndices(): mesh has an implementation-specific index type 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::generateIndices(): mesh has an implementation-specific index type 0xcaca\n");
}
}}}}

15
src/Magnum/MeshTools/Test/GenerateLinesTest.cpp

@ -24,10 +24,9 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h"
#include "Magnum/Math/PackingBatch.h"
@ -636,21 +635,21 @@ void GenerateLinesTest::notLines() {
Vector3 positions[3]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
generateLines(Trade::MeshData{MeshPrimitive::TriangleFan, {}, positions, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::stridedArrayView(positions)}
}});
CORRADE_COMPARE(out.str(), "MeshTools::generateLines(): expected a line primitive, got MeshPrimitive::TriangleFan\n");
CORRADE_COMPARE(out, "MeshTools::generateLines(): expected a line primitive, got MeshPrimitive::TriangleFan\n");
}
void GenerateLinesTest::noAttributes() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
generateLines(Trade::MeshData{MeshPrimitive::Lines, 12});
CORRADE_COMPARE(out.str(), "MeshTools::generateLines(): the mesh has no positions\n");
CORRADE_COMPARE(out, "MeshTools::generateLines(): the mesh has no positions\n");
}
void GenerateLinesTest::noPositionAttribute() {
@ -658,12 +657,12 @@ void GenerateLinesTest::noPositionAttribute() {
Vector3 colors[2]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
generateLines(Trade::MeshData{MeshPrimitive::Lines, {}, colors, {
Trade::MeshAttributeData{Trade::MeshAttribute::Color, Containers::stridedArrayView(colors)}
}});
CORRADE_COMPARE(out.str(), "MeshTools::generateLines(): the mesh has no positions\n");
CORRADE_COMPARE(out, "MeshTools::generateLines(): the mesh has no positions\n");
}
}}}}

32
src/Magnum/MeshTools/Test/GenerateNormalsTest.cpp

@ -24,13 +24,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/FunctionsBatch.h"
#include "Magnum/Math/Vector3.h"
@ -40,6 +39,7 @@
#include "Magnum/Trade/MeshData.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <tuple>
#include <vector>
#endif
@ -157,24 +157,24 @@ void GenerateNormalsTest::flatDeprecated() {
void GenerateNormalsTest::flatWrongCount() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
const Vector3 positions[7];
generateFlatNormals(positions);
CORRADE_COMPARE(out.str(), "MeshTools::generateFlatNormalsInto(): position count not divisible by 3\n");
CORRADE_COMPARE(out, "MeshTools::generateFlatNormalsInto(): position count not divisible by 3\n");
}
void GenerateNormalsTest::flatIntoWrongSize() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
const Vector3 positions[6];
Vector3 normals[7];
generateFlatNormalsInto(positions, normals);
CORRADE_COMPARE(out.str(), "MeshTools::generateFlatNormalsInto(): bad output size, expected 6 but got 7\n");
CORRADE_COMPARE(out, "MeshTools::generateFlatNormalsInto(): bad output size, expected 6 but got 7\n");
}
template<class T> void GenerateNormalsTest::smoothTwoTriangles() {
@ -394,38 +394,38 @@ void GenerateNormalsTest::smoothNanPosition() {
void GenerateNormalsTest::smoothWrongCount() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
const UnsignedByte indices[7]{};
const Vector3 positions[1];
generateSmoothNormals(indices, positions);
CORRADE_COMPARE(out.str(), "MeshTools::generateSmoothNormalsInto(): index count not divisible by 3\n");
CORRADE_COMPARE(out, "MeshTools::generateSmoothNormalsInto(): index count not divisible by 3\n");
}
void GenerateNormalsTest::smoothOutOfRange() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
const Vector3 positions[2];
const UnsignedInt indices[] { 0, 1, 2 };
generateSmoothNormals(indices, positions);
CORRADE_COMPARE(out.str(), "MeshTools::generateSmoothNormalsInto(): index 2 out of range for 2 elements\n");
CORRADE_COMPARE(out, "MeshTools::generateSmoothNormalsInto(): index 2 out of range for 2 elements\n");
}
void GenerateNormalsTest::smoothIntoWrongSize() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
const UnsignedByte indices[6]{};
const Vector3 positions[3];
Vector3 normals[4];
generateSmoothNormalsInto(indices, positions, normals);
CORRADE_COMPARE(out.str(), "MeshTools::generateSmoothNormalsInto(): bad output size, expected 3 but got 4\n");
CORRADE_COMPARE(out, "MeshTools::generateSmoothNormalsInto(): bad output size, expected 3 but got 4\n");
}
void GenerateNormalsTest::benchmarkFlat() {
@ -473,10 +473,10 @@ void GenerateNormalsTest::smoothErasedNonContiguous() {
const char indices[6*4]{};
const Vector3 positions[3];
std::stringstream out;
Containers::String out;
Error redirectError{&out};
generateSmoothNormals(Containers::StridedArrayView2D<const char>{indices, {6, 2}, {4, 2}}, positions);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateSmoothNormalsInto(): second index view dimension is not contiguous\n");
}
@ -486,10 +486,10 @@ void GenerateNormalsTest::smoothErasedWrongIndexSize() {
const char indices[6*3]{};
const Vector3 positions[3];
std::stringstream out;
Containers::String out;
Error redirectError{&out};
generateSmoothNormals(Containers::StridedArrayView2D<const char>{indices, {6, 3}}.every(2), positions);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::generateSmoothNormalsInto(): expected index type size 1, 2 or 4 but got 3\n");
}

58
src/Magnum/MeshTools/Test/InterleaveTest.cpp

@ -24,16 +24,14 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once Debug is stream-free */
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/Endianness.h>
#include <Corrade/Utility/Debug.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stream-free */
#include "Magnum/Math/Vector3.h"
#include "Magnum/MeshTools/Interleave.h"
@ -227,13 +225,13 @@ void InterleaveTest::attributeCountGaps() {
void InterleaveTest::attributeCountInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream ss;
Error redirectError{&ss};
Containers::String out;
Error redirectError{&out};
CORRADE_COMPARE(Implementation::AttributeCount{}(
Containers::arrayView<Byte>({0, 1, 2}),
Containers::arrayView<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, expected 3 but got 6\n");
CORRADE_COMPARE(out, "MeshTools::interleave(): attribute arrays don't have the same length, expected 3 but got 6\n");
}
void InterleaveTest::stride() {
@ -370,10 +368,10 @@ void InterleaveTest::interleaveIntoInvalid() {
Containers::Array<char> data{NoInit, 23};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleaveInto(data, 2, Containers::arrayView({1, 2, 3, 4}));
CORRADE_COMPARE(out.str(), "MeshTools::interleaveInto(): expected a buffer of at least 24 bytes but got 23\n");
CORRADE_COMPARE(out, "MeshTools::interleaveInto(): expected a buffer of at least 24 bytes but got 23\n");
}
void InterleaveTest::interleavedData() {
@ -614,10 +612,10 @@ void InterleaveTest::interleavedDataNotInterleaved() {
}};
CORRADE_VERIFY(!MeshTools::isInterleaved(data));
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleavedData(data);
CORRADE_COMPARE(out.str(), "MeshTools::interleavedData(): the mesh is not interleaved\n");
CORRADE_COMPARE(out, "MeshTools::interleavedData(): the mesh is not interleaved\n");
}
void InterleaveTest::interleavedDataAttributeAcrossStride() {
@ -697,10 +695,10 @@ void InterleaveTest::interleavedMutableDataNotMutable() {
Trade::MeshData data{MeshPrimitive::Lines, {}, a, {}, 15};
CORRADE_VERIFY(MeshTools::isInterleaved(data));
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleavedMutableData(data);
CORRADE_COMPARE(out.str(), "MeshTools::interleavedMutableData(): vertex data is not mutable\n");
CORRADE_COMPARE(out, "MeshTools::interleavedMutableData(): vertex data is not mutable\n");
}
void InterleaveTest::interleavedDataImplementationSpecificVertexFormat() {
@ -870,10 +868,10 @@ void InterleaveTest::interleavedLayoutImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleavedLayout(data, 5);
CORRADE_COMPARE(out.str(), "MeshTools::interleavedLayout(): attribute 1 has an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::interleavedLayout(): attribute 1 has an implementation-specific format 0xcaca\n");
}
void InterleaveTest::interleavedLayoutExtra() {
@ -972,14 +970,14 @@ void InterleaveTest::interleavedLayoutExtraTooNegativePadding() {
Trade::MeshData data{MeshPrimitive::Triangles,
Utility::move(vertexData), {positions}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleavedLayout(data, 100, {
Trade::MeshAttributeData{Trade::MeshAttribute::Normal,
VertexFormat::Vector3, positions.data()},
Trade::MeshAttributeData{-25}
});
CORRADE_COMPARE(out.str(), "MeshTools::interleavedLayout(): negative padding -25 in extra attribute 1 too large for stride 24\n");
CORRADE_COMPARE(out, "MeshTools::interleavedLayout(): negative padding -25 in extra attribute 1 too large for stride 24\n");
}
void InterleaveTest::interleavedLayoutExtraOnly() {
@ -1013,13 +1011,13 @@ void InterleaveTest::interleavedLayoutExtraImplementationSpecificVertexFormat()
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleavedLayout(data, 5, {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr},
});
CORRADE_COMPARE(out.str(), "MeshTools::interleavedLayout(): extra attribute 1 has an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::interleavedLayout(): extra attribute 1 has an implementation-specific format 0xcaca\n");
}
void InterleaveTest::interleavedLayoutAlreadyInterleaved() {
@ -1329,10 +1327,10 @@ void InterleaveTest::interleaveMeshDataImplementationSpecificIndexType() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleave(data);
CORRADE_COMPARE(out.str(), "MeshTools::interleave(): mesh has an implementation-specific index type 0xcaca, enable MeshTools::InterleaveFlag::PreserveStridedIndices to pass the array through unchanged\n");
CORRADE_COMPARE(out, "MeshTools::interleave(): mesh has an implementation-specific index type 0xcaca, enable MeshTools::InterleaveFlag::PreserveStridedIndices to pass the array through unchanged\n");
}
void InterleaveTest::interleaveMeshDataImplementationSpecificVertexFormat() {
@ -1343,11 +1341,11 @@ void InterleaveTest::interleaveMeshDataImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleave(data);
/* Assert is coming from interleavedLayout() because... that's easier */
CORRADE_COMPARE(out.str(), "MeshTools::interleavedLayout(): attribute 1 has an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::interleavedLayout(): attribute 1 has an implementation-specific format 0xcaca\n");
}
void InterleaveTest::interleaveMeshDataExtra() {
@ -1432,13 +1430,13 @@ void InterleaveTest::interleaveMeshDataExtraWrongCount() {
}};
const Vector3 normals[]{Vector3::xAxis(), Vector3::yAxis()};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleave(data, {
Trade::MeshAttributeData{10},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, VertexFormat::Vector3, Containers::arrayView(normals)}
});
CORRADE_COMPARE(out.str(), "MeshTools::interleave(): extra attribute 1 expected to have 3 items but got 2\n");
CORRADE_COMPARE(out, "MeshTools::interleave(): extra attribute 1 expected to have 3 items but got 2\n");
}
void InterleaveTest::interleaveMeshDataExtraOffsetOnly() {
@ -1446,13 +1444,13 @@ void InterleaveTest::interleaveMeshDataExtraOffsetOnly() {
Trade::MeshData data{MeshPrimitive::TriangleFan, 5};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleave(data, {
Trade::MeshAttributeData{10},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, VertexFormat::Vector3, 3, 5, 14}
});
CORRADE_COMPARE(out.str(), "MeshTools::interleave(): extra attribute 1 is offset-only\n");
CORRADE_COMPARE(out, "MeshTools::interleave(): extra attribute 1 is offset-only\n");
}
void InterleaveTest::interleaveMeshDataExtraImplementationSpecificVertexFormat() {
@ -1462,14 +1460,14 @@ void InterleaveTest::interleaveMeshDataExtraImplementationSpecificVertexFormat()
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleave(data, {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr},
});
/* Assert is coming from interleavedLayout() because... that's easier */
CORRADE_COMPARE(out.str(), "MeshTools::interleavedLayout(): extra attribute 1 has an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::interleavedLayout(): extra attribute 1 has an implementation-specific format 0xcaca\n");
}
void InterleaveTest::interleaveMeshDataAlreadyInterleavedMove() {
@ -1687,7 +1685,7 @@ void InterleaveTest::interleaveMeshDataLooseAttributesInvalid() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::ArrayView<Vector3>{nullptr, 0}}
}).vertexCount(), 0);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::interleave(MeshPrimitive::Triangles,
Trade::MeshIndexData{indices}, {
@ -1701,7 +1699,7 @@ void InterleaveTest::interleaveMeshDataLooseAttributesInvalid() {
Trade::MeshIndexData{meshIndexTypeWrap(0xcece), Containers::stridedArrayView(indices)}, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::ArrayView<Vector3>{nullptr, 3}}
});
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"MeshTools::interleave(): only padding found among 1 attributes, can't infer vertex count\n"
"MeshTools::interleave(): only padding found among 2 attributes, can't infer vertex count\n"
"MeshTools::interleave(): implementation-specific index type 0xcece\n",

63
src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp

@ -26,12 +26,11 @@
#include <algorithm> /* std::shuffle() */
#include <random> /* random device for std::shuffle() */
#include <sstream>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector3.h"
#include "Magnum/MeshTools/RemoveDuplicates.h"
@ -290,11 +289,11 @@ void RemoveDuplicatesTest::removeDuplicatesNonContiguous() {
Int data[8]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicates(Containers::arrayCast<2, const char>(Containers::arrayView(data)).every({1, 2}));
MeshTools::removeDuplicatesInPlace(Containers::arrayCast<2, char>(Containers::arrayView(data)).every({1, 2}));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesInto(): second data view dimension is not contiguous\n"
"MeshTools::removeDuplicatesInPlaceInto(): second data view dimension is not contiguous\n");
}
@ -305,7 +304,7 @@ void RemoveDuplicatesTest::removeDuplicatesIntoWrongOutputSize() {
Int data[8]{};
UnsignedInt output[7];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesInto(
Containers::arrayCast<2, const char>(Containers::arrayView(data)),
@ -313,7 +312,7 @@ void RemoveDuplicatesTest::removeDuplicatesIntoWrongOutputSize() {
MeshTools::removeDuplicatesInPlaceInto(
Containers::arrayCast<2, char>(Containers::arrayView(data)),
output);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesInto(): output index array has 7 elements but expected 8\n"
"MeshTools::removeDuplicatesInPlaceInto(): output index array has 7 elements but expected 8\n");
}
@ -337,7 +336,7 @@ template<class T> void RemoveDuplicatesTest::removeDuplicatesIndexedInPlace() {
void RemoveDuplicatesTest::removeDuplicatesIndexedInPlaceSmallType() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
UnsignedByte indices[1];
@ -345,7 +344,7 @@ void RemoveDuplicatesTest::removeDuplicatesIndexedInPlaceSmallType() {
MeshTools::removeDuplicatesIndexedInPlace(
Containers::stridedArrayView(indices),
Containers::arrayCast<2, char>(Containers::arrayView(data)));
CORRADE_COMPARE(out.str(), "MeshTools::removeDuplicatesIndexedInPlace(): a 1-byte index type is too small for 256 vertices\n");
CORRADE_COMPARE(out, "MeshTools::removeDuplicatesIndexedInPlace(): a 1-byte index type is too small for 256 vertices\n");
}
void RemoveDuplicatesTest::removeDuplicatesIndexedInPlaceEmptyIndices() {
@ -387,12 +386,12 @@ void RemoveDuplicatesTest::removeDuplicatesIndexedInPlaceErasedNonContiguous() {
char indices[6*4]{};
Int data[1]{};
std::stringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesIndexedInPlace(
Containers::StridedArrayView2D<char>{indices, {6, 2}, {4, 2}},
Containers::arrayCast<2, char>(Containers::arrayView(data)));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesIndexedInPlace(): second index view dimension is not contiguous\n");
}
@ -402,12 +401,12 @@ void RemoveDuplicatesTest::removeDuplicatesIndexedInPlaceErasedWrongIndexSize()
char indices[6*3]{};
Int data[1]{};
std::stringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesIndexedInPlace(
Containers::StridedArrayView2D<char>{indices, {6, 3}},
Containers::arrayCast<2, char>(Containers::arrayView(data)));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesIndexedInPlace(): expected index type size 1, 2 or 4 but got 3\n");
}
@ -490,12 +489,12 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyInPlaceIntoWrongOutputSize() {
Vector2 data[8]{};
UnsignedInt output[7];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesFuzzyInPlaceInto(
Containers::arrayCast<2, Float>(Containers::stridedArrayView(data)),
output);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesFuzzyInPlaceInto(): output index array has 7 elements but expected 8\n");
}
@ -547,7 +546,7 @@ template<class IndexType, class T> void RemoveDuplicatesTest::removeDuplicatesFu
void RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlaceSmallType() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
UnsignedByte indices[1];
@ -555,7 +554,7 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlaceSmallType() {
MeshTools::removeDuplicatesFuzzyIndexedInPlace(
Containers::stridedArrayView(indices),
Containers::arrayCast<2, Float>(Containers::stridedArrayView(data)));
CORRADE_COMPARE(out.str(), "MeshTools::removeDuplicatesFuzzyIndexedInPlace(): a 1-byte index type is too small for 256 vertices\n");
CORRADE_COMPARE(out, "MeshTools::removeDuplicatesFuzzyIndexedInPlace(): a 1-byte index type is too small for 256 vertices\n");
}
void RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlaceEmptyIndices() {
@ -609,12 +608,12 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlaceErasedNonContiguou
char indices[6*4]{};
Vector2 data[1];
std::stringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesFuzzyIndexedInPlace(
Containers::StridedArrayView2D<char>{indices, {6, 2}, {4, 2}},
Containers::arrayCast<2, Float>(Containers::stridedArrayView(data)));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesFuzzyIndexedInPlace(): second index view dimension is not contiguous\n");
}
@ -624,12 +623,12 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlaceErasedWrongIndexSi
char indices[6*3]{};
Vector2 data[1];
std::stringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesFuzzyIndexedInPlace(
Containers::StridedArrayView2D<char>{indices, {6, 3}},
Containers::arrayCast<2, Float>(Containers::stridedArrayView(data)));
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesFuzzyIndexedInPlace(): expected index type size 1, 2 or 4 but got 3\n");
}
@ -831,37 +830,37 @@ void RemoveDuplicatesTest::removeDuplicatesMeshDataPaddedAttributes() {
void RemoveDuplicatesTest::removeDuplicatesMeshDataAttributeless() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicates(Trade::MeshData{MeshPrimitive::Points, 10});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicates(): can't remove duplicates in an attributeless mesh\n");
}
void RemoveDuplicatesTest::removeDuplicatesMeshDataImplementationSpecificIndexType() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicates(Trade::MeshData{MeshPrimitive::Points,
nullptr, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::StridedArrayView1D<const void>{}},
nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr}
}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicates(): mesh has an implementation-specific index type 0xcaca\n");
}
void RemoveDuplicatesTest::removeDuplicatesMeshDataImplementationSpecificVertexFormat() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicates(Trade::MeshData{MeshPrimitive::Points, nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr}
}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicates(): attribute 1 has an implementation-specific format 0xcaca\n");
}
@ -1174,37 +1173,37 @@ void RemoveDuplicatesTest::removeDuplicatesMeshDataFuzzyDouble() {
void RemoveDuplicatesTest::removeDuplicatesMeshDataFuzzyAttributeless() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesFuzzy(Trade::MeshData{MeshPrimitive::Points, 10});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesFuzzy(): can't remove duplicates in an attributeless mesh\n");
}
void RemoveDuplicatesTest::removeDuplicatesMeshDataFuzzyImplementationSpecificIndexType() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesFuzzy(Trade::MeshData{MeshPrimitive::Points,
nullptr, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::StridedArrayView1D<const void>{}},
nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr}
}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesFuzzy(): mesh has an implementation-specific index type 0xcaca\n");
}
void RemoveDuplicatesTest::removeDuplicatesMeshDataFuzzyImplementationSpecificVertexFormat() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
MeshTools::removeDuplicatesFuzzy(Trade::MeshData{MeshPrimitive::Points, nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr}
}});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"MeshTools::removeDuplicatesFuzzy(): attribute 1 has an implementation-specific format 0xcaca\n");
}

15
src/Magnum/MeshTools/Test/SubdivideTest.cpp

@ -24,12 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector3.h"
#include "Magnum/MeshTools/RemoveDuplicates.h"
@ -112,13 +111,13 @@ void SubdivideTest::subdivideStl() {
void SubdivideTest::subdivideWrongIndexCount() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
Containers::Array<Vector1> positions;
Containers::Array<UnsignedInt> indices{2};
MeshTools::subdivide(indices, positions, interpolator1);
CORRADE_COMPARE(out.str(), "MeshTools::subdivide(): index count is not divisible by 3\n");
CORRADE_COMPARE(out, "MeshTools::subdivide(): index count is not divisible by 3\n");
}
template<class T> void SubdivideTest::subdivideInPlace() {
@ -140,27 +139,27 @@ template<class T> void SubdivideTest::subdivideInPlace() {
void SubdivideTest::subdivideInPlaceWrongIndexCount() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
UnsignedInt indices[6*4 + 1]{0, 1, 2, 1, 2, 3, /* and 18+1 more */};
Vector1 positions[]{0};
MeshTools::subdivideInPlace(Containers::stridedArrayView(indices),
Containers::stridedArrayView(positions), interpolator1);
CORRADE_COMPARE(out.str(), "MeshTools::subdivideInPlace(): can't divide 25 indices to four parts with each having triangle faces\n");
CORRADE_COMPARE(out, "MeshTools::subdivideInPlace(): can't divide 25 indices to four parts with each having triangle faces\n");
}
void SubdivideTest::subdivideInPlaceSmallIndexType() {
CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out;
Containers::String out;
Error redirectError{&out};
UnsignedByte indices[6*4]{0, 1, 2, 1, 2, 3, /* and 18 more */};
Vector1 positions[256]{};
MeshTools::subdivideInPlace(Containers::stridedArrayView(indices),
Containers::stridedArrayView(positions), interpolator1);
CORRADE_COMPARE(out.str(), "MeshTools::subdivideInPlace(): a 1-byte index type is too small for 256 vertices\n");
CORRADE_COMPARE(out, "MeshTools::subdivideInPlace(): a 1-byte index type is too small for 256 vertices\n");
}
void SubdivideTest::benchmark() {

103
src/Magnum/MeshTools/Test/TransformTest.cpp

@ -24,15 +24,14 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include "Magnum/Math/Half.h"
#include "Magnum/Math/Matrix3.h"
@ -552,13 +551,13 @@ void TransformTest::meshData2DNoPosition() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform2D(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transform2D(): the mesh has no positions with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transform2D(): the mesh has no positions with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transform2D(): the mesh has no positions with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transform2D(): the mesh has no positions with index 0 in morph target 37\n");
}
void TransformTest::meshData2DNot2D() {
@ -568,10 +567,10 @@ void TransformTest::meshData2DNot2D() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform2D(mesh, {});
CORRADE_COMPARE(out.str(), "MeshTools::transform2D(): expected 2D positions but got VertexFormat::Vector3\n");
CORRADE_COMPARE(out, "MeshTools::transform2D(): expected 2D positions but got VertexFormat::Vector3\n");
}
void TransformTest::meshData2DImplementationSpecificIndexType() {
@ -605,10 +604,10 @@ void TransformTest::meshData2DImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, vertexFormatWrap(0xcaca), nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform2D(mesh, {}, 1);
CORRADE_COMPARE(out.str(), "MeshTools::transform2D(): positions have an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::transform2D(): positions have an implementation-specific format 0xcaca\n");
}
void TransformTest::meshData2DRvaluePassthrough() {
@ -774,15 +773,15 @@ void TransformTest::meshData2DRvaluePassthroughNoPosition() {
/* Mainly to verify there's no other accidental assertion from checking
vertex format and that the ID + morph target ID gets correctly passed
through, this message comes from the l-value overload */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform2D(Trade::MeshData{MeshPrimitive::Points, nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}}, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transform2D(): the mesh has no positions with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transform2D(): the mesh has no positions with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transform2D(): the mesh has no positions with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transform2D(): the mesh has no positions with index 0 in morph target 37\n");
}
void TransformTest::meshData2DRvaluePassthroughWrongFormat() {
@ -824,10 +823,10 @@ void TransformTest::meshData2DInPlaceNotMutable() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform2DInPlace(mesh, {});
CORRADE_COMPARE(out.str(), "MeshTools::transform2DInPlace(): vertex data not mutable\n");
CORRADE_COMPARE(out, "MeshTools::transform2DInPlace(): vertex data not mutable\n");
}
void TransformTest::meshData2DInPlaceNoPosition() {
@ -840,13 +839,13 @@ void TransformTest::meshData2DInPlaceNoPosition() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform2DInPlace(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transform2DInPlace(): the mesh has no positions with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transform2DInPlace(): the mesh has no positions with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transform2DInPlace(): the mesh has no positions with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transform2DInPlace(): the mesh has no positions with index 0 in morph target 37\n");
}
void TransformTest::meshData2DInPlaceWrongFormat() {
@ -857,10 +856,10 @@ void TransformTest::meshData2DInPlaceWrongFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2us, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform2DInPlace(mesh, {}, 1);
CORRADE_COMPARE(out.str(), "MeshTools::transform2DInPlace(): expected VertexFormat::Vector2 positions but got VertexFormat::Vector2us\n");
CORRADE_COMPARE(out, "MeshTools::transform2DInPlace(): expected VertexFormat::Vector2 positions but got VertexFormat::Vector2us\n");
}
template<class T, class U, class V, class W> void TransformTest::meshData3D() {
@ -1002,13 +1001,13 @@ void TransformTest::meshData3DNoPosition() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform3D(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transform3D(): the mesh has no positions with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transform3D(): the mesh has no positions with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transform3D(): the mesh has no positions with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transform3D(): the mesh has no positions with index 0 in morph target 37\n");
}
void TransformTest::meshData3DNot3D() {
@ -1018,10 +1017,10 @@ void TransformTest::meshData3DNot3D() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform3D(mesh, {});
CORRADE_COMPARE(out.str(), "MeshTools::transform3D(): expected 3D positions but got VertexFormat::Vector2\n");
CORRADE_COMPARE(out, "MeshTools::transform3D(): expected 3D positions but got VertexFormat::Vector2\n");
}
void TransformTest::meshData3DImplementationSpecificIndexType() {
@ -1060,10 +1059,10 @@ void TransformTest::meshData3DImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{data.otherAttribute, data.otherAttributeFormat, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform3D(mesh, {}, 1);
CORRADE_COMPARE(out.str(), Utility::formatString("MeshTools::transform3D(): {} have an implementation-specific format 0xcaca\n", data.name));
CORRADE_COMPARE(out, Utility::format("MeshTools::transform3D(): {} have an implementation-specific format 0xcaca\n", data.name));
}
void TransformTest::meshData3DRvaluePassthrough() {
@ -1287,15 +1286,15 @@ void TransformTest::meshData3DRvaluePassthroughNoPosition() {
/* Mainly to verify there's no other accidental assertion from checking
vertex format and that the ID + morph target ID gets correctly passed
through, this message comes from the l-value overload */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform3D(Trade::MeshData{MeshPrimitive::Points, nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
}}, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transform3D(): the mesh has no positions with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transform3D(): the mesh has no positions with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transform3D(): the mesh has no positions with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transform3D(): the mesh has no positions with index 0 in morph target 37\n");
}
void TransformTest::meshData3DRvaluePassthroughWrongFormat() {
@ -1392,10 +1391,10 @@ void TransformTest::meshData3DInPlaceNotMutable() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform3DInPlace(mesh, {});
CORRADE_COMPARE(out.str(), "MeshTools::transform3DInPlace(): vertex data not mutable\n");
CORRADE_COMPARE(out, "MeshTools::transform3DInPlace(): vertex data not mutable\n");
}
void TransformTest::meshData3DInPlaceNoPosition() {
@ -1408,13 +1407,13 @@ void TransformTest::meshData3DInPlaceNoPosition() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform3DInPlace(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transform3DInPlace(): the mesh has no positions with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transform3DInPlace(): the mesh has no positions with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transform3DInPlace(): the mesh has no positions with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transform3DInPlace(): the mesh has no positions with index 0 in morph target 37\n");
}
void TransformTest::meshData3DInPlaceWrongFormat() {
@ -1439,10 +1438,10 @@ void TransformTest::meshData3DInPlaceWrongFormat() {
Trade::MeshData mesh{MeshPrimitive::Points, nullptr, Utility::move(attributes)};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transform3DInPlace(mesh, {}, 1);
CORRADE_COMPARE(out.str(), data.message);
CORRADE_COMPARE(out, data.message);
}
template<class T> void TransformTest::meshDataTextureCoordinates2D() {
@ -1518,13 +1517,13 @@ void TransformTest::meshDataTextureCoordinates2DNoCoordinates() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transformTextureCoordinates2D(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2D(): the mesh has no texture coordinates with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2D(): the mesh has no texture coordinates with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2D(): the mesh has no texture coordinates with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2D(): the mesh has no texture coordinates with index 0 in morph target 37\n");
}
void TransformTest::meshDataTextureCoordinates2DImplementationSpecificIndexType() {
@ -1558,10 +1557,10 @@ void TransformTest::meshDataTextureCoordinates2DImplementationSpecificVertexForm
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, vertexFormatWrap(0xcaca), nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transformTextureCoordinates2D(mesh, {}, 1);
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2D(): texture coordinates have an implementation-specific format 0xcaca\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2D(): texture coordinates have an implementation-specific format 0xcaca\n");
}
void TransformTest::meshDataTextureCoordinates2DRvaluePassthrough() {
@ -1727,15 +1726,15 @@ void TransformTest::meshDataTextureCoordinates2DRvaluePassthroughNoCoordinates()
/* Mainly to verify there's no other accidental assertion from checking
vertex format and that the ID + morph target ID gets correctly passed
through, this message comes from the l-value overload */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transformTextureCoordinates2D(Trade::MeshData{MeshPrimitive::Points, nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}}, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2D(): the mesh has no texture coordinates with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2D(): the mesh has no texture coordinates with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2D(): the mesh has no texture coordinates with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2D(): the mesh has no texture coordinates with index 0 in morph target 37\n");
}
void TransformTest::meshDataTextureCoordinates2DRvaluePassthroughWrongFormat() {
@ -1777,10 +1776,10 @@ void TransformTest::meshDataTextureCoordinates2DInPlaceNotMutable() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transformTextureCoordinates2DInPlace(mesh, {});
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2DInPlace(): vertex data not mutable\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2DInPlace(): vertex data not mutable\n");
}
void TransformTest::meshDataTextureCoordinates2DInPlaceNoCoordinates() {
@ -1793,13 +1792,13 @@ void TransformTest::meshDataTextureCoordinates2DInPlaceNoCoordinates() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transformTextureCoordinates2DInPlace(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1)
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2DInPlace(): the mesh has no texture coordinates with index 1\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2DInPlace(): the mesh has no texture coordinates with index 1\n");
else
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2DInPlace(): the mesh has no texture coordinates with index 0 in morph target 37\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2DInPlace(): the mesh has no texture coordinates with index 0 in morph target 37\n");
}
void TransformTest::meshDataTextureCoordinates2DInPlaceWrongFormat() {
@ -1810,10 +1809,10 @@ void TransformTest::meshDataTextureCoordinates2DInPlaceWrongFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2us, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
transformTextureCoordinates2DInPlace(mesh, {}, 1);
CORRADE_COMPARE(out.str(), "MeshTools::transformTextureCoordinates2DInPlace(): expected VertexFormat::Vector2 texture coordinates but got VertexFormat::Vector2us\n");
CORRADE_COMPARE(out, "MeshTools::transformTextureCoordinates2DInPlace(): expected VertexFormat::Vector2 texture coordinates but got VertexFormat::Vector2us\n");
}
}}}}

49
src/Magnum/SceneGraph/Test/AnimableTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/SceneGraph/AbstractFeature.hpp"
#include "Magnum/SceneGraph/Animable.hpp"
@ -82,15 +81,15 @@ template<class T> void AnimableTest::state() {
this->setDuration(1.0f);
}
std::string trackedState;
Containers::String trackedState;
protected:
void animationStep(Float, Float) override {}
void animationStarted() override { trackedState += "started"; }
void animationPaused() override { trackedState += "paused"; }
void animationResumed() override { trackedState += "resumed"; }
void animationStopped() override { trackedState += "stopped"; }
void animationStarted() override { trackedState = trackedState + "started"; }
void animationPaused() override { trackedState = trackedState + "paused"; }
void animationResumed() override { trackedState = trackedState + "resumed"; }
void animationStopped() override { trackedState = trackedState + "stopped"; }
};
Object3D<T> object;
@ -100,9 +99,9 @@ template<class T> void AnimableTest::state() {
/* Verify initial state */
StateTrackingAnimable animable(object, &group);
CORRADE_COMPARE(animable.state(), AnimationState::Stopped);
CORRADE_VERIFY(animable.trackedState.empty());
CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f);
CORRADE_VERIFY(animable.trackedState.empty());
CORRADE_COMPARE(animable.trackedState, "");
CORRADE_COMPARE(group.runningCount(), 0);
/* Stopped -> paused is not supported */
@ -112,36 +111,36 @@ template<class T> void AnimableTest::state() {
/* Stopped -> running */
CORRADE_COMPARE(animable.state(), AnimationState::Stopped);
animable.trackedState.clear();
animable.trackedState = {};
animable.setState(AnimationState::Running);
CORRADE_VERIFY(animable.trackedState.empty());
CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "started");
CORRADE_COMPARE(group.runningCount(), 1);
/* Running -> paused */
CORRADE_COMPARE(animable.state(), AnimationState::Running);
animable.trackedState.clear();
animable.trackedState = {};
animable.setState(AnimationState::Paused);
CORRADE_VERIFY(animable.trackedState.empty());
CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "paused");
CORRADE_COMPARE(group.runningCount(), 0);
/* Paused -> running */
CORRADE_COMPARE(animable.state(), AnimationState::Paused);
animable.trackedState.clear();
animable.trackedState = {};
animable.setState(AnimationState::Running);
CORRADE_VERIFY(animable.trackedState.empty());
CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "resumed");
CORRADE_COMPARE(group.runningCount(), 1);
/* Running -> stopped */
CORRADE_COMPARE(animable.state(), AnimationState::Running);
animable.trackedState.clear();
animable.trackedState = {};
animable.setState(AnimationState::Stopped);
CORRADE_VERIFY(animable.trackedState.empty());
CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "stopped");
CORRADE_COMPARE(group.runningCount(), 0);
@ -152,9 +151,9 @@ template<class T> void AnimableTest::state() {
/* Paused -> stopped */
CORRADE_COMPARE(animable.state(), AnimationState::Paused);
animable.trackedState.clear();
animable.trackedState = {};
animable.setState(AnimationState::Stopped);
CORRADE_VERIFY(animable.trackedState.empty());
CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "stopped");
CORRADE_COMPARE(group.runningCount(), 0);
@ -177,7 +176,7 @@ template<class T> class OneShotAnimable: public SceneGraph::BasicAnimable3D<T> {
}
Float time;
std::string stateChanges;
Containers::String stateChanges;
protected:
void animationStep(Float t, Float) override {
@ -185,11 +184,11 @@ template<class T> class OneShotAnimable: public SceneGraph::BasicAnimable3D<T> {
}
void animationStarted() override {
stateChanges += "started;";
stateChanges = stateChanges + "started;";
}
void animationStopped() override {
stateChanges += "stopped;";
stateChanges = stateChanges + "stopped;";
}
};
@ -401,9 +400,9 @@ void AnimableTest::deleteWhileRunning() {
}
void AnimableTest::debug() {
std::ostringstream o;
Debug(&o) << AnimationState::Running << AnimationState(0xbe);
CORRADE_COMPARE(o.str(), "SceneGraph::AnimationState::Running SceneGraph::AnimationState(0xbe)\n");
Containers::String out;
Debug{&out} << AnimationState::Running << AnimationState(0xbe);
CORRADE_COMPARE(out, "SceneGraph::AnimationState::Running SceneGraph::AnimationState(0xbe)\n");
}
}}}}

11
src/Magnum/SceneGraph/Test/DualComplexTransformationTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/SceneGraph/DualComplexTransformation.h"
#include "Magnum/SceneGraph/Object.hpp"
@ -145,10 +144,10 @@ template<class T> void DualComplexTransformationTest::setTransformationInvalid()
Object2D<T> o;
/* Can't transform with non-rigid transformation */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
o.setTransformation(Math::DualComplex<T>({T(1.0), T(2.0)}, {}));
CORRADE_COMPARE(out.str(), "SceneGraph::DualComplexTransformation::setTransformation(): the dual complex number is not normalized\n");
CORRADE_COMPARE(out, "SceneGraph::DualComplexTransformation::setTransformation(): the dual complex number is not normalized\n");
}
template<class T> void DualComplexTransformationTest::resetTransformation() {
@ -184,10 +183,10 @@ template<class T> void DualComplexTransformationTest::transformInvalid() {
/* Can't transform with non-rigid transformation */
Object2D<T> o;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
o.transform(Math::DualComplex<T>{{T(1.0), T(2.0)}, {}});
CORRADE_COMPARE(out.str(), "SceneGraph::DualComplexTransformation::transform(): the dual complex number is not normalized\n");
CORRADE_COMPARE(out, "SceneGraph::DualComplexTransformation::transform(): the dual complex number is not normalized\n");
}
template<class T> void DualComplexTransformationTest::translate() {

15
src/Magnum/SceneGraph/Test/DualQuaternionTransformationTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/SceneGraph/DualQuaternionTransformation.h"
#include "Magnum/SceneGraph/Object.hpp"
@ -102,10 +101,10 @@ template<class T> void DualQuaternionTransformationTest::fromMatrixInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Implementation::Transformation<BasicDualQuaternionTransformation<T>>::fromMatrix(Math::Matrix4<T>::scaling(Math::Vector3<T>{T(4.0)}));
CORRADE_COMPARE(out.str(), "SceneGraph::DualQuaternionTransformation: the matrix doesn't represent rigid transformation\n");
CORRADE_COMPARE(out, "SceneGraph::DualQuaternionTransformation: the matrix doesn't represent rigid transformation\n");
}
template<class T> void DualQuaternionTransformationTest::toMatrix() {
@ -160,10 +159,10 @@ template<class T> void DualQuaternionTransformationTest::setTransformationInvali
Object3D<T> o;
/* Can't transform with non-rigid transformation */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
o.setTransformation(Math::DualQuaternion<T>({{T(1.0), T(2.0), T(3.0)}, T(4.0)}, {}));
CORRADE_COMPARE(out.str(), "SceneGraph::DualQuaternionTransformation::setTransformation(): the dual quaternion is not normalized\n");
CORRADE_COMPARE(out, "SceneGraph::DualQuaternionTransformation::setTransformation(): the dual quaternion is not normalized\n");
}
template<class T> void DualQuaternionTransformationTest::resetTransformation() {
@ -199,10 +198,10 @@ template<class T> void DualQuaternionTransformationTest::transformInvalid() {
/* Can't transform with non-rigid transformation */
Object3D<T> o;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
o.transform(Math::DualQuaternion<T>({{T(1.0), T(2.0), T(3.0)}, T(4.0)}, {}));
CORRADE_COMPARE(out.str(), "SceneGraph::DualQuaternionTransformation::transform(): the dual quaternion is not normalized\n");
CORRADE_COMPARE(out, "SceneGraph::DualQuaternionTransformation::transform(): the dual quaternion is not normalized\n");
}
template<class T> void DualQuaternionTransformationTest::translate() {

23
src/Magnum/SceneGraph/Test/ObjectTest.cpp

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Format.h>
#include "Magnum/SceneGraph/AbstractFeature.hpp"
#include "Magnum/SceneGraph/MatrixTransformation3D.hpp"
@ -280,11 +279,11 @@ template<class T> void ObjectTest::setParentKeepTransformationInvalid() {
Object3D<T>* child = new Object3D<T>(&root);
/* Old parent and new parent must share the same scene */
std::ostringstream o;
Error redirectError{&o};
Containers::String out;
Error redirectError{&out};
Scene3D<T> scene;
child->setParentKeepTransformation(&scene);
CORRADE_COMPARE(o.str(), "SceneGraph::Object::setParentKeepTransformation(): both parents must be in the same scene\n");
CORRADE_COMPARE(out, "SceneGraph::Object::setParentKeepTransformation(): both parents must be in the same scene\n");
}
template<class T> void ObjectTest::absoluteTransformation() {
@ -389,14 +388,14 @@ template<class T> void ObjectTest::transformationsOrphan() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream o;
Error redirectError{&o};
Containers::String out;
Error redirectError{&out};
/* Transformation of objects not part of the same scene */
Scene3D<T> s;
Object3D<T> orphan;
CORRADE_COMPARE(s.transformations({orphan}), std::vector<Math::Matrix4<T>>{});
CORRADE_COMPARE(o.str(), "SceneGraph::Object::transformations(): the objects are not part of the same tree\n");
CORRADE_COMPARE(out, "SceneGraph::Object::transformations(): the objects are not part of the same tree\n");
}
template<class T> void ObjectTest::transformationsDuplicate() {
@ -662,7 +661,7 @@ void ObjectTest::treeDestructionOrder() {
int id;
};
std::stringstream out;
Containers::String out;
Debug redirectOutput{&out};
{
struct Scene: Scene3D<Float> {
@ -689,7 +688,7 @@ void ObjectTest::treeDestructionOrder() {
AccessingParent{5, nullptr};
AccessingObject{b, 4};
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Destructing an object 5 with 0 parents and no scene\n"
"Destructing a feature 4 attached to an object 1\n");
}
@ -701,7 +700,7 @@ void ObjectTest::treeDestructionOrder() {
"a scene" /* See below. */
#endif
;
CORRADE_COMPARE(out.str(), Utility::formatString(
CORRADE_COMPARE(out, Utility::format(
"Destructing an object 5 with 0 parents and no scene\n"
"Destructing a feature 4 attached to an object 1\n"

15
src/Magnum/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Complex.h"
#include "Magnum/SceneGraph/Object.hpp"
@ -105,10 +104,10 @@ template<class T> void RigidMatrixTransformation2DTest::fromMatrixInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
Implementation::Transformation<BasicRigidMatrixTransformation2D<T>>::fromMatrix(Math::Matrix3<T>::scaling(Math::Vector2<T>{T(4.0)}));
CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation2D: the matrix doesn't represent rigid transformation\n");
CORRADE_COMPARE(out, "SceneGraph::RigidMatrixTransformation2D: the matrix doesn't represent rigid transformation\n");
}
template<class T> void RigidMatrixTransformation2DTest::toMatrix() {
@ -161,10 +160,10 @@ template<class T> void RigidMatrixTransformation2DTest::setTransformationInvalid
Object2D<T> o;
/* Can't transform with non-rigid transformation */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
o.setTransformation(Math::Matrix3<T>::scaling(Math::Vector2<T>{T(3.0)}));
CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation2D::setTransformation(): the matrix doesn't represent rigid transformation\n");
CORRADE_COMPARE(out, "SceneGraph::RigidMatrixTransformation2D::setTransformation(): the matrix doesn't represent rigid transformation\n");
}
template<class T> void RigidMatrixTransformation2DTest::resetTransformation() {
@ -200,10 +199,10 @@ template<class T> void RigidMatrixTransformation2DTest::transformInvalid() {
/* Can't transform with non-rigid transformation */
Object2D<T> o;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
o.transform(Math::Matrix3<T>::scaling(Math::Vector2<T>{T(3.0)}));
CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation2D::transform(): the matrix doesn't represent rigid transformation\n");
CORRADE_COMPARE(out, "SceneGraph::RigidMatrixTransformation2D::transform(): the matrix doesn't represent rigid transformation\n");
}
template<class T> void RigidMatrixTransformation2DTest::translate() {

17
src/Magnum/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Quaternion.h"
#include "Magnum/SceneGraph/Object.hpp"
@ -105,10 +104,10 @@ template<class T> void RigidMatrixTransformation3DTest::fromMatrixInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream o;
Error redirectError{&o};
Containers::String out;
Error redirectError{&out};
Implementation::Transformation<BasicRigidMatrixTransformation3D<T>>::fromMatrix(Math::Matrix4<T>::scaling(Math::Vector3<T>(T(4.0))));
CORRADE_COMPARE(o.str(), "SceneGraph::RigidMatrixTransformation3D: the matrix doesn't represent rigid transformation\n");
CORRADE_COMPARE(out, "SceneGraph::RigidMatrixTransformation3D: the matrix doesn't represent rigid transformation\n");
}
template<class T> void RigidMatrixTransformation3DTest::toMatrix() {
@ -162,10 +161,10 @@ template<class T> void RigidMatrixTransformation3DTest::setTransformationInvalid
Object3D<T> o;
/* Can't transform with non-rigid transformation */
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
o.setTransformation(Math::Matrix4<T>::scaling(Math::Vector3<T>(T(3.0))));
CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation3D::setTransformation(): the matrix doesn't represent rigid transformation\n");
CORRADE_COMPARE(out, "SceneGraph::RigidMatrixTransformation3D::setTransformation(): the matrix doesn't represent rigid transformation\n");
}
template<class T> void RigidMatrixTransformation3DTest::resetTransformation() {
@ -201,10 +200,10 @@ template<class T> void RigidMatrixTransformation3DTest::transformInvalid() {
/* Can't transform with non-rigid transformation */
Object3D<T> o;
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
o.transform(Math::Matrix4<T>::scaling(Math::Vector3<T>(T(3.0))));
CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation3D::transform(): the matrix doesn't represent rigid transformation\n");
CORRADE_COMPARE(out, "SceneGraph::RigidMatrixTransformation3D::transform(): the matrix doesn't represent rigid transformation\n");
}
template<class T> void RigidMatrixTransformation3DTest::translate() {

9
src/Magnum/SceneGraph/Test/TranslationTransformationTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/SceneGraph/Object.hpp"
#include "Magnum/SceneGraph/TranslationTransformation.h"
@ -92,10 +91,10 @@ template<class T> void TranslationTransformationTest::fromMatrixInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream o;
Error redirectError{&o};
Containers::String out;
Error redirectError{&out};
Implementation::Transformation<BasicTranslationTransformation2D<T>>::fromMatrix(Math::Matrix3<T>::scaling(Math::Vector2<T>{T(4.0)}));
CORRADE_COMPARE(o.str(), "SceneGraph::TranslationTransformation: the matrix doesn't represent pure translation\n");
CORRADE_COMPARE(out, "SceneGraph::TranslationTransformation: the matrix doesn't represent pure translation\n");
}
template<class T> void TranslationTransformationTest::toMatrix() {

16
src/Magnum/SceneTools/Test/CombineTest.cpp

@ -24,17 +24,15 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StridedBitArrayView.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Complex.h"
#include "Magnum/Math/Vector2.h"
@ -996,7 +994,7 @@ void CombineTest::fieldsSharedMappingExpected() {
UnsignedInt meshes[3]{};
Int materials[3]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFields(Trade::SceneMappingType::UnsignedInt, 3, {
Trade::SceneFieldData{Trade::SceneField::Mesh,
@ -1014,7 +1012,7 @@ void CombineTest::fieldsSharedMappingExpected() {
Containers::ArrayView<UnsignedInt>{nullptr, 3},
Containers::arrayView(materials)},
});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::combineFields(): Trade::SceneField::MeshMaterial mapping data {0xbeef, 2, 4} is different from Trade::SceneField::Mesh mapping data {0xdead, 3, 4}\n"
/* Placeholder mapping is also disallowed right now -- it has to be
either all placeholders or none */
@ -1030,7 +1028,7 @@ void CombineTest::fieldsStringPlaceholder() {
} data[3]{};
auto view = Containers::stridedArrayView(data);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* A null string data pointer could work in this case (because it doesn't
need to be accessed), but disallowing it always for consistency */
@ -1060,7 +1058,7 @@ void CombineTest::fieldsStringPlaceholder() {
reinterpret_cast<char*>(0xfece5), Trade::SceneFieldType::StringRangeNullTerminated16,
Containers::StridedArrayView1D<const UnsignedShort>{{nullptr, 6}, 3}},
});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::combineFields(): string field 1 has a placeholder string data\n"
"SceneTools::combineFields(): string field 0 has a placeholder data\n");
}
@ -1078,7 +1076,7 @@ void CombineTest::fieldsOffsetOnly() {
};
auto view = Containers::stridedArrayView(data);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
combineFields(Trade::SceneMappingType::UnsignedInt, 173, {
Trade::SceneFieldData{Trade::SceneField::Mesh,
@ -1088,7 +1086,7 @@ void CombineTest::fieldsOffsetOnly() {
Trade::SceneMappingType::UnsignedInt, offsetof(Field, mapping), sizeof(Field),
Trade::SceneFieldType::UnsignedShort, offsetof(Field, light), sizeof(Field)}
});
CORRADE_COMPARE(out.str(), "SceneTools::combineFields(): field 1 is offset-only\n");
CORRADE_COMPARE(out, "SceneTools::combineFields(): field 1 is offset-only\n");
}
void CombineTest::fieldsFromDataOffsetOnly() {

8
src/Magnum/SceneTools/Test/CopyTest.cpp

@ -24,14 +24,12 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream> /** @todo remove once Debug is stream-free */
#include <Corrade/Containers/StridedBitArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stream-free */
#include "Magnum/SceneTools/Copy.h"
#include "Magnum/Trade/SceneData.h"
@ -424,10 +422,10 @@ void CopyTest::mutableReferenceNotMutable() {
}};
CORRADE_COMPARE(scene.dataFlags(), Trade::DataFlag::Global);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::mutableReference(scene);
CORRADE_COMPARE(out.str(), "SceneTools::mutableReference(): data not mutable\n");
CORRADE_COMPARE(out, "SceneTools::mutableReference(): data not mutable\n");
}
}}}}

35
src/Magnum/SceneTools/Test/FilterTest.cpp

@ -24,14 +24,13 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/BitArray.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StridedBitArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Complex.h"
#include "Magnum/Math/Vector2.h"
@ -259,10 +258,10 @@ void FilterTest::fieldsWrongBitCount() {
Containers::arrayView(data)},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
filterFields(scene, Containers::BitArray{ValueInit, 3});
CORRADE_COMPARE(out.str(), "SceneTools::filterFields(): expected 2 bits but got 3\n");
CORRADE_COMPARE(out, "SceneTools::filterFields(): expected 2 bits but got 3\n");
}
void FilterTest::onlyFields() {
@ -632,7 +631,7 @@ void FilterTest::fieldEntriesFieldNotFound() {
Containers::arrayView(data->light)},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
filterFieldEntries(scene, {
{Trade::SceneField::Light, Containers::BitArray{ValueInit, 4}},
@ -642,7 +641,7 @@ void FilterTest::fieldEntriesFieldNotFound() {
{1, Containers::BitArray{ValueInit, 4}},
{2, {}}
});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::filterFieldEntries(): field Trade::SceneField::Parent not found\n"
"SceneTools::filterFieldEntries(): index 2 out of range for 2 fields\n");
}
@ -666,7 +665,7 @@ void FilterTest::fieldEntriesDuplicated() {
Containers::arrayView(data->light)},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* The name-based variant just delegates to this one, no need to test it
as well */
@ -675,7 +674,7 @@ void FilterTest::fieldEntriesDuplicated() {
{0, Containers::BitArray{ValueInit, 5}},
{1, Containers::BitArray{ValueInit, 4}},
});
CORRADE_COMPARE(out.str(), "SceneTools::filterFieldEntries(): field Trade::SceneField::Light listed more than once\n");
CORRADE_COMPARE(out, "SceneTools::filterFieldEntries(): field Trade::SceneField::Light listed more than once\n");
}
void FilterTest::fieldEntriesWrongBitCount() {
@ -697,7 +696,7 @@ void FilterTest::fieldEntriesWrongBitCount() {
Containers::arrayView(data->light)},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* The name-based variant just delegates to this one, no need to test it
as well */
@ -705,7 +704,7 @@ void FilterTest::fieldEntriesWrongBitCount() {
{1, Containers::BitArray{ValueInit, 4}},
{0, Containers::BitArray{ValueInit, 6}}
});
CORRADE_COMPARE(out.str(), "SceneTools::filterFieldEntries(): expected 5 bits for Trade::SceneField::Mesh but got 6\n");
CORRADE_COMPARE(out, "SceneTools::filterFieldEntries(): expected 5 bits for Trade::SceneField::Mesh but got 6\n");
}
void FilterTest::fieldEntriesBitField() {
@ -727,7 +726,7 @@ void FilterTest::fieldEntriesBitField() {
Containers::stridedArrayView(data->visible).sliceBit(0)},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* The name-based variant just delegates to this one, no need to test it
as well */
@ -735,7 +734,7 @@ void FilterTest::fieldEntriesBitField() {
{0, Containers::BitArray{ValueInit, 5}},
{1, Containers::BitArray{ValueInit, 2}}
});
CORRADE_COMPARE(out.str(), "SceneTools::filterFieldEntries(): filtering bit fields is not implemented yet, sorry\n");
CORRADE_COMPARE(out, "SceneTools::filterFieldEntries(): filtering bit fields is not implemented yet, sorry\n");
}
void FilterTest::fieldEntriesStringField() {
@ -759,7 +758,7 @@ void FilterTest::fieldEntriesStringField() {
Containers::arrayView(data->nameRangeNullTerminated)},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
/* The name-based variant just delegates to this one, no need to test it
as well */
@ -767,7 +766,7 @@ void FilterTest::fieldEntriesStringField() {
{0, Containers::BitArray{ValueInit, 5}},
{1, Containers::BitArray{ValueInit, 2}}
});
CORRADE_COMPARE(out.str(), "SceneTools::filterFieldEntries(): filtering string fields is not implemented yet, sorry\n");
CORRADE_COMPARE(out, "SceneTools::filterFieldEntries(): filtering string fields is not implemented yet, sorry\n");
}
void FilterTest::fieldEntriesSharedMapping() {
@ -936,7 +935,7 @@ void FilterTest::fieldEntriesSharedMappingInvalid() {
Containers::BitArray meshesToKeep{ValueInit, 5};
Containers::BitArray meshesToKeepDifferent{DirectInit, 5, true};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
filterFieldEntries(scene, {
{Trade::SceneField::MeshMaterial, meshesToKeep},
@ -951,7 +950,7 @@ void FilterTest::fieldEntriesSharedMappingInvalid() {
{Trade::sceneFieldCustom(1), meshesToKeep},
{Trade::SceneField::MeshMaterial, meshesToKeep},
});
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::filterFieldEntries(): field Trade::SceneField::Custom(1) shares mapping with Trade::SceneField::MeshMaterial but was passed a different mask view\n"
"SceneTools::filterFieldEntries(): field Trade::SceneField::Mesh shares mapping with 3 fields but only 2 are filtered\n"
"SceneTools::filterFieldEntries(): field Trade::SceneField::Custom(1) shares mapping with 3 fields but only 2 are filtered\n");
@ -1258,10 +1257,10 @@ void FilterTest::objectsWrongBitCount() {
Trade::SceneData scene{Trade::SceneMappingType::UnsignedShort, 176, nullptr, {}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
filterObjects(scene, Containers::BitArray{ValueInit, 177});
CORRADE_COMPARE(out.str(), "SceneTools::filterObjects(): expected 176 bits but got 177\n");
CORRADE_COMPARE(out, "SceneTools::filterObjects(): expected 176 bits but got 177\n");
}
}}}}

15
src/Magnum/SceneTools/Test/FlattenMeshHierarchyTest.cpp

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/Triple.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
/* There's no better way to disable file deprecation warnings */
#define _MAGNUM_NO_DEPRECATED_FLATTENMESHHIERARCHY
@ -318,13 +317,13 @@ void FlattenMeshHierarchyTest::not2DNot3D() {
Trade::SceneFieldData{Trade::SceneField::Mesh, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::UnsignedInt, nullptr},
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_IGNORE_DEPRECATED_PUSH
flattenMeshHierarchy2D(scene);
flattenMeshHierarchy3D(scene);
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::absoluteFieldTransformations(): the scene is not 2D\n"
"SceneTools::absoluteFieldTransformations(): the scene is not 3D\n");
}
@ -340,12 +339,12 @@ void FlattenMeshHierarchyTest::noParentField() {
Trade::SceneFieldData{Trade::SceneField::Transformation, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::Matrix3x3, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_IGNORE_DEPRECATED_PUSH
flattenMeshHierarchy2D(scene);
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::absoluteFieldTransformations(): the scene has no hierarchy\n");
}
@ -493,13 +492,13 @@ void FlattenMeshHierarchyTest::intoInvalidSize() {
Matrix3 transformations2D[6];
Matrix4 transformations3D[4];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
CORRADE_IGNORE_DEPRECATED_PUSH
flattenMeshHierarchy2DInto(scene2D, transformations2D);
flattenMeshHierarchy3DInto(scene3D, transformations3D);
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::absoluteFieldTransformationsInto(): bad output size, expected 5 but got 6\n"
"SceneTools::absoluteFieldTransformationsInto(): bad output size, expected 5 but got 4\n");
}

47
src/Magnum/SceneTools/Test/HierarchyTest.cpp

@ -24,12 +24,11 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/Triple.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Matrix3.h"
#include "Magnum/Math/Matrix4.h"
@ -268,11 +267,11 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstNoParentField() {
Trade::SceneData scene{Trade::SceneMappingType::UnsignedByte, 0, nullptr, {}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): the scene has no hierarchy\n"
"SceneTools::childrenDepthFirst(): the scene has no hierarchy\n");
}
@ -295,11 +294,11 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstIntoNoParentField() {
Trade::SceneData scene{Trade::SceneMappingType::UnsignedByte, 0, nullptr, {}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
parentsBreadthFirstInto(scene, nullptr, nullptr);
childrenDepthFirstInto(scene, nullptr, nullptr);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirstInto(): the scene has no hierarchy\n"
"SceneTools::childrenDepthFirstInto(): the scene has no hierarchy\n");
}
@ -340,13 +339,13 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstIntoWrongDestinationSiz
UnsignedInt childCountCorrect[3];
UnsignedInt childCount[2];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
parentsBreadthFirstInto(scene, mappingCorrect, parentOffset);
parentsBreadthFirstInto(scene, mapping, parentOffsetCorrect);
childrenDepthFirstInto(scene, mappingCorrect, childCount);
childrenDepthFirstInto(scene, mapping, childCountCorrect);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirstInto(): expected parent destination view with 3 elements but got 2\n"
"SceneTools::parentsBreadthFirstInto(): expected mapping destination view with 3 elements but got 2\n"
"SceneTools::childrenDepthFirstInto(): expected child count destination view with 3 elements but got 2\n"
@ -376,11 +375,11 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstSparse() {
view.slice(&Field::parent)}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): hierarchy is sparse\n"
"SceneTools::childrenDepthFirst(): hierarchy is sparse\n");
}
@ -406,11 +405,11 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstCyclic() {
view.slice(&Field::parent)}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): hierarchy is sparse\n"
"SceneTools::childrenDepthFirst(): hierarchy is sparse\n");
}
@ -438,11 +437,11 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstCyclicDeep() {
view.slice(&Field::parent)}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): hierarchy is cyclic\n"
"SceneTools::childrenDepthFirst(): hierarchy is cyclic\n");
}
@ -472,12 +471,12 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstSparseAndCyclic() {
view.slice(&Field::parent)}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene);
CORRADE_EXPECT_FAIL("The implementation needs to track already visited objects with a BitArray to detect this, it'd also provide a much better diagnostic.");
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): hierarchy is cyclic\n"
"SceneTools::childrenDepthFirst(): hierarchy is cyclic\n");
}
@ -688,13 +687,13 @@ void HierarchyTest::absoluteFieldTransformationsFieldNotFound() {
Trade::SceneFieldData{Trade::SceneField::Transformation, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::Matrix3x3, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Mesh);
SceneTools::absoluteFieldTransformations3D(scene, Trade::SceneField::Mesh);
SceneTools::absoluteFieldTransformations2D(scene, 2);
SceneTools::absoluteFieldTransformations3D(scene, 2);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::absoluteFieldTransformations(): field Trade::SceneField::Mesh not found\n"
"SceneTools::absoluteFieldTransformations(): field Trade::SceneField::Mesh not found\n"
"SceneTools::absoluteFieldTransformations(): index 2 out of range for 2 fields\n"
@ -708,13 +707,13 @@ void HierarchyTest::absoluteFieldTransformationsNot2DNot3D() {
Trade::SceneFieldData{Trade::SceneField::Parent, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::Int, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Parent);
SceneTools::absoluteFieldTransformations2D(scene, 0);
SceneTools::absoluteFieldTransformations3D(scene, Trade::SceneField::Parent);
SceneTools::absoluteFieldTransformations3D(scene, 0);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::absoluteFieldTransformations(): the scene is not 2D\n"
"SceneTools::absoluteFieldTransformations(): the scene is not 2D\n"
"SceneTools::absoluteFieldTransformations(): the scene is not 3D\n"
@ -728,11 +727,11 @@ void HierarchyTest::absoluteFieldTransformationsNoParentField() {
Trade::SceneFieldData{Trade::SceneField::Transformation, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::Matrix3x3, nullptr}
}};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Transformation);
SceneTools::absoluteFieldTransformations2D(scene, 0);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::absoluteFieldTransformations(): the scene has no hierarchy\n"
"SceneTools::absoluteFieldTransformations(): the scene has no hierarchy\n");
}
@ -877,13 +876,13 @@ void HierarchyTest::absoluteFieldTransformationsIntoInvalidSize() {
Matrix3 transformations2D[6];
Matrix4 transformations3D[4];
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
absoluteFieldTransformations2DInto(scene2D, Trade::SceneField::Mesh, transformations2D);
absoluteFieldTransformations2DInto(scene2D, 1, transformations2D);
absoluteFieldTransformations3DInto(scene3D, Trade::SceneField::Mesh, transformations3D);
absoluteFieldTransformations3DInto(scene3D, 1, transformations3D);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"SceneTools::absoluteFieldTransformationsInto(): bad output size, expected 5 but got 6\n"
"SceneTools::absoluteFieldTransformationsInto(): bad output size, expected 5 but got 6\n"
"SceneTools::absoluteFieldTransformationsInto(): bad output size, expected 5 but got 4\n"

25
src/Magnum/SceneTools/Test/MapTest.cpp

@ -24,16 +24,13 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream> /** @todo remove once Debug is stream-free */
#include <Corrade/Containers/StridedBitArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once Debug is stream-free */
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stream-free */
#include "Magnum/Math/TypeTraits.h"
#include "Magnum/SceneTools/Map.h"
@ -362,13 +359,13 @@ void MapTest::indexFieldFieldNotFound() {
UnsignedInt mapping[5]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
mapIndexField(scene, 2, mapping);
mapIndexFieldInPlace(scene, 2, mapping);
mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping);
mapIndexFieldInPlace(scene, Trade::SceneField::MeshMaterial, mapping);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"SceneTools::mapIndexField(): index 2 out of range for 2 fields\n"
"SceneTools::mapIndexFieldInPlace(): index 2 out of range for 2 fields\n"
"SceneTools::mapIndexField(): field Trade::SceneField::MeshMaterial not found\n"
@ -390,11 +387,11 @@ void MapTest::indexFieldInvalidType() {
UnsignedInt mapping[5]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
mapIndexField(scene, 1, mapping);
mapIndexFieldInPlace(scene, 1, mapping);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"SceneTools::mapIndexField(): unsupported field type Trade::SceneFieldType::Long\n"
"SceneTools::mapIndexFieldInPlace(): unsupported field type Trade::SceneFieldType::Long\n",
TestSuite::Compare::String);
@ -414,11 +411,11 @@ void MapTest::indexFieldArrayField() {
UnsignedInt mapping[5]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
mapIndexField(scene, 1, mapping);
mapIndexFieldInPlace(scene, 1, mapping);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"SceneTools::mapIndexField(): array field mapping isn't supported\n"
"SceneTools::mapIndexFieldInPlace(): array field mapping isn't supported\n",
TestSuite::Compare::String);
@ -448,12 +445,12 @@ void MapTest::indexFieldIndexOutOfBounds() {
const UnsignedInt mapping9[9]{};
const UnsignedInt mapping10[10]{};
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping10);
mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping9);
mapIndexField(scene, Trade::SceneField::Mesh, mapping10);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"SceneTools::mapIndexFieldInPlace(): index -2 out of range for 10 mapping values\n"
"SceneTools::mapIndexFieldInPlace(): index 9 out of range for 9 mapping values\n"
"SceneTools::mapIndexFieldInPlace(): index 10 out of range for 10 mapping values\n",
@ -513,7 +510,7 @@ void MapTest::indexFieldMappingNotRepresentable() {
mapIndexField(scene, Trade::sceneFieldCustom(2), mappingSigned);
mapIndexField(scene, Trade::SceneField::MeshMaterial, mappingSigned);
std::ostringstream out;
Containers::String out;
Error redirectError{&out};
mapIndexFieldInPlace(scene, Trade::SceneField::Mesh, mappingUnsigned);
mapIndexFieldInPlace(scene, Trade::SceneField::Light, mappingUnsigned);
@ -522,7 +519,7 @@ void MapTest::indexFieldMappingNotRepresentable() {
mapIndexFieldInPlace(scene, Trade::sceneFieldCustom(1), mappingSigned);
mapIndexFieldInPlace(scene, Trade::sceneFieldCustom(2), mappingSigned);
mapIndexFieldInPlace(scene, Trade::SceneField::MeshMaterial, mappingSigned);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
"SceneTools::mapIndexFieldInPlace(): mapping value 65536 not representable in Trade::SceneFieldType::UnsignedShort\n"
"SceneTools::mapIndexFieldInPlace(): mapping value 65536 not representable in Trade::SceneFieldType::UnsignedByte\n"
"SceneTools::mapIndexFieldInPlace(): mapping value 2147483648 not representable in Trade::SceneFieldType::Int\n"

58
src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp

@ -24,12 +24,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/ArrayTuple.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/StringToFile.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h>
#include "Magnum/Math/CubicHermite.h"
@ -207,10 +205,10 @@ void SceneConverterImplementationTest::converterInfo() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
Implementation::printSceneConverterInfo(Debug::Flag::DisableColors, *converter);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
"Plugin name: AnySceneConverter\n"
"Features:\n"
" ConvertMeshToFile\n"
@ -231,10 +229,10 @@ void SceneConverterImplementationTest::infoEmpty() {
std::chrono::high_resolution_clock::duration time;
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false);
CORRADE_COMPARE(out.str(), "");
CORRADE_COMPARE(out, "");
}
void SceneConverterImplementationTest::infoScenesObjects() {
@ -332,10 +330,10 @@ void SceneConverterImplementationTest::infoScenesObjects() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join({SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles", data.expected}),
TestSuite::Compare::StringToFile);
}
@ -413,10 +411,10 @@ void SceneConverterImplementationTest::infoAnimations() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-animations.txt"),
TestSuite::Compare::StringToFile);
}
@ -486,10 +484,10 @@ void SceneConverterImplementationTest::infoSkins() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-skins.txt"),
TestSuite::Compare::StringToFile);
}
@ -542,10 +540,10 @@ void SceneConverterImplementationTest::infoLights() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-lights.txt"),
TestSuite::Compare::StringToFile);
}
@ -601,10 +599,10 @@ void SceneConverterImplementationTest::infoCameras() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-cameras.txt"),
TestSuite::Compare::StringToFile);
}
@ -668,10 +666,10 @@ void SceneConverterImplementationTest::infoMaterials() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-materials.txt"),
TestSuite::Compare::StringToFile);
}
@ -768,10 +766,10 @@ void SceneConverterImplementationTest::infoMeshes() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-meshes.txt"),
TestSuite::Compare::StringToFile);
}
@ -850,10 +848,10 @@ void SceneConverterImplementationTest::infoMeshesBounds() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-meshes-bounds.txt"),
TestSuite::Compare::StringToFile);
}
@ -908,10 +906,10 @@ void SceneConverterImplementationTest::infoTextures() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-textures.txt"),
TestSuite::Compare::StringToFile);
}
@ -945,10 +943,10 @@ void SceneConverterImplementationTest::infoImages() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-images.txt"),
TestSuite::Compare::StringToFile);
}
@ -1242,10 +1240,10 @@ void SceneConverterImplementationTest::infoReferenceCount() {
Debug{} << "======================== visual color verification end =========================";
}
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false);
CORRADE_COMPARE_AS(out.str(),
CORRADE_COMPARE_AS(out,
Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-references.txt"),
TestSuite::Compare::StringToFile);
}
@ -1330,12 +1328,12 @@ void SceneConverterImplementationTest::infoError() {
std::chrono::high_resolution_clock::duration time;
std::ostringstream out;
Containers::String out;
Debug redirectOutput{&out};
Error redirectError{&out};
/* It should return a failure */
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == true);
CORRADE_COMPARE(out.str(),
CORRADE_COMPARE(out,
/* It should not exit after first error... */
"Scene 0 error!\n"
"Can't import scene 0\n"

365
src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp

File diff suppressed because it is too large Load Diff

7
src/Magnum/ShaderTools/Test/StageTest.cpp

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/ShaderTools/Stage.h"
@ -43,10 +42,10 @@ StageTest::StageTest() {
}
void StageTest::debug() {
std::ostringstream out;
Containers::String out;
Debug{&out} << Stage::RayMiss << Stage(0xf0);
CORRADE_COMPARE(out.str(), "ShaderTools::Stage::RayMiss ShaderTools::Stage(0xf0)\n");
CORRADE_COMPARE(out, "ShaderTools::Stage::RayMiss ShaderTools::Stage(0xf0)\n");
}
}}}}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save