Browse Source

Math: I should have tested this.

Did I ever check the CIs?
pull/297/head
Vladimír Vondruš 8 years ago
parent
commit
8be57d1a21
  1. 2
      src/Magnum/Math/Angle.h
  2. 2
      src/Magnum/Math/Color.h
  3. 2
      src/Magnum/Math/Half.h
  4. 10
      src/Magnum/Math/Test/AngleTest.cpp
  5. 10
      src/Magnum/Math/Test/ColorTest.cpp
  6. 11
      src/Magnum/Math/Test/HalfTest.cpp

2
src/Magnum/Math/Angle.h

@ -334,8 +334,8 @@ template<> struct MAGNUM_EXPORT TweakableParser<Magnum::Math::Rad<Magnum::Double
/** @brief Parse the value */ /** @brief Parse the value */
static std::pair<TweakableState, Magnum::Math::Rad<Magnum::Double>> parse(Containers::ArrayView<const char> value); static std::pair<TweakableState, Magnum::Math::Rad<Magnum::Double>> parse(Containers::ArrayView<const char> value);
}; };
#endif
}} }}
#endif
#endif #endif

2
src/Magnum/Math/Color.h

@ -1284,6 +1284,7 @@ template<class T> struct ConfigurationValue<Magnum::Math::Color3<T>>: Configurat
/** @configurationvalue{Magnum::Color4} */ /** @configurationvalue{Magnum::Color4} */
template<class T> struct ConfigurationValue<Magnum::Math::Color4<T>>: ConfigurationValue<Magnum::Math::Vector<4, T>> {}; template<class T> struct ConfigurationValue<Magnum::Math::Color4<T>>: ConfigurationValue<Magnum::Math::Vector<4, T>> {};
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
/** /**
@tweakableliteral{Magnum::Math::Color3} @tweakableliteral{Magnum::Math::Color3}
@ -1347,6 +1348,7 @@ template<> struct MAGNUM_EXPORT TweakableParser<Magnum::Math::Color4<Magnum::Flo
/** @brief Parse the value */ /** @brief Parse the value */
static std::pair<TweakableState, Magnum::Math::Color4<Magnum::Float>> parse(Containers::ArrayView<const char> value); static std::pair<TweakableState, Magnum::Math::Color4<Magnum::Float>> parse(Containers::ArrayView<const char> value);
}; };
#endif
}} }}

2
src/Magnum/Math/Half.h

