From f184c6f005a263c8077b3abb5d50ad33a17ed133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 25 Nov 2012 01:21:19 +0100 Subject: [PATCH] Using real class for testing configuration value parsing. --- src/Math/RectangularMatrix.h | 6 +++--- src/Math/Test/Matrix3Test.cpp | 10 +++++++--- src/Math/Test/Matrix4Test.cpp | 10 +++++++--- src/Math/Test/MatrixTest.cpp | 10 +++++++--- src/Math/Test/Point2DTest.cpp | 10 +++++++--- src/Math/Test/Point3DTest.cpp | 10 +++++++--- src/Math/Test/RectangularMatrixTest.cpp | 10 +++++++--- src/Math/Test/Vector2Test.cpp | 10 +++++++--- src/Math/Test/Vector3Test.cpp | 10 +++++++--- src/Math/Test/Vector4Test.cpp | 10 +++++++--- src/Math/Test/VectorTest.cpp | 10 +++++++--- src/Test/ColorTest.cpp | 16 ++++++++++++---- 12 files changed, 85 insertions(+), 37 deletions(-) diff --git a/src/Math/RectangularMatrix.h b/src/Math/RectangularMatrix.h index 2dd862b2b..bc4822323 100644 --- a/src/Math/RectangularMatrix.h +++ b/src/Math/RectangularMatrix.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include "MathTypeTraits.h" @@ -508,7 +508,7 @@ namespace Corrade { namespace Utility { /** @configurationvalue{Magnum::Math::RectangularMatrix} */ template struct ConfigurationValue> { /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::RectangularMatrix& value, int flags = 0) { + static std::string toString(const Magnum::Math::RectangularMatrix& value, ConfigurationValueFlags flags) { std::string output; for(std::size_t row = 0; row != rows; ++row) { @@ -522,7 +522,7 @@ template struct ConfigurationValue< } /** @brief Reads elements separated with whitespace */ - static Magnum::Math::RectangularMatrix fromString(const std::string& stringValue, int flags = 0) { + static Magnum::Math::RectangularMatrix fromString(const std::string& stringValue, ConfigurationValueFlags flags) { Magnum::Math::RectangularMatrix result; std::istringstream in(stringValue); diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index 6df43a7ca..e25c020b0 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -15,7 +15,7 @@ #include "Matrix3Test.h" -#include +#include #include "Constants.h" #include "Matrix3.h" @@ -148,14 +148,18 @@ void Matrix3Test::debug() { } void Matrix3Test::configuration() { + Configuration c; + Matrix3 m( 5.0f, 8.0f, 4.0f, 4.0f, 7.0f, 3.125f, 4.0f, 5.0f, 9.55f ); string value("5 4 4 8 7 5 4 3.125 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(m), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), m); + + c.setValue("matrix", m); + CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), m); } }}} diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp index 89792fa4c..a1e8c4cbc 100644 --- a/src/Math/Test/Matrix4Test.cpp +++ b/src/Math/Test/Matrix4Test.cpp @@ -15,7 +15,7 @@ #include "Matrix4Test.h" -#include +#include #include "Constants.h" #include "Matrix4.h" @@ -195,6 +195,8 @@ void Matrix4Test::debug() { } void Matrix4Test::configuration() { + Configuration c; + Matrix4 m( 3.0f, 5.0f, 8.0f, 4.0f, 4.0f, 4.0f, 7.0f, 3.125f, @@ -202,8 +204,10 @@ void Matrix4Test::configuration() { 9.0f, 4.0f, 5.0f, 9.55f ); string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(m), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), m); + + c.setValue("matrix", m); + CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), m); } }}} diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index 6a015b328..cc902f199 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -15,7 +15,7 @@ #include "MatrixTest.h" -#include +#include #include "Matrix.h" @@ -186,6 +186,8 @@ void MatrixTest::debug() { } void MatrixTest::configuration() { + Configuration c; + Matrix4 m( 3.0f, 5.0f, 8.0f, 4.0f, 4.0f, 4.0f, 7.0f, 3.125f, @@ -193,8 +195,10 @@ void MatrixTest::configuration() { 9.0f, 4.0f, 5.0f, 9.55f ); string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(m), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), m); + + c.setValue("matrix", m); + CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), m); } }}} diff --git a/src/Math/Test/Point2DTest.cpp b/src/Math/Test/Point2DTest.cpp index 64d5540bc..63a93c345 100644 --- a/src/Math/Test/Point2DTest.cpp +++ b/src/Math/Test/Point2DTest.cpp @@ -15,7 +15,7 @@ #include "Point2DTest.h" -#include +#include #include "Point2D.h" @@ -47,10 +47,14 @@ void Point2DTest::debug() { } void Point2DTest::configuration() { + Configuration c; + Point2D vec(3.0f, 3.125f, 9.55f); string value("3 3.125 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(vec), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), vec); + + c.setValue("point", vec); + CORRADE_COMPARE(c.value("point"), value); + CORRADE_COMPARE(c.value("point"), vec); } }}} diff --git a/src/Math/Test/Point3DTest.cpp b/src/Math/Test/Point3DTest.cpp index 092f5a0f0..e4f24920f 100644 --- a/src/Math/Test/Point3DTest.cpp +++ b/src/Math/Test/Point3DTest.cpp @@ -15,7 +15,7 @@ #include "Point3DTest.h" -#include +#include #include "Point3D.h" @@ -47,10 +47,14 @@ void Point3DTest::debug() { } void Point3DTest::configuration() { + Configuration c; + Point3D vec(3.0f, 3.125f, 9.0f, 9.55f); string value("3 3.125 9 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(vec), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), vec); + + c.setValue("point", vec); + CORRADE_COMPARE(c.value("point"), value); + CORRADE_COMPARE(c.value("point"), vec); } }}} diff --git a/src/Math/Test/RectangularMatrixTest.cpp b/src/Math/Test/RectangularMatrixTest.cpp index e43c6e5e2..344e2fcd1 100644 --- a/src/Math/Test/RectangularMatrixTest.cpp +++ b/src/Math/Test/RectangularMatrixTest.cpp @@ -15,7 +15,7 @@ #include "RectangularMatrixTest.h" -#include +#include #include "RectangularMatrix.h" @@ -242,8 +242,12 @@ void RectangularMatrixTest::configuration() { 7.0f, -1.0f, 8.0f, 9.55f ); string value("3 4 7 5 4 -1 8 7 8 4 3.125 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(m), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), m); + + Configuration c; + c.setValue("matrix", m); + + CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), m); } }}} diff --git a/src/Math/Test/Vector2Test.cpp b/src/Math/Test/Vector2Test.cpp index a60a253d7..297e0e67a 100644 --- a/src/Math/Test/Vector2Test.cpp +++ b/src/Math/Test/Vector2Test.cpp @@ -15,7 +15,7 @@ #include "Vector2Test.h" -#include +#include #include "Vector2.h" @@ -57,10 +57,14 @@ void Vector2Test::debug() { } void Vector2Test::configuration() { + Configuration c; + Vector2 vec(3.125f, 9.0f); string value("3.125 9"); - CORRADE_COMPARE(ConfigurationValue::toString(vec), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), vec); + + c.setValue("vector", vec); + CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), vec); } }}} diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp index 6ffdc267d..7ef022ff7 100644 --- a/src/Math/Test/Vector3Test.cpp +++ b/src/Math/Test/Vector3Test.cpp @@ -15,7 +15,7 @@ #include "Vector3Test.h" -#include +#include #include "Vector3.h" @@ -75,10 +75,14 @@ void Vector3Test::debug() { } void Vector3Test::configuration() { + Configuration c; + Vector3 vec(3.0f, 3.125f, 9.55f); string value("3 3.125 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(vec), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), vec); + + c.setValue("vector", vec); + CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), vec); } }}} diff --git a/src/Math/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp index c12838a20..33d52deb0 100644 --- a/src/Math/Test/Vector4Test.cpp +++ b/src/Math/Test/Vector4Test.cpp @@ -15,7 +15,7 @@ #include "Vector4Test.h" -#include +#include #include "Vector4.h" @@ -59,10 +59,14 @@ void Vector4Test::debug() { } void Vector4Test::configuration() { + Configuration c; + Vector4 vec(3.0f, 3.125f, 9.0f, 9.55f); string value("3 3.125 9 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(vec), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), vec); + + c.setValue("vector", vec); + CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), vec); } }}} diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index 5bd824c16..e89907bf4 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -15,7 +15,7 @@ #include "VectorTest.h" -#include +#include #include "Constants.h" #include "Vector.h" @@ -116,10 +116,14 @@ void VectorTest::debug() { } void VectorTest::configuration() { + Configuration c; + Vector4 vec(3.0f, 3.125f, 9.0f, 9.55f); string value("3 3.125 9 9.55"); - CORRADE_COMPARE(ConfigurationValue::toString(vec), value); - CORRADE_COMPARE(ConfigurationValue::fromString(value), vec); + + c.setValue("vector", vec); + CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), vec); } }}} diff --git a/src/Test/ColorTest.cpp b/src/Test/ColorTest.cpp index 7625131af..176270f2b 100644 --- a/src/Test/ColorTest.cpp +++ b/src/Test/ColorTest.cpp @@ -15,6 +15,8 @@ #include "ColorTest.h" +#include + #include "Color.h" using namespace std; @@ -135,15 +137,21 @@ void ColorTest::debug() { } void ColorTest::configuration() { + Configuration c; + Color3f color3(0.5f, 0.75f, 1.0f); string value3("0.5 0.75 1"); - CORRADE_COMPARE(ConfigurationValue::toString(color3), value3); - CORRADE_COMPARE(ConfigurationValue::fromString(value3), color3); + + c.setValue("color3", color3); + CORRADE_COMPARE(c.value("color3"), value3); + CORRADE_COMPARE(c.value("color3"), color3); Color4f color4(0.5f, 0.75f, 0.0f, 1.0f); string value4("0.5 0.75 0 1"); - CORRADE_COMPARE(ConfigurationValue::toString(color4), value4); - CORRADE_COMPARE(ConfigurationValue::fromString(value4), color4); + + c.setValue("color4", color4); + CORRADE_COMPARE(c.value("color4"), value4); + CORRADE_COMPARE(c.value("color4"), color4); } }}