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 */
static std::pair<TweakableState, Magnum::Math::Rad<Magnum::Double>> parse(Containers::ArrayView<const char> value);
};
#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} */
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}
@ -1347,6 +1348,7 @@ template<> struct MAGNUM_EXPORT TweakableParser<Magnum::Math::Color4<Magnum::Flo
/** @brief Parse the 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 {
/**
@ -178,5 +179,6 @@ template<> struct MAGNUM_EXPORT TweakableParser<Magnum::Math::Half> {
};
}}
#endif
#endif

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

@ -29,7 +29,9 @@
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/Configuration.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>
#endif
#include "Magnum/Math/Angle.h"
@ -51,8 +53,10 @@ struct AngleTest: Corrade::TestSuite::Tester {
void debugRad();
void configurationDeg();
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 tweakableError();
#endif
};
typedef Math::Deg<Float> Deg;
@ -62,6 +66,7 @@ typedef Math::Rad<Double> Radd;
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 {
constexpr struct {
@ -111,6 +116,7 @@ template<> struct TweakableTraits<Radd> {
};
}
#endif
AngleTest::AngleTest() {
addTests({&AngleTest::construct,
@ -127,6 +133,7 @@ AngleTest::AngleTest() {
&AngleTest::configurationDeg,
&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>({
&AngleTest::tweakable<Deg>,
&AngleTest::tweakable<Degd>,
@ -140,6 +147,7 @@ AngleTest::AngleTest() {
&AngleTest::tweakableError<Rad>,
&AngleTest::tweakableError<Radd>},
Corrade::Containers::arraySize(TweakableErrorData));
#endif
}
void AngleTest::construct() {
@ -304,6 +312,7 @@ void AngleTest::configurationRad() {
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() {
auto&& data = TweakableData[testCaseInstanceId()];
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(state, data.state);
}
#endif
}}}

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

@ -28,7 +28,9 @@
#include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/Configuration.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>
#endif
#include "Magnum/Math/Color.h"
@ -108,6 +110,7 @@ struct ColorTest: Corrade::TestSuite::Tester {
void debugUb();
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 tweakableSrgb();
void tweakableRgbf();
@ -125,6 +128,7 @@ struct ColorTest: Corrade::TestSuite::Tester {
void tweakableErrorSrgbf();
void tweakableErrorRgbaf();
void tweakableErrorSrgbaf();
#endif
};
typedef Math::Vector3<Float> Vector3;
@ -139,6 +143,7 @@ typedef Math::Deg<Float> Deg;
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 {
const struct {
@ -174,6 +179,7 @@ constexpr struct {
};
}
#endif
ColorTest::ColorTest() {
addTests({&ColorTest::construct,
@ -216,6 +222,7 @@ ColorTest::ColorTest() {
&ColorTest::debugUb,
&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,
&ColorTest::tweakableSrgb,
&ColorTest::tweakableRgba,
@ -235,6 +242,7 @@ ColorTest::ColorTest() {
&ColorTest::tweakableErrorRgbaf,
&ColorTest::tweakableErrorSrgbaf},
Corrade::Containers::arraySize(TweakableErrorData));
#endif
}
void ColorTest::construct() {
@ -897,6 +905,7 @@ void ColorTest::configuration() {
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() {
auto&& data = TweakableData[testCaseInstanceId()];
setTestCaseDescription(data.name);
@ -1088,6 +1097,7 @@ void ColorTest::tweakableErrorSrgbaf() {
CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgbaf", "s"));
CORRADE_COMPARE(state, data.state);
}
#endif
}}}

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

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

Loading…
Cancel
Save