Browse Source

Port from Utility::formatString() to Utility::format() where possible.

There's still many cases where the formatted string is compared to a
std::stringstream, there it doesn't make sense to switch.
pull/556/head
Vladimír Vondruš 4 years ago
parent
commit
3b2ad338e2
  1. 5
      src/Magnum/DebugTools/FrameProfiler.cpp
  2. 8
      src/Magnum/Math/Test/AngleTest.cpp
  3. 58
      src/Magnum/Math/Test/ColorTest.cpp
  4. 28
      src/Magnum/SceneTools/sceneconverter.cpp
  5. 10
      src/MagnumPlugins/AnyShaderConverter/Test/AnyConverterTest.cpp

5
src/Magnum/DebugTools/FrameProfiler.cpp

@ -29,8 +29,9 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/EnumSet.hpp> #include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
#include "Magnum/Math/Functions.h" #include "Magnum/Math/Functions.h"
@ -294,7 +295,7 @@ namespace {
void printValue(Utility::Debug& out, const Double mean, const Double divisor, const char* const unitPrefix, const char* const units) { void printValue(Utility::Debug& out, const Double mean, const Double divisor, const char* const unitPrefix, const char* const units) {
out << Debug::boldColor(Debug::Color::Green) out << Debug::boldColor(Debug::Color::Green)
<< Utility::formatString("{:.2f}", mean/divisor) << Debug::resetColor << Utility::format("{:.2f}", mean/divisor) << Debug::resetColor
<< Debug::nospace << unitPrefix << Debug::nospace << units; << Debug::nospace << unitPrefix << Debug::nospace << units;
} }

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

@ -29,7 +29,7 @@
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Corrade/Containers/StringStl.h> #include <Corrade/Containers/String.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/TweakableParser.h> #include <Corrade/Utility/TweakableParser.h>
#endif #endif
@ -299,10 +299,9 @@ template<class T> void AngleTest::tweakable() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseTemplateName(TweakableTraits<T>::name()); setTestCaseTemplateName(TweakableTraits<T>::name());
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, TweakableTraits<T>::literal());
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
T result; T result;
std::tie(state, result) = Corrade::Utility::TweakableParser<T>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<T>::parse(Corrade::Utility::format(data.data, TweakableTraits<T>::literal()));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, T(typename T::Type(data.result))); CORRADE_COMPARE(result, T(typename T::Type(data.result)));
} }
@ -311,12 +310,11 @@ template<class T> void AngleTest::tweakableError() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseTemplateName(TweakableTraits<T>::name()); setTestCaseTemplateName(TweakableTraits<T>::name());
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, TweakableTraits<T>::literal());
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<T>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<T>::parse(Corrade::Utility::format(data.data, TweakableTraits<T>::literal())).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, TweakableTraits<T>::literal())); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, TweakableTraits<T>::literal()));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }

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

