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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Animation/Easing.h" #include "Magnum/Animation/Easing.h"
#include "Magnum/Animation/Interpolation.h" #include "Magnum/Animation/Interpolation.h"
@ -225,12 +224,12 @@ void InterpolationTest::interpolatorFor() {
void InterpolationTest::interpolatorForInvalid() { void InterpolationTest::interpolatorForInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<Float>(Interpolation::Spline); Animation::interpolatorFor<Float>(Interpolation::Spline);
Animation::interpolatorFor<Float>(Interpolation(0xde)); 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::Spline\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -245,12 +244,12 @@ void InterpolationTest::interpolatorForBool() {
void InterpolationTest::interpolatorForBoolInvalid() { void InterpolationTest::interpolatorForBoolInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<bool>(Interpolation::Custom); Animation::interpolatorFor<bool>(Interpolation::Custom);
Animation::interpolatorFor<bool>(Interpolation(0xde)); 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::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -265,12 +264,12 @@ void InterpolationTest::interpolatorForBitVector() {
void InterpolationTest::interpolatorForBitVectorInvalid() { void InterpolationTest::interpolatorForBitVectorInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<Math::BitVector<4>>(Interpolation::Custom); Animation::interpolatorFor<Math::BitVector<4>>(Interpolation::Custom);
Animation::interpolatorFor<Math::BitVector<4>>(Interpolation(0xde)); 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::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -289,12 +288,12 @@ void InterpolationTest::interpolatorForComplex() {
void InterpolationTest::interpolatorForComplexInvalid() { void InterpolationTest::interpolatorForComplexInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<Complex>(Interpolation::Custom); Animation::interpolatorFor<Complex>(Interpolation::Custom);
Animation::interpolatorFor<Complex>(Interpolation(0xde)); 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::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -313,12 +312,12 @@ void InterpolationTest::interpolatorForQuaternion() {
void InterpolationTest::interpolatorForQuaternionInvalid() { void InterpolationTest::interpolatorForQuaternionInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<Quaternion>(Interpolation::Spline); Animation::interpolatorFor<Quaternion>(Interpolation::Spline);
Animation::interpolatorFor<Quaternion>(Interpolation(0xde)); 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::Spline\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -337,12 +336,12 @@ void InterpolationTest::interpolatorForDualQuaternion() {
void InterpolationTest::interpolatorForDualQuaternionInvalid() { void InterpolationTest::interpolatorForDualQuaternionInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<DualQuaternion>(Interpolation::Custom); Animation::interpolatorFor<DualQuaternion>(Interpolation::Custom);
Animation::interpolatorFor<DualQuaternion>(Interpolation(0xde)); 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::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -358,12 +357,12 @@ void InterpolationTest::interpolatorForCubicHermiteScalar() {
void InterpolationTest::interpolatorForCubicHermiteScalarInvalid() { void InterpolationTest::interpolatorForCubicHermiteScalarInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<CubicHermite1D>(Interpolation::Custom); Animation::interpolatorFor<CubicHermite1D>(Interpolation::Custom);
Animation::interpolatorFor<CubicHermite1D>(Interpolation(0xde)); 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::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -379,12 +378,12 @@ void InterpolationTest::interpolatorForCubicHermiteVector() {
void InterpolationTest::interpolatorForCubicHermiteVectorInvalid() { void InterpolationTest::interpolatorForCubicHermiteVectorInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<CubicHermite2D>(Interpolation::Custom); Animation::interpolatorFor<CubicHermite2D>(Interpolation::Custom);
Animation::interpolatorFor<CubicHermite2D>(Interpolation(0xde)); 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::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -400,12 +399,12 @@ void InterpolationTest::interpolatorForCubicHermiteComplex() {
void InterpolationTest::interpolatorForCubicHermiteComplexInvalid() { void InterpolationTest::interpolatorForCubicHermiteComplexInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<CubicHermiteComplex>(Interpolation::Custom); Animation::interpolatorFor<CubicHermiteComplex>(Interpolation::Custom);
Animation::interpolatorFor<CubicHermiteComplex>(Interpolation(0xde)); 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::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -427,12 +426,12 @@ void InterpolationTest::interpolatorForCubicHermiteQuaternion() {
void InterpolationTest::interpolatorForCubicHermiteQuaternionInvalid() { void InterpolationTest::interpolatorForCubicHermiteQuaternionInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Animation::interpolatorFor<CubicHermiteQuaternion>(Interpolation::Custom); Animation::interpolatorFor<CubicHermiteQuaternion>(Interpolation::Custom);
Animation::interpolatorFor<CubicHermiteQuaternion>(Interpolation(0xde)); 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::Custom\n"
"Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n"); "Animation::interpolatorFor(): can't deduce interpolator function for Animation::Interpolation(0xde)\n");
} }
@ -544,7 +543,7 @@ void InterpolationTest::interpolateStrictIntegerKey() {
void InterpolationTest::interpolateError() { void InterpolationTest::interpolateError() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&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); 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"); "Animation::interpolate(): keys and values don't have the same size\n");
} }
void InterpolationTest::interpolateStrictError() { void InterpolationTest::interpolateStrictError() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
{ {
@ -575,7 +574,7 @@ void InterpolationTest::interpolateStrictError() {
Math::lerp, 0.0f, hint); Math::lerp, 0.0f, hint);
} }
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"Animation::interpolateStrict(): at least two keyframes required\n" "Animation::interpolateStrict(): at least two keyframes required\n"
"Animation::interpolateStrict(): keys and values don't have the same size\n"); "Animation::interpolateStrict(): keys and values don't have the same size\n");
} }
@ -629,31 +628,31 @@ void InterpolationTest::unpackEaseClamped() {
} }
void InterpolationTest::debugInterpolation() { void InterpolationTest::debugInterpolation() {
std::ostringstream out; Containers::String out;
Debug{&out} << Interpolation::Custom << Interpolation(0xde); 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() { void InterpolationTest::debugInterpolationPacked() {
std::ostringstream out; Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */ /* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << Interpolation::Custom << Debug::packed << Interpolation(0xde) << Interpolation::Constant; 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() { void InterpolationTest::debugExtrapolation() {
std::ostringstream out; Containers::String out;
Debug{&out} << Extrapolation::DefaultConstructed << Extrapolation(0xde); 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() { void InterpolationTest::debugExtrapolationPacked() {
std::ostringstream out; Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */ /* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << Extrapolation::DefaultConstructed << Debug::packed << Extrapolation(0xde) << Extrapolation::Constant; 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Reference.h> #include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/Numeric.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" #include "Magnum/Animation/Player.h"
@ -329,7 +329,7 @@ void PlayerTest::setDurationReplace() {
void PlayerTest::trackInvalidIndex() { void PlayerTest::trackInvalidIndex() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Float value; Float value;
@ -340,7 +340,7 @@ void PlayerTest::trackInvalidIndex() {
player.track(1); 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() { void PlayerTest::advanceNotRunning() {
@ -1400,10 +1400,10 @@ void PlayerTest::runFor100YearsChrono() {
} }
void PlayerTest::debugState() { void PlayerTest::debugState() {
std::ostringstream out; Containers::String out;
Debug{&out} << State::Playing << State(0xde); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.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/Animation/Track.h"
#include "Magnum/Math/Half.h" #include "Magnum/Math/Half.h"
@ -571,10 +571,10 @@ void TrackViewTest::constructInconsistentViewSize() {
Float keys[2]{}; Float keys[2]{};
Vector3 values[3]{}; Vector3 values[3]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
TrackView<Float, Vector3>{keys, values, Math::select}; 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() { void TrackViewTest::constructCopyStorage() {

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

@ -24,14 +24,13 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <string> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */ #include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h> #include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include "Magnum/Audio/AbstractImporter.h" #include "Magnum/Audio/AbstractImporter.h"
@ -187,13 +186,13 @@ void AbstractImporterTest::openFileAsDataNotFound() {
bool _opened = false; bool _opened = false;
} importer; } importer;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!importer.openFile("nonexistent.bin")); CORRADE_VERIFY(!importer.openFile("nonexistent.bin"));
CORRADE_VERIFY(!importer.isOpened()); CORRADE_VERIFY(!importer.isOpened());
/* There's an error from Path::read() before */ /* 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", "\nAudio::AbstractImporter::openFile(): cannot open file nonexistent.bin\n",
TestSuite::Compare::StringHasSuffix); TestSuite::Compare::StringHasSuffix);
} }
@ -211,11 +210,11 @@ void AbstractImporterTest::openFileNotImplemented() {
Containers::Array<char> doData() override { return nullptr; } Containers::Array<char> doData() override { return nullptr; }
} importer; } importer;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!importer.openFile("file.dat")); 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() { void AbstractImporterTest::openDataNotSupported() {
@ -231,11 +230,11 @@ void AbstractImporterTest::openDataNotSupported() {
Containers::Array<char> doData() override { return nullptr; } Containers::Array<char> doData() override { return nullptr; }
} importer; } importer;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!importer.openData(nullptr)); 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() { void AbstractImporterTest::openDataNotImplemented() {
@ -251,11 +250,11 @@ void AbstractImporterTest::openDataNotImplemented() {
Containers::Array<char> doData() override { return nullptr; } Containers::Array<char> doData() override { return nullptr; }
} importer; } importer;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!importer.openData(nullptr)); 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() { void AbstractImporterTest::format() {
@ -285,11 +284,11 @@ void AbstractImporterTest::formatNoFile() {
Containers::Array<char> doData() override { return nullptr; } Containers::Array<char> doData() override { return nullptr; }
} importer; } importer;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
importer.format(); 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() { void AbstractImporterTest::frequency() {
@ -319,11 +318,11 @@ void AbstractImporterTest::frequencyNoFile() {
Containers::Array<char> doData() override { return nullptr; } Containers::Array<char> doData() override { return nullptr; }
} importer; } importer;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
importer.frequency(); 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() { void AbstractImporterTest::data() {
@ -357,11 +356,11 @@ void AbstractImporterTest::dataNoFile() {
Containers::Array<char> doData() override { return nullptr; } Containers::Array<char> doData() override { return nullptr; }
} importer; } importer;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
importer.data(); 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() { void AbstractImporterTest::dataCustomDeleter() {
@ -379,39 +378,39 @@ void AbstractImporterTest::dataCustomDeleter() {
} }
} importer; } importer;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
importer.data(); 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() { void AbstractImporterTest::debugFeature() {
std::ostringstream out; Containers::String out;
Debug{&out} << ImporterFeature::OpenData << ImporterFeature(0xf0); 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() { void AbstractImporterTest::debugFeaturePacked() {
std::ostringstream out; Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */ /* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ImporterFeature::OpenData << Debug::packed << ImporterFeature(0xf0) << ImporterFeature::OpenData; 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() { void AbstractImporterTest::debugFeatures() {
std::ostringstream out; Containers::String out;
Debug{&out} << (ImporterFeature::OpenData|ImporterFeature(0xf0)) << ImporterFeatures{}; 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() { void AbstractImporterTest::debugFeaturesPacked() {
std::ostringstream out; Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */ /* 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; 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Audio/BufferFormat.h" #include "Magnum/Audio/BufferFormat.h"
@ -43,9 +42,9 @@ BufferFormatTest::BufferFormatTest() {
} }
void BufferFormatTest::debugFormat() { void BufferFormatTest::debugFormat() {
std::ostringstream out; Containers::String out;
Debug(&out) << BufferFormat::Stereo16 << BufferFormat(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/Reference.h> #include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
@ -194,11 +194,11 @@ void ContextALTest::quietLog() {
const char* argv[] = { "", "--magnum-log", testCaseInstanceId() ? "quiet" : "default" }; const char* argv[] = { "", "--magnum-log", testCaseInstanceId() ? "quiet" : "default" };
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
/* MSVC 2015 and 2017 needs the int cast otherwise C2398 */ /* MSVC 2015 and 2017 needs the int cast otherwise C2398 */
Context context{int(Containers::arraySize(argv)), argv}; Context context{int(Containers::arraySize(argv)), argv};
CORRADE_COMPARE(out.str().empty(), bool(testCaseInstanceId())); CORRADE_COMPARE(!out, bool(testCaseInstanceId()));
} }
void ContextALTest::ignoreUnrelatedOptions() { void ContextALTest::ignoreUnrelatedOptions() {

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

@ -26,11 +26,9 @@
*/ */
#include <set> #include <set>
#include <sstream>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Audio/Context.h" #include "Magnum/Audio/Context.h"
@ -103,9 +101,9 @@ void ContextTest::extensions() {
} }
void ContextTest::debugHrtfStatus() { void ContextTest::debugHrtfStatus() {
std::ostringstream out; Containers::String out;
Debug(&out) << Context::HrtfStatus::Denied << Context::HrtfStatus(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/Audio/Renderer.h" #include "Magnum/Audio/Renderer.h"
@ -46,15 +45,15 @@ RendererTest::RendererTest() {
} }
void RendererTest::debugError() { void RendererTest::debugError() {
std::ostringstream out; Containers::String out;
Debug(&out) << Renderer::Error::InvalidOperation << Renderer::Error(0xdead); 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() { void RendererTest::debugDistanceModel() {
std::ostringstream out; Containers::String out;
Debug(&out) << Renderer::DistanceModel::Inverse << Renderer::DistanceModel(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Audio/Source.h" #include "Magnum/Audio/Source.h"
@ -45,15 +44,15 @@ SourceTest::SourceTest() {
} }
void SourceTest::debugState() { void SourceTest::debugState() {
std::ostringstream out; Containers::String out;
Debug(&out) << Source::State::Playing << Source::State(0xdead); 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() { void SourceTest::debugType() {
std::ostringstream out; Containers::String out;
Debug(&out) << Source::Type::Streaming << Source::Type(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.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/Containers/Triple.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/File.h> #include <Corrade/TestSuite/Compare/File.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include <Corrade/Utility/String.h> /* replaceFirst() */ #include <Corrade/Utility/String.h> /* replaceFirst() */
@ -294,37 +291,37 @@ const ImageView2D ExpectedRed{PixelFormat::R32F, {3, 3}, ExpectedRedData};
void CompareImageTest::formatUnknown() { void CompareImageTest::formatUnknown() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
ImageView2D image{PixelStorage{}, PixelFormat(0xdead), 0, 0, {}}; ImageView2D image{PixelStorage{}, PixelFormat(0xdead), 0, 0, {}};
Implementation::calculateImageDelta(image.format(), image.pixels(), image); 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() { void CompareImageTest::formatPackedDepthStencil() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
ImageView2D image{PixelFormat::Depth24UnormStencil8UI, {}}; ImageView2D image{PixelFormat::Depth24UnormStencil8UI, {}};
Implementation::calculateImageDelta(image.format(), image.pixels(), image); 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() { void CompareImageTest::formatImplementationSpecific() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
ImageView2D image{PixelStorage{}, pixelFormatWrap(0xdead), 0, 0, {}}; ImageView2D image{PixelStorage{}, pixelFormatWrap(0xdead), 0, 0, {}};
Implementation::calculateImageDelta(image.format(), image.pixels(), image); 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() { void CompareImageTest::calculateDelta() {
@ -459,17 +456,20 @@ void CompareImageTest::calculateDeltaSpecials3() {
} }
void CompareImageTest::deltaImage() { void CompareImageTest::deltaImage() {
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Containers::Array<Float> delta{32*32}; Containers::Array<Float> delta{32*32};
for(std::int_fast32_t x = 0; x != 32; ++x) for(std::int_fast32_t x = 0; x != 32; ++x)
for(std::int_fast32_t y = 0; y != 32; ++y) for(std::int_fast32_t y = 0; y != 32; ++y)
delta[y*32 + x] = Vector2{Float(x), Float(y)}.length()/Vector2{32.0f}.length(); 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); /* The string gets fully written only on destruction or with a newline at
CORRADE_COMPARE(out.str(), 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" " |$$$$$$$$$$0000000888888DDDDNNNNM|\n"
" |ZZZZZZZ$$$$$$$$0000008888DDDDNNN|\n" " |ZZZZZZZ$$$$$$$$0000008888DDDDNNN|\n"
" |ZZZZZZZZZZZZZ$$$$$$00008888DDDDN|\n" " |ZZZZZZZZZZZZZ$$$$$$00008888DDDDN|\n"
@ -489,16 +489,19 @@ void CompareImageTest::deltaImage() {
} }
void CompareImageTest::deltaImageScaling() { void CompareImageTest::deltaImageScaling() {
std::ostringstream out;
Debug d{&out, Debug::Flag::DisableColors};
Containers::Array<Float> delta{65*40}; Containers::Array<Float> delta{65*40};
for(std::int_fast32_t x = 0; x != 65; ++x) for(std::int_fast32_t x = 0; x != 65; ++x)
for(std::int_fast32_t y = 0; y != 40; ++y) 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(); 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); /* The string gets fully written only on destruction or with a newline at
CORRADE_COMPARE(out.str(), 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" " |777777IIIIIIZZZZ$$$0000888DDDNNMM|\n"
" |????777777IIIIZZZZ$$$000888DDDNNN|\n" " |????777777IIIIZZZZ$$$000888DDDNNN|\n"
" |?????????7777IIIIZZZ$$$00888DDDNN|\n" " |?????????7777IIIIZZZ$$$00888DDDNN|\n"
@ -520,12 +523,16 @@ void CompareImageTest::deltaImageColors() {
Implementation::printDeltaImage(out, DeltaRed, {3, 3}, 2.0f, 0.5f, 0.2f); Implementation::printDeltaImage(out, DeltaRed, {3, 3}, 2.0f, 0.5f, 0.2f);
} }
std::ostringstream out; /* The string gets fully written only on destruction or with a newline at
Debug dc{&out, Debug::Flag::DisableColors}; the end */
Implementation::printDeltaImage(dc, DeltaRed, {3, 3}, 2.0f, 0.5f, 0.2f); 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 /* Yes, there is half of the rows (2 instead of 3) in order to roughly
preserve image ratio */ preserve image ratio */
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
" |.7 |\n" " |.7 |\n"
" |: ,|"); " |: ,|");
} }
@ -539,12 +546,16 @@ void CompareImageTest::deltaImageSpecials() {
nan, inf, 0.0f, nan, inf, 0.0f,
nan, inf, 0.0f}; nan, inf, 0.0f};
std::ostringstream out; /* The string gets fully written only on destruction or with a newline at
Debug dc{&out, Debug::Flag::DisableColors}; the end */
Implementation::printDeltaImage(dc, delta, {3, 4}, 3.0f, 0.0f, 0.0f); 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 /* Should show the max value for NaN and infs and the usual things
otherwise */ otherwise */
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
" |MM |\n" " |MM |\n"
" |~M8|"); " |~M8|");
} }
@ -556,11 +567,14 @@ void CompareImageTest::pixelDelta() {
Implementation::printPixelDeltas(out, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 10); Implementation::printPixelDeltas(out, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 10);
} }
std::ostringstream out; /* The string gets fully written only on destruction or with a newline at
Debug d{&out, Debug::Flag::DisableColors}; the end */
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 10); Containers::String out;
{
CORRADE_COMPARE(out.str(), "\n" 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" " Pixels above max/mean threshold:\n"
" [1,2] Vector(1), expected Vector(0) (Δ = 1)\n" " [1,2] Vector(1), expected Vector(0) (Δ = 1)\n"
" [0,0] Vector(0.3), expected Vector(0.65) (Δ = 0.35)\n" " [0,0] Vector(0.3), expected Vector(0.65) (Δ = 0.35)\n"
@ -569,19 +583,25 @@ void CompareImageTest::pixelDelta() {
} }
void CompareImageTest::pixelDeltaEmpty() { void CompareImageTest::pixelDeltaEmpty() {
std::ostringstream out; /* The string gets fully written only on destruction or with a newline at
Debug d{&out, Debug::Flag::DisableColors}; the end */
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 1.0f, 1.0f, 10); Containers::String out;
{
CORRADE_COMPARE(out.str(), ""); 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() { void CompareImageTest::pixelDeltaOverflow() {
std::ostringstream out; /* The string gets fully written only on destruction or with a newline at
Debug d{&out, Debug::Flag::DisableColors}; the end */
Implementation::printPixelDeltas(d, DeltaRed, ActualRed.format(), ActualRed.pixels(), ExpectedRed.pixels(), 0.5f, 0.1f, 3); Containers::String out;
{
CORRADE_COMPARE(out.str(), "\n" 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" " Top 3 out of 4 pixels above max/mean threshold:\n"
" [1,2] Vector(1), expected Vector(0) (Δ = 1)\n" " [1,2] Vector(1), expected Vector(0) (Δ = 1)\n"
" [0,0] Vector(0.3), expected Vector(0.65) (Δ = 0.35)\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}; const ImageView2D ExpectedHalf{PixelFormat::RG16F, {2, 2}, ExpectedHalfData};
void CompareImageTest::pixelDeltaHalf() { void CompareImageTest::pixelDeltaHalf() {
std::ostringstream out; /* The string gets fully written only on destruction or with a newline at
Debug d{&out, Debug::Flag::DisableColors}; the end */
Implementation::printPixelDeltas(d, DeltaHalf, ActualHalf.format(), ActualHalf.pixels(), ExpectedHalf.pixels(), 0.5f, 0.1f, 10); Containers::String out;
{
CORRADE_COMPARE(out.str(), "\n" 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" " Pixels above max/mean threshold:\n"
" [0,0] Vector(0.3, 1), expected Vector(0.6499, 1) (Δ = 0.175)\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" " [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() { void CompareImageTest::pixelDeltaSpecials() {
std::ostringstream out; /* The string gets fully written only on destruction or with a newline at
Debug d{&out, Debug::Flag::DisableColors}; the end */
Implementation::printPixelDeltas(d, DeltaSpecials, ActualSpecials.format(), ActualSpecials.pixels(), ExpectedSpecials.pixels(), 1.5f, 0.5f, 10); 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. /* MSVC before version 2019 16.10(11?) prints -nan(ind) instead of ±nan.
But only sometimes. */ But only sometimes. */
#if defined(CORRADE_TARGET_MSVC) && _MSC_VER < 1929 && !defined(CORRADE_TARGET_CLANG_CL) #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" " Pixels above max/mean threshold:\n"
" [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n" " [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n"
" [3,0] Vector(0.3), expected Vector(-nan(ind)) (Δ = -nan(ind))\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" " [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)"); " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)");
#else #else
CORRADE_COMPARE(out.str(), "\n" CORRADE_COMPARE(out, "\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
" [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n" " [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n"
" [3,0] Vector(0.3), expected Vector(nan) (Δ = nan)\n" " [3,0] Vector(0.3), expected Vector(nan) (Δ = nan)\n"
@ -647,7 +673,7 @@ void CompareImageTest::pixelDeltaSpecials() {
} }
void CompareImageTest::compareDifferentSize() { void CompareImageTest::compareDifferentSize() {
std::stringstream out; Containers::String out;
char data[8*5]; char data[8*5];
ImageView2D a{PixelFormat::RG8UI, {3, 4}, data}; ImageView2D a{PixelFormat::RG8UI, {3, 4}, data};
@ -662,11 +688,11 @@ void CompareImageTest::compareDifferentSize() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::compareDifferentFormat() {
std::stringstream out; Containers::String out;
char data[16*12]; char data[16*12];
ImageView2D a{PixelFormat::RGBA32F, {3, 4}, data}; ImageView2D a{PixelFormat::RGBA32F, {3, 4}, data};
@ -681,7 +707,7 @@ void CompareImageTest::compareDifferentFormat() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::compareSameZeroThreshold() {
@ -697,7 +723,7 @@ void CompareImageTest::compareSameZeroThreshold() {
} }
void CompareImageTest::compareAboveThresholds() { void CompareImageTest::compareAboveThresholds() {
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f}; TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f};
@ -708,7 +734,7 @@ void CompareImageTest::compareAboveThresholds() {
compare.printMessage(flags, d, "a", "b"); 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" "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" " |?M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -718,7 +744,7 @@ void CompareImageTest::compareAboveThresholds() {
} }
void CompareImageTest::compareAboveMaxThreshold() { void CompareImageTest::compareAboveMaxThreshold() {
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{30.0f, 20.0f}; TestSuite::Comparator<CompareImage> compare{30.0f, 20.0f};
@ -729,7 +755,7 @@ void CompareImageTest::compareAboveMaxThreshold() {
compare.printMessage(flags, d, "a", "b"); 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" "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" " |?M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -737,7 +763,7 @@ void CompareImageTest::compareAboveMaxThreshold() {
} }
void CompareImageTest::compareAboveMeanThreshold() { void CompareImageTest::compareAboveMeanThreshold() {
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{50.0f, 18.0f}; TestSuite::Comparator<CompareImage> compare{50.0f, 18.0f};
@ -748,7 +774,7 @@ void CompareImageTest::compareAboveMeanThreshold() {
compare.printMessage(flags, d, "a", "b"); 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" "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" " |?M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -757,7 +783,7 @@ void CompareImageTest::compareAboveMeanThreshold() {
} }
void CompareImageTest::compareNonZeroThreshold() { void CompareImageTest::compareNonZeroThreshold() {
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f}; TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f};
@ -768,7 +794,7 @@ void CompareImageTest::compareNonZeroThreshold() {
compare.printMessage(flags, d, "a", "b"); 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" "Images a and b have deltas 39/18.5 below threshold 40/20. Delta image:\n"
" |?M|\n" " |?M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -776,7 +802,7 @@ void CompareImageTest::compareNonZeroThreshold() {
} }
void CompareImageTest::compareSpecials() { void CompareImageTest::compareSpecials() {
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{1.5f, 0.5f}; 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 */ /* clang-cl prints -nan(ind) instead of ±nan, but differently than MSVC */
#ifdef CORRADE_TARGET_CLANG_CL #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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -806,7 +832,7 @@ void CompareImageTest::compareSpecials() {
#elif defined(CORRADE_TARGET_MSVC) #elif defined(CORRADE_TARGET_MSVC)
#if _MSC_VER < 1929 #if _MSC_VER < 1929
#ifdef _M_X64 #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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -817,7 +843,7 @@ void CompareImageTest::compareSpecials() {
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n" " [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n"); " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#else #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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\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"); " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#endif #endif
#else #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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -857,9 +883,9 @@ void CompareImageTest::compareSpecials() {
" [1,0] Vector(0.3), expected Vector(-inf) (Δ = inf)\n" " [1,0] Vector(0.3), expected Vector(-inf) (Δ = inf)\n"
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n" " [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n"; " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n";
if(out.str() == expectedPositive) if(out == expectedPositive)
CORRADE_COMPARE(out.str(), expectedPositive); CORRADE_COMPARE(out, expectedPositive);
else CORRADE_COMPARE(out.str(), 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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -873,7 +899,7 @@ void CompareImageTest::compareSpecials() {
} }
void CompareImageTest::compareSpecialsMeanOnly() { void CompareImageTest::compareSpecialsMeanOnly() {
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{15.0f, 0.5f}; 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 */ /* clang-cl prints -nan(ind) instead of ±nan, but differently than MSVC */
#ifdef CORRADE_TARGET_CLANG_CL #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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -903,7 +929,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
#elif defined(CORRADE_TARGET_MSVC) #elif defined(CORRADE_TARGET_MSVC)
#if _MSC_VER < 1929 #if _MSC_VER < 1929
#ifdef _M_X64 #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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -914,7 +940,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n" " [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n"); " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#else #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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\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"); " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#endif #endif
#else #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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -954,9 +980,9 @@ void CompareImageTest::compareSpecialsMeanOnly() {
" [1,0] Vector(0.3), expected Vector(-inf) (Δ = inf)\n" " [1,0] Vector(0.3), expected Vector(-inf) (Δ = inf)\n"
" [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n" " [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n"
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n"; " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n";
if(out.str() == expectedPositive) if(out == expectedPositive)
CORRADE_COMPARE(out.str(), expectedPositive); CORRADE_COMPARE(out, expectedPositive);
else CORRADE_COMPARE(out.str(), 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" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
@ -972,7 +998,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
void CompareImageTest::compareSpecialsDisallowedThreshold() { void CompareImageTest::compareSpecialsDisallowedThreshold() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out; Containers::String out;
{ {
Error redirectError{&out}; Error redirectError{&out};
@ -980,7 +1006,7 @@ void CompareImageTest::compareSpecialsDisallowedThreshold() {
TestSuite::Comparator<CompareImage> b{0.3f, Constants::nan()}; 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"
"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 */ /* This will produce output if --verbose is specified */
CORRADE_COMPARE_WITH(ActualRgb, ExpectedRgb, (CompareImage{40.0f, 20.0f})); CORRADE_COMPARE_WITH(ActualRgb, ExpectedRgb, (CompareImage{40.0f, 20.0f}));
std::ostringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f}; TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f};
@ -1046,14 +1072,14 @@ void CompareImageTest::imageNonZeroDelta() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareVerbose); CORRADE_COMPARE(out, ImageCompareVerbose);
} }
void CompareImageTest::imageNonZeroDeltaNoPixels() { void CompareImageTest::imageNonZeroDeltaNoPixels() {
/* This will produce output if --verbose is specified */ /* This will produce output if --verbose is specified */
CORRADE_COMPARE_WITH(ActualRgb, ExpectedRgb, (CompareImage{40.0f, 40.0f})); CORRADE_COMPARE_WITH(ActualRgb, ExpectedRgb, (CompareImage{40.0f, 40.0f}));
std::ostringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{40.0f, 40.0f}; 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 /* No pixel list written as there are no outliers. Testing this just once
since all other combinations (image/file/pixels) use the same codepath. */ 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" "Images a and b have deltas 39/18.5 below threshold 40/40. Delta image:\n"
" |?M|\n"); " |?M|\n");
} }
void CompareImageTest::imageError() { void CompareImageTest::imageError() {
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f}; TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f};
@ -1083,7 +1109,7 @@ void CompareImageTest::imageError() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareError); CORRADE_COMPARE(out, ImageCompareError);
} }
void CompareImageTest::imageFileZeroDelta() { void CompareImageTest::imageFileZeroDelta() {
@ -1120,7 +1146,7 @@ void CompareImageTest::imageFileNonZeroDelta() {
CORRADE_COMPARE_WITH(actualFilename, expectedFilename, CORRADE_COMPARE_WITH(actualFilename, expectedFilename,
(CompareImageFile{*_importerManager, 40.0f, 20.0f})); (CompareImageFile{*_importerManager, 40.0f, 20.0f}));
std::ostringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f};
@ -1131,7 +1157,7 @@ void CompareImageTest::imageFileNonZeroDelta() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareVerbose); CORRADE_COMPARE(out, ImageCompareVerbose);
} }
void CompareImageTest::imageFileError() { void CompareImageTest::imageFileError() {
@ -1139,7 +1165,7 @@ void CompareImageTest::imageFileError() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out; Containers::String out;
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f}; TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that /* 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"); 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 /* Create the output dir if it doesn't exist, but avoid stale files making
false positives */ false positives */
@ -1172,7 +1198,7 @@ void CompareImageTest::imageFileError() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found."); CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{ {
out.str({}); out = {};
Debug redirectOutput(&out); Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR); compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
} }
@ -1180,7 +1206,7 @@ void CompareImageTest::imageFileError() {
/* We expect the *actual* contents, but under the *expected* filename. /* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same Comparing file contents, expecting the converter makes exactly the same
file. */ file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename)); CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename, CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File); 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) if(manager.loadState("AnyImageImporter") != PluginManager::LoadState::NotFound)
CORRADE_SKIP("AnyImageImporter plugin found, can't test."); CORRADE_SKIP("AnyImageImporter plugin found, can't test.");
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImageFile> compare{&manager, nullptr, 20.0f, 10.0f}; TestSuite::Comparator<CompareImageFile> compare{&manager, nullptr, 20.0f, 10.0f};
@ -1208,7 +1234,7 @@ void CompareImageTest::imageFilePluginLoadFailed() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::imageFileActualLoadFailed() {
@ -1216,7 +1242,7 @@ void CompareImageTest::imageFileActualLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, nullptr, 20.0f, 10.0f}; TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, nullptr, 20.0f, 10.0f};
@ -1233,7 +1259,7 @@ void CompareImageTest::imageFileActualLoadFailed() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::imageFileExpectedLoadFailed() {
@ -1241,7 +1267,7 @@ void CompareImageTest::imageFileExpectedLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out; Containers::String out;
TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f}; TestSuite::Comparator<CompareImageFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that /* 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"); 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 /* Create the output dir if it doesn't exist, but avoid stale files making
false positives */ false positives */
@ -1272,7 +1298,7 @@ void CompareImageTest::imageFileExpectedLoadFailed() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found."); CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{ {
out.str({}); out = {};
Debug redirectOutput(&out); Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR); compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
} }
@ -1280,7 +1306,7 @@ void CompareImageTest::imageFileExpectedLoadFailed() {
/* We expect the *actual* contents, but under the *expected* filename. /* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same Comparing file contents, expecting the converter makes exactly the same
file. */ file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename)); CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename, CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File); Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
} }
@ -1291,7 +1317,7 @@ void CompareImageTest::imageFileActualIsCompressed() {
manager.load("DdsImporter") < PluginManager::LoadState::Loaded) manager.load("DdsImporter") < PluginManager::LoadState::Loaded)
CORRADE_SKIP("AnyImageImporter or DdsImporter plugins can't be 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}; TestSuite::Comparator<CompareImageFile> compare{&manager, nullptr, 20.0f, 10.0f};
@ -1309,7 +1335,7 @@ void CompareImageTest::imageFileActualIsCompressed() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::imageFileExpectedIsCompressed() {
@ -1318,7 +1344,7 @@ void CompareImageTest::imageFileExpectedIsCompressed() {
manager.load("DdsImporter") < PluginManager::LoadState::Loaded) manager.load("DdsImporter") < PluginManager::LoadState::Loaded)
CORRADE_SKIP("AnyImageImporter or DdsImporter plugins can't be 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}; TestSuite::Comparator<CompareImageFile> compare{&manager, nullptr, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that /* The filenames are referenced as string views as the assumption is that
@ -1385,7 +1411,7 @@ void CompareImageTest::imageToFileNonZeroDelta() {
CORRADE_COMPARE_WITH(ActualRgb, expectedFilename, CORRADE_COMPARE_WITH(ActualRgb, expectedFilename,
(CompareImageToFile{*_importerManager, 40.0f, 20.0f})); (CompareImageToFile{*_importerManager, 40.0f, 20.0f}));
std::ostringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f};
@ -1396,7 +1422,7 @@ void CompareImageTest::imageToFileNonZeroDelta() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareVerbose); CORRADE_COMPARE(out, ImageCompareVerbose);
} }
void CompareImageTest::imageToFileError() { void CompareImageTest::imageToFileError() {
@ -1404,7 +1430,7 @@ void CompareImageTest::imageToFileError() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out; Containers::String out;
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f}; TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that /* 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"); 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 /* Create the output dir if it doesn't exist, but avoid stale files making
false positives */ false positives */
@ -1436,7 +1462,7 @@ void CompareImageTest::imageToFileError() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found."); CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{ {
out.str({}); out = {};
Debug redirectOutput(&out); Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR); compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
} }
@ -1444,7 +1470,7 @@ void CompareImageTest::imageToFileError() {
/* We expect the *actual* contents, but under the *expected* filename. /* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same Comparing file contents, expecting the converter makes exactly the same
file. */ file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename)); CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename, CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File); 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) if(manager.loadState("AnyImageImporter") != PluginManager::LoadState::NotFound)
CORRADE_SKIP("AnyImageImporter plugin found, can't test."); CORRADE_SKIP("AnyImageImporter plugin found, can't test.");
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImageToFile> compare{&manager, nullptr, 20.0f, 10.0f}; TestSuite::Comparator<CompareImageToFile> compare{&manager, nullptr, 20.0f, 10.0f};
@ -1471,7 +1497,7 @@ void CompareImageTest::imageToFilePluginLoadFailed() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::imageToFileExpectedLoadFailed() {
@ -1479,7 +1505,7 @@ void CompareImageTest::imageToFileExpectedLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out; Containers::String out;
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f}; TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb, "nonexistent.tga"); TestSuite::ComparisonStatusFlags flags = compare(ActualRgb, "nonexistent.tga");
@ -1491,7 +1517,7 @@ void CompareImageTest::imageToFileExpectedLoadFailed() {
compare.printMessage(flags, d, "a", "b"); 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 /* Create the output dir if it doesn't exist, but avoid stale files making
false positives */ false positives */
@ -1505,7 +1531,7 @@ void CompareImageTest::imageToFileExpectedLoadFailed() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found."); CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{ {
out.str({}); out = {};
Debug redirectOutput(&out); Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR); compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
} }
@ -1513,7 +1539,7 @@ void CompareImageTest::imageToFileExpectedLoadFailed() {
/* We expect the *actual* contents, but under the *expected* filename. /* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same Comparing file contents, expecting the converter makes exactly the same
file. */ file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename)); CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename, CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File); Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
} }
@ -1524,7 +1550,7 @@ void CompareImageTest::imageToFileExpectedIsCompressed() {
manager.load("DdsImporter") < PluginManager::LoadState::Loaded) manager.load("DdsImporter") < PluginManager::LoadState::Loaded)
CORRADE_SKIP("AnyImageImporter or DdsImporter plugins can't be 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}; TestSuite::Comparator<CompareImageToFile> compare{&manager, nullptr, 20.0f, 10.0f};
/* The filenames are referenced as string views as the assumption is that /* 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"); 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"); "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 /* 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, CORRADE_COMPARE_WITH(actualFilename, ExpectedRgb,
(CompareFileToImage{*_importerManager, 40.0f, 20.0f})); (CompareFileToImage{*_importerManager, 40.0f, 20.0f}));
std::ostringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 40.0f, 20.0f}; TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 40.0f, 20.0f};
@ -1603,7 +1629,7 @@ void CompareImageTest::fileToImageNonZeroDelta() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareVerbose); CORRADE_COMPARE(out, ImageCompareVerbose);
} }
void CompareImageTest::fileToImageError() { void CompareImageTest::fileToImageError() {
@ -1611,7 +1637,7 @@ void CompareImageTest::fileToImageError() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 20.0f, 10.0f}; TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 20.0f, 10.0f};
@ -1627,7 +1653,7 @@ void CompareImageTest::fileToImageError() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareError); CORRADE_COMPARE(out, ImageCompareError);
} }
void CompareImageTest::fileToImagePluginLoadFailed() { void CompareImageTest::fileToImagePluginLoadFailed() {
@ -1635,7 +1661,7 @@ void CompareImageTest::fileToImagePluginLoadFailed() {
if(manager.loadState("AnyImageImporter") != PluginManager::LoadState::NotFound) if(manager.loadState("AnyImageImporter") != PluginManager::LoadState::NotFound)
CORRADE_SKIP("AnyImageImporter plugin found, can't test."); CORRADE_SKIP("AnyImageImporter plugin found, can't test.");
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareFileToImage> compare{&manager, 20.0f, 10.0f}; TestSuite::Comparator<CompareFileToImage> compare{&manager, 20.0f, 10.0f};
@ -1651,7 +1677,7 @@ void CompareImageTest::fileToImagePluginLoadFailed() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::fileToImageActualLoadFailed() {
@ -1659,7 +1685,7 @@ void CompareImageTest::fileToImageActualLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 20.0f, 10.0f}; TestSuite::Comparator<CompareFileToImage> compare{&*_importerManager, 20.0f, 10.0f};
@ -1670,7 +1696,7 @@ void CompareImageTest::fileToImageActualLoadFailed() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::fileToImageActualIsCompressed() {
@ -1679,7 +1705,7 @@ void CompareImageTest::fileToImageActualIsCompressed() {
manager.load("DdsImporter") < PluginManager::LoadState::Loaded) manager.load("DdsImporter") < PluginManager::LoadState::Loaded)
CORRADE_SKIP("AnyImageImporter or DdsImporter plugins can't be 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}; TestSuite::Comparator<CompareFileToImage> compare{&manager, 20.0f, 10.0f};
@ -1695,7 +1721,7 @@ void CompareImageTest::fileToImageActualIsCompressed() {
compare.printMessage(flags, d, "a", "b"); 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"); "Actual image a (.../CompareImageCompressed.dds) is compressed, comparison not possible.\n");
} }
@ -1906,7 +1932,7 @@ void CompareImageTest::pixelsToImageNonZeroDelta() {
CORRADE_COMPARE_WITH(ActualRgb.pixels<Color3ub>(), CORRADE_COMPARE_WITH(ActualRgb.pixels<Color3ub>(),
ExpectedRgb, (CompareImage{40.0f, 20.0f})); ExpectedRgb, (CompareImage{40.0f, 20.0f}));
std::ostringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f}; TestSuite::Comparator<CompareImage> compare{40.0f, 20.0f};
@ -1917,11 +1943,11 @@ void CompareImageTest::pixelsToImageNonZeroDelta() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareVerbose); CORRADE_COMPARE(out, ImageCompareVerbose);
} }
void CompareImageTest::pixelsToImageDifferentFormat() { void CompareImageTest::pixelsToImageDifferentFormat() {
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{{}, {}}; TestSuite::Comparator<CompareImage> compare{{}, {}};
@ -1933,13 +1959,13 @@ void CompareImageTest::pixelsToImageDifferentFormat() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::pixelsToImageError() {
/* Same as imageError(), but taking pixels instead */ /* Same as imageError(), but taking pixels instead */
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f}; TestSuite::Comparator<CompareImage> compare{20.0f, 10.0f};
@ -1951,7 +1977,7 @@ void CompareImageTest::pixelsToImageError() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareError); CORRADE_COMPARE(out, ImageCompareError);
} }
template<class T> void CompareImageTest::pixelsToFileZeroDelta() { template<class T> void CompareImageTest::pixelsToFileZeroDelta() {
@ -2006,7 +2032,7 @@ void CompareImageTest::pixelsToFileNonZeroDelta() {
expectedFilename, expectedFilename,
(CompareImageToFile{*_importerManager, 40.0f, 20.0f})); (CompareImageToFile{*_importerManager, 40.0f, 20.0f}));
std::ostringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f}; TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, 40.0f, 20.0f};
@ -2017,7 +2043,7 @@ void CompareImageTest::pixelsToFileNonZeroDelta() {
compare.printMessage(flags, d, "a", "b"); compare.printMessage(flags, d, "a", "b");
} }
CORRADE_COMPARE(out.str(), ImageCompareVerbose); CORRADE_COMPARE(out, ImageCompareVerbose);
} }
void CompareImageTest::pixelsToFileDifferentFormat() { void CompareImageTest::pixelsToFileDifferentFormat() {
@ -2031,7 +2057,7 @@ void CompareImageTest::pixelsToFileDifferentFormat() {
views. */ views. */
Containers::String expectedFilename = Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"); Containers::String expectedFilename = Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga");
std::stringstream out; Containers::String out;
{ {
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, {}, {}}; TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, nullptr, {}, {}};
@ -2044,7 +2070,7 @@ void CompareImageTest::pixelsToFileDifferentFormat() {
compare.printMessage(flags, d, "a", "b"); 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() { void CompareImageTest::pixelsToFileError() {
@ -2060,7 +2086,7 @@ void CompareImageTest::pixelsToFileError() {
views. */ views. */
Containers::String expectedFilename = Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageExpected.tga"); 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}; TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
/* Vector3ub gets matched to PixelFormat::R8UI initially, but once the /* Vector3ub gets matched to PixelFormat::R8UI initially, but once the
@ -2076,7 +2102,7 @@ void CompareImageTest::pixelsToFileError() {
compare.printMessage(flags, d, "a", "b"); 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 /* Create the output dir if it doesn't exist, but avoid stale files making
false positives */ false positives */
@ -2090,7 +2116,7 @@ void CompareImageTest::pixelsToFileError() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found."); CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{ {
out.str({}); out = {};
Debug redirectOutput(&out); Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR); compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
} }
@ -2098,7 +2124,7 @@ void CompareImageTest::pixelsToFileError() {
/* We expect the *actual* contents, but under the *expected* filename. /* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same Comparing file contents, expecting the converter makes exactly the same
file. */ file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename)); CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename, CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File); Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File);
} }
@ -2110,7 +2136,7 @@ void CompareImageTest::pixelsToFileExpectedLoadFailed() {
!(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager->loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
std::stringstream out; Containers::String out;
TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f}; TestSuite::Comparator<CompareImageToFile> compare{&*_importerManager, &*_converterManager, 20.0f, 10.0f};
TestSuite::ComparisonStatusFlags flags = compare(ActualRgb.pixels<Color3ub>(), "nonexistent.tga"); TestSuite::ComparisonStatusFlags flags = compare(ActualRgb.pixels<Color3ub>(), "nonexistent.tga");
@ -2122,7 +2148,7 @@ void CompareImageTest::pixelsToFileExpectedLoadFailed() {
compare.printMessage(flags, d, "a", "b"); 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 /* Create the output dir if it doesn't exist, but avoid stale files making
false positives */ false positives */
@ -2136,7 +2162,7 @@ void CompareImageTest::pixelsToFileExpectedLoadFailed() {
CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found."); CORRADE_SKIP("AnyImageConverter / TgaImageConverter plugins not found.");
{ {
out.str({}); out = {};
Debug redirectOutput(&out); Debug redirectOutput(&out);
compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR); compare.saveDiagnostic(flags, redirectOutput, COMPAREIMAGETEST_SAVE_DIR);
} }
@ -2144,7 +2170,7 @@ void CompareImageTest::pixelsToFileExpectedLoadFailed() {
/* We expect the *actual* contents, but under the *expected* filename. /* We expect the *actual* contents, but under the *expected* filename.
Comparing file contents, expecting the converter makes exactly the same Comparing file contents, expecting the converter makes exactly the same
file. */ file. */
CORRADE_COMPARE(out.str(), Utility::formatString("-> {}\n", filename)); CORRADE_COMPARE(out, Utility::format("-> {}\n", filename));
CORRADE_COMPARE_AS(filename, CORRADE_COMPARE_AS(filename,
Utility::Path::join(DEBUGTOOLS_TEST_DIR, "CompareImageActual.tga"), TestSuite::Compare::File); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/DebugTools/CompareMaterial.h" #include "Magnum/DebugTools/CompareMaterial.h"
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
@ -353,12 +352,12 @@ void CompareMaterialTest::different() {
compare.printMessage(flags, out, "a", "b"); compare.printMessage(flags, out, "a", "b");
} }
std::ostringstream out; Containers::String out;
{ {
Debug dc{&out, Debug::Flag::DisableColors}; Debug dc{&out, Debug::Flag::DisableColors};
compare.printMessage(flags, dc, "a", "b"); compare.printMessage(flags, dc, "a", "b");
} }
CORRADE_COMPARE(out.str(), data.message); CORRADE_COMPARE(out, data.message);
} }
void CompareMaterialTest::differentReverse() { void CompareMaterialTest::differentReverse() {
@ -375,12 +374,12 @@ void CompareMaterialTest::differentReverse() {
compare.printMessage(flags, out, "b", "a"); compare.printMessage(flags, out, "b", "a");
} }
std::ostringstream out; Containers::String out;
{ {
Debug dc{&out, Debug::Flag::DisableColors}; Debug dc{&out, Debug::Flag::DisableColors};
compare.printMessage(flags, dc, "b", "a"); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/ConfigurationGroup.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 <Corrade/Utility/System.h>
#include "Magnum/DebugTools/FrameProfiler.h" #include "Magnum/DebugTools/FrameProfiler.h"
@ -781,32 +780,32 @@ void FrameProfilerTest::move() {
void FrameProfilerTest::delayZero() { void FrameProfilerTest::delayZero() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
FrameProfiler::Measurement{"", FrameProfiler::Units::Count, 0, FrameProfiler::Measurement{"", FrameProfiler::Units::Count, 0,
nullptr, nullptr, nullptr, nullptr}; 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() { void FrameProfilerTest::frameCountZero() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
FrameProfiler{{}, 0}; 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() { void FrameProfilerTest::delayTooLittleFrames() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
FrameProfiler profiler{{ FrameProfiler profiler{{
FrameProfiler::Measurement{"", FrameProfiler::Units::Count, 3, FrameProfiler::Measurement{"", FrameProfiler::Units::Count, 3,
nullptr, nullptr, nullptr, nullptr} nullptr, nullptr, nullptr, nullptr}
}, 2}; }, 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() { void FrameProfilerTest::startStopFrameUnexpected() {
@ -814,7 +813,7 @@ void FrameProfilerTest::startStopFrameUnexpected() {
FrameProfiler profiler; FrameProfiler profiler;
std::ostringstream out; Containers::String out;
{ {
Error redirectError{&out}; Error redirectError{&out};
profiler.endFrame(); profiler.endFrame();
@ -824,7 +823,7 @@ void FrameProfilerTest::startStopFrameUnexpected() {
Error redirectError{&out}; Error redirectError{&out};
profiler.beginFrame(); profiler.beginFrame();
} }
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::endFrame(): expected begin of frame\n" "DebugTools::FrameProfiler::endFrame(): expected begin of frame\n"
"DebugTools::FrameProfiler::beginFrame(): expected end of frame\n"); "DebugTools::FrameProfiler::beginFrame(): expected end of frame\n");
} }
@ -839,14 +838,14 @@ void FrameProfilerTest::measurementOutOfRange() {
nullptr, nullptr, nullptr} nullptr, nullptr, nullptr}
}, 1}; }, 1};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
profiler.measurementName(2); profiler.measurementName(2);
profiler.measurementUnits(2); profiler.measurementUnits(2);
profiler.measurementDelay(2); profiler.measurementDelay(2);
profiler.measurementData(2, 0); profiler.measurementData(2, 0);
profiler.measurementMean(2); profiler.measurementMean(2);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementName(): index 2 out of range for 2 measurements\n" "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::measurementUnits(): index 2 out of range for 2 measurements\n"
"DebugTools::FrameProfiler::measurementDelay(): 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.beginFrame();
profiler.endFrame(); profiler.endFrame();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
profiler.measurementData(0, 3); profiler.measurementData(0, 3);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementData(): frame 3 out of range for max 3 frames\n"); "DebugTools::FrameProfiler::measurementData(): frame 3 out of range for max 3 frames\n");
} }
@ -889,10 +888,10 @@ void FrameProfilerTest::dataNotAvailableYet() {
/* Empty state */ /* Empty state */
{ {
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
profiler.measurementData(0, 0); 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"); "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, 0);
profiler.measurementData(0, 1); profiler.measurementData(0, 1);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
profiler.measurementData(0, 2); profiler.measurementData(0, 2);
profiler.measurementData(0, 3); profiler.measurementData(0, 3);
profiler.measurementData(0, 4); 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 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 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"); "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, 2);
profiler.measurementData(0, 3); profiler.measurementData(0, 3);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
profiler.measurementData(0, 4); 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"); "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_COMPARE(profiler.measuredFrameCount(), 1);
CORRADE_VERIFY(!profiler.isMeasurementAvailable(0)); CORRADE_VERIFY(!profiler.isMeasurementAvailable(0));
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
profiler.measurementMean(0); profiler.measurementMean(0);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"DebugTools::FrameProfiler::measurementMean(): measurement data available after 2 more frames\n"); "DebugTools::FrameProfiler::measurementMean(): measurement data available after 2 more frames\n");
} }
@ -1160,13 +1159,13 @@ void FrameProfilerTest::glNotEnabled() {
FrameProfilerGL profiler{{}, 5}; FrameProfilerGL profiler{{}, 5};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
profiler.isMeasurementAvailable(FrameProfilerGL::Value::CpuDuration); profiler.isMeasurementAvailable(FrameProfilerGL::Value::CpuDuration);
profiler.frameTimeMean(); profiler.frameTimeMean();
profiler.cpuDurationMean(); profiler.cpuDurationMean();
profiler.gpuDurationMean(); profiler.gpuDurationMean();
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"DebugTools::FrameProfilerGL::isMeasurementAvailable(): DebugTools::FrameProfilerGL::Value::CpuDuration not enabled\n" "DebugTools::FrameProfilerGL::isMeasurementAvailable(): DebugTools::FrameProfilerGL::Value::CpuDuration not enabled\n"
"DebugTools::FrameProfilerGL::frameTimeMean(): not enabled\n" "DebugTools::FrameProfilerGL::frameTimeMean(): not enabled\n"
"DebugTools::FrameProfilerGL::cpuDurationMean(): not enabled\n" "DebugTools::FrameProfilerGL::cpuDurationMean(): not enabled\n"
@ -1175,25 +1174,25 @@ void FrameProfilerTest::glNotEnabled() {
#endif #endif
void FrameProfilerTest::debugUnits() { void FrameProfilerTest::debugUnits() {
std::ostringstream out; Containers::String out;
Debug{&out} << FrameProfiler::Units::Nanoseconds << FrameProfiler::Units(0xf0); 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 #ifdef MAGNUM_TARGET_GL
void FrameProfilerTest::debugGLValue() { void FrameProfilerTest::debugGLValue() {
std::ostringstream out; Containers::String out;
Debug{&out} << FrameProfilerGL::Value::GpuDuration << FrameProfilerGL::Value(0xfff0); 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() { void FrameProfilerTest::debugGLValues() {
std::ostringstream out; Containers::String out;
Debug{&out} << (FrameProfilerGL::Value::CpuDuration|FrameProfilerGL::Value::FrameTime) << FrameProfilerGL::Values{}; 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() { void FrameProfilerTest::configurationGLValue() {

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

@ -24,12 +24,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/ScopeGuard.h> #include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -130,7 +128,7 @@ void ScreenshotGLTest::rgba8() {
else else
CORRADE_VERIFY(Utility::Path::make(SCREENSHOTTEST_SAVE_DIR)); CORRADE_VERIFY(Utility::Path::make(SCREENSHOTTEST_SAVE_DIR));
std::ostringstream out; Containers::String out;
bool succeeded; bool succeeded;
{ {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
@ -145,8 +143,8 @@ void ScreenshotGLTest::rgba8() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(succeeded); CORRADE_VERIFY(succeeded);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
Utility::formatString("DebugTools::screenshot(): saved a PixelFormat::RGBA8Unorm image of size Vector(4, 3) to {}\n", file)); Utility::format("DebugTools::screenshot(): saved a PixelFormat::RGBA8Unorm image of size Vector(4, 3) to {}\n", file));
if(!(_importerManager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) || if(!(_importerManager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) ||
!(_importerManager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
@ -187,7 +185,7 @@ void ScreenshotGLTest::r8() {
else else
CORRADE_VERIFY(Utility::Path::make(SCREENSHOTTEST_SAVE_DIR)); CORRADE_VERIFY(Utility::Path::make(SCREENSHOTTEST_SAVE_DIR));
std::ostringstream out; Containers::String out;
bool succeeded; bool succeeded;
{ {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
@ -207,8 +205,8 @@ void ScreenshotGLTest::r8() {
CORRADE_EXPECT_FAIL_IF(framebuffer.implementationColorReadFormat() != GL::PixelFormat::Red, CORRADE_EXPECT_FAIL_IF(framebuffer.implementationColorReadFormat() != GL::PixelFormat::Red,
"Implementation-defined color read format is not single-channel."); "Implementation-defined color read format is not single-channel.");
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
Utility::formatString("DebugTools::screenshot(): saved a PixelFormat::R8Unorm image of size Vector(4, 3) to {}\n", file)); Utility::format("DebugTools::screenshot(): saved a PixelFormat::R8Unorm image of size Vector(4, 3) to {}\n", file));
if(!(_importerManager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) || if(!(_importerManager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) ||
!(_importerManager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_importerManager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
@ -234,7 +232,7 @@ void ScreenshotGLTest::unknownFormat() {
framebuffer.implementationColorReadType() == GL::PixelType::UnsignedByte) framebuffer.implementationColorReadType() == GL::PixelType::UnsignedByte)
CORRADE_SKIP("The framebuffer read format is RGBA8, can't test."); CORRADE_SKIP("The framebuffer read format is RGBA8, can't test.");
std::ostringstream out; Containers::String out;
bool succeeded; bool succeeded;
{ {
Error redirectOutput{&out}; Error redirectOutput{&out};
@ -245,9 +243,9 @@ void ScreenshotGLTest::unknownFormat() {
CORRADE_VERIFY(!succeeded); CORRADE_VERIFY(!succeeded);
if(framebuffer.implementationColorReadFormat() == GL::PixelFormat::RGBA) 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 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() { void ScreenshotGLTest::pluginLoadFailed() {
@ -271,7 +269,7 @@ void ScreenshotGLTest::pluginLoadFailed() {
CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete);
std::ostringstream out; Containers::String out;
bool succeeded; bool succeeded;
{ {
Error redirectOutput{&out}; Error redirectOutput{&out};
@ -281,9 +279,9 @@ void ScreenshotGLTest::pluginLoadFailed() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(!succeeded); CORRADE_VERIFY(!succeeded);
#ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT #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 #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 #endif
} }
@ -307,7 +305,7 @@ void ScreenshotGLTest::saveFailed() {
CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete);
std::ostringstream out; Containers::String out;
bool succeeded; bool succeeded;
{ {
Error redirectOutput{&out}; Error redirectOutput{&out};
@ -316,7 +314,7 @@ void ScreenshotGLTest::saveFailed() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(!succeeded); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.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}); texture.setImage(0, GL::TextureFormat::RGB9E5, ImageView2D{GL::PixelFormat::RGB, GL::PixelType::UnsignedInt5999Rev, Vector2i{2}, Data2D});
#endif #endif
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */ /* 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}); textureSubImage(texture, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES #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 #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
} }
@ -186,15 +185,15 @@ void TextureImageGLTest::subImage2DBufferNotReadable() {
GL::Texture2D texture; GL::Texture2D texture;
texture.setImage(0, GL::TextureFormat::RGB9E5, ImageView2D{GL::PixelFormat::RGB, GL::PixelType::UnsignedInt5999Rev, Vector2i{2}, Data2D}); 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}; Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */ /* 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); textureSubImage(texture, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES #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 #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
} }
#endif #endif
@ -272,15 +271,15 @@ void TextureImageGLTest::subImageCubeNotReadable() {
.setImage(GL::CubeMapCoordinate::PositiveZ, 0, format, view) .setImage(GL::CubeMapCoordinate::PositiveZ, 0, format, view)
.setImage(GL::CubeMapCoordinate::NegativeZ, 0, format, view); .setImage(GL::CubeMapCoordinate::NegativeZ, 0, format, view);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */ /* 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}); textureSubImage(texture, GL::CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES #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 #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
} }
@ -330,15 +329,15 @@ void TextureImageGLTest::subImageCubeBufferNotReadable() {
.setImage(GL::CubeMapCoordinate::PositiveZ, 0, format, view) .setImage(GL::CubeMapCoordinate::PositiveZ, 0, format, view)
.setImage(GL::CubeMapCoordinate::NegativeZ, 0, format, view); .setImage(GL::CubeMapCoordinate::NegativeZ, 0, format, view);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The read type doesn't have to match, it doesn't get that far */ /* 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); textureSubImage(texture, GL::CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {GL::PixelFormat::RGBA, GL::PixelType::UnsignedByte}, GL::BufferUsage::StaticRead);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
#ifndef MAGNUM_TARGET_GLES #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 #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
} }
#endif #endif

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

@ -25,16 +25,13 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Iterable.h> #include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/Reference.h> #include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/StringStl.h> /* StringHasPrefix / StringHasSuffix */
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/TestSuite/Compare/String.h> #include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include <Corrade/Utility/System.h> #include <Corrade/Utility/System.h>
@ -630,7 +627,7 @@ void AbstractShaderProgramGLTest::linkFailure() {
/* And thus linking as well, saying something like "error: linking with /* And thus linking as well, saying something like "error: linking with
uncompiled/unspecialized shader" */ uncompiled/unspecialized shader" */
std::ostringstream out; Containers::String out;
{ {
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!program.link()); CORRADE_VERIFY(!program.link());
@ -640,12 +637,12 @@ void AbstractShaderProgramGLTest::linkFailure() {
CORRADE_VERIFY(program.isLinkFinished()); CORRADE_VERIFY(program.isLinkFinished());
/* There's a driver-specific message after */ /* 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); TestSuite::Compare::StringHasPrefix);
/* No stray \0 should be anywhere */ /* 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 */ /* 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() { void AbstractShaderProgramGLTest::linkFailureAsync() {
@ -672,7 +669,7 @@ void AbstractShaderProgramGLTest::linkFailureAsync() {
program.attachShaders({shader}); program.attachShaders({shader});
/* The link submission should not print anything ... */ /* The link submission should not print anything ... */
std::ostringstream out; Containers::String out;
{ {
Error redirectError{&out}; Error redirectError{&out};
program.submitLink(); program.submitLink();
@ -681,7 +678,7 @@ void AbstractShaderProgramGLTest::linkFailureAsync() {
while(!program.isLinkFinished()) while(!program.isLinkFinished())
Utility::System::sleep(100); 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 /* ... only the final check should. In this case it's "error: linking with
uncompiled/unspecialized shader" as well, but if the shaders would be 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.checkLink({}));
} }
CORRADE_VERIFY(program.isLinkFinished()); 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); TestSuite::Compare::StringHasPrefix);
/* Not testing presence of \0 etc., as that's tested well enough in /* 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 ... */ /* The link submission should not print anything ... */
{ {
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
program.submitLink(); program.submitLink();
CORRADE_VERIFY(out.str().empty()); CORRADE_COMPARE(out, "");
} }
/* ... only the final check should. Vertex shader should be fine, but /* ... only the final check should. Vertex shader should be fine, but
fragment should fail. */ fragment should fail. */
std::ostringstream out; Containers::String out;
{ {
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!program.checkLink({vert, frag})); 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); TestSuite::Compare::StringHasPrefix);
/* The linker error (which would most probably say something like "error: /* The linker error (which would most probably say something like "error:
linking with uncompiled/unspecialized shader") should not be even linking with uncompiled/unspecialized shader") should not be even
printed */ 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); TestSuite::Compare::StringNotContains);
} }
@ -876,10 +873,10 @@ void AbstractShaderProgramGLTest::uniformNotFound() {
program.attachShaders({vert, frag}); program.attachShaders({vert, frag});
CORRADE_VERIFY(program.link()); CORRADE_VERIFY(program.link());
std::ostringstream out; Containers::String out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
program.uniformLocation("nonexistent"); program.uniformLocation("nonexistent");
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::AbstractShaderProgram: location of uniform 'nonexistent' cannot be retrieved\n"); "GL::AbstractShaderProgram: location of uniform 'nonexistent' cannot be retrieved\n");
} }
@ -1174,10 +1171,10 @@ void AbstractShaderProgramGLTest::uniformBlockIndexNotFound() {
program.attachShaders({vert, frag}); program.attachShaders({vert, frag});
CORRADE_VERIFY(program.link()); CORRADE_VERIFY(program.link());
std::ostringstream out; Containers::String out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
program.uniformBlockIndex("nonexistent"); program.uniformBlockIndex("nonexistent");
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::AbstractShaderProgram: index of uniform block 'nonexistent' cannot be retrieved\n"); "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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
#include "Magnum/GL/Context.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}}; MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, {nullptr, 2*2*4}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.image(0, image); 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() { void AbstractTextureGLTest::imageQueryViewBadSize() {
@ -149,10 +148,10 @@ void AbstractTextureGLTest::imageQueryViewBadSize() {
char data[2*4]; char data[2*4];
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2, 1}, data}; MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2, 1}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.image(0, image); 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() { void AbstractTextureGLTest::subImageQueryViewNullptr() {
@ -165,10 +164,10 @@ void AbstractTextureGLTest::subImageQueryViewNullptr() {
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, {nullptr, 2*2*4}}; MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, {nullptr, 2*2*4}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.subImage(0, {{}, Vector2i{2}}, image); 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() { void AbstractTextureGLTest::subImageQueryViewBadSize() {
@ -185,10 +184,10 @@ void AbstractTextureGLTest::subImageQueryViewBadSize() {
char data[2*4]; char data[2*4];
MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2, 1}, data}; MutableImageView2D image{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2, 1}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.subImage(0, {{}, Vector2i{2}}, image); 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() { void AbstractTextureGLTest::compressedImageQueryViewNullptr() {
@ -204,10 +203,10 @@ void AbstractTextureGLTest::compressedImageQueryViewNullptr() {
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, {nullptr, 16}}; MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, {nullptr, 16}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.compressedImage(0, image); 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() { void AbstractTextureGLTest::compressedImageQueryViewBadSize() {
@ -224,10 +223,10 @@ void AbstractTextureGLTest::compressedImageQueryViewBadSize() {
char data[2*16]; char data[2*16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4, 8}, data}; MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4, 8}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.compressedImage(0, image); 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() { void AbstractTextureGLTest::compressedImageQueryViewBadDataSize() {
@ -244,10 +243,10 @@ void AbstractTextureGLTest::compressedImageQueryViewBadDataSize() {
char data[16 - 1]; char data[16 - 1];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data}; MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.compressedImage(0, image); 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() { void AbstractTextureGLTest::compressedImageQueryViewBadFormat() {
@ -264,10 +263,10 @@ void AbstractTextureGLTest::compressedImageQueryViewBadFormat() {
char data[16]; char data[16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector2i{4}, data}; MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector2i{4}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.compressedImage(0, image); 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() { void AbstractTextureGLTest::compressedSubImageQueryViewNullptr() {
@ -287,10 +286,10 @@ void AbstractTextureGLTest::compressedSubImageQueryViewNullptr() {
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, {nullptr, 16}}; MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, {nullptr, 16}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.compressedSubImage(0, {{}, Vector2i{4}}, image); 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() { void AbstractTextureGLTest::compressedSubImageQueryViewBadSize() {
@ -311,10 +310,10 @@ void AbstractTextureGLTest::compressedSubImageQueryViewBadSize() {
char data[2*16]; char data[2*16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4, 8}, data}; MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4, 8}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.compressedSubImage(0, {{}, Vector2i{4}}, image); 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() { void AbstractTextureGLTest::compressedSubImageQueryViewBadDataSize() {
@ -335,10 +334,10 @@ void AbstractTextureGLTest::compressedSubImageQueryViewBadDataSize() {
char data[16 - 1]; char data[16 - 1];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data}; MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.compressedSubImage(0, {{}, Vector2i{4}}, image); 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() { void AbstractTextureGLTest::compressedSubImageQueryViewBadFormat() {
@ -359,10 +358,10 @@ void AbstractTextureGLTest::compressedSubImageQueryViewBadFormat() {
char data[16]; char data[16];
MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector2i{4}, data}; MutableCompressedImageView2D image{CompressedPixelFormat::RGBAS3tcDxt1, Vector2i{4}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
texture.compressedSubImage(0, {{}, Vector2i{4}}, image); 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 #endif

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

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/VertexFormat.h" #include "Magnum/VertexFormat.h"
#include "Magnum/GL/Attribute.h" #include "Magnum/GL/Attribute.h"
@ -1109,11 +1108,11 @@ void AttributeTest::attributeFromGenericFormatEnableNormalized() {
void AttributeTest::attributeFromGenericFormatUnexpectedForNormalizedKind() { void AttributeTest::attributeFromGenericFormatUnexpectedForNormalizedKind() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DynamicAttribute{DynamicAttribute::Kind::GenericNormalized, 3, DynamicAttribute{DynamicAttribute::Kind::GenericNormalized, 3,
VertexFormat::Int}; VertexFormat::Int};
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::DynamicAttribute: can't use VertexFormat::Int for a normalized attribute\n"); "GL::DynamicAttribute: can't use VertexFormat::Int for a normalized attribute\n");
} }
@ -1121,13 +1120,13 @@ void AttributeTest::attributeFromGenericFormatUnexpectedForNormalizedKind() {
void AttributeTest::attributeFromGenericFormatUnexpectedForIntegralKind() { void AttributeTest::attributeFromGenericFormatUnexpectedForIntegralKind() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DynamicAttribute{DynamicAttribute::Kind::Integral, 3, DynamicAttribute{DynamicAttribute::Kind::Integral, 3,
VertexFormat::Vector2bNormalized}; VertexFormat::Vector2bNormalized};
DynamicAttribute{DynamicAttribute::Kind::Integral, 3, DynamicAttribute{DynamicAttribute::Kind::Integral, 3,
VertexFormat::Vector3}; 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::Vector2bNormalized for a GL::DynamicAttribute::Kind::Integral attribute\n"
"GL::DynamicAttribute: can't use VertexFormat::Vector3 for an 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() { void AttributeTest::attributeFromGenericFormatUnexpectedForLongKind() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DynamicAttribute{DynamicAttribute::Kind::Long, 3, DynamicAttribute{DynamicAttribute::Kind::Long, 3,
VertexFormat::UnsignedShortNormalized}; VertexFormat::UnsignedShortNormalized};
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::DynamicAttribute: can't use VertexFormat::UnsignedShortNormalized for a GL::DynamicAttribute::Kind::Long attribute\n"); "GL::DynamicAttribute: can't use VertexFormat::UnsignedShortNormalized for a GL::DynamicAttribute::Kind::Long attribute\n");
} }
#endif #endif
@ -1149,20 +1148,20 @@ void AttributeTest::attributeFromGenericFormatUnexpectedForLongKind() {
void AttributeTest::attributeFromGenericFormatTooManyVectors() { void AttributeTest::attributeFromGenericFormatTooManyVectors() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DynamicAttribute{Attribute<7, Vector2>{}, VertexFormat::Matrix2x2}; 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"); "GL::DynamicAttribute: can't use VertexFormat::Matrix2x2 for a 1-vector attribute\n");
} }
void AttributeTest::attributeFromGenericFormatTooManyComponents() { void AttributeTest::attributeFromGenericFormatTooManyComponents() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DynamicAttribute{Attribute<7, Vector2>{}, VertexFormat::Vector3}; 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"); "GL::DynamicAttribute: can't use VertexFormat::Vector3 for a 2-component attribute\n");
} }
@ -1170,10 +1169,10 @@ void AttributeTest::attributeFromGenericFormatNotAvailable() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_SKIP("All attribute formats available on desktop GL."); CORRADE_SKIP("All attribute formats available on desktop GL.");
#else #else
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DynamicAttribute{Attribute<7, Vector2>{}, VertexFormat::Vector3d}; DynamicAttribute{Attribute<7, Vector2>{}, VertexFormat::Vector3d};
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::DynamicAttribute: VertexFormat::Vector3d isn't available on this target\n"); "GL::DynamicAttribute: VertexFormat::Vector3d isn't available on this target\n");
#endif #endif
} }
@ -1219,79 +1218,79 @@ void AttributeTest::hasVertexFormat() {
void AttributeTest::debugComponents1() { void AttributeTest::debugComponents1() {
typedef Attribute<3, Float> Attribute; typedef Attribute<3, Float> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::Components::One << Attribute::Components(0xdead); 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() { void AttributeTest::debugComponents2() {
typedef Attribute<3, Vector2> Attribute; typedef Attribute<3, Vector2> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::Components::Two << Attribute::Components(0xdead); 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() { void AttributeTest::debugComponents3() {
typedef Attribute<3, Vector3> Attribute; typedef Attribute<3, Vector3> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::Components::Three << Attribute::Components(0xdead); 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 #ifndef MAGNUM_TARGET_GLES2
void AttributeTest::debugComponents4() { void AttributeTest::debugComponents4() {
typedef Attribute<3, Vector4i> Attribute; typedef Attribute<3, Vector4i> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::Components::Four << Attribute::Components(0xdead); 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 #endif
void AttributeTest::debugComponentsMatrix2() { void AttributeTest::debugComponentsMatrix2() {
typedef Attribute<3, Matrix2x2> Attribute; typedef Attribute<3, Matrix2x2> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::Components::Two << Attribute::Components(0xdead); 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() { void AttributeTest::debugComponentsMatrix3() {
typedef Attribute<3, Matrix3> Attribute; typedef Attribute<3, Matrix3> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::Components::Three << Attribute::Components(0xdead); 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() { void AttributeTest::debugComponentsMatrix4() {
typedef Attribute<3, Matrix4> Attribute; typedef Attribute<3, Matrix4> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::Components::Four << Attribute::Components(0xdead); 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() { void AttributeTest::debugComponentsVector4() {
typedef Attribute<3, Vector4> Attribute; typedef Attribute<3, Vector4> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::Components::Three << Attribute::Components(0xdead); 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() { void AttributeTest::debugDataTypeFloat() {
typedef Attribute<3, Float> Attribute; typedef Attribute<3, Float> Attribute;
std::ostringstream out; Containers::String out;
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
Debug{&out} << Attribute::DataType::Half << Attribute::DataType(0xdead); 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 #else
Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead); 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 #endif
} }
@ -1299,9 +1298,9 @@ void AttributeTest::debugDataTypeFloat() {
void AttributeTest::debugDataTypeInt() { void AttributeTest::debugDataTypeInt() {
typedef Attribute<3, Int> Attribute; typedef Attribute<3, Int> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::DataType::Short << Attribute::DataType(0xdead); 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 #endif
@ -1309,44 +1308,44 @@ void AttributeTest::debugDataTypeInt() {
void AttributeTest::debugDataTypeDouble() { void AttributeTest::debugDataTypeDouble() {
typedef Attribute<3, Double> Attribute; typedef Attribute<3, Double> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::DataType::Double << Attribute::DataType(0xdead); 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 #endif
void AttributeTest::debugDataTypeVector3() { void AttributeTest::debugDataTypeVector3() {
typedef Attribute<3, Vector3> Attribute; typedef Attribute<3, Vector3> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead); 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() { void AttributeTest::debugDataTypeVector4() {
typedef Attribute<3, Vector4> Attribute; typedef Attribute<3, Vector4> Attribute;
std::ostringstream out; Containers::String out;
Debug{&out} << Attribute::DataType::Float << Attribute::DataType(0xdead); 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() { void AttributeTest::debugDynamicKind() {
std::ostringstream out; Containers::String out;
Debug{&out} << DynamicAttribute::Kind::GenericNormalized << DynamicAttribute::Kind(0xfe); 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() { void AttributeTest::debugDynamicComponents() {
std::ostringstream out; Containers::String out;
Debug{&out} << DynamicAttribute::Components::Three << DynamicAttribute::Components(0xdead); 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() { void AttributeTest::debugDynamicDataType() {
std::ostringstream out; Containers::String out;
Debug{&out} << DynamicAttribute::DataType::Float << DynamicAttribute::DataType(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Container.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/PixelFormat.h"
#include "Magnum/GL/BufferImage.h" #include "Magnum/GL/BufferImage.h"
@ -333,12 +333,12 @@ void BufferImageGLTest::constructBufferCompressedGeneric() {
void BufferImageGLTest::constructInvalidSize() { void BufferImageGLTest::constructInvalidSize() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* Doesn't consider alignment */ /* Doesn't consider alignment */
BufferImage2D{Magnum::PixelFormat::RGB8Unorm, {1, 3}, Containers::Array<char>{3*3}, BufferUsage::StaticDraw}; 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() { void BufferImageGLTest::constructCompressedInvalidSize() {
@ -346,17 +346,17 @@ void BufferImageGLTest::constructCompressedInvalidSize() {
/* Too small for given format */ /* Too small for given format */
{ {
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CompressedBufferImage2D{Magnum::CompressedPixelFormat::Bc2RGBAUnorm, {4, 4}, Containers::Array<char>{2}, BufferUsage::StaticDraw}; 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 */ /* Size should be rounded up even if the image size is not full block */
} { } {
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CompressedBufferImage2D{Magnum::CompressedPixelFormat::Bc2RGBAUnorm, {2, 2}, Containers::Array<char>{2}, BufferUsage::StaticDraw}; 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Buffer.h" #include "Magnum/GL/Buffer.h"
@ -72,16 +71,16 @@ void BufferTest::constructCopy() {
} }
void BufferTest::debugTargetHint() { void BufferTest::debugTargetHint() {
std::ostringstream out; Containers::String out;
Debug{&out} << Buffer::TargetHint::Array << Buffer::TargetHint(0xdead); 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 #ifndef MAGNUM_TARGET_GLES2
void BufferTest::debugTarget() { void BufferTest::debugTarget() {
std::ostringstream out; Containers::String out;
Debug{&out} << Buffer::Target::Uniform << Buffer::Target(0xdead); 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 #endif

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

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

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

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

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

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

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

@ -24,10 +24,10 @@
DEALINGS IN THE SOFTWARE. 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/StringView.h>
#include <Corrade/Containers/ScopeGuard.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/Context.h"
#include "Magnum/GL/DebugOutput.h" #include "Magnum/GL/DebugOutput.h"
@ -137,7 +137,7 @@ void DebugOutputGLTest::setCallbackDeprecated() {
DebugOutput::setDefaultCallback(); DebugOutput::setDefaultCallback();
}}; }};
std::ostringstream out; Containers::String out;
CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_IGNORE_DEPRECATED_PUSH
DebugOutput::setCallback([](DebugOutput::Source source, DebugOutput::Type type, UnsignedInt id, DebugOutput::Severity severity, const std::string& string, const void* userPtr) { 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))); 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!"); 1337, DebugOutput::Severity::High, "Hello from OpenGL command stream!");
MAGNUM_VERIFY_NO_GL_ERROR(); 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"); "Debug output: high severity application marker (1337): Hello from OpenGL command stream!\n");
} }
#endif #endif

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

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/DebugOutput.h" #include "Magnum/GL/DebugOutput.h"
@ -57,39 +56,39 @@ DebugOutputTest::DebugOutputTest() {
} }
void DebugOutputTest::debugSource() { void DebugOutputTest::debugSource() {
std::ostringstream o; Containers::String out;
Debug(&o) << DebugOutput::Source::ShaderCompiler << DebugOutput::Source(0xdead); Debug{&out} << DebugOutput::Source::ShaderCompiler << DebugOutput::Source(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugOutput::Source::ShaderCompiler GL::DebugOutput::Source(0xdead)\n"); CORRADE_COMPARE(out, "GL::DebugOutput::Source::ShaderCompiler GL::DebugOutput::Source(0xdead)\n");
} }
void DebugOutputTest::debugType() { void DebugOutputTest::debugType() {
std::ostringstream o; Containers::String out;
Debug(&o) << DebugOutput::Type::PushGroup << DebugOutput::Type(0xdead); Debug{&out} << DebugOutput::Type::PushGroup << DebugOutput::Type(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugOutput::Type::PushGroup GL::DebugOutput::Type(0xdead)\n"); CORRADE_COMPARE(out, "GL::DebugOutput::Type::PushGroup GL::DebugOutput::Type(0xdead)\n");
} }
void DebugOutputTest::debugSeverity() { void DebugOutputTest::debugSeverity() {
std::ostringstream o; Containers::String out;
Debug(&o) << DebugOutput::Severity::Notification << DebugOutput::Severity(0xdead); Debug{&out} << DebugOutput::Severity::Notification << DebugOutput::Severity(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugOutput::Severity::Notification GL::DebugOutput::Severity(0xdead)\n"); CORRADE_COMPARE(out, "GL::DebugOutput::Severity::Notification GL::DebugOutput::Severity(0xdead)\n");
} }
void DebugOutputTest::debugMessageSource() { void DebugOutputTest::debugMessageSource() {
std::ostringstream o; Containers::String out;
Debug(&o) << DebugMessage::Source::Application << DebugMessage::Source(0xdead); Debug{&out} << DebugMessage::Source::Application << DebugMessage::Source(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugMessage::Source::Application GL::DebugMessage::Source(0xdead)\n"); CORRADE_COMPARE(out, "GL::DebugMessage::Source::Application GL::DebugMessage::Source(0xdead)\n");
} }
void DebugOutputTest::debugMessageType() { void DebugOutputTest::debugMessageType() {
std::ostringstream o; Containers::String out;
Debug(&o) << DebugMessage::Type::DeprecatedBehavior << DebugMessage::Type(0xdead); Debug{&out} << DebugMessage::Type::DeprecatedBehavior << DebugMessage::Type(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugMessage::Type::DeprecatedBehavior GL::DebugMessage::Type(0xdead)\n"); CORRADE_COMPARE(out, "GL::DebugMessage::Type::DeprecatedBehavior GL::DebugMessage::Type(0xdead)\n");
} }
void DebugOutputTest::debugGroupSource() { void DebugOutputTest::debugGroupSource() {
std::ostringstream o; Containers::String out;
Debug(&o) << DebugGroup::Source::ThirdParty << DebugGroup::Source(0xdead); Debug{&out} << DebugGroup::Source::ThirdParty << DebugGroup::Source(0xdead);
CORRADE_COMPARE(o.str(), "GL::DebugGroup::Source::ThirdParty GL::DebugGroup::Source(0xdead)\n"); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/DefaultFramebuffer.h" #include "Magnum/GL/DefaultFramebuffer.h"
@ -43,10 +42,10 @@ DefaultFramebufferTest::DefaultFramebufferTest() {
} }
void DefaultFramebufferTest::debugStatus() { void DefaultFramebufferTest::debugStatus() {
std::ostringstream out; Containers::String out;
Debug(&out) << DefaultFramebuffer::Status::Complete << DefaultFramebuffer::Status(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -1715,10 +1713,10 @@ void FramebufferGLTest::readViewNullptr() {
MutableImageView2D view{DataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, {8, 16}}; MutableImageView2D view{DataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, {8, 16}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
framebuffer.read({{}, {8, 16}}, view); 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() { void FramebufferGLTest::readViewBadSize() {
@ -1742,10 +1740,10 @@ void FramebufferGLTest::readViewBadSize() {
char data[(DataOffset + 8*15)*sizeof(Color4ub)]{}; char data[(DataOffset + 8*15)*sizeof(Color4ub)]{};
MutableImageView2D view{DataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, {8, 15}, data}; MutableImageView2D view{DataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, {8, 15}, data};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
framebuffer.read({{}, {8, 16}}, view); 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 #ifndef MAGNUM_TARGET_GLES2

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

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Framebuffer.h" #include "Magnum/GL/Framebuffer.h"
@ -64,10 +63,10 @@ void FramebufferTest::constructCopy() {
} }
void FramebufferTest::debugStatus() { void FramebufferTest::debugStatus() {
std::ostringstream out; Containers::String out;
Debug(&out) << Framebuffer::Status::IncompleteMissingAttachment << Framebuffer::Status(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Iterable.h> #include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/ScopeGuard.h> #include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/FormatStl.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/Mesh.h" #include "Magnum/Mesh.h"
@ -2278,12 +2276,12 @@ void MeshGLTest::addVertexBufferMovedOutInstance() {
Buffer buffer{NoCreate}; Buffer buffer{NoCreate};
Mesh mesh; Mesh mesh;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
mesh.addVertexBuffer(buffer, 0, Attribute<0, Float>{}); 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() { void MeshGLTest::addVertexBufferTransferOwnwership() {
@ -2599,12 +2597,12 @@ void MeshGLTest::setIndexBufferMovedOutInstance() {
Buffer buffer{NoCreate}; Buffer buffer{NoCreate};
Mesh mesh; Mesh mesh;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
mesh.setIndexBuffer(buffer, 0, MeshIndexType::UnsignedByte); 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() { template<class T> void MeshGLTest::setIndexBufferTransferOwnership() {
@ -2721,12 +2719,12 @@ void MeshGLTest::indexTypeSetIndexOffsetNotIndexed() {
Mesh mesh; Mesh mesh;
MeshView view{mesh}; MeshView view{mesh};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
mesh.indexType(); mesh.indexType();
mesh.setIndexOffset(3); mesh.setIndexOffset(3);
view.setIndexOffset(3); view.setIndexOffset(3);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::Mesh::indexType(): mesh is not indexed\n" "GL::Mesh::indexType(): mesh is not indexed\n"
"GL::Mesh::setIndexOffset(): mesh is not indexed\n" "GL::Mesh::setIndexOffset(): mesh is not indexed\n"
"GL::MeshView::setIndexOffset(): mesh is not indexed\n"); "GL::MeshView::setIndexOffset(): mesh is not indexed\n");
@ -3086,13 +3084,13 @@ void MeshGLTest::setBaseVertexNoExtensionAvailable() {
.setBaseVertex(1) .setBaseVertex(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort); .setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultipleShader{}.draw(mesh); MultipleShader{}.draw(mesh);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #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 #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
} }
@ -3122,13 +3120,13 @@ void MeshGLTest::setBaseVertexRangeNoExtensionAvailable() {
.setBaseVertex(1) .setBaseVertex(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort, 0, 2); .setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort, 0, 2);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultipleShader{}.draw(mesh); MultipleShader{}.draw(mesh);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #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 #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
} }
#endif #endif
@ -3242,10 +3240,10 @@ void MeshGLTest::setInstanceCountBaseInstanceNoExtensionAvailable() {
.setInstanceCount(2) .setInstanceCount(2)
.setBaseInstance(1); .setBaseInstance(1);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultipleShader{}.draw(mesh); 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
#endif #endif
@ -3367,10 +3365,10 @@ void MeshGLTest::setInstanceCountIndexedBaseInstanceNoExtensionAvailable() {
.setBaseInstance(1) .setBaseInstance(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort); .setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultipleShader{}.draw(mesh); 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
#endif #endif
@ -3457,13 +3455,13 @@ void MeshGLTest::setInstanceCountIndexedBaseVertexNoExtensionAvailable() {
.setBaseVertex(1) .setBaseVertex(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort); .setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultipleShader{}.draw(mesh); MultipleShader{}.draw(mesh);
#ifndef MAGNUM_TARGET_GLES2 #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 #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
} }
#endif #endif
@ -3535,13 +3533,13 @@ void MeshGLTest::setInstanceCountIndexedBaseVertexBaseInstanceNoExtensionAvailab
.setBaseInstance(1) .setBaseInstance(1)
.setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort); .setIndexBuffer(indices, 0, MeshIndexType::UnsignedShort);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultipleShader{}.draw(mesh); MultipleShader{}.draw(mesh);
#ifndef MAGNUM_TARGET_GLES2 #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 #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
} }
#endif #endif
@ -4474,11 +4472,11 @@ void MeshGLTest::multiDrawWrongVertexOffsetSize() {
UnsignedInt counts[3]{}; UnsignedInt counts[3]{};
UnsignedInt vertexOffsets[2]{}; UnsignedInt vertexOffsets[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, vertexOffsets, nullptr); shader.draw(mesh, counts, vertexOffsets, nullptr);
shader.draw(mesh, counts, nullptr, 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 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 0\n"); "GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 0\n");
} }
@ -4493,11 +4491,11 @@ void MeshGLTest::multiDrawIndexedWrongVertexOffsetSize() {
UnsignedInt vertexOffsets[2]{}; UnsignedInt vertexOffsets[2]{};
UnsignedInt indexOffsets[3]{}; UnsignedInt indexOffsets[3]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, vertexOffsets, indexOffsets); shader.draw(mesh, counts, vertexOffsets, indexOffsets);
/* Omitting vertex offsets altogether is okay */ /* 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"); "GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 2\n");
} }
@ -4510,11 +4508,11 @@ void MeshGLTest::multiDrawIndexedWrongIndexOffsetSize() {
UnsignedInt counts[3]{}; UnsignedInt counts[3]{};
UnsignedInt indexOffsets[2]{}; UnsignedInt indexOffsets[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, nullptr, indexOffsets); shader.draw(mesh, counts, nullptr, indexOffsets);
shader.draw(mesh, counts, nullptr, nullptr); 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 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 index offset items but got 0\n"); "GL::AbstractShaderProgram::draw(): expected 3 index offset items but got 0\n");
} }
@ -4555,13 +4553,13 @@ void MeshGLTest::multiDrawIndexedBaseVertexNoExtensionAvailable() {
UnsignedInt vertexOffsets[]{0}; UnsignedInt vertexOffsets[]{0};
UnsignedInt indexOffsets[]{0}; UnsignedInt indexOffsets[]{0};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultiDrawShader{}.draw(mesh, counts, vertexOffsets, indexOffsets); MultiDrawShader{}.draw(mesh, counts, vertexOffsets, indexOffsets);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #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 #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
} }
@ -4600,13 +4598,13 @@ void MeshGLTest::multiDrawIndexedViewsBaseVertexNoExtensionAvailable() {
UnsignedInt vertexOffsets[]{1}; UnsignedInt vertexOffsets[]{1};
UnsignedInt indexOffsets[]{0}; UnsignedInt indexOffsets[]{0};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultiDrawShader{}.draw(mesh, counts, vertexOffsets, indexOffsets); MultiDrawShader{}.draw(mesh, counts, vertexOffsets, indexOffsets);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #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 #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
} }
#endif #endif
@ -4619,10 +4617,10 @@ void MeshGLTest::multiDrawViewsInstanced() {
view.setCount(3) view.setCount(3)
.setInstanceCount(2); .setInstanceCount(2);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultiDrawShader{}.draw({view, view}); 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() { void MeshGLTest::multiDrawViewsDifferentMeshes() {
@ -4631,10 +4629,10 @@ void MeshGLTest::multiDrawViewsDifferentMeshes() {
Mesh a, b; Mesh a, b;
MeshView viewA{a}, viewB{b}; MeshView viewA{a}, viewB{b};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultiDrawShader{}.draw({viewA, viewB}); 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 #ifdef MAGNUM_TARGET_GLES
@ -5125,11 +5123,11 @@ void MeshGLTest::multiDrawInstancedWrongInstanceCountSize() {
UnsignedInt counts[3]{}; UnsignedInt counts[3]{};
UnsignedInt instanceCounts[2]{}; UnsignedInt instanceCounts[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, nullptr, nullptr); shader.draw(mesh, counts, instanceCounts, nullptr, nullptr);
shader.draw(mesh, counts, nullptr, 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 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 instance count items but got 0\n"); "GL::AbstractShaderProgram::draw(): expected 3 instance count items but got 0\n");
} }
@ -5143,11 +5141,11 @@ void MeshGLTest::multiDrawInstancedWrongVertexOffsetSize() {
UnsignedInt instanceCounts[3]{}; UnsignedInt instanceCounts[3]{};
UnsignedInt vertexOffsets[2]{}; UnsignedInt vertexOffsets[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, vertexOffsets, nullptr); shader.draw(mesh, counts, instanceCounts, vertexOffsets, nullptr);
shader.draw(mesh, counts, instanceCounts, nullptr, 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 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 0\n"); "GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 0\n");
} }
@ -5163,11 +5161,11 @@ void MeshGLTest::multiDrawInstancedWrongInstanceOffsetSize() {
UnsignedInt vertexOffsets[3]{}; UnsignedInt vertexOffsets[3]{};
UnsignedInt instanceOffsets[2]{}; UnsignedInt instanceOffsets[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, vertexOffsets, nullptr, instanceOffsets); shader.draw(mesh, counts, instanceCounts, vertexOffsets, nullptr, instanceOffsets);
/* Omitting vertex offsets altogether is okay */ /* 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 #endif
@ -5180,11 +5178,11 @@ void MeshGLTest::multiDrawInstancedIndexedWrongInstanceCountSize() {
UnsignedInt counts[3]{}; UnsignedInt counts[3]{};
UnsignedInt instanceCounts[2]{}; UnsignedInt instanceCounts[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, nullptr, nullptr); shader.draw(mesh, counts, instanceCounts, nullptr, nullptr);
shader.draw(mesh, counts, nullptr, 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 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 instance count items but got 0\n"); "GL::AbstractShaderProgram::draw(): expected 3 instance count items but got 0\n");
} }
@ -5200,11 +5198,11 @@ void MeshGLTest::multiDrawInstancedIndexedWrongVertexOffsetSize() {
UnsignedInt vertexOffsets[2]{}; UnsignedInt vertexOffsets[2]{};
UnsignedInt indexOffsets[3]{}; UnsignedInt indexOffsets[3]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, vertexOffsets, indexOffsets); shader.draw(mesh, counts, instanceCounts, vertexOffsets, indexOffsets);
/* Omitting vertex offsets altogether is okay */ /* 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"); "GL::AbstractShaderProgram::draw(): expected 3 vertex offset items but got 2\n");
} }
@ -5218,11 +5216,11 @@ void MeshGLTest::multiDrawInstancedIndexedWrongIndexOffsetSize() {
UnsignedInt instanceCounts[3]{}; UnsignedInt instanceCounts[3]{};
UnsignedInt indexOffsets[2]{}; UnsignedInt indexOffsets[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, nullptr, indexOffsets); shader.draw(mesh, counts, instanceCounts, nullptr, indexOffsets);
shader.draw(mesh, counts, instanceCounts, nullptr, nullptr); 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 2\n"
"GL::AbstractShaderProgram::draw(): expected 3 index offset items but got 0\n"); "GL::AbstractShaderProgram::draw(): expected 3 index offset items but got 0\n");
} }
@ -5239,11 +5237,11 @@ void MeshGLTest::multiDrawInstancedIndexedWrongInstanceOffsetSize() {
UnsignedInt indexOffsets[3]{}; UnsignedInt indexOffsets[3]{};
UnsignedInt instanceOffsets[2]{}; UnsignedInt instanceOffsets[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.draw(mesh, counts, instanceCounts, nullptr, indexOffsets, instanceOffsets); shader.draw(mesh, counts, instanceCounts, nullptr, indexOffsets, instanceOffsets);
/* Omitting instance offsets altogether is okay */ /* 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() { void MeshGLTest::multiDrawInstancedBaseVertexNoExtensionAvailable() {
@ -5269,13 +5267,13 @@ void MeshGLTest::multiDrawInstancedBaseVertexNoExtensionAvailable() {
UnsignedInt vertexOffsets[]{0}; UnsignedInt vertexOffsets[]{0};
UnsignedInt indexOffsets[]{0}; UnsignedInt indexOffsets[]{0};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultiDrawInstancedShader{}.draw(mesh, counts, instanceCounts, vertexOffsets, indexOffsets); MultiDrawInstancedShader{}.draw(mesh, counts, instanceCounts, vertexOffsets, indexOffsets);
#ifndef MAGNUM_TARGET_GLES2 #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 #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 #endif
} }
@ -5304,11 +5302,11 @@ void MeshGLTest::multiDrawInstancedBaseInstanceNoExtensionAvailable() {
UnsignedInt indexOffsets[]{0}; UnsignedInt indexOffsets[]{0};
UnsignedInt instanceOffsets[]{0}; UnsignedInt instanceOffsets[]{0};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MultiDrawInstancedShader{}.draw(nonIndexed, counts, instanceCounts, vertexOffsets, nullptr, instanceOffsets); MultiDrawInstancedShader{}.draw(nonIndexed, counts, instanceCounts, vertexOffsets, nullptr, instanceOffsets);
MultiDrawInstancedShader{}.draw(indexed, counts, instanceCounts, nullptr, indexOffsets, 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 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"); "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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Mesh.h" #include "Magnum/Mesh.h"
#include "Magnum/GL/AbstractShaderProgram.h" #include "Magnum/GL/AbstractShaderProgram.h"
@ -142,25 +141,25 @@ struct Shader: AbstractShaderProgram {
void MeshTest::drawCountNotSet() { void MeshTest::drawCountNotSet() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Shader{NoCreate}.draw(Mesh{NoCreate}); Shader{NoCreate}.draw(Mesh{NoCreate});
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): Mesh::setCount() was never called, probably a mistake?\n"); "GL::AbstractShaderProgram::draw(): Mesh::setCount() was never called, probably a mistake?\n");
} }
void MeshTest::drawViewCountNotSet() { void MeshTest::drawViewCountNotSet() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Mesh mesh{NoCreate}; Mesh mesh{NoCreate};
Shader{NoCreate}.draw(MeshView{mesh}); Shader{NoCreate}.draw(MeshView{mesh});
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::AbstractShaderProgram::draw(): MeshView::setCount() was never called, probably a mistake?\n"); "GL::AbstractShaderProgram::draw(): MeshView::setCount() was never called, probably a mistake?\n");
} }
@ -206,21 +205,21 @@ void MeshTest::mapPrimitiveImplementationSpecific() {
void MeshTest::mapPrimitiveUnsupported() { void MeshTest::mapPrimitiveUnsupported() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
meshPrimitive(Magnum::MeshPrimitive::Instances); 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() { void MeshTest::mapPrimitiveInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
meshPrimitive(Magnum::MeshPrimitive{}); meshPrimitive(Magnum::MeshPrimitive{});
meshPrimitive(Magnum::MeshPrimitive(0x12)); meshPrimitive(Magnum::MeshPrimitive(0x12));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::meshPrimitive(): invalid primitive MeshPrimitive(0x0)\n" "GL::meshPrimitive(): invalid primitive MeshPrimitive(0x0)\n"
"GL::meshPrimitive(): invalid primitive MeshPrimitive(0x12)\n"); "GL::meshPrimitive(): invalid primitive MeshPrimitive(0x12)\n");
} }
@ -261,12 +260,12 @@ void MeshTest::mapIndexTypeImplementationSpecific() {
void MeshTest::mapIndexTypeInvalid() { void MeshTest::mapIndexTypeInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
meshIndexType(Magnum::MeshIndexType(0x0)); meshIndexType(Magnum::MeshIndexType(0x0));
meshIndexType(Magnum::MeshIndexType(0x12)); meshIndexType(Magnum::MeshIndexType(0x12));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::meshIndexType(): invalid type MeshIndexType(0x0)\n" "GL::meshIndexType(): invalid type MeshIndexType(0x0)\n"
"GL::meshIndexType(): invalid type MeshIndexType(0x12)\n"); "GL::meshIndexType(): invalid type MeshIndexType(0x12)\n");
} }
@ -280,25 +279,25 @@ void MeshTest::indexTypeSize() {
void MeshTest::indexTypeSizeInvalid() { void MeshTest::indexTypeSizeInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
meshIndexTypeSize(MeshIndexType{}); meshIndexTypeSize(MeshIndexType{});
meshIndexTypeSize(MeshIndexType(0xbadcafe)); meshIndexTypeSize(MeshIndexType(0xbadcafe));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::meshIndexTypeSize(): invalid type GL::MeshIndexType(0x0)\n" "GL::meshIndexTypeSize(): invalid type GL::MeshIndexType(0x0)\n"
"GL::meshIndexTypeSize(): invalid type GL::MeshIndexType(0xbadcafe)\n"); "GL::meshIndexTypeSize(): invalid type GL::MeshIndexType(0xbadcafe)\n");
} }
void MeshTest::debugPrimitive() { void MeshTest::debugPrimitive() {
std::ostringstream o; Containers::String out;
Debug(&o) << MeshPrimitive::TriangleFan << MeshPrimitive(0xdead); Debug{&out} << MeshPrimitive::TriangleFan << MeshPrimitive(0xdead);
CORRADE_COMPARE(o.str(), "GL::MeshPrimitive::TriangleFan GL::MeshPrimitive(0xdead)\n"); CORRADE_COMPARE(out, "GL::MeshPrimitive::TriangleFan GL::MeshPrimitive(0xdead)\n");
} }
void MeshTest::debugIndexType() { void MeshTest::debugIndexType() {
std::ostringstream o; Containers::String out;
Debug(&o) << MeshIndexType::UnsignedShort << MeshIndexType(0xdead); Debug{&out} << MeshIndexType::UnsignedShort << MeshIndexType(0xdead);
CORRADE_COMPARE(o.str(), "GL::MeshIndexType::UnsignedShort GL::MeshIndexType(0xdead)\n"); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/GL/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(pixelType(Magnum::PixelFormat::format), Magnum::GL::PixelType::expectedType); \
CORRADE_COMPARE(genericPixelFormat(Magnum::GL::PixelFormat::expectedFormat, Magnum::GL::PixelType::expectedType), Magnum::PixelFormat::format); \ CORRADE_COMPARE(genericPixelFormat(Magnum::GL::PixelFormat::expectedFormat, Magnum::GL::PixelType::expectedType), Magnum::PixelFormat::format); \
CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \ CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \
std::ostringstream out; \ Containers::String out; \
{ /* Redirected otherwise graceful assert would abort */ \ { /* Redirected otherwise graceful assert would abort */ \
Error redirectError{&out}; \ Error redirectError{&out}; \
textureFormat(Magnum::PixelFormat::format); \ textureFormat(Magnum::PixelFormat::format); \
} \ } \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \ Debug{Debug::Flag::NoNewlineAtTheEnd} << out; \
++nextHandled; \ ++nextHandled; \
continue; \ continue; \
} }
@ -238,12 +237,12 @@ void PixelFormatTest::mapFormatTypeTextureFormat() {
CORRADE_COMPARE(pixelFormat(Magnum::PixelFormat::format), Magnum::GL::PixelFormat::expectedFormat); \ CORRADE_COMPARE(pixelFormat(Magnum::PixelFormat::format), Magnum::GL::PixelFormat::expectedFormat); \
CORRADE_COMPARE(pixelType(Magnum::PixelFormat::format), Magnum::GL::PixelType::expectedType); \ CORRADE_COMPARE(pixelType(Magnum::PixelFormat::format), Magnum::GL::PixelType::expectedType); \
CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \ CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \
std::ostringstream out; \ Containers::String out; \
{ /* Redirected otherwise graceful assert would abort */ \ { /* Redirected otherwise graceful assert would abort */ \
Error redirectError{&out}; \ Error redirectError{&out}; \
textureFormat(Magnum::PixelFormat::format); \ textureFormat(Magnum::PixelFormat::format); \
} \ } \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \ Debug{Debug::Flag::NoNewlineAtTheEnd} << out; \
++nextHandled; \ ++nextHandled; \
continue; \ continue; \
} }
@ -253,14 +252,14 @@ void PixelFormatTest::mapFormatTypeTextureFormat() {
CORRADE_COMPARE(firstUnhandled, 0xffff); \ CORRADE_COMPARE(firstUnhandled, 0xffff); \
CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::format)); \ CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::format)); \
CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \ CORRADE_VERIFY(!hasTextureFormat(Magnum::PixelFormat::format)); \
std::ostringstream out; \ Containers::String out; \
{ /* Redirected otherwise graceful assert would abort */ \ { /* Redirected otherwise graceful assert would abort */ \
Error redirectError{&out}; \ Error redirectError{&out}; \
pixelFormat(Magnum::PixelFormat::format); \ pixelFormat(Magnum::PixelFormat::format); \
pixelType(Magnum::PixelFormat::format); \ pixelType(Magnum::PixelFormat::format); \
textureFormat(Magnum::PixelFormat::format); \ textureFormat(Magnum::PixelFormat::format); \
} \ } \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \ Debug{Debug::Flag::NoNewlineAtTheEnd} << out; \
++nextHandled; \ ++nextHandled; \
continue; \ continue; \
} }
@ -295,26 +294,26 @@ void PixelFormatTest::mapFormatUnsupported() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
CORRADE_SKIP("All pixel formats are supported on ES3+."); CORRADE_SKIP("All pixel formats are supported on ES3+.");
#else #else
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::RGB16UI)); CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::RGB16UI));
pixelFormat(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 #endif
} }
void PixelFormatTest::mapFormatInvalid() { void PixelFormatTest::mapFormatInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
hasPixelFormat(Magnum::PixelFormat{}); hasPixelFormat(Magnum::PixelFormat{});
hasPixelFormat(Magnum::PixelFormat(0x123)); hasPixelFormat(Magnum::PixelFormat(0x123));
pixelFormat(Magnum::PixelFormat{}); pixelFormat(Magnum::PixelFormat{});
pixelFormat(Magnum::PixelFormat(0x123)); pixelFormat(Magnum::PixelFormat(0x123));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::hasPixelFormat(): invalid format PixelFormat(0x0)\n" "GL::hasPixelFormat(): invalid format PixelFormat(0x0)\n"
"GL::hasPixelFormat(): invalid format PixelFormat(0x123)\n" "GL::hasPixelFormat(): invalid format PixelFormat(0x123)\n"
"GL::pixelFormat(): invalid format PixelFormat(0x0)\n" "GL::pixelFormat(): invalid format PixelFormat(0x0)\n"
@ -329,11 +328,11 @@ void PixelFormatTest::mapTypeImplementationSpecific() {
void PixelFormatTest::mapTypeImplementationSpecificZero() { void PixelFormatTest::mapTypeImplementationSpecificZero() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
pixelType(Magnum::pixelFormatWrap(PixelFormat::RGBA)); 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() { void PixelFormatTest::mapTypeUnsupported() {
@ -344,21 +343,21 @@ void PixelFormatTest::mapTypeUnsupported() {
#else #else
CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::RGBA16UI)); CORRADE_VERIFY(!hasPixelFormat(Magnum::PixelFormat::RGBA16UI));
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
pixelType(Magnum::PixelFormat::RGB16UI); 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 #endif
} }
void PixelFormatTest::mapTypeInvalid() { void PixelFormatTest::mapTypeInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
pixelType(Magnum::PixelFormat{}); pixelType(Magnum::PixelFormat{});
pixelType(Magnum::PixelFormat(0x123)); pixelType(Magnum::PixelFormat(0x123));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::pixelType(): invalid format PixelFormat(0x0)\n" "GL::pixelType(): invalid format PixelFormat(0x0)\n"
"GL::pixelType(): invalid format PixelFormat(0x123)\n"); "GL::pixelType(): invalid format PixelFormat(0x123)\n");
} }
@ -366,11 +365,11 @@ void PixelFormatTest::mapTypeInvalid() {
void PixelFormatTest::mapTextureFormatImplementationSpecific() { void PixelFormatTest::mapTextureFormatImplementationSpecific() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
hasTextureFormat(Magnum::pixelFormatWrap(PixelFormat::RGBA)); hasTextureFormat(Magnum::pixelFormatWrap(PixelFormat::RGBA));
textureFormat(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::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"); "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) #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2)
CORRADE_SKIP("All pixel formats are supported on ES3+."); CORRADE_SKIP("All pixel formats are supported on ES3+.");
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
textureFormat(Magnum::PixelFormat::Depth32F); 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 #else
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
textureFormat(Magnum::PixelFormat::Depth16UnormStencil8UI); 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 #endif
} }
void PixelFormatTest::mapTextureFormatInvalid() { void PixelFormatTest::mapTextureFormatInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
hasTextureFormat(Magnum::PixelFormat{}); hasTextureFormat(Magnum::PixelFormat{});
hasTextureFormat(Magnum::PixelFormat(0x123)); hasTextureFormat(Magnum::PixelFormat(0x123));
textureFormat(Magnum::PixelFormat{}); textureFormat(Magnum::PixelFormat{});
textureFormat(Magnum::PixelFormat(0x123)); textureFormat(Magnum::PixelFormat(0x123));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::hasTextureFormat(): invalid format PixelFormat(0x0)\n" "GL::hasTextureFormat(): invalid format PixelFormat(0x0)\n"
"GL::hasTextureFormat(): invalid format PixelFormat(0x123)\n" "GL::hasTextureFormat(): invalid format PixelFormat(0x123)\n"
"GL::textureFormat(): invalid format PixelFormat(0x0)\n" "GL::textureFormat(): invalid format PixelFormat(0x0)\n"
@ -443,10 +442,10 @@ void PixelFormatTest::size() {
void PixelFormatTest::sizeInvalid() { void PixelFormatTest::sizeInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
pixelFormatSize(PixelFormat::DepthStencil, PixelType::Float); 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() { void PixelFormatTest::mapCompressedFormatTextureFormat() {
@ -507,13 +506,13 @@ void PixelFormatTest::mapCompressedFormatTextureFormat() {
CORRADE_COMPARE(firstUnhandled, 0xffff); \ CORRADE_COMPARE(firstUnhandled, 0xffff); \
CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::format)); \ CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::format)); \
CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::format)); \ CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::format)); \
std::ostringstream out; \ Containers::String out; \
{ /* Redirected otherwise graceful assert would abort */ \ { /* Redirected otherwise graceful assert would abort */ \
Error redirectError{&out}; \ Error redirectError{&out}; \
compressedPixelFormat(Magnum::CompressedPixelFormat::format); \ compressedPixelFormat(Magnum::CompressedPixelFormat::format); \
textureFormat(Magnum::CompressedPixelFormat::format); \ textureFormat(Magnum::CompressedPixelFormat::format); \
} \ } \
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \ Debug{Debug::Flag::NoNewlineAtTheEnd} << out; \
++nextHandled; \ ++nextHandled; \
continue; \ continue; \
} }
@ -547,17 +546,17 @@ void PixelFormatTest::mapCompressedFormatUnsupported() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm)); CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm));
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compressedPixelFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm); 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) #elif !defined(MAGNUM_TARGET_GLES)
CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm)); CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm));
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compressedPixelFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm); 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 #else
CORRADE_SKIP("All compressed pixel formats are supported on ES3."); CORRADE_SKIP("All compressed pixel formats are supported on ES3.");
#endif #endif
@ -566,14 +565,14 @@ void PixelFormatTest::mapCompressedFormatUnsupported() {
void PixelFormatTest::mapCompressedFormatInvalid() { void PixelFormatTest::mapCompressedFormatInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
hasCompressedPixelFormat(Magnum::CompressedPixelFormat{}); hasCompressedPixelFormat(Magnum::CompressedPixelFormat{});
hasCompressedPixelFormat(Magnum::CompressedPixelFormat(0x123)); hasCompressedPixelFormat(Magnum::CompressedPixelFormat(0x123));
compressedPixelFormat(Magnum::CompressedPixelFormat{}); compressedPixelFormat(Magnum::CompressedPixelFormat{});
compressedPixelFormat(Magnum::CompressedPixelFormat(0x123)); compressedPixelFormat(Magnum::CompressedPixelFormat(0x123));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::hasCompressedPixelFormat(): invalid format CompressedPixelFormat(0x0)\n" "GL::hasCompressedPixelFormat(): invalid format CompressedPixelFormat(0x0)\n"
"GL::hasCompressedPixelFormat(): invalid format CompressedPixelFormat(0x123)\n" "GL::hasCompressedPixelFormat(): invalid format CompressedPixelFormat(0x123)\n"
"GL::compressedPixelFormat(): invalid format CompressedPixelFormat(0x0)\n" "GL::compressedPixelFormat(): invalid format CompressedPixelFormat(0x0)\n"
@ -592,17 +591,17 @@ void PixelFormatTest::mapCompressedTextureFormatUnsupported() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm)); CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm));
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
textureFormat(Magnum::CompressedPixelFormat::Astc3x3x3RGBAUnorm); 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) #elif !defined(MAGNUM_TARGET_GLES)
CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm)); CORRADE_VERIFY(!hasTextureFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm));
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
textureFormat(Magnum::CompressedPixelFormat::PvrtcRGB2bppUnorm); 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 #else
CORRADE_SKIP("All compressed pixel formats are supported on ES3."); CORRADE_SKIP("All compressed pixel formats are supported on ES3.");
#endif #endif
@ -611,14 +610,14 @@ void PixelFormatTest::mapCompressedTextureFormatUnsupported() {
void PixelFormatTest::mapCompressedTextureFormatInvalid() { void PixelFormatTest::mapCompressedTextureFormatInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
hasTextureFormat(Magnum::CompressedPixelFormat{}); hasTextureFormat(Magnum::CompressedPixelFormat{});
hasTextureFormat(Magnum::CompressedPixelFormat(0x123)); hasTextureFormat(Magnum::CompressedPixelFormat(0x123));
textureFormat(Magnum::CompressedPixelFormat{}); textureFormat(Magnum::CompressedPixelFormat{});
textureFormat(Magnum::CompressedPixelFormat(0x123)); textureFormat(Magnum::CompressedPixelFormat(0x123));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"GL::hasTextureFormat(): invalid format CompressedPixelFormat(0x0)\n" "GL::hasTextureFormat(): invalid format CompressedPixelFormat(0x0)\n"
"GL::hasTextureFormat(): invalid format CompressedPixelFormat(0x123)\n" "GL::hasTextureFormat(): invalid format CompressedPixelFormat(0x123)\n"
"GL::textureFormat(): invalid format CompressedPixelFormat(0x0)\n" "GL::textureFormat(): invalid format CompressedPixelFormat(0x0)\n"
@ -637,31 +636,31 @@ void PixelFormatTest::mapGenericCompressedFormatUnsupported() {
} }
void PixelFormatTest::debugPixelFormat() { void PixelFormatTest::debugPixelFormat() {
std::ostringstream out; Containers::String out;
Debug(&out) << PixelFormat::RGBA << PixelFormat(0xdead); 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() { void PixelFormatTest::debugPixelType() {
std::ostringstream out; Containers::String out;
Debug(&out) << PixelType::UnsignedByte << PixelType(0xdead); 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() { void PixelFormatTest::debugCompressedPixelFormat() {
std::ostringstream out; Containers::String out;
Debug{&out} << CompressedPixelFormat::RGBS3tcDxt1 << CompressedPixelFormat(0xdead); 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() { void PixelFormatTest::debugTextureFormat() {
std::ostringstream out; Containers::String out;
Debug(&out) << TextureFormat::DepthComponent << TextureFormat(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Renderer.h" #include "Magnum/GL/Renderer.h"
@ -52,25 +51,25 @@ RendererTest::RendererTest() {
} }
void RendererTest::debugError() { void RendererTest::debugError() {
std::ostringstream out; Containers::String out;
Debug(&out) << Renderer::Error::InvalidOperation << Renderer::Error(0xdead); 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 #ifndef MAGNUM_TARGET_WEBGL
void RendererTest::debugResetNotificationStrategy() { void RendererTest::debugResetNotificationStrategy() {
std::ostringstream out; Containers::String out;
Debug(&out) << Renderer::ResetNotificationStrategy::LoseContextOnReset << Renderer::ResetNotificationStrategy(0xdead); 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() { void RendererTest::debugGraphicsResetStatus() {
std::ostringstream out; Containers::String out;
Debug(&out) << Renderer::GraphicsResetStatus::GuiltyContextReset << Renderer::GraphicsResetStatus(0xdead); 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 #endif

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

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

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

@ -25,14 +25,11 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h> #include <Corrade/Containers/StringIterable.h>
#include <Corrade/Containers/StringStl.h> /* StringHasPrefix / StringHasSuffix */
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h> #include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/System.h> #include <Corrade/Utility/System.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
@ -399,11 +396,11 @@ void ShaderGLTest::addFileNonexistent() {
Shader shader(Version::GLES200, Shader::Type::Fragment); Shader shader(Version::GLES200, Shader::Type::Fragment);
#endif #endif
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
shader.addFile("nonexistent"); shader.addFile("nonexistent");
/* There's an error message from Path::read() before */ /* 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", "\nGL::Shader::addFile(): can't read nonexistent\n",
TestSuite::Compare::StringHasSuffix); TestSuite::Compare::StringHasSuffix);
} }
@ -467,7 +464,7 @@ void ShaderGLTest::compileFailure() {
/* First line is 1, so 175 newlines means the error is on line 176 */ /* 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"); shader.addSource("void main() {" + "\n"_s*175 + "someOutputVariable = ERROR_ERROR();\n}\n");
std::ostringstream out; Containers::String out;
{ {
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!shader.compile()); CORRADE_VERIFY(!shader.compile());
@ -475,33 +472,33 @@ void ShaderGLTest::compileFailure() {
CORRADE_VERIFY(shader.isCompileFinished()); CORRADE_VERIFY(shader.isCompileFinished());
/* There's a driver-specific message after */ /* 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); TestSuite::Compare::StringHasPrefix);
/* The error message should contain the correct source number */ /* 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 #ifndef MAGNUM_TARGET_WEBGL
/* Fixed in 23.1.4, https://gitlab.freedesktop.org/mesa/mesa/-/commit/d5ff432d7d08c8bb644594ccf28b83be4b521ffe /* 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, Since I don't have any builtin way to compare version strings yet,
XFAILing only optionally, if it actually doesn't contain the XFAILing only optionally, if it actually doesn't contain the
string. */ 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."); "Mesa reports source number only in some cases.");
#endif #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 */ /* The error message should contain the correct line number */
CORRADE_COMPARE_AS(out.str(), "175", TestSuite::Compare::StringNotContains); CORRADE_COMPARE_AS(out, "175", TestSuite::Compare::StringNotContains);
CORRADE_COMPARE_AS(out.str(), "176", TestSuite::Compare::StringContains); CORRADE_COMPARE_AS(out, "176", TestSuite::Compare::StringContains);
CORRADE_COMPARE_AS(out.str(), "177", TestSuite::Compare::StringNotContains); CORRADE_COMPARE_AS(out, "177", TestSuite::Compare::StringNotContains);
/* No stray \0 should be anywhere */ /* 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 */ /* 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() { void ShaderGLTest::compileFailureAsync() {
@ -521,7 +518,7 @@ void ShaderGLTest::compileFailureAsync() {
shader.addSource("[fu] bleh error #:! stuff\n"); shader.addSource("[fu] bleh error #:! stuff\n");
/* The compile submission should not print anything ... */ /* The compile submission should not print anything ... */
std::ostringstream out; Containers::String out;
{ {
Error redirectError{&out}; Error redirectError{&out};
shader.submitCompile(); shader.submitCompile();
@ -530,7 +527,7 @@ void ShaderGLTest::compileFailureAsync() {
while(!shader.isCompileFinished()) while(!shader.isCompileFinished())
Utility::System::sleep(100); Utility::System::sleep(100);
CORRADE_VERIFY(out.str().empty()); CORRADE_COMPARE(out, "");
/* ... only the final check should */ /* ... only the final check should */
{ {
@ -538,7 +535,7 @@ void ShaderGLTest::compileFailureAsync() {
CORRADE_VERIFY(!shader.checkCompile()); CORRADE_VERIFY(!shader.checkCompile());
} }
CORRADE_VERIFY(shader.isCompileFinished()); 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); TestSuite::Compare::StringHasPrefix);
/* Not testing presence of \0 etc., as that's tested well enough in /* 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Shader.h" #include "Magnum/GL/Shader.h"
@ -62,10 +61,10 @@ void ShaderTest::constructCopy() {
} }
void ShaderTest::debugType() { void ShaderTest::debugType() {
std::ostringstream out; Containers::String out;
Debug(&out) << Shader::Type::Fragment << Shader::Type(0xdead); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Version.h" #include "Magnum/GL/Version.h"
@ -103,7 +102,7 @@ void VersionTest::compare() {
} }
void VersionTest::debug() { void VersionTest::debug() {
std::ostringstream out; Containers::String out;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Debug(&out) << Version::GL210 << Version(0xdead); Debug(&out) << Version::GL210 << Version(0xdead);
@ -112,20 +111,20 @@ void VersionTest::debug() {
#endif #endif
#ifdef MAGNUM_TARGET_WEBGL #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) #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 #else
CORRADE_COMPARE(out.str(), "OpenGL 2.1 Invalid(0xdead)\n"); CORRADE_COMPARE(out, "OpenGL 2.1 Invalid(0xdead)\n");
#endif #endif
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void VersionTest::debugES() { void VersionTest::debugES() {
std::ostringstream out; Containers::String out;
Debug{&out} << Version::GLES310; Debug{&out} << Version::GLES310;
CORRADE_COMPARE(out.str(), "OpenGL ES 3.1\n"); CORRADE_COMPARE(out, "OpenGL ES 3.1\n");
} }
#endif #endif

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

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/BitArray.h> #include <Corrade/Containers/BitArray.h>
#include <Corrade/Containers/BitArrayView.h> #include <Corrade/Containers/BitArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/DebugTools/CompareMaterial.h" #include "Magnum/DebugTools/CompareMaterial.h"
#include "Magnum/MaterialTools/Filter.h" #include "Magnum/MaterialTools/Filter.h"
@ -162,10 +161,10 @@ void FilterTest::attributesWrongBitCount() {
}, {2, 4}}; }, {2, 4}};
Containers::BitArrayView attributesToKeep{nullptr, 0, 5}; Containers::BitArrayView attributesToKeep{nullptr, 0, 5};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
filterAttributes(material, attributesToKeep); 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() { void FilterTest::layers() {
@ -253,10 +252,10 @@ void FilterTest::layersWrongBitCount() {
}, {2, 4}}; }, {2, 4}};
Containers::BitArrayView layersToKeep{nullptr, 0, 3}; Containers::BitArrayView layersToKeep{nullptr, 0, 3};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
filterLayers(material, layersToKeep); 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() { void FilterTest::attributesLayers() {
@ -356,11 +355,11 @@ void FilterTest::attributesLayersWrongBitCount() {
Containers::BitArrayView attributesToKeep{nullptr, 0, 5}; Containers::BitArrayView attributesToKeep{nullptr, 0, 5};
Containers::BitArrayView layersToKeep{nullptr, 0, 3}; Containers::BitArrayView layersToKeep{nullptr, 0, 3};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
filterAttributesLayers(material, attributesToKeep, layersToKeep.prefix(2)); filterAttributesLayers(material, attributesToKeep, layersToKeep.prefix(2));
filterAttributesLayers(material, attributesToKeep.prefix(4), layersToKeep); 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 4 attribute bits but got 5\n"
"MaterialTools::filterAttributesLayers(): expected 2 layer bits but got 3\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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/DebugTools/CompareMaterial.h" #include "Magnum/DebugTools/CompareMaterial.h"
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
@ -306,13 +305,13 @@ void MergeTest::conflictsFail() {
}, {2, 3}}; }, {2, 3}};
/* Verify that it fails in all variants */ /* Verify that it fails in all variants */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!merge(a, b)); CORRADE_VERIFY(!merge(a, b));
CORRADE_VERIFY(!merge(b, a)); CORRADE_VERIFY(!merge(b, a));
CORRADE_VERIFY(!merge(a, c, MergeConflicts::KeepFirstIfSameType)); CORRADE_VERIFY(!merge(a, c, MergeConflicts::KeepFirstIfSameType));
CORRADE_VERIFY(!merge(c, a, 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 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" "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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.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/DebugTools/CompareMaterial.h"
#include "Magnum/MaterialTools/PhongToPbrMetallicRoughness.h" #include "Magnum/MaterialTools/PhongToPbrMetallicRoughness.h"
@ -278,35 +277,35 @@ void PhongToPbrMetallicRoughnessTest::convert() {
auto&& data = ConvertData[testCaseInstanceId()]; auto&& data = ConvertData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Containers::Optional<Trade::MaterialData> actual = phongToPbrMetallicRoughness(data.material, data.flags); Containers::Optional<Trade::MaterialData> actual = phongToPbrMetallicRoughness(data.material, data.flags);
CORRADE_VERIFY(actual); CORRADE_VERIFY(actual);
CORRADE_COMPARE_AS(*actual, data.expected, DebugTools::CompareMaterial); CORRADE_COMPARE_AS(*actual, data.expected, DebugTools::CompareMaterial);
CORRADE_COMPARE(out.str(), ""); CORRADE_COMPARE(out, "");
} }
void PhongToPbrMetallicRoughnessTest::warning() { void PhongToPbrMetallicRoughnessTest::warning() {
auto&& data = WarningData[testCaseInstanceId()]; auto&& data = WarningData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::ostringstream out; Containers::String out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Containers::Optional<Trade::MaterialData> actual = phongToPbrMetallicRoughness(data.material, data.flags); Containers::Optional<Trade::MaterialData> actual = phongToPbrMetallicRoughness(data.material, data.flags);
CORRADE_VERIFY(actual); CORRADE_VERIFY(actual);
CORRADE_COMPARE_AS(*actual, data.expected, DebugTools::CompareMaterial); CORRADE_COMPARE_AS(*actual, data.expected, DebugTools::CompareMaterial);
CORRADE_COMPARE(out.str(), data.message); CORRADE_COMPARE(out, data.message);
} }
void PhongToPbrMetallicRoughnessTest::fail() { void PhongToPbrMetallicRoughnessTest::fail() {
auto&& data = FailData[testCaseInstanceId()]; auto&& data = FailData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_VERIFY(!phongToPbrMetallicRoughness(data.material, data.flags)); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> /** @todo remove once Debug is stream-free */
#include <Corrade/Containers/Iterable.h> #include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.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/DebugTools/CompareMaterial.h"
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
@ -648,11 +647,11 @@ void RemoveDuplicatesTest::invalidSize() {
}; };
UnsignedInt mapping[3]; UnsignedInt mapping[3];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
removeDuplicatesInto(data, mapping); removeDuplicatesInto(data, mapping);
removeDuplicatesInPlaceInto(data, mapping); removeDuplicatesInPlaceInto(data, mapping);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MaterialTools::removeDuplicatesInto(): bad output size, expected 2 but got 3\n" "MaterialTools::removeDuplicatesInto(): bad output size, expected 2 but got 3\n"
"MaterialTools::removeDuplicatesInPlaceInto(): 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <new>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.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) #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/Format.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/TweakableParser.h> #include <Corrade/Utility/TweakableParser.h>
#endif #endif
@ -341,43 +340,43 @@ void AngleTest::conversion() {
} }
void AngleTest::debugDeg() { void AngleTest::debugDeg() {
std::ostringstream o; Containers::String out;
Debug(&o) << 90.0_degf; Debug{&out} << 90.0_degf;
CORRADE_COMPARE(o.str(), "Deg(90)\n"); CORRADE_COMPARE(out, "Deg(90)\n");
/* Verify that this compiles */ /* Verify that this compiles */
o.str({}); out = {};
Debug(&o) << 56.0_degf - 34.0_degf; Debug{&out} << 56.0_degf - 34.0_degf;
CORRADE_COMPARE(o.str(), "Deg(22)\n"); CORRADE_COMPARE(out, "Deg(22)\n");
} }
void AngleTest::debugDegPacked() { void AngleTest::debugDegPacked() {
std::ostringstream out; Containers::String out;
/* Second is not packed, the first should not make any flags persistent */ /* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << 90.0_degf << 45.0_degf; 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() { void AngleTest::debugRad() {
std::ostringstream o; Containers::String out;
Debug(&o) << 1.5708_radf; Debug{&out} << 1.5708_radf;
CORRADE_COMPARE(o.str(), "Rad(1.5708)\n"); CORRADE_COMPARE(out, "Rad(1.5708)\n");
/* Verify that this compiles */ /* Verify that this compiles */
o.str({}); out = {};
Debug(&o) << 1.5708_radf - 3.1416_radf; Debug{&out} << 1.5708_radf - 3.1416_radf;
CORRADE_COMPARE(o.str(), "Rad(-1.5708)\n"); CORRADE_COMPARE(out, "Rad(-1.5708)\n");
} }
void AngleTest::debugRadPacked() { void AngleTest::debugRadPacked() {
std::ostringstream out; Containers::String out;
/* Second is not packed, the first should not make any flags persistent */ /* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << 1.5708_radf << 3.1416_radf; 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) #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()); setTestCaseTemplateName(TweakableTraits<T>::name());
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::ostringstream out; Containers::String out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<T>::parse(Utility::format(data.data, TweakableTraits<T>::literal())).first(); 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); CORRADE_COMPARE(state, data.state);
} }
#endif #endif

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

@ -25,9 +25,10 @@
DEALINGS IN THE SOFTWARE. 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/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Bezier.h" #include "Magnum/Math/Bezier.h"
#include "Magnum/Math/CubicHermite.h" #include "Magnum/Math/CubicHermite.h"
@ -337,9 +338,9 @@ void BezierTest::strictWeakOrdering() {
} }
void BezierTest::debug() { 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}}; 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. 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/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/BitVector.h" #include "Magnum/Math/BitVector.h"
#include "Magnum/Math/StrictWeakOrdering.h" #include "Magnum/Math/StrictWeakOrdering.h"
@ -373,12 +374,12 @@ void BitVectorTest::strictWeakOrdering() {
} }
void BitVectorTest::debug() { void BitVectorTest::debug() {
std::ostringstream o; Containers::String out;
/* 0b00100101 0b01010011 0b010 */ /* 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
@ -32,7 +31,6 @@
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h> #include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is stram-free */
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -369,11 +367,11 @@ void ColorBatchTest::yFlipInvalidLastDimension() {
it's enough to test just some */ it's enough to test just some */
char data[32]; char data[32];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
yFlipBc3InPlace(Containers::stridedArrayView(data).expanded<0>(Containers::Size3D{1, 4, 8})); 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})); 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::yFlipBc3InPlace(): expected last dimension to be 16 bytes but got 8\n"
"Math::yFlipBc1InPlace(): last dimension is not contiguous\n"); "Math::yFlipBc1InPlace(): last dimension is not contiguous\n");
} }

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

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

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

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

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

@ -24,9 +24,10 @@
DEALINGS IN THE SOFTWARE. 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/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Bezier.h" #include "Magnum/Math/Bezier.h"
#include "Magnum/Math/CubicHermite.h" #include "Magnum/Math/CubicHermite.h"
@ -892,7 +893,7 @@ void CubicHermiteTest::lerpComplex() {
void CubicHermiteTest::lerpComplexNotNormalized() { void CubicHermiteTest::lerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* This one should not assert as the default constructor should create /* This one should not assert as the default constructor should create
@ -903,7 +904,7 @@ void CubicHermiteTest::lerpComplexNotNormalized() {
CubicHermiteComplex a{{}, Complex{}*2.0f, {}}; CubicHermiteComplex a{{}, Complex{}*2.0f, {}};
Math::lerp({}, a, 0.3f); Math::lerp({}, a, 0.3f);
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(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"); "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() { void CubicHermiteTest::lerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* This one should not assert as the default constructor should create /* This one should not assert as the default constructor should create
@ -946,7 +947,7 @@ void CubicHermiteTest::lerpQuaternionNotNormalized() {
CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}}; CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}};
Math::lerp({}, a, 0.3f); Math::lerp({}, a, 0.3f);
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}, 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"); "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() { void CubicHermiteTest::lerpQuaternionShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* This one should not assert as the default constructor should create /* 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);
Math::lerpShortestPath(a, {}, 0.3f); Math::lerpShortestPath(a, {}, 0.3f);
/* lerpShortestPath() is calling lerp(), so the message is from there */ /* 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}, 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"); "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() { void CubicHermiteTest::slerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* This one should not assert as the default constructor should create /* This one should not assert as the default constructor should create
@ -1026,7 +1027,7 @@ void CubicHermiteTest::slerpComplexNotNormalized() {
CubicHermiteComplex a{{}, Complex{}*2.0f, {}}; CubicHermiteComplex a{{}, Complex{}*2.0f, {}};
Math::slerp({}, a, 0.3f); Math::slerp({}, a, 0.3f);
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(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"); "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() { void CubicHermiteTest::slerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* This one should not assert as the default constructor should create /* This one should not assert as the default constructor should create
@ -1069,7 +1070,7 @@ void CubicHermiteTest::slerpQuaternionNotNormalized() {
CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}}; CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}};
Math::slerp({}, a, 0.3f); Math::slerp({}, a, 0.3f);
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}, 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"); "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() { void CubicHermiteTest::slerpQuaternionShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* This one should not assert as the default constructor should create /* This one should not assert as the default constructor should create
@ -1112,7 +1113,7 @@ void CubicHermiteTest::slerpQuaternionShortestPathNotNormalized() {
CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}}; CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}};
Math::slerpShortestPath({}, a, 0.3f); Math::slerpShortestPath({}, a, 0.3f);
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}, 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"); "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() { void CubicHermiteTest::splerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* This one should not assert as the default constructor should create /* This one should not assert as the default constructor should create
@ -1186,7 +1187,7 @@ void CubicHermiteTest::splerpComplexNotNormalized() {
CubicHermiteComplex a{{}, Complex{}*2.0f, {}}; CubicHermiteComplex a{{}, Complex{}*2.0f, {}};
Math::splerp({}, a, 0.3f); Math::splerp({}, a, 0.3f);
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(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"); "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() { void CubicHermiteTest::splerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* This one should not assert as the default constructor should create /* This one should not assert as the default constructor should create
@ -1225,7 +1226,7 @@ void CubicHermiteTest::splerpQuaternionNotNormalized() {
CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}}; CubicHermiteQuaternion a{{}, Quaternion{}*2.0f, {}};
Math::splerp({}, a, 0.3f); Math::splerp({}, a, 0.3f);
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}, 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"); "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() { void CubicHermiteTest::debugScalar() {
std::ostringstream out; Containers::String out;
Debug{&out} << CubicHermite1D{2.0f, 3.0f, -1.0f}; 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() { void CubicHermiteTest::debugVector() {
std::ostringstream out; Containers::String out;
Debug{&out} << CubicHermite2D{{2.0f, 1.5f}, {3.0f, 0.1f}, {-1.0f, 0.0f}}; 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() { void CubicHermiteTest::debugComplex() {
std::ostringstream out; Containers::String out;
Debug{&out} << CubicHermiteComplex{{2.0f, 1.5f}, {3.0f, 0.1f}, {-1.0f, 0.0f}}; 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() { void CubicHermiteTest::debugQuaternion() {
std::ostringstream out; Containers::String out;
Debug{&out} << CubicHermiteQuaternion{ Debug{&out} << CubicHermiteQuaternion{
{{2.0f, 1.5f, 0.3f}, 1.1f}, {{2.0f, 1.5f, 0.3f}, 1.1f},
{{3.0f, 0.1f, 2.3f}, 0.7f}, {{3.0f, 0.1f, 2.3f}, 0.7f},
{{-1.0f, 0.0f, 0.3f}, 0.4f}}; {{-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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Constants.h" #include "Magnum/Math/Constants.h"
#include "Magnum/Math/Distance.h" #include "Magnum/Math/Distance.h"
@ -237,12 +236,12 @@ void DistanceTest::pointPlaneNormalized() {
void DistanceTest::pointPlaneNormalizedNotNormalized() { void DistanceTest::pointPlaneNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Vector4 invalidPlane{2.0f, 2.0f, 2.0f, 0.0f}; Vector4 invalidPlane{2.0f, 2.0f, 2.0f, 0.0f};
Distance::pointPlaneNormalized({}, invalidPlane); 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. 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/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/DualComplex.h" #include "Magnum/Math/DualComplex.h"
#include "Magnum/Math/DualQuaternion.h" #include "Magnum/Math/DualQuaternion.h"
@ -406,11 +407,11 @@ void DualComplexTest::invertedNormalized() {
void DualComplexTest::invertedNormalizedNotNormalized() { void DualComplexTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DualComplex({-1.0f, -2.5f}, {}).invertedNormalized(); 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() { void DualComplexTest::rotation() {
@ -468,11 +469,11 @@ void DualComplexTest::matrix() {
void DualComplexTest::matrixNotOrthogonal() { void DualComplexTest::matrixNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream o; Containers::String out;
Error redirectError{&o}; Error redirectError{&out};
DualComplex::fromMatrix(Matrix3::rotation(23.0_degf)*Matrix3::translation({2.0f, 3.0f})*2); 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" "Math::DualComplex::fromMatrix(): the matrix doesn't represent rigid transformation:\n"
"Matrix(1.84101, -0.781462, 1.33763,\n" "Matrix(1.84101, -0.781462, 1.33763,\n"
" 0.781462, 1.84101, 7.08595,\n" " 0.781462, 1.84101, 7.08595,\n"
@ -522,10 +523,10 @@ void DualComplexTest::strictWeakOrdering() {
} }
void DualComplexTest::debug() { void DualComplexTest::debug() {
std::ostringstream o; Containers::String out;
Debug(&o) << DualComplex({-1.0f, -2.5f}, {-3.0f, -7.5f}); Debug{&out} << DualComplex({-1.0f, -2.5f}, {-3.0f, -7.5f});
CORRADE_COMPARE(o.str(), "DualComplex({-1, -2.5}, {-3, -7.5})\n"); 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. 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/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/DualQuaternion.h" #include "Magnum/Math/DualQuaternion.h"
#include "Magnum/Math/StrictWeakOrdering.h" #include "Magnum/Math/StrictWeakOrdering.h"
@ -443,11 +444,11 @@ void DualQuaternionTest::invertedNormalized() {
void DualQuaternionTest::invertedNormalizedNotNormalized() { void DualQuaternionTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DualQuaternion({{ 1.0f, 2.0f, 3.0f}, -4.0f}, {{ 2.5f, -3.1f, 3.3f}, 2.0f}).invertedNormalized(); 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() { void DualQuaternionTest::rotation() {
@ -471,11 +472,11 @@ void DualQuaternionTest::rotation() {
void DualQuaternionTest::rotationNotNormalized() { void DualQuaternionTest::rotationNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DualQuaternion::rotation(120.0_degf, Vector3(2.0f)); 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() { void DualQuaternionTest::translation() {
@ -525,11 +526,11 @@ void DualQuaternionTest::matrix() {
void DualQuaternionTest::matrixNotOrthogonal() { void DualQuaternionTest::matrixNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DualQuaternion::fromMatrix(Matrix4::rotationX(23.0_degf)*Matrix4::translation({-1.0f, 2.0f, 3.0f})*2); 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" "Math::DualQuaternion::fromMatrix(): the matrix doesn't represent a rigid transformation:\n"
"Matrix(2, 0, 0, -2,\n" "Matrix(2, 0, 0, -2,\n"
" 0, 1.84101, -0.781462, 1.33763,\n" " 0, 1.84101, -0.781462, 1.33763,\n"
@ -562,13 +563,13 @@ void DualQuaternionTest::transformVectorNormalized() {
void DualQuaternionTest::transformVectorNormalizedNotNormalized() { void DualQuaternionTest::transformVectorNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion a = Quaternion::rotation(23.0_degf, Vector3::xAxis()); Quaternion a = Quaternion::rotation(23.0_degf, Vector3::xAxis());
(a*2).transformVectorNormalized({}); (a*2).transformVectorNormalized({});
/* Delegates to quaternion, so the assert prints Quaternion */ /* 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() { void DualQuaternionTest::transformPoint() {
@ -606,12 +607,12 @@ void DualQuaternionTest::transformPointNormalized() {
void DualQuaternionTest::transformPointNormalizedNotNormalized() { void DualQuaternionTest::transformPointNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
DualQuaternion a = DualQuaternion::translation({-1.0f, 2.0f, 3.0f})*DualQuaternion::rotation(23.0_degf, Vector3::xAxis()); DualQuaternion a = DualQuaternion::translation({-1.0f, 2.0f, 3.0f})*DualQuaternion::rotation(23.0_degf, Vector3::xAxis());
(a*Dual(2)).transformPointNormalized({}); (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() { void DualQuaternionTest::sclerp() {
@ -726,10 +727,10 @@ void DualQuaternionTest::strictWeakOrdering() {
} }
void DualQuaternionTest::debug() { 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}); Debug{&out} << 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"); 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. 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/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Dual.h" #include "Magnum/Math/Dual.h"
#include "Magnum/Math/Quaternion.h" #include "Magnum/Math/Quaternion.h"
@ -385,10 +386,10 @@ void DualTest::subclass() {
} }
void DualTest::debug() { void DualTest::debug() {
std::ostringstream o; Containers::String out;
Debug(&o) << Dual(2.5f, -0.3f); Debug{&out} << Dual(2.5f, -0.3f);
CORRADE_COMPARE(o.str(), "Dual(2.5, -0.3)\n"); CORRADE_COMPARE(out, "Dual(2.5, -0.3)\n");
} }
}}}} }}}}

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

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

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

@ -25,9 +25,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Functions.h" #include "Magnum/Math/Functions.h"
#include "Magnum/Math/Time.h" #include "Magnum/Math/Time.h"
@ -345,19 +344,19 @@ void FunctionsTest::binomialCoefficient() {
void FunctionsTest::binomialCoefficientInvalidInput() { void FunctionsTest::binomialCoefficientInvalidInput() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Math::binomialCoefficient(15, 16); 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() { void FunctionsTest::binomialCoefficientOverflow() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Math::binomialCoefficient(63, 31); 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() { void FunctionsTest::fmod() {
@ -590,10 +589,10 @@ void FunctionsTest::reflect() {
void FunctionsTest::reflectNotNormalized() { void FunctionsTest::reflectNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Math::reflect(Vector3{}, Vector3{1.0f}); Math::reflect(Vector3{}, Vector3{1.0f});
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"Math::reflect(): normal Vector(1, 1, 1) is not normalized\n"); "Math::reflect(): normal Vector(1, 1, 1) is not normalized\n");
} }
@ -617,10 +616,10 @@ void FunctionsTest::refract() {
void FunctionsTest::refractNotNormalized() { void FunctionsTest::refractNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Math::refract(Vector3{}, Vector3{1.0f}, 0.0f); 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"); "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. DEALINGS IN THE SOFTWARE.
*/ */
#include <cstring> #include <new>
#include <sstream>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.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) #if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Corrade/Utility/Tweakable.h> #include <Corrade/Utility/Tweakable.h>
#endif #endif
@ -624,14 +623,14 @@ void HalfTest::literal() {
} }
void HalfTest::debug() { void HalfTest::debug() {
std::ostringstream out; Containers::String out;
Debug{&out} << -36.41_h << Half{Constants::inf()} Debug{&out} << -36.41_h << Half{Constants::inf()}
<< Math::Vector3<Half>{3.14159_h, -1.4142_h, 1.618_h}; << Math::Vector3<Half>{3.14159_h, -1.4142_h, 1.618_h};
#ifdef CORRADE_TARGET_MSVC #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 #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 #endif
} }
@ -648,11 +647,11 @@ void HalfTest::tweakableError() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::ostringstream out; Containers::String out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Utility::TweakableState state = Utility::TweakableParser<Half>::parse(data.data).first(); 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); CORRADE_COMPARE(state, data.state);
} }
#endif #endif

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

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

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

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

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

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Matrix.h" #include "Magnum/Math/Matrix.h"
#include "Magnum/Math/StrictWeakOrdering.h" #include "Magnum/Math/StrictWeakOrdering.h"
@ -536,14 +536,14 @@ void MatrixTest::invertedOrthogonal() {
void MatrixTest::invertedOrthogonalNotOrthogonal() { void MatrixTest::invertedOrthogonalNotOrthogonal() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream o; Containers::String out;
Error redirectError{&o}; Error redirectError{&out};
Matrix3x3 a(Vector3(Constants::sqrt3()/2.0f, 0.5f, 0.0f), Matrix3x3 a(Vector3(Constants::sqrt3()/2.0f, 0.5f, 0.0f),
Vector3(-0.5f, Constants::sqrt3()/2.0f, 0.0f), Vector3(-0.5f, Constants::sqrt3()/2.0f, 0.0f),
Vector3(0.0f, 0.0f, 1.0f)); Vector3(0.0f, 0.0f, 1.0f));
(a*2).invertedOrthogonal(); (a*2).invertedOrthogonal();
CORRADE_COMPARE(o.str(), CORRADE_COMPARE(out,
"Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal:\n" "Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal:\n"
"Matrix(1.73205, -1, 0,\n" "Matrix(1.73205, -1, 0,\n"
" 1, 1.73205, 0,\n" " 1, 1.73205, 0,\n"
@ -631,16 +631,16 @@ void MatrixTest::debug() {
Vector4(7.0f, -1.0f, 8.0f, 0.0f), Vector4(7.0f, -1.0f, 8.0f, 0.0f),
Vector4(9.0f, 4.0f, 5.0f, 9.0f)); Vector4(9.0f, 4.0f, 5.0f, 9.0f));
std::ostringstream o; Containers::String out;
Debug(&o) << m; Debug{&out} << m;
CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7, 9,\n" CORRADE_COMPARE(out, "Matrix(3, 4, 7, 9,\n"
" 5, 4, -1, 4,\n" " 5, 4, -1, 4,\n"
" 8, 7, 8, 5,\n" " 8, 7, 8, 5,\n"
" 4, 3, 0, 9)\n"); " 4, 3, 0, 9)\n");
o.str({}); out = {};
Debug(&o) << "a" << Matrix4x4() << "b" << Matrix4x4(); Debug{&out} << "a" << Matrix4x4() << "b" << Matrix4x4();
CORRADE_COMPARE(o.str(), "a Matrix(1, 0, 0, 0,\n" CORRADE_COMPARE(out, "a Matrix(1, 0, 0, 0,\n"
" 0, 1, 0, 0,\n" " 0, 1, 0, 0,\n"
" 0, 0, 1, 0,\n" " 0, 0, 1, 0,\n"
" 0, 0, 0, 1) b Matrix(1, 0, 0, 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/Math/Packing.h" #include "Magnum/Math/Packing.h"
@ -674,7 +673,7 @@ template<class T> void PackingBatchTest::assertionsPackUnpack() {
auto dstNotContiguous = Containers::arrayCast<2, Float>( auto dstNotContiguous = Containers::arrayCast<2, Float>(
Containers::arrayView(resultNonContiguous)).every({1, 2}); Containers::arrayView(resultNonContiguous)).every({1, 2});
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
unpackInto(src, dstWrongCount); unpackInto(src, dstWrongCount);
unpackInto(src, dstWrongVectorSize); unpackInto(src, dstWrongVectorSize);
@ -684,7 +683,7 @@ template<class T> void PackingBatchTest::assertionsPackUnpack() {
packInto(dstWrongVectorSize, src); packInto(dstWrongVectorSize, src);
packInto(dstNotContiguous, src); packInto(dstNotContiguous, src);
packInto(dst, srcNonContiguous); 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 {1, 2} but expected {2, 2}\n"
"Math::unpackInto(): wrong destination size, got {2, 3} 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" "Math::unpackInto(): second destination view dimension is not contiguous\n"
@ -718,7 +717,7 @@ void PackingBatchTest::assertionsPackUnpackHalf() {
auto dstNotContiguous = Containers::arrayCast<2, Float>( auto dstNotContiguous = Containers::arrayCast<2, Float>(
Containers::arrayView(resultNonContiguous)).every({1, 2}); Containers::arrayView(resultNonContiguous)).every({1, 2});
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
unpackHalfInto(src, dstWrongCount); unpackHalfInto(src, dstWrongCount);
unpackHalfInto(src, dstWrongVectorSize); unpackHalfInto(src, dstWrongVectorSize);
@ -728,7 +727,7 @@ void PackingBatchTest::assertionsPackUnpackHalf() {
packHalfInto(dstWrongVectorSize, src); packHalfInto(dstWrongVectorSize, src);
packHalfInto(dstNotContiguous, src); packHalfInto(dstNotContiguous, src);
packHalfInto(dst, srcNonContiguous); 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 {1, 2} but expected {2, 2}\n"
"Math::unpackHalfInto(): wrong destination size, got {2, 3} 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" "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>( auto dstNotContiguous = Containers::arrayCast<2, U>(
Containers::arrayView(resultNonContiguous)).every({1, 2}); Containers::arrayView(resultNonContiguous)).every({1, 2});
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
castInto(src, dstWrongCount); castInto(src, dstWrongCount);
castInto(src, dstWrongVectorSize); castInto(src, dstWrongVectorSize);
@ -766,7 +765,7 @@ template<class U, class T> void PackingBatchTest::assertionsCast() {
castInto(dstWrongCount, src); castInto(dstWrongCount, src);
castInto(dstWrongVectorSize, src); castInto(dstWrongVectorSize, src);
castInto(dstNotContiguous, 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 {1, 2} but expected {2, 2}\n"
"Math::castInto(): wrong destination size, got {2, 3} 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" "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. 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/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Functions.h" #include "Magnum/Math/Functions.h"
#include "Magnum/Math/Matrix4.h" #include "Magnum/Math/Matrix4.h"
@ -395,13 +396,13 @@ void QuaternionTest::axisAngle() {
void QuaternionTest::axisAngleNotNormalized() { void QuaternionTest::axisAngleNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion a = Quaternion::rotation(23.0_degf, {0.6f, -0.8f, 0.0f})*2; Quaternion a = Quaternion::rotation(23.0_degf, {0.6f, -0.8f, 0.0f})*2;
a.angle(); a.angle();
a.axis(); 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::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"); "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() { void QuaternionTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion{{1.0f, 3.0f, -2.0f}, -4.0f}.invertedNormalized(); 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() { void QuaternionTest::rotation() {
@ -528,11 +529,11 @@ void QuaternionTest::rotation() {
void QuaternionTest::rotationNotNormalized() { void QuaternionTest::rotationNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion::rotation(-74.0_degf, {-1.0f, 2.0f, 2.0f}); 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() { void QuaternionTest::rotationFromTwoVectors() {
@ -599,12 +600,12 @@ void QuaternionTest::rotationFromTwoVectors() {
void QuaternionTest::rotationFromTwoVectorsNotNormalized() { void QuaternionTest::rotationFromTwoVectorsNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion::rotation({2.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}); 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}); 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(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"); "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() { void QuaternionTest::reflectionNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion::reflection({-1.0f, 2.0f, 2.0f}); 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() { void QuaternionTest::angle() {
@ -666,13 +667,13 @@ void QuaternionTest::angleNormalizedButOver1() {
void QuaternionTest::angleNotNormalized() { void QuaternionTest::angleNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&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(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()); 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({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"); "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() { void QuaternionTest::matrixNotRotation() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* Shear, using rotationShear() instead of rotationScaling() as that isn't /* Shear, using rotationShear() instead of rotationScaling() as that isn't
supposed to "fix" the shear */ supposed to "fix" the shear */
@ -739,7 +740,7 @@ void QuaternionTest::matrixNotRotation() {
supposed to "fix" the reflection either */ supposed to "fix" the reflection either */
Quaternion::fromMatrix((Matrix4::scaling({-1.0f, 1.0f, 1.0f})* Quaternion::fromMatrix((Matrix4::scaling({-1.0f, 1.0f, 1.0f})*
Matrix4::rotationZ(45.0_degf)).rotation()); Matrix4::rotationZ(45.0_degf)).rotation());
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"Math::Quaternion::fromMatrix(): the matrix is not a rotation:\n" "Math::Quaternion::fromMatrix(): the matrix is not a rotation:\n"
"Matrix(0.894427, -0.894427, 0,\n" "Matrix(0.894427, -0.894427, 0,\n"
" 0.447214, 0.447214, 0,\n" " 0.447214, 0.447214, 0,\n"
@ -773,11 +774,11 @@ void QuaternionTest::euler() {
void QuaternionTest::eulerNotNormalized() { void QuaternionTest::eulerNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion{{1.0f, 3.0f, -2.0f}, -4.0f}.toEuler(); 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"); "Math::Quaternion::toEuler(): Quaternion({1, 3, -2}, -4) is not normalized\n");
} }
@ -810,13 +811,13 @@ void QuaternionTest::lerp2D() {
void QuaternionTest::lerpNotNormalized() { void QuaternionTest::lerpNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion a; Quaternion a;
Math::lerp(a*3.0f, a, 0.35f); Math::lerp(a*3.0f, a, 0.35f);
Math::lerp(a, a*-3.0f, 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}, 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"); "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() { void QuaternionTest::lerpShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion a; Quaternion a;
Math::lerpShortestPath(a*3.0f, a, 0.35f); Math::lerpShortestPath(a*3.0f, a, 0.35f);
Math::lerpShortestPath(a, a*-3.0f, 0.35f); Math::lerpShortestPath(a, a*-3.0f, 0.35f);
/* lerpShortestPath() is calling lerp(), so the message is from there */ /* 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}, 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"); "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() { void QuaternionTest::slerpNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion a; Quaternion a;
Math::slerp(a*3.0f, a, 0.35f); Math::slerp(a*3.0f, a, 0.35f);
Math::slerp(a, a*-3.0f, 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}, 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"); "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() { void QuaternionTest::slerpShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion a; Quaternion a;
Math::slerpShortestPath(a*3.0f, a, 0.35f); Math::slerpShortestPath(a*3.0f, a, 0.35f);
Math::slerpShortestPath(a, a*-3.0f, 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}, 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"); "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() { void QuaternionTest::transformVectorNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Quaternion a = Quaternion::rotation(23.0_degf, Vector3::xAxis()); Quaternion a = Quaternion::rotation(23.0_degf, Vector3::xAxis());
(a*2).transformVectorNormalized({}); (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() { void QuaternionTest::reflectVector() {
@ -1066,10 +1067,10 @@ void QuaternionTest::strictWeakOrdering() {
} }
void QuaternionTest::debug() { void QuaternionTest::debug() {
std::ostringstream o; Containers::String out;
Debug(&o) << Quaternion({1.0f, 2.0f, 3.0f}, -4.0f); Debug{&out} << Quaternion({1.0f, 2.0f, 3.0f}, -4.0f);
CORRADE_COMPARE(o.str(), "Quaternion({1, 2, 3}, -4)\n"); CORRADE_COMPARE(out, "Quaternion({1, 2, 3}, -4)\n");
} }
}}}} }}}}

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

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

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

@ -25,9 +25,8 @@
*/ */
#include <new> #include <new>
#include <sstream> /** @todo remove once Debug is STL-free */ #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h> /** @todo remove once Debug is STL-free */
#include "Magnum/Math/Time.h" #include "Magnum/Math/Time.h"
@ -405,37 +404,37 @@ void TimeTest::nanosecondFloatScaling() {
} }
void TimeTest::debugNanoseconds() { void TimeTest::debugNanoseconds() {
std::ostringstream out; Containers::String out;
/* Also verify that the second expression compiles (it's the Unit type, /* Also verify that the second expression compiles (it's the Unit type,
not Nanoseconds) */ not Nanoseconds) */
Debug{&out} << 987654321987654321_nsec << 15.0_sec - 7.5_sec; 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() { void TimeTest::debugNanosecondsPacked() {
std::ostringstream out; Containers::String out;
/* Second is not packed, the first should not make any flags persistent */ /* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << 15.0_sec << 45.0_sec; 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() { void TimeTest::debugSeconds() {
std::ostringstream out; Containers::String out;
/* Also verify that the second expression compiles (it's the Unit type, /* Also verify that the second expression compiles (it's the Unit type,
not Nanoseconds) */ not Nanoseconds) */
Debug{&out} << Seconds{123.45_sec} << Seconds{15.0_sec} - Seconds{7.5_sec}; 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() { void TimeTest::debugSecondsPacked() {
std::ostringstream out; Containers::String out;
/* Second is not packed, the first should not make any flags persistent */ /* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << Seconds{123.45_sec} << Seconds{45.0_sec}; 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector3.h" /* Vector3 used in Vector2Test::cross() */ #include "Magnum/Math/Vector3.h" /* Vector3 used in Vector2Test::cross() */
#include "Magnum/Math/StrictWeakOrdering.h" #include "Magnum/Math/StrictWeakOrdering.h"
@ -363,9 +363,9 @@ void Vector2Test::swizzleType() {
} }
void Vector2Test::debug() { void Vector2Test::debug() {
std::ostringstream o; Containers::String out;
Debug(&o) << Vector2(0.5f, 15.0f); Debug{&out} << Vector2(0.5f, 15.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 15)\n"); CORRADE_COMPARE(out, "Vector(0.5, 15)\n");
} }
}}}} }}}}

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

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

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

@ -24,9 +24,9 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <new>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector4.h" #include "Magnum/Math/Vector4.h"
#include "Magnum/Math/StrictWeakOrdering.h" #include "Magnum/Math/StrictWeakOrdering.h"
@ -430,9 +430,9 @@ void Vector4Test::swizzleType() {
} }
void Vector4Test::debug() { void Vector4Test::debug() {
std::ostringstream o; Containers::String out;
Debug(&o) << Vector4(0.5f, 15.0f, 1.0f, 1.0f); Debug{&out} << Vector4(0.5f, 15.0f, 1.0f, 1.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n"); 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. 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/Tester.h>
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Half.h" #include "Magnum/Math/Half.h"
#include "Magnum/Math/Vector.h" #include "Magnum/Math/Vector.h"
@ -839,10 +840,10 @@ void VectorTest::projectedOntoNormalizedNotNormalized() {
Vector3 vector(1.0f, 2.0f, 3.0f); Vector3 vector(1.0f, 2.0f, 3.0f);
Vector3 line(1.0f, -1.0f, 0.5f); Vector3 line(1.0f, -1.0f, 0.5f);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
vector.projectedOntoNormalized(line); 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() { void VectorTest::flipped() {
@ -881,12 +882,12 @@ void VectorTest::angleNormalizedButOver1() {
void VectorTest::angleNotNormalized() { void VectorTest::angleNotNormalized() {
CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Math::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), {1.0f, -2.0f, 3.0f}); 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()); 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(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"); "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() { void VectorTest::debug() {
std::ostringstream o; Containers::String out;
Debug(&o) << Vector4(0.5f, 15.0f, 1.0f, 1.0f); Debug{&out} << Vector4(0.5f, 15.0f, 1.0f, 1.0f);
CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n"); CORRADE_COMPARE(out, "Vector(0.5, 15, 1, 1)\n");
o.str({}); out = {};
Debug(&o) << "a" << Vector4() << "b" << Vector4(); Debug{&out} << "a" << Vector4() << "b" << Vector4();
CORRADE_COMPARE(o.str(), "a Vector(0, 0, 0, 0) b Vector(0, 0, 0, 0)\n"); CORRADE_COMPARE(out, "a Vector(0, 0, 0, 0) b Vector(0, 0, 0, 0)\n");
} }
void VectorTest::debugPacked() { void VectorTest::debugPacked() {
std::ostringstream out; Containers::String out;
/* Second is not packed, the first should not make any flags persistent */ /* 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(); 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() { void VectorTest::debugPropagateFlags() {
std::ostringstream out; Containers::String out;
/* The modifier shouldn't become persistent for values after. The nospace /* The modifier shouldn't become persistent for values after. The nospace
modifier shouldn't get propagated. */ modifier shouldn't get propagated. */
Debug{&out} << ">" << Debug::nospace << Debug::hex << Vector2i(0xab, 0xcd) << Vector2i(12, 13); 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 <functional>
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#define _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS #define _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS
@ -54,13 +53,13 @@ CORRADE_IGNORE_DEPRECATED_PUSH
void CombineIndexedArraysTest::wrongIndexCount() { void CombineIndexedArraysTest::wrongIndexCount() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream ss; Containers::String out;
Error redirectError{&ss}; Error redirectError{&out};
std::vector<UnsignedInt> a{0, 1, 0}; std::vector<UnsignedInt> a{0, 1, 0};
std::vector<UnsignedInt> b{3, 4}; std::vector<UnsignedInt> b{3, 4};
std::vector<UnsignedInt> result = combineIndexArrays({a, b}); 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() { void CombineIndexedArraysTest::indexArrays() {

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

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

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

@ -25,15 +25,13 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/EnumSet.h> #include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h> #include <Corrade/Containers/StringIterable.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
@ -1355,12 +1353,12 @@ void CompileGLTest::skinning() {
CORRADE_COMPARE(jointCount.second(), data.expectedSecondaryJointCount); CORRADE_COMPARE(jointCount.second(), data.expectedSecondaryJointCount);
GL::Mesh mesh{NoCreate}; GL::Mesh mesh{NoCreate};
std::ostringstream out; Containers::String out;
{ {
Warning redirectWarning{&out}; Warning redirectWarning{&out};
mesh = compile(meshData); mesh = compile(meshData);
} }
CORRADE_COMPARE(out.str(), data.expectedMessage); CORRADE_COMPARE(out, data.expectedMessage);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1499,13 +1497,13 @@ void CompileGLTest::conflictingAttributes() {
GL::Mesh mesh{NoCreate}; GL::Mesh mesh{NoCreate};
std::ostringstream out; Containers::String out;
{ {
Warning redirectWarning{&out}; Warning redirectWarning{&out};
mesh = compile(meshData); mesh = compile(meshData);
} }
MAGNUM_VERIFY_NO_GL_ERROR(); 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) || if(!(_manager.loadState("AnyImageImporter") & PluginManager::LoadState::Loaded) ||
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded)) !(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
@ -1562,10 +1560,10 @@ void CompileGLTest::unsupportedIndexStride() {
{}, indices, Trade::MeshIndexData{Containers::stridedArrayView(indices).every(2)}, {}, indices, Trade::MeshIndexData{Containers::stridedArrayView(indices).every(2)},
1}; 1};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compile(data); compile(data);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::compile(): MeshIndexType::UnsignedShort with stride of 4 bytes isn't supported by OpenGL\n"); "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}, Containers::arrayView(vertexData), 26},
}}; }};
std::ostringstream out; Containers::String out;
Warning redirectError{&out}; Warning redirectError{&out};
if(instanceData.flags) if(instanceData.flags)
compile(data, instanceData.flags); compile(data, instanceData.flags);
else else
compile(data); compile(data);
CORRADE_COMPARE(out.str(), instanceData.flags ? "" : CORRADE_COMPARE(out, instanceData.flags ? "" :
"MeshTools::compile(): ignoring 2 morph target attributes\n"); "MeshTools::compile(): ignoring 2 morph target attributes\n");
} }
@ -1602,13 +1600,13 @@ void CompileGLTest::customAttribute() {
VertexFormat::Short, nullptr} VertexFormat::Short, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Warning redirectError{&out}; Warning redirectError{&out};
if(instanceData.flags) if(instanceData.flags)
compile(data, instanceData.flags); compile(data, instanceData.flags);
else else
compile(data); compile(data);
CORRADE_COMPARE(out.str(), instanceData.flags ? "" : CORRADE_COMPARE(out, instanceData.flags ? "" :
"MeshTools::compile(): ignoring unknown/unsupported attribute Trade::MeshAttribute::Custom(115)\n"); "MeshTools::compile(): ignoring unknown/unsupported attribute Trade::MeshAttribute::Custom(115)\n");
} }
@ -1624,14 +1622,14 @@ void CompileGLTest::unsupportedAttribute() {
VertexFormat::UnsignedByte, nullptr} VertexFormat::UnsignedByte, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Warning redirectError{&out}; Warning redirectError{&out};
if(instanceData.flags) if(instanceData.flags)
compile(data, instanceData.flags); compile(data, instanceData.flags);
else else
compile(data); compile(data);
/* Warns always, regardless of the flag */ /* 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 #endif
} }
@ -1648,11 +1646,11 @@ void CompileGLTest::unsupportedAttributeStride() {
Containers::stridedArrayView(data).flipped<0>()} Containers::stridedArrayView(data).flipped<0>()}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compile(zero); compile(zero);
compile(negative); 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::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"); "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} vertexFormatWrap(0xdead), nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Warning redirectError{&out}; Warning redirectError{&out};
if(instanceData.flags) if(instanceData.flags)
compile(data, instanceData.flags); compile(data, instanceData.flags);
else else
compile(data); 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"); "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}; Trade::MeshData data{MeshPrimitive::Triangles, 1};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compile(data, CompileFlag::GenerateFlatNormals); compile(data, CompileFlag::GenerateFlatNormals);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::compile(): the mesh has no positions, can't generate normals\n"); "MeshTools::compile(): the mesh has no positions, can't generate normals\n");
} }
@ -1696,10 +1694,10 @@ void CompileGLTest::generateNormals2DPosition() {
VertexFormat::Vector2, nullptr} VertexFormat::Vector2, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compile(data, CompileFlag::GenerateFlatNormals); compile(data, CompileFlag::GenerateFlatNormals);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::compile(): can't generate normals for VertexFormat::Vector2 positions\n"); "MeshTools::compile(): can't generate normals for VertexFormat::Vector2 positions\n");
} }
@ -1713,10 +1711,10 @@ void CompileGLTest::generateNormalsNoFloats() {
VertexFormat::Vector3h, nullptr}, VertexFormat::Vector3h, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compile(data, CompileFlag::GenerateFlatNormals); compile(data, CompileFlag::GenerateFlatNormals);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::compile(): can't generate normals into VertexFormat::Vector3h\n"); "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 */ compile(data, GL::Buffer{NoCreate}, GL::Buffer{}); /* this is okay */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compile(data, GL::Buffer{NoCreate}, GL::Buffer{NoCreate}); compile(data, GL::Buffer{NoCreate}, GL::Buffer{NoCreate});
compile(indexedData, GL::Buffer{NoCreate}, GL::Buffer{}); 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"
"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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h> #include <Corrade/Containers/StringIterable.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
@ -301,7 +299,7 @@ void CompileLinesGLTest::conflictingAttributes() {
Trade::MeshAttributeData{data.attribute, data.format, vertices.slice(&Vertex::extra)}, Trade::MeshAttributeData{data.attribute, data.format, vertices.slice(&Vertex::extra)},
}}); }});
std::ostringstream out; Containers::String out;
GL::Mesh mesh{NoCreate}; GL::Mesh mesh{NoCreate};
{ {
Warning redirectWarning{&out}; Warning redirectWarning{&out};
@ -319,7 +317,7 @@ void CompileLinesGLTest::conflictingAttributes() {
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileLinesTestFiles/miter.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileLinesTestFiles/miter.tga"),
(DebugTools::CompareImageToFile{_manager})); (DebugTools::CompareImageToFile{_manager}));
CORRADE_COMPARE(out.str(), data.expected); CORRADE_COMPARE(out, data.expected);
} }
void CompileLinesGLTest::emptyMesh() { void CompileLinesGLTest::emptyMesh() {
@ -337,7 +335,7 @@ void CompileLinesGLTest::notGeneratedLineMesh() {
Vector3 positions[3]{}; Vector3 positions[3]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compileLines(Trade::MeshData{MeshPrimitive::Lines, {}, positions, { compileLines(Trade::MeshData{MeshPrimitive::Lines, {}, positions, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::stridedArrayView(positions)} Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::stridedArrayView(positions)}
@ -345,7 +343,7 @@ void CompileLinesGLTest::notGeneratedLineMesh() {
compileLines(Trade::MeshData{MeshPrimitive::Triangles, {}, positions, { compileLines(Trade::MeshData{MeshPrimitive::Triangles, {}, positions, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::stridedArrayView(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"
"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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Endianness.h> #include <Corrade/Utility/Endianness.h>
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
@ -38,6 +37,7 @@
#include "Magnum/Trade/MeshData.h" #include "Magnum/Trade/MeshData.h"
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#include <tuple>
#include <vector> #include <vector>
#endif #endif
@ -218,10 +218,10 @@ void CompressIndicesTest::compressErasedNonContiguous() {
const char indices[6*4]{}; const char indices[6*4]{};
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compressIndices(Containers::StridedArrayView2D<const char>{indices, {6, 2}, {4, 2}}); 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"); "MeshTools::compressIndices(): second view dimension is not contiguous\n");
} }
@ -230,10 +230,10 @@ void CompressIndicesTest::compressErasedWrongIndexSize() {
const char indices[6*3]{}; const char indices[6*3]{};
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compressIndices(Containers::StridedArrayView2D<const char>{indices, {6, 3}}); 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"); "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}; Trade::MeshData mesh{MeshPrimitive::TriangleFan, 5};
/* Test both r-value and l-value overload */ /* Test both r-value and l-value overload */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compressIndices(mesh); compressIndices(mesh);
compressIndices(Utility::move(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"
"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}; nullptr, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::StridedArrayView1D<const void>{}}, 1};
/* Test both r-value and l-value overload */ /* Test both r-value and l-value overload */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compressIndices(mesh); compressIndices(mesh);
compressIndices(Utility::move(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"
"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, Trade::MeshData mesh{MeshPrimitive::Points,
{}, indices, Trade::MeshIndexData{indices}, 1}; {}, indices, Trade::MeshIndexData{indices}, 1};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compressIndices(mesh, meshIndexTypeWrap(0xcaca)); compressIndices(mesh, meshIndexTypeWrap(0xcaca));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::compressIndices(): can't compress to an implementation-specific index type 0xcaca\n"); "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}), Containers::arrayView<UnsignedShort>({123, 456}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
compressIndicesAs<UnsignedShort>({65536}); 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 CORRADE_IGNORE_DEPRECATED_POP
} }
#endif #endif

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

@ -24,13 +24,11 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Optional.h> #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/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h> #include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/MeshTools/Concatenate.h" #include "Magnum/MeshTools/Concatenate.h"
@ -462,10 +460,10 @@ void ConcatenateTest::concatenateOne() {
void ConcatenateTest::concatenateNone() { void ConcatenateTest::concatenateNone() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenate({}); 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() { void ConcatenateTest::concatenateInto() {
@ -641,11 +639,11 @@ void ConcatenateTest::concatenateUnsupportedPrimitive() {
Trade::MeshData a{MeshPrimitive::TriangleStrip, 0}; Trade::MeshData a{MeshPrimitive::TriangleStrip, 0};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenate({a}); MeshTools::concatenate({a});
MeshTools::concatenateInto(a, {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::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"); "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 a{MeshPrimitive::Triangles, 0};
Trade::MeshData b{MeshPrimitive::Lines, 0}; Trade::MeshData b{MeshPrimitive::Lines, 0};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenate({a, a, b}); MeshTools::concatenate({a, a, b});
MeshTools::concatenateInto(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::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"); "MeshTools::concatenateInto(): expected MeshPrimitive::Triangles but got MeshPrimitive::Lines in mesh 1\n");
} }
@ -685,11 +683,11 @@ void ConcatenateTest::concatenateInconsistentAttributeFormat() {
VertexFormat::Vector3usNormalized, nullptr} VertexFormat::Vector3usNormalized, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenate({a, a, a, a, b}); MeshTools::concatenate({a, a, a, a, b});
MeshTools::concatenateInto(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::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"); "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} VertexFormat::ByteNormalized, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenate({a, a, a, a, b}); MeshTools::concatenate({a, a, a, a, b});
MeshTools::concatenate({b, b, b, b, a}); MeshTools::concatenate({b, b, b, b, a});
MeshTools::concatenateInto(a2, {a, a, a, b}); MeshTools::concatenateInto(a2, {a, a, a, b});
MeshTools::concatenateInto(b, {b, b, b, a}); 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 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::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" "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) */ concatenate() above) */
MeshTools::concatenate({b, a}); MeshTools::concatenate({b, a});
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenate({a, a, a, a, b}); MeshTools::concatenate({a, a, a, a, b});
MeshTools::concatenateInto(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::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", "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); TestSuite::Compare::String);
@ -795,11 +793,11 @@ void ConcatenateTest::concatenateImplementationSpecificIndexType() {
a tightly-packed 32bit buffer */ a tightly-packed 32bit buffer */
MeshTools::concatenateInto(bDestination, {a}); MeshTools::concatenateInto(bDestination, {a});
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenate({a, b}); MeshTools::concatenate({a, b});
MeshTools::concatenateInto(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::concatenate(): mesh 1 has an implementation-specific index type 0xcaca\n"
"MeshTools::concatenateInto(): mesh 0 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} VertexFormat::Vector3, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenate({a, b}); MeshTools::concatenate({a, b});
MeshTools::concatenateInto(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::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"); "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}; Trade::MeshData destination{MeshPrimitive::Triangles, 0};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::concatenateInto(destination, {}); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h> #include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/MeshTools/Copy.h" #include "Magnum/MeshTools/Copy.h"
@ -497,10 +496,10 @@ void CopyTest::mutableReferenceNotMutable() {
CORRADE_COMPARE(cube.indexDataFlags(), Trade::DataFlag::Global); CORRADE_COMPARE(cube.indexDataFlags(), Trade::DataFlag::Global);
CORRADE_COMPARE(cube.vertexDataFlags(), Trade::DataFlag::Global); CORRADE_COMPARE(cube.vertexDataFlags(), Trade::DataFlag::Global);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::mutableReference(cube); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Algorithms.h> #include <Corrade/Utility/Algorithms.h>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
@ -121,11 +120,11 @@ void DuplicateTest::duplicateOutOfRange() {
constexpr UnsignedByte indices[]{1, 1, 0, 4, 2, 2}; constexpr UnsignedByte indices[]{1, 1, 0, 4, 2, 2};
constexpr Int data[]{-7, 35, 12, -18}; constexpr Int data[]{-7, 35, 12, -18};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicate<UnsignedByte, Int>(indices, data); MeshTools::duplicate<UnsignedByte, Int>(indices, data);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::duplicateInto(): index 4 out of range for 4 elements\n"); "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}; constexpr Int data[]{-7, 35, 12, -18};
Int output[5]; Int output[5];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicateInto<UnsignedByte, Int>(indices, data, output); 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"); "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}; constexpr Int data[]{-7, 35, 12, -18};
Short output[6]; Short output[6];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicateInto( MeshTools::duplicateInto(
Containers::stridedArrayView(indices), Containers::stridedArrayView(indices),
Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)), Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)),
Containers::arrayCast<2, char>(Containers::stridedArrayView(output))); 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"); "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}; constexpr Int data[]{-7, 35, 12, -18};
Short output[6]; Short output[6];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicateInto( MeshTools::duplicateInto(
@ -216,7 +215,7 @@ void DuplicateTest::duplicateIntoErasedNonContiguous() {
Containers::stridedArrayView(indices), Containers::stridedArrayView(indices),
Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)), Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)),
Containers::arrayCast<2, char>(Containers::stridedArrayView(output)).every({1, 2})); 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 data view dimension is not contiguous\n"
"MeshTools::duplicateInto(): second output 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}; constexpr Int data[]{-7, 35, 12, -18};
Short output[6]; Short output[6];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicateInto( MeshTools::duplicateInto(
Containers::StridedArrayView2D<const char>{indices, {6, 3}}.every(2), Containers::StridedArrayView2D<const char>{indices, {6, 3}}.every(2),
Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)), Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)),
Containers::arrayCast<2, char>(Containers::stridedArrayView(output))); 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"); "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}; constexpr Int data[]{-7, 35, 12, -18};
Short output[6]; Short output[6];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicateInto( MeshTools::duplicateInto(
Containers::StridedArrayView2D<const char>{indices, {3, 3}, {6, 2}}, Containers::StridedArrayView2D<const char>{indices, {3, 3}, {6, 2}},
Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)).every({1, 2}), Containers::arrayCast<2, const char>(Containers::stridedArrayView(data)).every({1, 2}),
Containers::arrayCast<2, char>(Containers::stridedArrayView(output))); Containers::arrayCast<2, char>(Containers::stridedArrayView(output)));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::duplicateInto(): second index view dimension is not contiguous\n"); "MeshTools::duplicateInto(): second index view dimension is not contiguous\n");
} }
@ -318,10 +317,10 @@ template<class T> void DuplicateTest::duplicateMeshData() {
void DuplicateTest::duplicateMeshDataNotIndexed() { void DuplicateTest::duplicateMeshDataNotIndexed() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicate(Trade::MeshData{MeshPrimitive::Points, 0}); 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() { void DuplicateTest::duplicateMeshDataImplementationSpecificIndexType() {
@ -334,10 +333,10 @@ void DuplicateTest::duplicateMeshDataImplementationSpecificIndexType() {
VertexFormat::Vector3, nullptr}, VertexFormat::Vector3, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicate(a); 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() { void DuplicateTest::duplicateMeshDataImplementationSpecificVertexFormat() {
@ -354,10 +353,10 @@ void DuplicateTest::duplicateMeshDataImplementationSpecificVertexFormat() {
vertexFormatWrap(0xcaca), nullptr} vertexFormatWrap(0xcaca), nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicate(a); 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() { void DuplicateTest::duplicateMeshDataExtra() {
@ -436,13 +435,13 @@ void DuplicateTest::duplicateMeshDataExtraWrongCount() {
}}; }};
const Vector3 normals[]{Vector3::xAxis(), Vector3::yAxis()}; const Vector3 normals[]{Vector3::xAxis(), Vector3::yAxis()};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicate(data, { MeshTools::duplicate(data, {
Trade::MeshAttributeData{10}, Trade::MeshAttributeData{10},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, Containers::arrayView(normals)} 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() { void DuplicateTest::duplicateMeshDataExtraOffsetOnly() {
@ -452,13 +451,13 @@ void DuplicateTest::duplicateMeshDataExtraOffsetOnly() {
Trade::MeshData data{MeshPrimitive::TriangleFan, Trade::MeshData data{MeshPrimitive::TriangleFan,
{}, indices, Trade::MeshIndexData{indices}, 3}; {}, indices, Trade::MeshIndexData{indices}, 3};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicate(data, { MeshTools::duplicate(data, {
Trade::MeshAttributeData{10}, Trade::MeshAttributeData{10},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, VertexFormat::Vector3, 3, 5, 14} 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() { void DuplicateTest::duplicateMeshDataExtraImplementationSpecificVertexFormat() {
@ -471,7 +470,7 @@ void DuplicateTest::duplicateMeshDataExtraImplementationSpecificVertexFormat() {
VertexFormat::Vector3, nullptr}, VertexFormat::Vector3, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::duplicate(a, { MeshTools::duplicate(a, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Trade::MeshAttributeData{Trade::MeshAttribute::Position,
@ -479,7 +478,7 @@ void DuplicateTest::duplicateMeshDataExtraImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Color, Trade::MeshAttributeData{Trade::MeshAttribute::Color,
vertexFormatWrap(0xcaca), nullptr} 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() { void DuplicateTest::duplicateMeshDataNoAttributes() {

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

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

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

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
#include "Magnum/MeshTools/FlipNormals.h" #include "Magnum/MeshTools/FlipNormals.h"
@ -74,13 +73,13 @@ FlipNormalsTest::FlipNormalsTest() {
void FlipNormalsTest::wrongIndexCount() { void FlipNormalsTest::wrongIndexCount() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream ss; Containers::String out;
Error redirectError{&ss}; Error redirectError{&out};
UnsignedByte indices[2]; UnsignedByte indices[2];
flipFaceWindingInPlace(Containers::stridedArrayView(indices)); 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() { template<class T> void FlipNormalsTest::flipFaceWinding() {
@ -110,10 +109,10 @@ void FlipNormalsTest::flipFaceWindingErasedNonContiguous() {
char indices[6*4]{}; char indices[6*4]{};
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
flipFaceWindingInPlace(Containers::StridedArrayView2D<char>{indices, {6, 2}, {4, 2}}); 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"); "MeshTools::flipFaceWindingInPlace(): second index view dimension is not contiguous\n");
} }
@ -122,10 +121,10 @@ void FlipNormalsTest::flipFaceWindingErasedWrongIndexSize() {
char indices[6*3]{}; char indices[6*3]{};
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
flipFaceWindingInPlace(Containers::StridedArrayView2D<char>{indices, {6, 3}}); 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"); "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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Array.h> #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/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h> #include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/FormatStl.h>
#include "Magnum/Math/Matrix4.h" #include "Magnum/Math/Matrix4.h"
#include "Magnum/MeshTools/GenerateIndices.h" #include "Magnum/MeshTools/GenerateIndices.h"
@ -338,14 +336,14 @@ void GenerateIndicesTest::primitiveCount() {
void GenerateIndicesTest::primitiveCountInvalidVertexCount() { void GenerateIndicesTest::primitiveCountInvalidVertexCount() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::primitiveCount(MeshPrimitive::LineLoop, 1); MeshTools::primitiveCount(MeshPrimitive::LineLoop, 1);
MeshTools::primitiveCount(MeshPrimitive::TriangleStrip, 1); MeshTools::primitiveCount(MeshPrimitive::TriangleStrip, 1);
MeshTools::primitiveCount(MeshPrimitive::TriangleFan, 2); MeshTools::primitiveCount(MeshPrimitive::TriangleFan, 2);
MeshTools::primitiveCount(MeshPrimitive::Lines, 7); MeshTools::primitiveCount(MeshPrimitive::Lines, 7);
MeshTools::primitiveCount(MeshPrimitive::Triangles, 14); 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 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::TriangleStrip, got 1\n"
"MeshTools::primitiveCount(): expected either zero or at least 3 elements for MeshPrimitive::TriangleFan, got 2\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() { void GenerateIndicesTest::primitiveCountInvalidPrimitive() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::primitiveCount(MeshPrimitive(0xdead), 2); MeshTools::primitiveCount(MeshPrimitive(0xdead), 2);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::primitiveCount(): invalid primitive MeshPrimitive(0xdead)\n"); "MeshTools::primitiveCount(): invalid primitive MeshPrimitive(0xdead)\n");
} }
@ -509,11 +507,11 @@ void GenerateIndicesTest::generateLineStripIndicesWrongVertexCount() {
UnsignedShort indices[1]; UnsignedShort indices[1];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateLineStripIndices(1); MeshTools::generateLineStripIndices(1);
MeshTools::generateLineStripIndices(indices); 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 vertices, got 1\n"
"MeshTools::generateLineStripIndicesInto(): expected either zero or at least two indices, 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]; UnsignedByte indices[5];
UnsignedInt output[7]; UnsignedInt output[7];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateLineStripIndicesInto(0, output); MeshTools::generateLineStripIndicesInto(0, output);
MeshTools::generateLineStripIndicesInto(Containers::arrayView(indices).prefix(0), output); MeshTools::generateLineStripIndicesInto(Containers::arrayView(indices).prefix(0), output);
MeshTools::generateLineStripIndicesInto(5, output); MeshTools::generateLineStripIndicesInto(5, output);
MeshTools::generateLineStripIndicesInto(indices, 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 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" "MeshTools::generateLineStripIndicesInto(): bad output size, expected 8 but got 7\n"
@ -542,11 +540,11 @@ void GenerateIndicesTest::generateLineStripIndicesIndexed2DInvalid() {
char indices[3*4]; char indices[3*4];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateLineStripIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2})); MeshTools::generateLineStripIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2}));
MeshTools::generateLineStripIndices(Containers::StridedArrayView2D<char>{indices, {4, 3}}); 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(): second index view dimension is not contiguous\n"
"MeshTools::generateLineStripIndicesInto(): expected index type size 1, 2 or 4 but got 3\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]; UnsignedInt indices[1];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateLineLoopIndices(1); MeshTools::generateLineLoopIndices(1);
MeshTools::generateLineLoopIndices(indices); 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 vertices, got 1\n"
"MeshTools::generateLineLoopIndicesInto(): expected either zero or at least two indices, 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]; UnsignedShort indices[5];
UnsignedInt output[9]; UnsignedInt output[9];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateLineLoopIndicesInto(0, output); MeshTools::generateLineLoopIndicesInto(0, output);
MeshTools::generateLineLoopIndicesInto(Containers::arrayView(indices).prefix(0), output); MeshTools::generateLineLoopIndicesInto(Containers::arrayView(indices).prefix(0), output);
MeshTools::generateLineLoopIndicesInto(5, output); MeshTools::generateLineLoopIndicesInto(5, output);
MeshTools::generateLineLoopIndicesInto(indices, 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 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" "MeshTools::generateLineLoopIndicesInto(): bad output size, expected 10 but got 9\n"
@ -721,11 +719,11 @@ void GenerateIndicesTest::generateLineLoopIndicesIndexed2DInvalid() {
char indices[3*4]; char indices[3*4];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateLineLoopIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2})); MeshTools::generateLineLoopIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2}));
MeshTools::generateLineLoopIndices(Containers::StridedArrayView2D<char>{indices, {4, 3}}); 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(): second index view dimension is not contiguous\n"
"MeshTools::generateLineLoopIndicesInto(): expected index type size 1, 2 or 4 but got 3\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]; UnsignedByte indices[2];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateTriangleStripIndices(2); MeshTools::generateTriangleStripIndices(2);
MeshTools::generateTriangleStripIndices(indices); 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 vertices, got 2\n"
"MeshTools::generateTriangleStripIndicesInto(): expected either zero or at least three indices, 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 indices[5];
UnsignedInt output[8]; UnsignedInt output[8];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateTriangleStripIndicesInto(0, output); MeshTools::generateTriangleStripIndicesInto(0, output);
MeshTools::generateTriangleStripIndicesInto(Containers::arrayView(indices).prefix(0), output); MeshTools::generateTriangleStripIndicesInto(Containers::arrayView(indices).prefix(0), output);
MeshTools::generateTriangleStripIndicesInto(5, output); MeshTools::generateTriangleStripIndicesInto(5, output);
MeshTools::generateTriangleStripIndicesInto(indices, 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 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" "MeshTools::generateTriangleStripIndicesInto(): bad output size, expected 9 but got 8\n"
@ -897,11 +895,11 @@ void GenerateIndicesTest::generateTriangleStripIndicesIndexed2DInvalid() {
char indices[3*4]; char indices[3*4];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateTriangleStripIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2})); MeshTools::generateTriangleStripIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2}));
MeshTools::generateTriangleStripIndices(Containers::StridedArrayView2D<char>{indices, {4, 3}}); 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(): second index view dimension is not contiguous\n"
"MeshTools::generateTriangleStripIndicesInto(): expected index type size 1, 2 or 4 but got 3\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]; UnsignedInt indices[2];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateTriangleFanIndices(2); MeshTools::generateTriangleFanIndices(2);
MeshTools::generateTriangleFanIndices(indices); 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 vertices, got 2\n"
"MeshTools::generateTriangleFanIndicesInto(): expected either zero or at least three indices, 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 indices[5];
UnsignedInt output[8]; UnsignedInt output[8];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateTriangleFanIndicesInto(0, output); MeshTools::generateTriangleFanIndicesInto(0, output);
MeshTools::generateTriangleFanIndicesInto(Containers::arrayView(indices).prefix(0), output); MeshTools::generateTriangleFanIndicesInto(Containers::arrayView(indices).prefix(0), output);
MeshTools::generateTriangleFanIndicesInto(5, output); MeshTools::generateTriangleFanIndicesInto(5, output);
MeshTools::generateTriangleFanIndicesInto(indices, 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 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" "MeshTools::generateTriangleFanIndicesInto(): bad output size, expected 9 but got 8\n"
@ -1074,11 +1072,11 @@ void GenerateIndicesTest::generateTriangleFanIndicesIndexed2DInvalid() {
char indices[3*4]; char indices[3*4];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateTriangleFanIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2})); MeshTools::generateTriangleFanIndices(Containers::StridedArrayView2D<char>{indices, {3, 4}}.every({1, 2}));
MeshTools::generateTriangleFanIndices(Containers::StridedArrayView2D<char>{indices, {4, 3}}); 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(): second index view dimension is not contiguous\n"
"MeshTools::generateTriangleFanIndicesInto(): expected index type size 1, 2 or 4 but got 3\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]; UnsignedInt quads[13];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateQuadIndices({}, quads); MeshTools::generateQuadIndices({}, quads);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::generateQuadIndicesInto(): quad index count 13 not divisible by 4\n"); "MeshTools::generateQuadIndicesInto(): quad index count 13 not divisible by 4\n");
} }
@ -1220,10 +1218,10 @@ void GenerateIndicesTest::generateQuadIndicesIndexOutOfRange() {
UnsignedInt quads[]{5, 4, 6, 7}; UnsignedInt quads[]{5, 4, 6, 7};
Vector3 positions[7]; Vector3 positions[7];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateQuadIndices(positions, quads); MeshTools::generateQuadIndices(positions, quads);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::generateQuadIndicesInto(): index 7 out of range for 7 elements\n"); "MeshTools::generateQuadIndicesInto(): index 7 out of range for 7 elements\n");
} }
@ -1233,19 +1231,19 @@ void GenerateIndicesTest::generateQuadIndicesIntoWrongSize() {
UnsignedInt quads[12]; UnsignedInt quads[12];
UnsignedInt output[19]; UnsignedInt output[19];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::generateQuadIndicesInto({}, quads, output); MeshTools::generateQuadIndicesInto({}, quads, output);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"MeshTools::generateQuadIndicesInto(): bad output size, expected 18 but got 19\n"); "MeshTools::generateQuadIndicesInto(): bad output size, expected 18 but got 19\n");
} }
void GenerateIndicesTest::generateIndicesMeshData() { void GenerateIndicesTest::generateIndicesMeshData() {
auto&& data = MeshDataData[testCaseInstanceId()]; auto&& data = MeshDataData[testCaseInstanceId()];
{ {
std::ostringstream out; Containers::String out;
Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive; Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive;
setTestCaseDescription(out.str()); setTestCaseDescription(out);
} }
const struct Vertex { const struct Vertex {
@ -1302,9 +1300,9 @@ template<class T> void GenerateIndicesTest::generateIndicesMeshDataIndexed() {
auto&& data = MeshDataData[testCaseInstanceId()]; auto&& data = MeshDataData[testCaseInstanceId()];
setTestCaseTemplateName(Math::TypeTraits<T>::name()); setTestCaseTemplateName(Math::TypeTraits<T>::name());
{ {
std::ostringstream out; Containers::String out;
Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive; Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive;
setTestCaseDescription(out.str()); setTestCaseDescription(out);
} }
const struct Vertex { const struct Vertex {
@ -1364,9 +1362,9 @@ template<class T> void GenerateIndicesTest::generateIndicesMeshDataIndexed() {
void GenerateIndicesTest::generateIndicesMeshDataEmpty() { void GenerateIndicesTest::generateIndicesMeshDataEmpty() {
auto&& data = MeshDataData[testCaseInstanceId()]; auto&& data = MeshDataData[testCaseInstanceId()];
{ {
std::ostringstream out; Containers::String out;
Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive; Debug{&out, Debug::Flag::NoNewlineAtTheEnd} << data.primitive;
setTestCaseDescription(out.str()); setTestCaseDescription(out);
} }
/* Similar to generateIndicesMeshData(), just with 0 vertices. Verifying it /* Similar to generateIndicesMeshData(), just with 0 vertices. Verifying it
@ -1604,19 +1602,19 @@ void GenerateIndicesTest::generateIndicesMeshDataTrivialIndexedMoveDifferentInde
void GenerateIndicesTest::generateIndicesMeshDataInvalidVertexCount() { void GenerateIndicesTest::generateIndicesMeshDataInvalidVertexCount() {
auto&& data = MeshDataInvalidVertexCountData[testCaseInstanceId()]; auto&& data = MeshDataInvalidVertexCountData[testCaseInstanceId()];
std::ostringstream primitiveName; Containers::String primitiveName;
Debug{&primitiveName, Debug::Flag::NoNewlineAtTheEnd} << data.primitive; Debug{&primitiveName, Debug::Flag::NoNewlineAtTheEnd} << data.primitive;
setTestCaseDescription(primitiveName.str()); setTestCaseDescription(primitiveName);
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
Trade::MeshData mesh{data.primitive, data.invalidVertexCount}; Trade::MeshData mesh{data.primitive, data.invalidVertexCount};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
generateIndices(mesh); generateIndices(mesh);
CORRADE_COMPARE(out.str(), Utility::formatString( CORRADE_COMPARE(out, Utility::format(
"MeshTools::generateIndices(): expected either zero or at least {} vertices for {}, got {}\n", data.expectedVertexCount, primitiveName.str(), data.invalidVertexCount)); "MeshTools::generateIndices(): expected either zero or at least {} vertices for {}, got {}\n", data.expectedVertexCount, primitiveName, data.invalidVertexCount));
} }
void GenerateIndicesTest::generateIndicesMeshDataImplementationSpecificIndexType() { void GenerateIndicesTest::generateIndicesMeshDataImplementationSpecificIndexType() {
@ -1626,10 +1624,10 @@ void GenerateIndicesTest::generateIndicesMeshDataImplementationSpecificIndexType
nullptr, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::StridedArrayView1D<const void>{}}, nullptr, Trade::MeshIndexData{meshIndexTypeWrap(0xcaca), Containers::StridedArrayView1D<const void>{}},
nullptr, {}, 3}; nullptr, {}, 3};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
generateIndices(a); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/Math/PackingBatch.h" #include "Magnum/Math/PackingBatch.h"
@ -636,21 +635,21 @@ void GenerateLinesTest::notLines() {
Vector3 positions[3]{}; Vector3 positions[3]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
generateLines(Trade::MeshData{MeshPrimitive::TriangleFan, {}, positions, { generateLines(Trade::MeshData{MeshPrimitive::TriangleFan, {}, positions, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::stridedArrayView(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() { void GenerateLinesTest::noAttributes() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
generateLines(Trade::MeshData{MeshPrimitive::Lines, 12}); 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() { void GenerateLinesTest::noPositionAttribute() {
@ -658,12 +657,12 @@ void GenerateLinesTest::noPositionAttribute() {
Vector3 colors[2]{}; Vector3 colors[2]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
generateLines(Trade::MeshData{MeshPrimitive::Lines, {}, colors, { generateLines(Trade::MeshData{MeshPrimitive::Lines, {}, colors, {
Trade::MeshAttributeData{Trade::MeshAttribute::Color, Containers::stridedArrayView(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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayViewStl.h> #include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/FunctionsBatch.h" #include "Magnum/Math/FunctionsBatch.h"
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
@ -40,6 +39,7 @@
#include "Magnum/Trade/MeshData.h" #include "Magnum/Trade/MeshData.h"
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#include <tuple>
#include <vector> #include <vector>
#endif #endif
@ -157,24 +157,24 @@ void GenerateNormalsTest::flatDeprecated() {
void GenerateNormalsTest::flatWrongCount() { void GenerateNormalsTest::flatWrongCount() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
const Vector3 positions[7]; const Vector3 positions[7];
generateFlatNormals(positions); 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() { void GenerateNormalsTest::flatIntoWrongSize() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
const Vector3 positions[6]; const Vector3 positions[6];
Vector3 normals[7]; Vector3 normals[7];
generateFlatNormalsInto(positions, normals); 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() { template<class T> void GenerateNormalsTest::smoothTwoTriangles() {
@ -394,38 +394,38 @@ void GenerateNormalsTest::smoothNanPosition() {
void GenerateNormalsTest::smoothWrongCount() { void GenerateNormalsTest::smoothWrongCount() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
const UnsignedByte indices[7]{}; const UnsignedByte indices[7]{};
const Vector3 positions[1]; const Vector3 positions[1];
generateSmoothNormals(indices, positions); 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() { void GenerateNormalsTest::smoothOutOfRange() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
const Vector3 positions[2]; const Vector3 positions[2];
const UnsignedInt indices[] { 0, 1, 2 }; const UnsignedInt indices[] { 0, 1, 2 };
generateSmoothNormals(indices, positions); 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() { void GenerateNormalsTest::smoothIntoWrongSize() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
const UnsignedByte indices[6]{}; const UnsignedByte indices[6]{};
const Vector3 positions[3]; const Vector3 positions[3];
Vector3 normals[4]; Vector3 normals[4];
generateSmoothNormalsInto(indices, positions, normals); 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() { void GenerateNormalsTest::benchmarkFlat() {
@ -473,10 +473,10 @@ void GenerateNormalsTest::smoothErasedNonContiguous() {
const char indices[6*4]{}; const char indices[6*4]{};
const Vector3 positions[3]; const Vector3 positions[3];
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
generateSmoothNormals(Containers::StridedArrayView2D<const char>{indices, {6, 2}, {4, 2}}, positions); 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"); "MeshTools::generateSmoothNormalsInto(): second index view dimension is not contiguous\n");
} }
@ -486,10 +486,10 @@ void GenerateNormalsTest::smoothErasedWrongIndexSize() {
const char indices[6*3]{}; const char indices[6*3]{};
const Vector3 positions[3]; const Vector3 positions[3];
std::stringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
generateSmoothNormals(Containers::StridedArrayView2D<const char>{indices, {6, 3}}.every(2), positions); 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"); "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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Optional.h> #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/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h> #include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/Algorithms.h> #include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/Endianness.h> #include <Corrade/Utility/Endianness.h>
#include <Corrade/Utility/Debug.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/Math/Vector3.h"
#include "Magnum/MeshTools/Interleave.h" #include "Magnum/MeshTools/Interleave.h"
@ -227,13 +225,13 @@ void InterleaveTest::attributeCountGaps() {
void InterleaveTest::attributeCountInvalid() { void InterleaveTest::attributeCountInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::stringstream ss; Containers::String out;
Error redirectError{&ss}; Error redirectError{&out};
CORRADE_COMPARE(Implementation::AttributeCount{}( CORRADE_COMPARE(Implementation::AttributeCount{}(
Containers::arrayView<Byte>({0, 1, 2}), Containers::arrayView<Byte>({0, 1, 2}),
Containers::arrayView<Byte>({0, 1, 2, 3, 4, 5}) Containers::arrayView<Byte>({0, 1, 2, 3, 4, 5})
), std::size_t(0)); ), 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() { void InterleaveTest::stride() {
@ -370,10 +368,10 @@ void InterleaveTest::interleaveIntoInvalid() {
Containers::Array<char> data{NoInit, 23}; Containers::Array<char> data{NoInit, 23};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleaveInto(data, 2, Containers::arrayView({1, 2, 3, 4})); 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() { void InterleaveTest::interleavedData() {
@ -614,10 +612,10 @@ void InterleaveTest::interleavedDataNotInterleaved() {
}}; }};
CORRADE_VERIFY(!MeshTools::isInterleaved(data)); CORRADE_VERIFY(!MeshTools::isInterleaved(data));
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleavedData(data); 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() { void InterleaveTest::interleavedDataAttributeAcrossStride() {
@ -697,10 +695,10 @@ void InterleaveTest::interleavedMutableDataNotMutable() {
Trade::MeshData data{MeshPrimitive::Lines, {}, a, {}, 15}; Trade::MeshData data{MeshPrimitive::Lines, {}, a, {}, 15};
CORRADE_VERIFY(MeshTools::isInterleaved(data)); CORRADE_VERIFY(MeshTools::isInterleaved(data));
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleavedMutableData(data); 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() { void InterleaveTest::interleavedDataImplementationSpecificVertexFormat() {
@ -870,10 +868,10 @@ void InterleaveTest::interleavedLayoutImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleavedLayout(data, 5); 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() { void InterleaveTest::interleavedLayoutExtra() {
@ -972,14 +970,14 @@ void InterleaveTest::interleavedLayoutExtraTooNegativePadding() {
Trade::MeshData data{MeshPrimitive::Triangles, Trade::MeshData data{MeshPrimitive::Triangles,
Utility::move(vertexData), {positions}}; Utility::move(vertexData), {positions}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleavedLayout(data, 100, { MeshTools::interleavedLayout(data, 100, {
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, Trade::MeshAttributeData{Trade::MeshAttribute::Normal,
VertexFormat::Vector3, positions.data()}, VertexFormat::Vector3, positions.data()},
Trade::MeshAttributeData{-25} 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() { void InterleaveTest::interleavedLayoutExtraOnly() {
@ -1013,13 +1011,13 @@ void InterleaveTest::interleavedLayoutExtraImplementationSpecificVertexFormat()
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleavedLayout(data, 5, { MeshTools::interleavedLayout(data, 5, {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), 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() { void InterleaveTest::interleavedLayoutAlreadyInterleaved() {
@ -1329,10 +1327,10 @@ void InterleaveTest::interleaveMeshDataImplementationSpecificIndexType() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr} Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleave(data); 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() { void InterleaveTest::interleaveMeshDataImplementationSpecificVertexFormat() {
@ -1343,11 +1341,11 @@ void InterleaveTest::interleaveMeshDataImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleave(data); MeshTools::interleave(data);
/* Assert is coming from interleavedLayout() because... that's easier */ /* 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() { void InterleaveTest::interleaveMeshDataExtra() {
@ -1432,13 +1430,13 @@ void InterleaveTest::interleaveMeshDataExtraWrongCount() {
}}; }};
const Vector3 normals[]{Vector3::xAxis(), Vector3::yAxis()}; const Vector3 normals[]{Vector3::xAxis(), Vector3::yAxis()};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleave(data, { MeshTools::interleave(data, {
Trade::MeshAttributeData{10}, Trade::MeshAttributeData{10},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, VertexFormat::Vector3, Containers::arrayView(normals)} 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() { void InterleaveTest::interleaveMeshDataExtraOffsetOnly() {
@ -1446,13 +1444,13 @@ void InterleaveTest::interleaveMeshDataExtraOffsetOnly() {
Trade::MeshData data{MeshPrimitive::TriangleFan, 5}; Trade::MeshData data{MeshPrimitive::TriangleFan, 5};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleave(data, { MeshTools::interleave(data, {
Trade::MeshAttributeData{10}, Trade::MeshAttributeData{10},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, VertexFormat::Vector3, 3, 5, 14} 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() { void InterleaveTest::interleaveMeshDataExtraImplementationSpecificVertexFormat() {
@ -1462,14 +1460,14 @@ void InterleaveTest::interleaveMeshDataExtraImplementationSpecificVertexFormat()
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleave(data, { MeshTools::interleave(data, {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Normal, vertexFormatWrap(0xcaca), nullptr},
}); });
/* Assert is coming from interleavedLayout() because... that's easier */ /* 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() { void InterleaveTest::interleaveMeshDataAlreadyInterleavedMove() {
@ -1687,7 +1685,7 @@ void InterleaveTest::interleaveMeshDataLooseAttributesInvalid() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::ArrayView<Vector3>{nullptr, 0}} Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::ArrayView<Vector3>{nullptr, 0}}
}).vertexCount(), 0); }).vertexCount(), 0);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
MeshTools::interleave(MeshPrimitive::Triangles, MeshTools::interleave(MeshPrimitive::Triangles,
Trade::MeshIndexData{indices}, { Trade::MeshIndexData{indices}, {
@ -1701,7 +1699,7 @@ void InterleaveTest::interleaveMeshDataLooseAttributesInvalid() {
Trade::MeshIndexData{meshIndexTypeWrap(0xcece), Containers::stridedArrayView(indices)}, { Trade::MeshIndexData{meshIndexTypeWrap(0xcece), Containers::stridedArrayView(indices)}, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, Containers::ArrayView<Vector3>{nullptr, 3}} 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 1 attributes, can't infer vertex count\n"
"MeshTools::interleave(): only padding found among 2 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", "MeshTools::interleave(): implementation-specific index type 0xcece\n",

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

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

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

@ -24,15 +24,14 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.h> #include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/FormatStl.h>
#include "Magnum/Math/Half.h" #include "Magnum/Math/Half.h"
#include "Magnum/Math/Matrix3.h" #include "Magnum/Math/Matrix3.h"
@ -552,13 +551,13 @@ void TransformTest::meshData2DNoPosition() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform2D(mesh, {}, data.id, data.morphTargetId); transform2D(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshData2DNot2D() {
@ -568,10 +567,10 @@ void TransformTest::meshData2DNot2D() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr} Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform2D(mesh, {}); 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() { void TransformTest::meshData2DImplementationSpecificIndexType() {
@ -605,10 +604,10 @@ void TransformTest::meshData2DImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, vertexFormatWrap(0xcaca), nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, vertexFormatWrap(0xcaca), nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform2D(mesh, {}, 1); 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() { void TransformTest::meshData2DRvaluePassthrough() {
@ -774,15 +773,15 @@ void TransformTest::meshData2DRvaluePassthroughNoPosition() {
/* Mainly to verify there's no other accidental assertion from checking /* Mainly to verify there's no other accidental assertion from checking
vertex format and that the ID + morph target ID gets correctly passed vertex format and that the ID + morph target ID gets correctly passed
through, this message comes from the l-value overload */ through, this message comes from the l-value overload */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform2D(Trade::MeshData{MeshPrimitive::Points, nullptr, { transform2D(Trade::MeshData{MeshPrimitive::Points, nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}}, {}, data.id, data.morphTargetId); }}, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshData2DRvaluePassthroughWrongFormat() {
@ -824,10 +823,10 @@ void TransformTest::meshData2DInPlaceNotMutable() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform2DInPlace(mesh, {}); 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() { void TransformTest::meshData2DInPlaceNoPosition() {
@ -840,13 +839,13 @@ void TransformTest::meshData2DInPlaceNoPosition() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform2DInPlace(mesh, {}, data.id, data.morphTargetId); transform2DInPlace(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshData2DInPlaceWrongFormat() {
@ -857,10 +856,10 @@ void TransformTest::meshData2DInPlaceWrongFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2us, nullptr} Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2us, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform2DInPlace(mesh, {}, 1); 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() { 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}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform3D(mesh, {}, data.id, data.morphTargetId); transform3D(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshData3DNot3D() {
@ -1018,10 +1017,10 @@ void TransformTest::meshData3DNot3D() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr} Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector2, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform3D(mesh, {}); 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() { void TransformTest::meshData3DImplementationSpecificIndexType() {
@ -1060,10 +1059,10 @@ void TransformTest::meshData3DImplementationSpecificVertexFormat() {
Trade::MeshAttributeData{data.otherAttribute, data.otherAttributeFormat, nullptr}, Trade::MeshAttributeData{data.otherAttribute, data.otherAttributeFormat, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform3D(mesh, {}, 1); 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() { void TransformTest::meshData3DRvaluePassthrough() {
@ -1287,15 +1286,15 @@ void TransformTest::meshData3DRvaluePassthroughNoPosition() {
/* Mainly to verify there's no other accidental assertion from checking /* Mainly to verify there's no other accidental assertion from checking
vertex format and that the ID + morph target ID gets correctly passed vertex format and that the ID + morph target ID gets correctly passed
through, this message comes from the l-value overload */ through, this message comes from the l-value overload */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform3D(Trade::MeshData{MeshPrimitive::Points, nullptr, { transform3D(Trade::MeshData{MeshPrimitive::Points, nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
}}, {}, data.id, data.morphTargetId); }}, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshData3DRvaluePassthroughWrongFormat() {
@ -1392,10 +1391,10 @@ void TransformTest::meshData3DInPlaceNotMutable() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform3DInPlace(mesh, {}); 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() { void TransformTest::meshData3DInPlaceNoPosition() {
@ -1408,13 +1407,13 @@ void TransformTest::meshData3DInPlaceNoPosition() {
Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::Position, VertexFormat::Vector3, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform3DInPlace(mesh, {}, data.id, data.morphTargetId); transform3DInPlace(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshData3DInPlaceWrongFormat() {
@ -1439,10 +1438,10 @@ void TransformTest::meshData3DInPlaceWrongFormat() {
Trade::MeshData mesh{MeshPrimitive::Points, nullptr, Utility::move(attributes)}; Trade::MeshData mesh{MeshPrimitive::Points, nullptr, Utility::move(attributes)};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transform3DInPlace(mesh, {}, 1); transform3DInPlace(mesh, {}, 1);
CORRADE_COMPARE(out.str(), data.message); CORRADE_COMPARE(out, data.message);
} }
template<class T> void TransformTest::meshDataTextureCoordinates2D() { template<class T> void TransformTest::meshDataTextureCoordinates2D() {
@ -1518,13 +1517,13 @@ void TransformTest::meshDataTextureCoordinates2DNoCoordinates() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transformTextureCoordinates2D(mesh, {}, data.id, data.morphTargetId); transformTextureCoordinates2D(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshDataTextureCoordinates2DImplementationSpecificIndexType() {
@ -1558,10 +1557,10 @@ void TransformTest::meshDataTextureCoordinates2DImplementationSpecificVertexForm
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, vertexFormatWrap(0xcaca), nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, vertexFormatWrap(0xcaca), nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transformTextureCoordinates2D(mesh, {}, 1); 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() { void TransformTest::meshDataTextureCoordinates2DRvaluePassthrough() {
@ -1727,15 +1726,15 @@ void TransformTest::meshDataTextureCoordinates2DRvaluePassthroughNoCoordinates()
/* Mainly to verify there's no other accidental assertion from checking /* Mainly to verify there's no other accidental assertion from checking
vertex format and that the ID + morph target ID gets correctly passed vertex format and that the ID + morph target ID gets correctly passed
through, this message comes from the l-value overload */ through, this message comes from the l-value overload */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transformTextureCoordinates2D(Trade::MeshData{MeshPrimitive::Points, nullptr, { transformTextureCoordinates2D(Trade::MeshData{MeshPrimitive::Points, nullptr, {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}}, {}, data.id, data.morphTargetId); }}, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshDataTextureCoordinates2DRvaluePassthroughWrongFormat() {
@ -1777,10 +1776,10 @@ void TransformTest::meshDataTextureCoordinates2DInPlaceNotMutable() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transformTextureCoordinates2DInPlace(mesh, {}); 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() { void TransformTest::meshDataTextureCoordinates2DInPlaceNoCoordinates() {
@ -1793,13 +1792,13 @@ void TransformTest::meshDataTextureCoordinates2DInPlaceNoCoordinates() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr}, Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transformTextureCoordinates2DInPlace(mesh, {}, data.id, data.morphTargetId); transformTextureCoordinates2DInPlace(mesh, {}, data.id, data.morphTargetId);
if(data.morphTargetId == -1) 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 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() { void TransformTest::meshDataTextureCoordinates2DInPlaceWrongFormat() {
@ -1810,10 +1809,10 @@ void TransformTest::meshDataTextureCoordinates2DInPlaceWrongFormat() {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2us, nullptr} Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, VertexFormat::Vector2us, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
transformTextureCoordinates2DInPlace(mesh, {}, 1); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/SceneGraph/AbstractFeature.hpp" #include "Magnum/SceneGraph/AbstractFeature.hpp"
#include "Magnum/SceneGraph/Animable.hpp" #include "Magnum/SceneGraph/Animable.hpp"
@ -82,15 +81,15 @@ template<class T> void AnimableTest::state() {
this->setDuration(1.0f); this->setDuration(1.0f);
} }
std::string trackedState; Containers::String trackedState;
protected: protected:
void animationStep(Float, Float) override {} void animationStep(Float, Float) override {}
void animationStarted() override { trackedState += "started"; } void animationStarted() override { trackedState = trackedState + "started"; }
void animationPaused() override { trackedState += "paused"; } void animationPaused() override { trackedState = trackedState + "paused"; }
void animationResumed() override { trackedState += "resumed"; } void animationResumed() override { trackedState = trackedState + "resumed"; }
void animationStopped() override { trackedState += "stopped"; } void animationStopped() override { trackedState = trackedState + "stopped"; }
}; };
Object3D<T> object; Object3D<T> object;
@ -100,9 +99,9 @@ template<class T> void AnimableTest::state() {
/* Verify initial state */ /* Verify initial state */
StateTrackingAnimable animable(object, &group); StateTrackingAnimable animable(object, &group);
CORRADE_COMPARE(animable.state(), AnimationState::Stopped); CORRADE_COMPARE(animable.state(), AnimationState::Stopped);
CORRADE_VERIFY(animable.trackedState.empty()); CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f); group.step(1.0f, 1.0f);
CORRADE_VERIFY(animable.trackedState.empty()); CORRADE_COMPARE(animable.trackedState, "");
CORRADE_COMPARE(group.runningCount(), 0); CORRADE_COMPARE(group.runningCount(), 0);
/* Stopped -> paused is not supported */ /* Stopped -> paused is not supported */
@ -112,36 +111,36 @@ template<class T> void AnimableTest::state() {
/* Stopped -> running */ /* Stopped -> running */
CORRADE_COMPARE(animable.state(), AnimationState::Stopped); CORRADE_COMPARE(animable.state(), AnimationState::Stopped);
animable.trackedState.clear(); animable.trackedState = {};
animable.setState(AnimationState::Running); animable.setState(AnimationState::Running);
CORRADE_VERIFY(animable.trackedState.empty()); CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f); group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "started"); CORRADE_COMPARE(animable.trackedState, "started");
CORRADE_COMPARE(group.runningCount(), 1); CORRADE_COMPARE(group.runningCount(), 1);
/* Running -> paused */ /* Running -> paused */
CORRADE_COMPARE(animable.state(), AnimationState::Running); CORRADE_COMPARE(animable.state(), AnimationState::Running);
animable.trackedState.clear(); animable.trackedState = {};
animable.setState(AnimationState::Paused); animable.setState(AnimationState::Paused);
CORRADE_VERIFY(animable.trackedState.empty()); CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f); group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "paused"); CORRADE_COMPARE(animable.trackedState, "paused");
CORRADE_COMPARE(group.runningCount(), 0); CORRADE_COMPARE(group.runningCount(), 0);
/* Paused -> running */ /* Paused -> running */
CORRADE_COMPARE(animable.state(), AnimationState::Paused); CORRADE_COMPARE(animable.state(), AnimationState::Paused);
animable.trackedState.clear(); animable.trackedState = {};
animable.setState(AnimationState::Running); animable.setState(AnimationState::Running);
CORRADE_VERIFY(animable.trackedState.empty()); CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f); group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "resumed"); CORRADE_COMPARE(animable.trackedState, "resumed");
CORRADE_COMPARE(group.runningCount(), 1); CORRADE_COMPARE(group.runningCount(), 1);
/* Running -> stopped */ /* Running -> stopped */
CORRADE_COMPARE(animable.state(), AnimationState::Running); CORRADE_COMPARE(animable.state(), AnimationState::Running);
animable.trackedState.clear(); animable.trackedState = {};
animable.setState(AnimationState::Stopped); animable.setState(AnimationState::Stopped);
CORRADE_VERIFY(animable.trackedState.empty()); CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f); group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "stopped"); CORRADE_COMPARE(animable.trackedState, "stopped");
CORRADE_COMPARE(group.runningCount(), 0); CORRADE_COMPARE(group.runningCount(), 0);
@ -152,9 +151,9 @@ template<class T> void AnimableTest::state() {
/* Paused -> stopped */ /* Paused -> stopped */
CORRADE_COMPARE(animable.state(), AnimationState::Paused); CORRADE_COMPARE(animable.state(), AnimationState::Paused);
animable.trackedState.clear(); animable.trackedState = {};
animable.setState(AnimationState::Stopped); animable.setState(AnimationState::Stopped);
CORRADE_VERIFY(animable.trackedState.empty()); CORRADE_COMPARE(animable.trackedState, "");
group.step(1.0f, 1.0f); group.step(1.0f, 1.0f);
CORRADE_COMPARE(animable.trackedState, "stopped"); CORRADE_COMPARE(animable.trackedState, "stopped");
CORRADE_COMPARE(group.runningCount(), 0); CORRADE_COMPARE(group.runningCount(), 0);
@ -177,7 +176,7 @@ template<class T> class OneShotAnimable: public SceneGraph::BasicAnimable3D<T> {
} }
Float time; Float time;
std::string stateChanges; Containers::String stateChanges;
protected: protected:
void animationStep(Float t, Float) override { void animationStep(Float t, Float) override {
@ -185,11 +184,11 @@ template<class T> class OneShotAnimable: public SceneGraph::BasicAnimable3D<T> {
} }
void animationStarted() override { void animationStarted() override {
stateChanges += "started;"; stateChanges = stateChanges + "started;";
} }
void animationStopped() override { void animationStopped() override {
stateChanges += "stopped;"; stateChanges = stateChanges + "stopped;";
} }
}; };
@ -401,9 +400,9 @@ void AnimableTest::deleteWhileRunning() {
} }
void AnimableTest::debug() { void AnimableTest::debug() {
std::ostringstream o; Containers::String out;
Debug(&o) << AnimationState::Running << AnimationState(0xbe); Debug{&out} << AnimationState::Running << AnimationState(0xbe);
CORRADE_COMPARE(o.str(), "SceneGraph::AnimationState::Running SceneGraph::AnimationState(0xbe)\n"); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/SceneGraph/DualComplexTransformation.h" #include "Magnum/SceneGraph/DualComplexTransformation.h"
#include "Magnum/SceneGraph/Object.hpp" #include "Magnum/SceneGraph/Object.hpp"
@ -145,10 +144,10 @@ template<class T> void DualComplexTransformationTest::setTransformationInvalid()
Object2D<T> o; Object2D<T> o;
/* Can't transform with non-rigid transformation */ /* Can't transform with non-rigid transformation */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
o.setTransformation(Math::DualComplex<T>({T(1.0), T(2.0)}, {})); 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() { template<class T> void DualComplexTransformationTest::resetTransformation() {
@ -184,10 +183,10 @@ template<class T> void DualComplexTransformationTest::transformInvalid() {
/* Can't transform with non-rigid transformation */ /* Can't transform with non-rigid transformation */
Object2D<T> o; Object2D<T> o;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
o.transform(Math::DualComplex<T>{{T(1.0), T(2.0)}, {}}); 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() { template<class T> void DualComplexTransformationTest::translate() {

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

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

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

@ -24,11 +24,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/FormatStl.h>
#include "Magnum/SceneGraph/AbstractFeature.hpp" #include "Magnum/SceneGraph/AbstractFeature.hpp"
#include "Magnum/SceneGraph/MatrixTransformation3D.hpp" #include "Magnum/SceneGraph/MatrixTransformation3D.hpp"
@ -280,11 +279,11 @@ template<class T> void ObjectTest::setParentKeepTransformationInvalid() {
Object3D<T>* child = new Object3D<T>(&root); Object3D<T>* child = new Object3D<T>(&root);
/* Old parent and new parent must share the same scene */ /* Old parent and new parent must share the same scene */
std::ostringstream o; Containers::String out;
Error redirectError{&o}; Error redirectError{&out};
Scene3D<T> scene; Scene3D<T> scene;
child->setParentKeepTransformation(&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() { template<class T> void ObjectTest::absoluteTransformation() {
@ -389,14 +388,14 @@ template<class T> void ObjectTest::transformationsOrphan() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream o; Containers::String out;
Error redirectError{&o}; Error redirectError{&out};
/* Transformation of objects not part of the same scene */ /* Transformation of objects not part of the same scene */
Scene3D<T> s; Scene3D<T> s;
Object3D<T> orphan; Object3D<T> orphan;
CORRADE_COMPARE(s.transformations({orphan}), std::vector<Math::Matrix4<T>>{}); 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() { template<class T> void ObjectTest::transformationsDuplicate() {
@ -662,7 +661,7 @@ void ObjectTest::treeDestructionOrder() {
int id; int id;
}; };
std::stringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
{ {
struct Scene: Scene3D<Float> { struct Scene: Scene3D<Float> {
@ -689,7 +688,7 @@ void ObjectTest::treeDestructionOrder() {
AccessingParent{5, nullptr}; AccessingParent{5, nullptr};
AccessingObject{b, 4}; AccessingObject{b, 4};
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"Destructing an object 5 with 0 parents and no scene\n" "Destructing an object 5 with 0 parents and no scene\n"
"Destructing a feature 4 attached to an object 1\n"); "Destructing a feature 4 attached to an object 1\n");
} }
@ -701,7 +700,7 @@ void ObjectTest::treeDestructionOrder() {
"a scene" /* See below. */ "a scene" /* See below. */
#endif #endif
; ;
CORRADE_COMPARE(out.str(), Utility::formatString( CORRADE_COMPARE(out, Utility::format(
"Destructing an object 5 with 0 parents and no scene\n" "Destructing an object 5 with 0 parents and no scene\n"
"Destructing a feature 4 attached to an object 1\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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Complex.h" #include "Magnum/Math/Complex.h"
#include "Magnum/SceneGraph/Object.hpp" #include "Magnum/SceneGraph/Object.hpp"
@ -105,10 +104,10 @@ template<class T> void RigidMatrixTransformation2DTest::fromMatrixInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
Implementation::Transformation<BasicRigidMatrixTransformation2D<T>>::fromMatrix(Math::Matrix3<T>::scaling(Math::Vector2<T>{T(4.0)})); 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() { template<class T> void RigidMatrixTransformation2DTest::toMatrix() {
@ -161,10 +160,10 @@ template<class T> void RigidMatrixTransformation2DTest::setTransformationInvalid
Object2D<T> o; Object2D<T> o;
/* Can't transform with non-rigid transformation */ /* Can't transform with non-rigid transformation */
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
o.setTransformation(Math::Matrix3<T>::scaling(Math::Vector2<T>{T(3.0)})); 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() { template<class T> void RigidMatrixTransformation2DTest::resetTransformation() {
@ -200,10 +199,10 @@ template<class T> void RigidMatrixTransformation2DTest::transformInvalid() {
/* Can't transform with non-rigid transformation */ /* Can't transform with non-rigid transformation */
Object2D<T> o; Object2D<T> o;
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
o.transform(Math::Matrix3<T>::scaling(Math::Vector2<T>{T(3.0)})); 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() { template<class T> void RigidMatrixTransformation2DTest::translate() {

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

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

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

@ -24,9 +24,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/SceneGraph/Object.hpp" #include "Magnum/SceneGraph/Object.hpp"
#include "Magnum/SceneGraph/TranslationTransformation.h" #include "Magnum/SceneGraph/TranslationTransformation.h"
@ -92,10 +91,10 @@ template<class T> void TranslationTransformationTest::fromMatrixInvalid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream o; Containers::String out;
Error redirectError{&o}; Error redirectError{&out};
Implementation::Transformation<BasicTranslationTransformation2D<T>>::fromMatrix(Math::Matrix3<T>::scaling(Math::Vector2<T>{T(4.0)})); 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() { template<class T> void TranslationTransformationTest::toMatrix() {

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

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

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

@ -24,14 +24,12 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> /** @todo remove once Debug is stream-free */
#include <Corrade/Containers/StridedBitArrayView.h> #include <Corrade/Containers/StridedBitArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.h> #include <Corrade/Containers/StringIterable.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Algorithms.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/SceneTools/Copy.h"
#include "Magnum/Trade/SceneData.h" #include "Magnum/Trade/SceneData.h"
@ -424,10 +422,10 @@ void CopyTest::mutableReferenceNotMutable() {
}}; }};
CORRADE_COMPARE(scene.dataFlags(), Trade::DataFlag::Global); CORRADE_COMPARE(scene.dataFlags(), Trade::DataFlag::Global);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::mutableReference(scene); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/BitArray.h> #include <Corrade/Containers/BitArray.h>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StridedBitArrayView.h> #include <Corrade/Containers/StridedBitArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Complex.h" #include "Magnum/Math/Complex.h"
#include "Magnum/Math/Vector2.h" #include "Magnum/Math/Vector2.h"
@ -259,10 +258,10 @@ void FilterTest::fieldsWrongBitCount() {
Containers::arrayView(data)}, Containers::arrayView(data)},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
filterFields(scene, Containers::BitArray{ValueInit, 3}); 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() { void FilterTest::onlyFields() {
@ -632,7 +631,7 @@ void FilterTest::fieldEntriesFieldNotFound() {
Containers::arrayView(data->light)}, Containers::arrayView(data->light)},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
filterFieldEntries(scene, { filterFieldEntries(scene, {
{Trade::SceneField::Light, Containers::BitArray{ValueInit, 4}}, {Trade::SceneField::Light, Containers::BitArray{ValueInit, 4}},
@ -642,7 +641,7 @@ void FilterTest::fieldEntriesFieldNotFound() {
{1, Containers::BitArray{ValueInit, 4}}, {1, Containers::BitArray{ValueInit, 4}},
{2, {}} {2, {}}
}); });
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"SceneTools::filterFieldEntries(): field Trade::SceneField::Parent not found\n" "SceneTools::filterFieldEntries(): field Trade::SceneField::Parent not found\n"
"SceneTools::filterFieldEntries(): index 2 out of range for 2 fields\n"); "SceneTools::filterFieldEntries(): index 2 out of range for 2 fields\n");
} }
@ -666,7 +665,7 @@ void FilterTest::fieldEntriesDuplicated() {
Containers::arrayView(data->light)}, Containers::arrayView(data->light)},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The name-based variant just delegates to this one, no need to test it /* The name-based variant just delegates to this one, no need to test it
as well */ as well */
@ -675,7 +674,7 @@ void FilterTest::fieldEntriesDuplicated() {
{0, Containers::BitArray{ValueInit, 5}}, {0, Containers::BitArray{ValueInit, 5}},
{1, Containers::BitArray{ValueInit, 4}}, {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() { void FilterTest::fieldEntriesWrongBitCount() {
@ -697,7 +696,7 @@ void FilterTest::fieldEntriesWrongBitCount() {
Containers::arrayView(data->light)}, Containers::arrayView(data->light)},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The name-based variant just delegates to this one, no need to test it /* The name-based variant just delegates to this one, no need to test it
as well */ as well */
@ -705,7 +704,7 @@ void FilterTest::fieldEntriesWrongBitCount() {
{1, Containers::BitArray{ValueInit, 4}}, {1, Containers::BitArray{ValueInit, 4}},
{0, Containers::BitArray{ValueInit, 6}} {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() { void FilterTest::fieldEntriesBitField() {
@ -727,7 +726,7 @@ void FilterTest::fieldEntriesBitField() {
Containers::stridedArrayView(data->visible).sliceBit(0)}, Containers::stridedArrayView(data->visible).sliceBit(0)},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The name-based variant just delegates to this one, no need to test it /* The name-based variant just delegates to this one, no need to test it
as well */ as well */
@ -735,7 +734,7 @@ void FilterTest::fieldEntriesBitField() {
{0, Containers::BitArray{ValueInit, 5}}, {0, Containers::BitArray{ValueInit, 5}},
{1, Containers::BitArray{ValueInit, 2}} {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() { void FilterTest::fieldEntriesStringField() {
@ -759,7 +758,7 @@ void FilterTest::fieldEntriesStringField() {
Containers::arrayView(data->nameRangeNullTerminated)}, Containers::arrayView(data->nameRangeNullTerminated)},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
/* The name-based variant just delegates to this one, no need to test it /* The name-based variant just delegates to this one, no need to test it
as well */ as well */
@ -767,7 +766,7 @@ void FilterTest::fieldEntriesStringField() {
{0, Containers::BitArray{ValueInit, 5}}, {0, Containers::BitArray{ValueInit, 5}},
{1, Containers::BitArray{ValueInit, 2}} {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() { void FilterTest::fieldEntriesSharedMapping() {
@ -936,7 +935,7 @@ void FilterTest::fieldEntriesSharedMappingInvalid() {
Containers::BitArray meshesToKeep{ValueInit, 5}; Containers::BitArray meshesToKeep{ValueInit, 5};
Containers::BitArray meshesToKeepDifferent{DirectInit, 5, true}; Containers::BitArray meshesToKeepDifferent{DirectInit, 5, true};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
filterFieldEntries(scene, { filterFieldEntries(scene, {
{Trade::SceneField::MeshMaterial, meshesToKeep}, {Trade::SceneField::MeshMaterial, meshesToKeep},
@ -951,7 +950,7 @@ void FilterTest::fieldEntriesSharedMappingInvalid() {
{Trade::sceneFieldCustom(1), meshesToKeep}, {Trade::sceneFieldCustom(1), meshesToKeep},
{Trade::SceneField::MeshMaterial, 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::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::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"); "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, {}}; Trade::SceneData scene{Trade::SceneMappingType::UnsignedShort, 176, nullptr, {}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
filterObjects(scene, Containers::BitArray{ValueInit, 177}); 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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/Triple.h> #include <Corrade/Containers/Triple.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
/* There's no better way to disable file deprecation warnings */ /* There's no better way to disable file deprecation warnings */
#define _MAGNUM_NO_DEPRECATED_FLATTENMESHHIERARCHY #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}, Trade::SceneFieldData{Trade::SceneField::Mesh, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::UnsignedInt, nullptr},
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_IGNORE_DEPRECATED_PUSH
flattenMeshHierarchy2D(scene); flattenMeshHierarchy2D(scene);
flattenMeshHierarchy3D(scene); flattenMeshHierarchy3D(scene);
CORRADE_IGNORE_DEPRECATED_POP 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 2D\n"
"SceneTools::absoluteFieldTransformations(): the scene is not 3D\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} Trade::SceneFieldData{Trade::SceneField::Transformation, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::Matrix3x3, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_IGNORE_DEPRECATED_PUSH
flattenMeshHierarchy2D(scene); flattenMeshHierarchy2D(scene);
CORRADE_IGNORE_DEPRECATED_POP CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"SceneTools::absoluteFieldTransformations(): the scene has no hierarchy\n"); "SceneTools::absoluteFieldTransformations(): the scene has no hierarchy\n");
} }
@ -493,13 +492,13 @@ void FlattenMeshHierarchyTest::intoInvalidSize() {
Matrix3 transformations2D[6]; Matrix3 transformations2D[6];
Matrix4 transformations3D[4]; Matrix4 transformations3D[4];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_IGNORE_DEPRECATED_PUSH
flattenMeshHierarchy2DInto(scene2D, transformations2D); flattenMeshHierarchy2DInto(scene2D, transformations2D);
flattenMeshHierarchy3DInto(scene3D, transformations3D); flattenMeshHierarchy3DInto(scene3D, transformations3D);
CORRADE_IGNORE_DEPRECATED_POP 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 6\n"
"SceneTools::absoluteFieldTransformationsInto(): bad output size, expected 5 but got 4\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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/Triple.h> #include <Corrade/Containers/Triple.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Math/Matrix3.h" #include "Magnum/Math/Matrix3.h"
#include "Magnum/Math/Matrix4.h" #include "Magnum/Math/Matrix4.h"
@ -268,11 +267,11 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstNoParentField() {
Trade::SceneData scene{Trade::SceneMappingType::UnsignedByte, 0, nullptr, {}}; Trade::SceneData scene{Trade::SceneMappingType::UnsignedByte, 0, nullptr, {}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene); SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene); SceneTools::childrenDepthFirst(scene);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): the scene has no hierarchy\n" "SceneTools::parentsBreadthFirst(): the scene has no hierarchy\n"
"SceneTools::childrenDepthFirst(): 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, {}}; Trade::SceneData scene{Trade::SceneMappingType::UnsignedByte, 0, nullptr, {}};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
parentsBreadthFirstInto(scene, nullptr, nullptr); parentsBreadthFirstInto(scene, nullptr, nullptr);
childrenDepthFirstInto(scene, nullptr, nullptr); childrenDepthFirstInto(scene, nullptr, nullptr);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirstInto(): the scene has no hierarchy\n" "SceneTools::parentsBreadthFirstInto(): the scene has no hierarchy\n"
"SceneTools::childrenDepthFirstInto(): 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 childCountCorrect[3];
UnsignedInt childCount[2]; UnsignedInt childCount[2];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
parentsBreadthFirstInto(scene, mappingCorrect, parentOffset); parentsBreadthFirstInto(scene, mappingCorrect, parentOffset);
parentsBreadthFirstInto(scene, mapping, parentOffsetCorrect); parentsBreadthFirstInto(scene, mapping, parentOffsetCorrect);
childrenDepthFirstInto(scene, mappingCorrect, childCount); childrenDepthFirstInto(scene, mappingCorrect, childCount);
childrenDepthFirstInto(scene, mapping, childCountCorrect); 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 parent destination view with 3 elements but got 2\n"
"SceneTools::parentsBreadthFirstInto(): expected mapping 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" "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)} view.slice(&Field::parent)}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene); SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene); SceneTools::childrenDepthFirst(scene);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): hierarchy is sparse\n" "SceneTools::parentsBreadthFirst(): hierarchy is sparse\n"
"SceneTools::childrenDepthFirst(): hierarchy is sparse\n"); "SceneTools::childrenDepthFirst(): hierarchy is sparse\n");
} }
@ -406,11 +405,11 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstCyclic() {
view.slice(&Field::parent)} view.slice(&Field::parent)}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene); SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene); SceneTools::childrenDepthFirst(scene);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): hierarchy is sparse\n" "SceneTools::parentsBreadthFirst(): hierarchy is sparse\n"
"SceneTools::childrenDepthFirst(): hierarchy is sparse\n"); "SceneTools::childrenDepthFirst(): hierarchy is sparse\n");
} }
@ -438,11 +437,11 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstCyclicDeep() {
view.slice(&Field::parent)} view.slice(&Field::parent)}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene); SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(scene); SceneTools::childrenDepthFirst(scene);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"SceneTools::parentsBreadthFirst(): hierarchy is cyclic\n" "SceneTools::parentsBreadthFirst(): hierarchy is cyclic\n"
"SceneTools::childrenDepthFirst(): hierarchy is cyclic\n"); "SceneTools::childrenDepthFirst(): hierarchy is cyclic\n");
} }
@ -472,12 +471,12 @@ void HierarchyTest::parentsBreadthFirstChildrenDepthFirstSparseAndCyclic() {
view.slice(&Field::parent)} view.slice(&Field::parent)}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::parentsBreadthFirst(scene); SceneTools::parentsBreadthFirst(scene);
SceneTools::childrenDepthFirst(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_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::parentsBreadthFirst(): hierarchy is cyclic\n"
"SceneTools::childrenDepthFirst(): 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} Trade::SceneFieldData{Trade::SceneField::Transformation, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::Matrix3x3, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Mesh); SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Mesh);
SceneTools::absoluteFieldTransformations3D(scene, Trade::SceneField::Mesh); SceneTools::absoluteFieldTransformations3D(scene, Trade::SceneField::Mesh);
SceneTools::absoluteFieldTransformations2D(scene, 2); SceneTools::absoluteFieldTransformations2D(scene, 2);
SceneTools::absoluteFieldTransformations3D(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(): 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" "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} Trade::SceneFieldData{Trade::SceneField::Parent, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::Int, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Parent); SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Parent);
SceneTools::absoluteFieldTransformations2D(scene, 0); SceneTools::absoluteFieldTransformations2D(scene, 0);
SceneTools::absoluteFieldTransformations3D(scene, Trade::SceneField::Parent); SceneTools::absoluteFieldTransformations3D(scene, Trade::SceneField::Parent);
SceneTools::absoluteFieldTransformations3D(scene, 0); 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 2D\n" "SceneTools::absoluteFieldTransformations(): the scene is not 2D\n"
"SceneTools::absoluteFieldTransformations(): the scene is not 3D\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} Trade::SceneFieldData{Trade::SceneField::Transformation, Trade::SceneMappingType::UnsignedInt, nullptr, Trade::SceneFieldType::Matrix3x3, nullptr}
}}; }};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Transformation); SceneTools::absoluteFieldTransformations2D(scene, Trade::SceneField::Transformation);
SceneTools::absoluteFieldTransformations2D(scene, 0); 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"
"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]; Matrix3 transformations2D[6];
Matrix4 transformations3D[4]; Matrix4 transformations3D[4];
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
absoluteFieldTransformations2DInto(scene2D, Trade::SceneField::Mesh, transformations2D); absoluteFieldTransformations2DInto(scene2D, Trade::SceneField::Mesh, transformations2D);
absoluteFieldTransformations2DInto(scene2D, 1, transformations2D); absoluteFieldTransformations2DInto(scene2D, 1, transformations2D);
absoluteFieldTransformations3DInto(scene3D, Trade::SceneField::Mesh, transformations3D); absoluteFieldTransformations3DInto(scene3D, Trade::SceneField::Mesh, transformations3D);
absoluteFieldTransformations3DInto(scene3D, 1, 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 6\n" "SceneTools::absoluteFieldTransformationsInto(): bad output size, expected 5 but got 6\n"
"SceneTools::absoluteFieldTransformationsInto(): bad output size, expected 5 but got 4\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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> /** @todo remove once Debug is stream-free */
#include <Corrade/Containers/StridedBitArrayView.h> #include <Corrade/Containers/StridedBitArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringIterable.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/Tester.h>
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/TestSuite/Compare/String.h> #include <Corrade/TestSuite/Compare/String.h>
#include <Corrade/Utility/Algorithms.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/Math/TypeTraits.h"
#include "Magnum/SceneTools/Map.h" #include "Magnum/SceneTools/Map.h"
@ -362,13 +359,13 @@ void MapTest::indexFieldFieldNotFound() {
UnsignedInt mapping[5]{}; UnsignedInt mapping[5]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
mapIndexField(scene, 2, mapping); mapIndexField(scene, 2, mapping);
mapIndexFieldInPlace(scene, 2, mapping); mapIndexFieldInPlace(scene, 2, mapping);
mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping); mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping);
mapIndexFieldInPlace(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::mapIndexField(): index 2 out of range for 2 fields\n"
"SceneTools::mapIndexFieldInPlace(): 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" "SceneTools::mapIndexField(): field Trade::SceneField::MeshMaterial not found\n"
@ -390,11 +387,11 @@ void MapTest::indexFieldInvalidType() {
UnsignedInt mapping[5]{}; UnsignedInt mapping[5]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
mapIndexField(scene, 1, mapping); mapIndexField(scene, 1, mapping);
mapIndexFieldInPlace(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::mapIndexField(): unsupported field type Trade::SceneFieldType::Long\n"
"SceneTools::mapIndexFieldInPlace(): unsupported field type Trade::SceneFieldType::Long\n", "SceneTools::mapIndexFieldInPlace(): unsupported field type Trade::SceneFieldType::Long\n",
TestSuite::Compare::String); TestSuite::Compare::String);
@ -414,11 +411,11 @@ void MapTest::indexFieldArrayField() {
UnsignedInt mapping[5]{}; UnsignedInt mapping[5]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
mapIndexField(scene, 1, mapping); mapIndexField(scene, 1, mapping);
mapIndexFieldInPlace(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::mapIndexField(): array field mapping isn't supported\n"
"SceneTools::mapIndexFieldInPlace(): array field mapping isn't supported\n", "SceneTools::mapIndexFieldInPlace(): array field mapping isn't supported\n",
TestSuite::Compare::String); TestSuite::Compare::String);
@ -448,12 +445,12 @@ void MapTest::indexFieldIndexOutOfBounds() {
const UnsignedInt mapping9[9]{}; const UnsignedInt mapping9[9]{};
const UnsignedInt mapping10[10]{}; const UnsignedInt mapping10[10]{};
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping10); mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping10);
mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping9); mapIndexField(scene, Trade::SceneField::MeshMaterial, mapping9);
mapIndexField(scene, Trade::SceneField::Mesh, mapping10); 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 -2 out of range for 10 mapping values\n"
"SceneTools::mapIndexFieldInPlace(): index 9 out of range for 9 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", "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::sceneFieldCustom(2), mappingSigned);
mapIndexField(scene, Trade::SceneField::MeshMaterial, mappingSigned); mapIndexField(scene, Trade::SceneField::MeshMaterial, mappingSigned);
std::ostringstream out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
mapIndexFieldInPlace(scene, Trade::SceneField::Mesh, mappingUnsigned); mapIndexFieldInPlace(scene, Trade::SceneField::Mesh, mappingUnsigned);
mapIndexFieldInPlace(scene, Trade::SceneField::Light, mappingUnsigned); mapIndexFieldInPlace(scene, Trade::SceneField::Light, mappingUnsigned);
@ -522,7 +519,7 @@ void MapTest::indexFieldMappingNotRepresentable() {
mapIndexFieldInPlace(scene, Trade::sceneFieldCustom(1), mappingSigned); mapIndexFieldInPlace(scene, Trade::sceneFieldCustom(1), mappingSigned);
mapIndexFieldInPlace(scene, Trade::sceneFieldCustom(2), mappingSigned); mapIndexFieldInPlace(scene, Trade::sceneFieldCustom(2), mappingSigned);
mapIndexFieldInPlace(scene, Trade::SceneField::MeshMaterial, 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::UnsignedShort\n"
"SceneTools::mapIndexFieldInPlace(): mapping value 65536 not representable in Trade::SceneFieldType::UnsignedByte\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" "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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream>
#include <Corrade/Containers/ArrayTuple.h> #include <Corrade/Containers/ArrayTuple.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/StringToFile.h> #include <Corrade/TestSuite/Compare/StringToFile.h>
#include <Corrade/Utility/Algorithms.h> #include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include "Magnum/Math/CubicHermite.h" #include "Magnum/Math/CubicHermite.h"
@ -207,10 +205,10 @@ void SceneConverterImplementationTest::converterInfo() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
Implementation::printSceneConverterInfo(Debug::Flag::DisableColors, *converter); Implementation::printSceneConverterInfo(Debug::Flag::DisableColors, *converter);
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out,
"Plugin name: AnySceneConverter\n" "Plugin name: AnySceneConverter\n"
"Features:\n" "Features:\n"
" ConvertMeshToFile\n" " ConvertMeshToFile\n"
@ -231,10 +229,10 @@ void SceneConverterImplementationTest::infoEmpty() {
std::chrono::high_resolution_clock::duration time; std::chrono::high_resolution_clock::duration time;
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false); CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false);
CORRADE_COMPARE(out.str(), ""); CORRADE_COMPARE(out, "");
} }
void SceneConverterImplementationTest::infoScenesObjects() { void SceneConverterImplementationTest::infoScenesObjects() {
@ -332,10 +330,10 @@ void SceneConverterImplementationTest::infoScenesObjects() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false); 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}), Utility::Path::join({SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles", data.expected}),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -413,10 +411,10 @@ void SceneConverterImplementationTest::infoAnimations() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-animations.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -486,10 +484,10 @@ void SceneConverterImplementationTest::infoSkins() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-skins.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -542,10 +540,10 @@ void SceneConverterImplementationTest::infoLights() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-lights.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -601,10 +599,10 @@ void SceneConverterImplementationTest::infoCameras() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-cameras.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -668,10 +666,10 @@ void SceneConverterImplementationTest::infoMaterials() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-materials.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -768,10 +766,10 @@ void SceneConverterImplementationTest::infoMeshes() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-meshes.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -850,10 +848,10 @@ void SceneConverterImplementationTest::infoMeshesBounds() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-meshes-bounds.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -908,10 +906,10 @@ void SceneConverterImplementationTest::infoTextures() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-textures.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -945,10 +943,10 @@ void SceneConverterImplementationTest::infoImages() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-images.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -1242,10 +1240,10 @@ void SceneConverterImplementationTest::infoReferenceCount() {
Debug{} << "======================== visual color verification end ========================="; Debug{} << "======================== visual color verification end =========================";
} }
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, false, _infoArgs, importer, time) == false); 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"), Utility::Path::join(SCENETOOLS_TEST_DIR, "SceneConverterImplementationTestFiles/info-references.txt"),
TestSuite::Compare::StringToFile); TestSuite::Compare::StringToFile);
} }
@ -1330,12 +1328,12 @@ void SceneConverterImplementationTest::infoError() {
std::chrono::high_resolution_clock::duration time; std::chrono::high_resolution_clock::duration time;
std::ostringstream out; Containers::String out;
Debug redirectOutput{&out}; Debug redirectOutput{&out};
Error redirectError{&out}; Error redirectError{&out};
/* It should return a failure */ /* It should return a failure */
CORRADE_VERIFY(Implementation::printInfo(Debug::Flag::DisableColors, {}, _infoArgs, importer, time) == true); 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... */ /* It should not exit after first error... */
"Scene 0 error!\n" "Scene 0 error!\n"
"Can't import scene 0\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. DEALINGS IN THE SOFTWARE.
*/ */
#include <sstream> #include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/ShaderTools/Stage.h" #include "Magnum/ShaderTools/Stage.h"
@ -43,10 +42,10 @@ StageTest::StageTest() {
} }
void StageTest::debug() { void StageTest::debug() {
std::ostringstream out; Containers::String out;
Debug{&out} << Stage::RayMiss << Stage(0xf0); 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