@ -163,6 +163,7 @@ MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& debug
}} }}
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
namespace Corrade { namespace Utility { namespace Corrade { namespace Utility {
/** /**
@ -178,5 +179,6 @@ template<> struct MAGNUM_EXPORT TweakableParser<Magnum::Math::Half> {
}; };
}} }}
#endif
#endif #endif

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

@ -29,7 +29,9 @@
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/Configuration.h> #include <Corrade/Utility/Configuration.h>
#include <Corrade/Utility/Format.h> #include <Corrade/Utility/Format.h>
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Corrade/Utility/TweakableParser.h> #include <Corrade/Utility/TweakableParser.h>
#endif
#include "Magnum/Math/Angle.h" #include "Magnum/Math/Angle.h"
@ -51,8 +53,10 @@ struct AngleTest: Corrade::TestSuite::Tester {
void debugRad(); void debugRad();
void configurationDeg(); void configurationDeg();
void configurationRad(); void configurationRad();
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
template<class T> void tweakable(); template<class T> void tweakable();
template<class T> void tweakableError(); template<class T> void tweakableError();
#endif
}; };
typedef Math::Deg<Float> Deg; typedef Math::Deg<Float> Deg;
@ -62,6 +66,7 @@ typedef Math::Rad<Double> Radd;
using namespace Literals; using namespace Literals;
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
namespace { namespace {
constexpr struct { constexpr struct {
@ -111,6 +116,7 @@ template<> struct TweakableTraits<Radd> {
}; };
} }
#endif
AngleTest::AngleTest() { AngleTest::AngleTest() {
addTests({&AngleTest::construct, addTests({&AngleTest::construct,
@ -127,6 +133,7 @@ AngleTest::AngleTest() {
&AngleTest::configurationDeg, &AngleTest::configurationDeg,
&AngleTest::configurationRad}); &AngleTest::configurationRad});
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
addInstancedTests<AngleTest>({ addInstancedTests<AngleTest>({
&AngleTest::tweakable<Deg>, &AngleTest::tweakable<Deg>,
&AngleTest::tweakable<Degd>, &AngleTest::tweakable<Degd>,
@ -140,6 +147,7 @@ AngleTest::AngleTest() {
&AngleTest::tweakableError<Rad>, &AngleTest::tweakableError<Rad>,
&AngleTest::tweakableError<Radd>}, &AngleTest::tweakableError<Radd>},
Corrade::Containers::arraySize(TweakableErrorData)); Corrade::Containers::arraySize(TweakableErrorData));
#endif
} }
void AngleTest::construct() { void AngleTest::construct() {
@ -304,6 +312,7 @@ void AngleTest::configurationRad() {
CORRADE_COMPARE(c.value<Rad>("angle"), angle); CORRADE_COMPARE(c.value<Rad>("angle"), angle);
} }
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
template<class T> void AngleTest::tweakable() { template<class T> void AngleTest::tweakable() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseName(Corrade::Utility::formatString("tweakable<{}>", TweakableTraits<T>::name())); setTestCaseName(Corrade::Utility::formatString("tweakable<{}>", TweakableTraits<T>::name()));
@ -329,6 +338,7 @@ template<class T> void AngleTest::tweakableError() {
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);
} }
#endif
}}} }}}

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

@ -28,7 +28,9 @@
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/Configuration.h> #include <Corrade/Utility/Configuration.h>
#include <Corrade/Utility/Format.h> #include <Corrade/Utility/Format.h>
#if defined(DOXYGEN_GENERATING_OUTPUT) || 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
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
@ -108,6 +110,7 @@ struct ColorTest: Corrade::TestSuite::Tester {
void debugUb(); void debugUb();
void configuration(); void configuration();
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
void tweakableRgb(); void tweakableRgb();
void tweakableSrgb(); void tweakableSrgb();
void tweakableRgbf(); void tweakableRgbf();
@ -125,6 +128,7 @@ struct ColorTest: Corrade::TestSuite::Tester {
void tweakableErrorSrgbf(); void tweakableErrorSrgbf();
void tweakableErrorRgbaf(); void tweakableErrorRgbaf();
void tweakableErrorSrgbaf(); void tweakableErrorSrgbaf();
#endif
}; };
typedef Math::Vector3<Float> Vector3; typedef Math::Vector3<Float> Vector3;
@ -139,6 +143,7 @@ typedef Math::Deg<Float> Deg;
using namespace Literals; using namespace Literals;
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
namespace { namespace {
const struct { const struct {
@ -174,6 +179,7 @@ constexpr struct {
}; };
} }
#endif
ColorTest::ColorTest() { ColorTest::ColorTest() {
addTests({&ColorTest::construct, addTests({&ColorTest::construct,
@ -216,6 +222,7 @@ ColorTest::ColorTest() {
&ColorTest::debugUb, &ColorTest::debugUb,
&ColorTest::configuration}); &ColorTest::configuration});
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
addInstancedTests({&ColorTest::tweakableRgb, addInstancedTests({&ColorTest::tweakableRgb,
&ColorTest::tweakableSrgb, &ColorTest::tweakableSrgb,
&ColorTest::tweakableRgba, &ColorTest::tweakableRgba,
@ -235,6 +242,7 @@ ColorTest::ColorTest() {
&ColorTest::tweakableErrorRgbaf, &ColorTest::tweakableErrorRgbaf,
&ColorTest::tweakableErrorSrgbaf}, &ColorTest::tweakableErrorSrgbaf},
Corrade::Containers::arraySize(TweakableErrorData)); Corrade::Containers::arraySize(TweakableErrorData));
#endif
} }
void ColorTest::construct() { void ColorTest::construct() {
@ -897,6 +905,7 @@ void ColorTest::configuration() {
CORRADE_COMPARE(c.value<Color4>("color4"), color4); CORRADE_COMPARE(c.value<Color4>("color4"), color4);
} }
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
void ColorTest::tweakableRgb() { void ColorTest::tweakableRgb() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
@ -1088,6 +1097,7 @@ void ColorTest::tweakableErrorSrgbaf() {
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);
} }
#endif
}}} }}}

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

@ -27,7 +27,9 @@
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#if defined(DOXYGEN_GENERATING_OUTPUT) || 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
#include "Magnum/Math/Half.h" #include "Magnum/Math/Half.h"
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
@ -62,8 +64,10 @@ struct HalfTest: Corrade::TestSuite::Tester {
void literal(); void literal();
void debug(); void debug();
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
void tweakable(); void tweakable();
void tweakableError(); void tweakableError();
#endif
private: private:
/* Naive / ground-truth packing helpers */ /* Naive / ground-truth packing helpers */
@ -86,6 +90,7 @@ typedef Math::Constants<Float> Constants;
using namespace Literals; using namespace Literals;
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
namespace { namespace {
const struct { const struct {
@ -119,6 +124,7 @@ constexpr struct {
}; };
} }
#endif
HalfTest::HalfTest() { HalfTest::HalfTest() {
addTests({&HalfTest::unpack, addTests({&HalfTest::unpack,
@ -150,11 +156,13 @@ HalfTest::HalfTest() {
&HalfTest::literal, &HalfTest::literal,
&HalfTest::debug}); &HalfTest::debug});
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
addInstancedTests({&HalfTest::tweakable}, addInstancedTests({&HalfTest::tweakable},
Corrade::Containers::arraySize(TweakableData)); Corrade::Containers::arraySize(TweakableData));
addInstancedTests({&HalfTest::tweakableError}, addInstancedTests({&HalfTest::tweakableError},
Corrade::Containers::arraySize(TweakableErrorData)); Corrade::Containers::arraySize(TweakableErrorData));
#endif
/* Calculate tables for table-based benchmark */ /* Calculate tables for table-based benchmark */
_mantissaTable[0] = 0; _mantissaTable[0] = 0;
@ -661,6 +669,7 @@ void HalfTest::debug() {
#endif #endif
} }
#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN)
void HalfTest::tweakable() { void HalfTest::tweakable() {
auto&& data = TweakableData[testCaseInstanceId()]; auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
@ -682,8 +691,8 @@ void HalfTest::tweakableError() {
CORRADE_COMPARE(out.str(), data.error); CORRADE_COMPARE(out.str(), data.error);
CORRADE_COMPARE(state, data.state); CORRADE_COMPARE(state, data.state);
} }
#endif
}}} }}}
CORRADE_TEST_MAIN(Magnum::Math::Test::HalfTest) CORRADE_TEST_MAIN(Magnum::Math::Test::HalfTest)

Loading…
Cancel
Save