@ -28,7 +28,7 @@
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Corrade/Containers/StringStl.h> #include <Corrade/Containers/String.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Tweakable.h> #include <Corrade/Utility/Tweakable.h>
#endif #endif
@ -1104,10 +1104,10 @@ void ColorTest::debugHsv() {
void ColorTest::tweakableRgb() { void ColorTest::tweakableRgb() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.dataRgb, "rgb");
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
Color3ub result; Color3ub result;
std::tie(state, result) = Corrade::Utility::TweakableParser<Color3ub>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<Color3ub>::parse(Corrade::Utility::format(data.dataRgb, "rgb"));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, data.resultUb.rgb()); CORRADE_COMPARE(result, data.resultUb.rgb());
} }
@ -1115,10 +1115,10 @@ void ColorTest::tweakableRgb() {
void ColorTest::tweakableSrgb() { void ColorTest::tweakableSrgb() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.dataRgb, "srgb");
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
Math::Vector3<UnsignedByte> result; Math::Vector3<UnsignedByte> result;
std::tie(state, result) = Corrade::Utility::TweakableParser<Math::Vector3<UnsignedByte>>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<Math::Vector3<UnsignedByte>>::parse(Corrade::Utility::format(data.dataRgb, "srgb"));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, data.resultUb.rgb()); CORRADE_COMPARE(result, data.resultUb.rgb());
} }
@ -1126,10 +1126,10 @@ void ColorTest::tweakableSrgb() {
void ColorTest::tweakableRgba() { void ColorTest::tweakableRgba() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.dataRgba, "rgba");
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
Color4ub result; Color4ub result;
std::tie(state, result) = Corrade::Utility::TweakableParser<Color4ub>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<Color4ub>::parse(Corrade::Utility::format(data.dataRgba, "rgba"));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, data.resultUb); CORRADE_COMPARE(result, data.resultUb);
} }
@ -1137,10 +1137,10 @@ void ColorTest::tweakableRgba() {
void ColorTest::tweakableSrgba() { void ColorTest::tweakableSrgba() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.dataRgba, "srgba");
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
Math::Vector4<UnsignedByte> result; Math::Vector4<UnsignedByte> result;
std::tie(state, result) = Corrade::Utility::TweakableParser<Math::Vector4<UnsignedByte>>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<Math::Vector4<UnsignedByte>>::parse(Corrade::Utility::format(data.dataRgba, "srgba"));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, data.resultUb); CORRADE_COMPARE(result, data.resultUb);
} }
@ -1148,10 +1148,10 @@ void ColorTest::tweakableSrgba() {
void ColorTest::tweakableRgbf() { void ColorTest::tweakableRgbf() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.dataRgb, "rgbf");
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
Color3 result; Color3 result;
std::tie(state, result) = Corrade::Utility::TweakableParser<Color3>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<Color3>::parse(Corrade::Utility::format(data.dataRgb, "rgbf"));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, data.result.rgb()); CORRADE_COMPARE(result, data.result.rgb());
} }
@ -1159,10 +1159,10 @@ void ColorTest::tweakableRgbf() {
void ColorTest::tweakableSrgbf() { void ColorTest::tweakableSrgbf() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.dataRgb, "srgbf");
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
Color3 result; Color3 result;
std::tie(state, result) = Corrade::Utility::TweakableParser<Color3>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<Color3>::parse(Corrade::Utility::format(data.dataRgb, "srgbf"));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, data.resultSrgba.rgb()); CORRADE_COMPARE(result, data.resultSrgba.rgb());
} }
@ -1170,10 +1170,10 @@ void ColorTest::tweakableSrgbf() {
void ColorTest::tweakableRgbaf() { void ColorTest::tweakableRgbaf() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.dataRgba, "rgbaf");
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
Color4 result; Color4 result;
std::tie(state, result) = Corrade::Utility::TweakableParser<Color4>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<Color4>::parse(Corrade::Utility::format(data.dataRgba, "rgbaf"));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, data.result); CORRADE_COMPARE(result, data.result);
} }
@ -1181,10 +1181,10 @@ void ColorTest::tweakableRgbaf() {
void ColorTest::tweakableSrgbaf() { void ColorTest::tweakableSrgbaf() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.dataRgba, "srgbaf");
Corrade::Utility::TweakableState state; Corrade::Utility::TweakableState state;
Color4 result; Color4 result;
std::tie(state, result) = Corrade::Utility::TweakableParser<Color4>::parse(input); std::tie(state, result) = Corrade::Utility::TweakableParser<Color4>::parse(Corrade::Utility::format(data.dataRgba, "srgbaf"));
CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success);
CORRADE_COMPARE(result, data.resultSrgba); CORRADE_COMPARE(result, data.resultSrgba);
} }
@ -1192,12 +1192,11 @@ void ColorTest::tweakableSrgbaf() {
void ColorTest::tweakableErrorRgb() { void ColorTest::tweakableErrorRgb() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, "ff3366", "rgb");
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color3ub>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color3ub>::parse(Corrade::Utility::format(data.data, "ff3366", "rgb")).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgb", "")); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgb", ""));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }
@ -1205,12 +1204,11 @@ void ColorTest::tweakableErrorRgb() {
void ColorTest::tweakableErrorSrgb() { void ColorTest::tweakableErrorSrgb() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, "ff3366", "srgb");
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Math::Vector3<UnsignedByte>>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Math::Vector3<UnsignedByte>>::parse(Corrade::Utility::format(data.data, "ff3366", "srgb")).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgb", "s")); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgb", "s"));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }
@ -1218,12 +1216,11 @@ void ColorTest::tweakableErrorSrgb() {
void ColorTest::tweakableErrorRgba() { void ColorTest::tweakableErrorRgba() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, "ff3366aa", "rgba");
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color4ub>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color4ub>::parse(Corrade::Utility::format(data.data, "ff3366aa", "rgba")).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgba", "")); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgba", ""));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }
@ -1231,12 +1228,11 @@ void ColorTest::tweakableErrorRgba() {
void ColorTest::tweakableErrorSrgba() { void ColorTest::tweakableErrorSrgba() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, "ff3366aa", "srgba");
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Math::Vector4<UnsignedByte>>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Math::Vector4<UnsignedByte>>::parse(Corrade::Utility::format(data.data, "ff3366aa", "srgba")).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgba", "s")); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgba", "s"));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }
@ -1244,12 +1240,11 @@ void ColorTest::tweakableErrorSrgba() {
void ColorTest::tweakableErrorRgbf() { void ColorTest::tweakableErrorRgbf() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, "ff3366", "rgbf");
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color3>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color3>::parse(Corrade::Utility::format(data.data, "ff3366", "rgbf")).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgbf", "")); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgbf", ""));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }
@ -1257,12 +1252,11 @@ void ColorTest::tweakableErrorRgbf() {
void ColorTest::tweakableErrorSrgbf() { void ColorTest::tweakableErrorSrgbf() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, "ff3366", "srgbf");
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color3>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color3>::parse(Corrade::Utility::format(data.data, "ff3366", "srgbf")).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgbf", "s")); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgbf", "s"));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }
@ -1270,12 +1264,11 @@ void ColorTest::tweakableErrorSrgbf() {
void ColorTest::tweakableErrorRgbaf() { void ColorTest::tweakableErrorRgbaf() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, "ff3366aa", "rgbaf");
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color4>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color4>::parse(Corrade::Utility::format(data.data, "ff3366aa", "rgbaf")).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgbaf", "")); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgbaf", ""));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }
@ -1283,12 +1276,11 @@ void ColorTest::tweakableErrorRgbaf() {
void ColorTest::tweakableErrorSrgbaf() { void ColorTest::tweakableErrorSrgbaf() {
auto&& data = TweakableErrorData[testCaseInstanceId()]; auto&& data = TweakableErrorData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
std::string input = Corrade::Utility::formatString(data.data, "ff3366aa", "srgbaf");
std::ostringstream out; std::ostringstream out;
Warning redirectWarning{&out}; Warning redirectWarning{&out};
Error redirectError{&out}; Error redirectError{&out};
Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color4>::parse(input).first; Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser<Color4>::parse(Corrade::Utility::format(data.data, "ff3366aa", "srgbaf")).first;
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgbaf", "s")); CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgbaf", "s"));
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }

28
src/Magnum/SceneTools/sceneconverter.cpp

@ -31,7 +31,7 @@
#include <Corrade/Utility/Arguments.h> #include <Corrade/Utility/Arguments.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
@ -730,7 +730,7 @@ is specified as well, the IDs reference attributes of the first mesh.)")
if(!info.name.empty()) d << info.name; if(!info.name.empty()) d << info.name;
d << Debug::newline; d << Debug::newline;
d << " bound:" << info.mappingBound << "objects," << info.mappingType d << " bound:" << info.mappingBound << "objects," << info.mappingType
<< "(" << Debug::nospace << Utility::formatString("{:.1f}", info.dataSize/1024.0f) << "kB)"; << "(" << Debug::nospace << Utility::format("{:.1f}", info.dataSize/1024.0f) << "kB)";
for(const SceneFieldInfo& field: info.fields) { for(const SceneFieldInfo& field: info.fields) {
d << Debug::newline << " " << field.name; d << Debug::newline << " " << field.name;
@ -740,7 +740,7 @@ is specified as well, the IDs reference attributes of the first mesh.)")
} }
d << "@" << field.type; d << "@" << field.type;
if(field.arraySize) if(field.arraySize)
d << Debug::nospace << Utility::formatString("[{}]", field.arraySize); d << Debug::nospace << Utility::format("[{}]", field.arraySize);
d << Debug::nospace << "," << field.size << "entries"; d << Debug::nospace << "," << field.size << "entries";
if(field.flags) if(field.flags)
d << Debug::newline << " " << field.flags; d << Debug::newline << " " << field.flags;
@ -782,7 +782,7 @@ is specified as well, the IDs reference attributes of the first mesh.)")
/* Print reference count only if there actually are scenes and they /* Print reference count only if there actually are scenes and they
were parsed, otherwise this information is useless */ were parsed, otherwise this information is useless */
if(skinReferenceCount) if(skinReferenceCount)
d << Utility::formatString("(referenced by {} objects)", skinReferenceCount[info.skin]); d << Utility::format("(referenced by {} objects)", skinReferenceCount[info.skin]);
d << Debug::nospace << ":"; d << Debug::nospace << ":";
if(!info.name.empty()) d << info.name; if(!info.name.empty()) d << info.name;
@ -797,7 +797,7 @@ is specified as well, the IDs reference attributes of the first mesh.)")
/* Print reference count only if there actually are scenes and they /* Print reference count only if there actually are scenes and they
were parsed, otherwise this information is useless */ were parsed, otherwise this information is useless */
if(lightReferenceCount) if(lightReferenceCount)
d << Utility::formatString("(referenced by {} objects)", lightReferenceCount[info.light]); d << Utility::format("(referenced by {} objects)", lightReferenceCount[info.light]);
d << Debug::nospace << ":"; d << Debug::nospace << ":";
if(!info.name.empty()) d << info.name; if(!info.name.empty()) d << info.name;
@ -818,7 +818,7 @@ is specified as well, the IDs reference attributes of the first mesh.)")
/* Print reference count only if there actually are scenes and they /* Print reference count only if there actually are scenes and they
were parsed, otherwise this information is useless */ were parsed, otherwise this information is useless */
if(materialReferenceCount) if(materialReferenceCount)
d << Utility::formatString("(referenced by {} objects)", materialReferenceCount[info.material]); d << Utility::format("(referenced by {} objects)", materialReferenceCount[info.material]);
d << Debug::nospace << ":"; d << Debug::nospace << ":";
if(!info.name.empty()) d << info.name; if(!info.name.empty()) d << info.name;
@ -903,7 +903,7 @@ is specified as well, the IDs reference attributes of the first mesh.)")
/* Print reference count only if there actually are scenes and /* Print reference count only if there actually are scenes and
they were parsed, otherwise this information is useless */ they were parsed, otherwise this information is useless */
if(meshReferenceCount) if(meshReferenceCount)
d << Utility::formatString("(referenced by {} objects)", meshReferenceCount[info.mesh]); d << Utility::format("(referenced by {} objects)", meshReferenceCount[info.mesh]);
d << Debug::nospace << ":"; d << Debug::nospace << ":";
if(!info.name.empty()) d << info.name; if(!info.name.empty()) d << info.name;
@ -912,12 +912,12 @@ is specified as well, the IDs reference attributes of the first mesh.)")
d << " Level" << info.level << Debug::nospace << ":" d << " Level" << info.level << Debug::nospace << ":"
<< info.primitive << Debug::nospace << "," << info.vertexCount << info.primitive << Debug::nospace << "," << info.vertexCount
<< "vertices (" << Debug::nospace << "vertices (" << Debug::nospace
<< Utility::formatString("{:.1f}", info.vertexDataSize/1024.0f) << Utility::format("{:.1f}", info.vertexDataSize/1024.0f)
<< "kB)"; << "kB)";
if(info.indexType != MeshIndexType{}) { if(info.indexType != MeshIndexType{}) {
d << Debug::newline << " " << info.indexCount << "indices, offset" << info.indexOffset << "@" d << Debug::newline << " " << info.indexCount << "indices, offset" << info.indexOffset << "@"
<< info.indexType << Debug::nospace << ", stride" << info.indexStride << "(" << Debug::nospace << info.indexType << Debug::nospace << ", stride" << info.indexStride << "(" << Debug::nospace
<< Utility::formatString("{:.1f}", info.indexDataSize/1024.0f) << Utility::format("{:.1f}", info.indexDataSize/1024.0f)
<< "kB)"; << "kB)";
if(!info.indexBounds.empty()) if(!info.indexBounds.empty())
d << Debug::newline << " bounds:" << info.indexBounds; d << Debug::newline << " bounds:" << info.indexBounds;
@ -932,7 +932,7 @@ is specified as well, the IDs reference attributes of the first mesh.)")
} }
d << "@" << attribute.format; d << "@" << attribute.format;
if(attribute.arraySize) if(attribute.arraySize)
d << Debug::nospace << Utility::formatString("[{}]", attribute.arraySize); d << Debug::nospace << Utility::format("[{}]", attribute.arraySize);
d << Debug::nospace << ", stride" d << Debug::nospace << ", stride"
<< attribute.stride; << attribute.stride;
if(!attribute.bounds.empty()) if(!attribute.bounds.empty())
@ -947,7 +947,7 @@ is specified as well, the IDs reference attributes of the first mesh.)")
/* Print reference count only if there actually are materials and /* Print reference count only if there actually are materials and
they were parsed, otherwise this information is useless */ they were parsed, otherwise this information is useless */
if(textureReferenceCount) if(textureReferenceCount)
d << Utility::formatString("(referenced by {} material attributes)", textureReferenceCount[info.texture]); d << Utility::format("(referenced by {} material attributes)", textureReferenceCount[info.texture]);
d << Debug::nospace << ":"; d << Debug::nospace << ":";
if(!info.name.empty()) d << info.name; if(!info.name.empty()) d << info.name;
@ -971,11 +971,11 @@ is specified as well, the IDs reference attributes of the first mesh.)")
and they were parsed otherwise this information is and they were parsed otherwise this information is
useless */ useless */
if(info.size.z() && image3DReferenceCount) if(info.size.z() && image3DReferenceCount)
d << Utility::formatString("(referenced by {} textures)", image3DReferenceCount[info.image]); d << Utility::format("(referenced by {} textures)", image3DReferenceCount[info.image]);
else if(info.size.y() && image2DReferenceCount) else if(info.size.y() && image2DReferenceCount)
d << Utility::formatString("(referenced by {} textures)", image2DReferenceCount[info.image]); d << Utility::format("(referenced by {} textures)", image2DReferenceCount[info.image]);
else if(image1DReferenceCount) else if(image1DReferenceCount)
d << Utility::formatString("(referenced by {} textures)", image1DReferenceCount[info.image]); d << Utility::format("(referenced by {} textures)", image1DReferenceCount[info.image]);
d << Debug::nospace << ":"; d << Debug::nospace << ":";
if(!info.name.empty()) d << info.name; if(!info.name.empty()) d << info.name;

10
src/MagnumPlugins/AnyShaderConverter/Test/AnyConverterTest.cpp

@ -263,7 +263,7 @@ void AnyConverterTest::validateFile() {
/* Make it print a warning so we know it's doing something */ /* Make it print a warning so we know it's doing something */
CORRADE_COMPARE(converter->validateFile(Stage::Fragment, filename), CORRADE_COMPARE(converter->validateFile(Stage::Fragment, filename),
std::make_pair(true, Utility::formatString("WARNING: {}:10: 'reserved__identifier' : identifiers containing consecutive underscores (\"__\") are reserved", filename))); std::make_pair(true, Utility::format("WARNING: {}:10: 'reserved__identifier' : identifiers containing consecutive underscores (\"__\") are reserved", filename)));
} }
void AnyConverterTest::validateFilePluginLoadFailed() { void AnyConverterTest::validateFilePluginLoadFailed() {
@ -341,7 +341,7 @@ void AnyConverterTest::validateFilePropagateFlags() {
std::ostringstream out; std::ostringstream out;
Debug redirectDebug{&out}; Debug redirectDebug{&out};
CORRADE_COMPARE(converter->validateFile(Stage::Fragment, filename), CORRADE_COMPARE(converter->validateFile(Stage::Fragment, filename),
std::make_pair(false, Utility::formatString("WARNING: {}:10: 'reserved__identifier' : identifiers containing consecutive underscores (\"__\") are reserved", filename))); std::make_pair(false, Utility::format("WARNING: {}:10: 'reserved__identifier' : identifiers containing consecutive underscores (\"__\") are reserved", filename)));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"ShaderTools::AnyConverter::validateFile(): using GlslShaderConverter (provided by GlslangShaderConverter)\n"); "ShaderTools::AnyConverter::validateFile(): using GlslShaderConverter (provided by GlslangShaderConverter)\n");
} }
@ -416,7 +416,7 @@ void AnyConverterTest::validateFilePropagatePreprocess() {
}); });
CORRADE_COMPARE(converter->validateFile(Stage::Fragment, filename), CORRADE_COMPARE(converter->validateFile(Stage::Fragment, filename),
std::make_pair(true, Utility::formatString("WARNING: {}:10: 'different__but_also_wrong' : identifiers containing consecutive underscores (\"__\") are reserved", filename))); std::make_pair(true, Utility::format("WARNING: {}:10: 'different__but_also_wrong' : identifiers containing consecutive underscores (\"__\") are reserved", filename)));
} }
void AnyConverterTest::validateFilePropagateConfiguration() { void AnyConverterTest::validateFilePropagateConfiguration() {
@ -434,7 +434,7 @@ void AnyConverterTest::validateFilePropagateConfiguration() {
{ {
CORRADE_COMPARE(converter->validateFile(Stage::Fragment, filename), CORRADE_COMPARE(converter->validateFile(Stage::Fragment, filename),
std::make_pair(false, Utility::formatString("ERROR: {}:2: '#version' : must occur first in shader \nERROR: 1 compilation errors. No code generated.", filename))); std::make_pair(false, Utility::format("ERROR: {}:2: '#version' : must occur first in shader \nERROR: 1 compilation errors. No code generated.", filename)));
} { } {
converter->configuration().setValue("permissive", true); converter->configuration().setValue("permissive", true);
/* Lol stupid thing, apparently it has two differently worded messages /* Lol stupid thing, apparently it has two differently worded messages
@ -667,7 +667,7 @@ void AnyConverterTest::validateDataPropagateConfiguration() {
/* Lol stupid thing, apparently it has two differently worded messages /* Lol stupid thing, apparently it has two differently worded messages
for the same thing? Dumpster fire. */ for the same thing? Dumpster fire. */
CORRADE_COMPARE(converter->validateData(Stage::Fragment, Utility::Directory::read(filename)), CORRADE_COMPARE(converter->validateData(Stage::Fragment, Utility::Directory::read(filename)),
std::make_pair(true, Utility::formatString("WARNING: 0:0: '#version' : Illegal to have non-comment, non-whitespace tokens before #version"))); std::make_pair(true, Utility::format("WARNING: 0:0: '#version' : Illegal to have non-comment, non-whitespace tokens before #version")));
} }
} }

Loading…
Cancel
Save