- Restructure Rotation classes to make the base class store the rotation to remove an additional virtual function

- Add Matrix verifiers
- Add documentation to StaticRotation and SpiceRotation
This commit is contained in:
Alexander Bock
2016-10-26 16:47:42 +02:00
parent b95c80bb40
commit db4524d2ac
12 changed files with 650 additions and 69 deletions

View File

@@ -235,6 +235,100 @@ struct Vector4Verifier : public TemplateVerifier<glm::tvec4<T>>, public VectorVe
std::string type() const override;
};
//----------------------------------------------------------------------------------------
// Matrix verifiers
//----------------------------------------------------------------------------------------
/**
* This struct is the base class for all Verifier%s that check for \c glm matrix types.
* The template parameter for the subclasses is the containing type, not the full matrix
* type. For example to check for <code>glm::dmat4x3</code>, one would create a
* <code>Matrix4x3Verifier<double></code>.
*/
struct MatrixVerifier {};
/**
* This Verifier checks whether the value is of type <code>glm::mat2x2<T></code>
*/
template <typename T>
struct Matrix2x2Verifier :
public TemplateVerifier<glm::tmat2x2<T>>, public MatrixVerifier
{
std::string type() const override;
};
/**
* This Verifier checks whether the value is of type <code>glm::mat2x3<T></code>
*/
template <typename T>
struct Matrix2x3Verifier :
public TemplateVerifier<glm::tmat2x3<T>>, public MatrixVerifier {
std::string type() const override;
};
/**
* This Verifier checks whether the value is of type <code>glm::mat2x4<T></code>
*/
template <typename T>
struct Matrix2x4Verifier :
public TemplateVerifier<glm::tmat2x4<T>>, public MatrixVerifier {
std::string type() const override;
};
/**
* This Verifier checks whether the value is of type <code>glm::mat3x2<T></code>
*/
template <typename T>
struct Matrix3x2Verifier :
public TemplateVerifier<glm::tmat3x2<T>>, public MatrixVerifier {
std::string type() const override;
};
/**
* This Verifier checks whether the value is of type <code>glm::mat3x3<T></code>
*/
template <typename T>
struct Matrix3x3Verifier :
public TemplateVerifier<glm::tmat3x3<T>>, public MatrixVerifier {
std::string type() const override;
};
/**
* This Verifier checks whether the value is of type <code>glm::mat3x4<T></code>
*/
template <typename T>
struct Matrix3x4Verifier :
public TemplateVerifier<glm::tmat3x4<T>>, public MatrixVerifier {
std::string type() const override;
};
/**
* This Verifier checks whether the value is of type <code>glm::mat4x2<T></code>
*/
template <typename T>
struct Matrix4x2Verifier :
public TemplateVerifier<glm::tmat4x2<T>>, public MatrixVerifier {
std::string type() const override;
};
/**
* This Verifier checks whether the value is of type <code>glm::mat4x3<T></code>
*/
template <typename T>
struct Matrix4x3Verifier :
public TemplateVerifier<glm::tmat4x3<T>>, public MatrixVerifier {
std::string type() const override;
};
/**
* This Verifier checks whether the value is of type <code>glm::mat4x4<T></code>
*/
template <typename T>
struct Matrix4x4Verifier :
public TemplateVerifier<glm::tmat4x4<T>>, public MatrixVerifier {
std::string type() const override;
};
//----------------------------------------------------------------------------------------
// Operator verifiers
//----------------------------------------------------------------------------------------
@@ -840,6 +934,28 @@ using IntVector4Verifier = Vector4Verifier<int>;
/// A short-hand definition for a Verifier checking for <code>glm::dvec4</code>
using DoubleVector4Verifier = Vector4Verifier<double>;
/// A short-hand definition for a Verifier checking for <code>glm::dmat2x2</code>
using DoubleMatrix2x2Verifier = Matrix2x2Verifier<double>;
using DoubleMatrix2Verifier = DoubleMatrix2x2Verifier;
/// A short-hand definition for a Verifier checking for <code>glm::dmat2x3</code>
using DoubleMatrix2x3Verifier = Matrix2x3Verifier<double>;
/// A short-hand definition for a Verifier checking for <code>glm::dmat2x4</code>
using DoubleMatrix2x4Verifier = Matrix2x4Verifier<double>;
/// A short-hand definition for a Verifier checking for <code>glm::dmat3x2</code>
using DoubleMatrix3x2Verifier = Matrix3x2Verifier<double>;
/// A short-hand definition for a Verifier checking for <code>glm::dmat3x3</code>
using DoubleMatrix3x3Verifier = Matrix3x3Verifier<double>;
using DoubleMatrix3Verifier = DoubleMatrix3x3Verifier;
/// A short-hand definition for a Verifier checking for <code>glm::dmat3x4</code>
using DoubleMatrix3x4Verifier = Matrix3x4Verifier<double>;
/// A short-hand definition for a Verifier checking for <code>glm::dmat4x2</code>
using DoubleMatrix4x2Verifier = Matrix4x2Verifier<double>;
/// A short-hand definition for a Verifier checking for <code>glm::dmat4x3</code>
using DoubleMatrix4x3Verifier = Matrix4x3Verifier<double>;
/// A short-hand definition for a Verifier checking for <code>glm::dmat4x4</code>
using DoubleMatrix4x4Verifier = Matrix4x4Verifier<double>;
using DoubleMatrix4Verifier = DoubleMatrix4x4Verifier;
/// A short-hand definition for a LessVerifier with a type check for \c int
using IntLessVerifier = LessVerifier<IntVerifier>;
/// A short-hand definition for a LessVerifier with a type check for \c double
@@ -936,6 +1052,16 @@ extern template struct Vector4Verifier<bool>;
extern template struct Vector4Verifier<int>;
extern template struct Vector4Verifier<double>;
extern template struct Matrix2x2Verifier<double>;
extern template struct Matrix2x3Verifier<double>;
extern template struct Matrix2x4Verifier<double>;
extern template struct Matrix3x2Verifier<double>;
extern template struct Matrix3x3Verifier<double>;
extern template struct Matrix3x4Verifier<double>;
extern template struct Matrix4x2Verifier<double>;
extern template struct Matrix4x3Verifier<double>;
extern template struct Matrix4x4Verifier<double>;
extern template struct LessVerifier<IntVerifier>;
extern template struct LessVerifier<DoubleVerifier>;
extern template struct LessEqualVerifier<IntVerifier>;

View File

@@ -74,6 +74,69 @@ std::string Vector4Verifier<T>::type() const {
return "Vector4<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix2x2Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix2x2<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix2x3Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix2x3<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix2x4Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix2x4<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix3x2Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix3x2<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix3x3Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix3x3<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix3x4Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix3x4<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix4x2Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix4x2<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix4x3Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix4x3<"s + typeid(T).name() + ">";
}
template <typename T>
std::string Matrix4x4Verifier<T>::type() const {
using namespace std::string_literals;
return "Matrix4x4<"s + typeid(T).name() + ">";
}
template <typename T, typename Operator>
OperatorVerifier<T, Operator>::OperatorVerifier(typename T::Type value)
: value(std::move(value))

View File

@@ -39,13 +39,15 @@ public:
Rotation(const ghoul::Dictionary& dictionary);
virtual ~Rotation();
virtual bool initialize();
virtual const glm::dmat3& matrix() const = 0;
const glm::dmat3& matrix() const;
virtual void update(const UpdateData& data);
static openspace::Documentation Documentation();
protected:
Rotation();
glm::dmat3 _matrix;
};
} // namespace openspace

View File

@@ -136,6 +136,7 @@ void BaseModule::internalInitialize() {
std::vector<Documentation> BaseModule::documentations() const {
return {
SpiceRotation::Documentation(),
StaticScale::Documentation(),
StaticTranslation::Documentation(),
SpiceTranslation::Documentation()

View File

@@ -24,6 +24,8 @@
#include <modules/base/rotation/spicerotation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/time.h>
@@ -38,56 +40,90 @@ namespace {
namespace openspace {
SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
: _sourceFrame("")
, _destinationFrame("")
, _rotationMatrix(1.0)
, _kernelsLoadedSuccessfully(true)
{
const bool hasSourceFrame = dictionary.getValue(KeySourceFrame, _sourceFrame);
if (!hasSourceFrame)
LERROR("SpiceRotation does not contain the key '" << KeySourceFrame << "'");
const bool hasDestinationFrame = dictionary.getValue(KeyDestinationFrame, _destinationFrame);
if (!hasDestinationFrame)
LERROR("SpiceRotation does not contain the key '" << KeyDestinationFrame << "'");
ghoul::Dictionary kernels;
dictionary.getValue(KeyKernels, kernels);
for (size_t i = 1; i <= kernels.size(); ++i) {
std::string kernel;
bool success = kernels.getValue(std::to_string(i), kernel);
if (!success)
LERROR("'" << KeyKernels << "' has to be an array-style table");
try {
SpiceManager::ref().loadKernel(kernel);
_kernelsLoadedSuccessfully = true;
Documentation SpiceRotation::Documentation() {
using namespace openspace::documentation;
return {
"Spice Rotation",
"base_transform_rotation_spice",
{
{
"Type",
new StringEqualVerifier("SpiceRotation"),
"",
Optional::No
},
{
KeySourceFrame,
new StringAnnotationVerifier("A valid SPICE NAIF name or integer"),
"The source frame that is used as the basis for the coordinate "
"transformation. This has to be a valid SPICE name.",
Optional::No
},
{
KeyDestinationFrame,
new StringAnnotationVerifier("A valid SPICE NAIF name or integer"),
"The destination frame that is used for the coordinate transformation. "
"This has to be a valid SPICE name.",
Optional::No
},
{
KeyKernels,
new OrVerifier(
new TableVerifier({
{ "*", new StringVerifier }
}),
new StringVerifier
),
"A single kernel or list of kernels that this SpiceTranslation depends "
"on. All provided kernels will be loaded before any other operation is "
"performed.",
Optional::Yes
}
}
catch (const SpiceManager::SpiceException& e) {
LERROR("Could not load SPICE kernel: " << e.what());
_kernelsLoadedSuccessfully = false;
};
}
SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
: _sourceFrame("source", "Source", "")
, _destinationFrame("destination", "Destination", "")
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"SpiceRotation"
);
_sourceFrame = dictionary.value<std::string>(KeySourceFrame);
_destinationFrame = dictionary.value<std::string>(KeyDestinationFrame);
if (dictionary.hasKeyAndValue<std::string>(KeyKernels)) {
SpiceManager::ref().loadKernel(dictionary.value<std::string>(KeyKernels));
}
else if (dictionary.hasKeyAndValue<ghoul::Dictionary>(KeyKernels)) {
ghoul::Dictionary kernels = dictionary.value<ghoul::Dictionary>(KeyKernels);
for (size_t i = 1; i <= kernels.size(); ++i) {
if (!kernels.hasKeyAndValue<std::string>(std::to_string(i))) {
throw ghoul::RuntimeError("Kernels has to be an array-style table");
}
std::string kernel = kernels.value<std::string>(std::to_string(i));
SpiceManager::ref().loadKernel(kernel);
}
}
}
const glm::dmat3& SpiceRotation::matrix() const {
return _rotationMatrix;
}
void SpiceRotation::update(const UpdateData& data) {
if (!_kernelsLoadedSuccessfully)
return;
try {
_rotationMatrix = SpiceManager::ref().positionTransformMatrix(
_matrix = SpiceManager::ref().positionTransformMatrix(
_sourceFrame,
_destinationFrame,
data.time);
data.time
);
}
catch (const ghoul::RuntimeError&) {
// In case of missing coverage
_rotationMatrix = glm::dmat3(1);
_matrix = glm::dmat3(1);
}
}
} // namespace openspace
} // namespace openspace

View File

@@ -26,20 +26,22 @@
#define __SPICEROTATION_H__
#include <openspace/scene/rotation.h>
#include <openspace/documentation/documentation.h>
#include <openspace/properties/stringproperty.h>
namespace openspace {
class SpiceRotation : public Rotation {
public:
SpiceRotation(const ghoul::Dictionary& dictionary);
virtual const glm::dmat3& matrix() const;
const glm::dmat3& matrix() const;
void update(const UpdateData& data) override;
static openspace::Documentation Documentation();
private:
std::string _sourceFrame;
std::string _destinationFrame;
glm::dmat3 _rotationMatrix;
bool _kernelsLoadedSuccessfully;
properties::StringProperty _sourceFrame;
properties::StringProperty _destinationFrame;
};
} // namespace openspace

View File

@@ -24,29 +24,66 @@
#include <modules/base/rotation/staticrotation.h>
#include <openspace/documentation/verifier.h>
namespace {
const std::string KeyEulerAngles = "EulerAngles";
const std::string KeyRotation = "Rotation";
}
namespace openspace {
Documentation StaticRotation::Documentation() {
using namespace openspace::documentation;
return {
"Static Rotation",
"base_transform_rotation_static",
{
{
"Type",
new StringEqualVerifier("StaticRotation"),
"",
Optional::No
},
{
KeyRotation,
new OrVerifier(
new DoubleVector3Verifier(),
new DoubleMatrix3Verifier()
),
"Stores the static rotation as either a vector containing Euler angles "
"or by specifiying the 3x3 rotation matrix directly",
Optional::No
}
},
Exhaustive::Yes
};
}
StaticRotation::StaticRotation()
: _rotationMatrix("rotation", "Rotation", glm::dmat3(1.0))
{}
StaticRotation::StaticRotation(const ghoul::Dictionary& dictionary)
: _rotationMatrix(1.0)
: StaticRotation()
{
const bool hasEulerAngles = dictionary.hasKeyAndValue<glm::dvec3>(KeyEulerAngles);
if (hasEulerAngles) {
glm::dvec3 tmp;
dictionary.getValue(KeyEulerAngles, tmp);
_rotationMatrix = glm::mat3_cast(glm::dquat(tmp));
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"StaticRotation"
);
if (dictionary.hasKeyAndValue<glm::dvec3>(KeyRotation)) {
_rotationMatrix = glm::mat3_cast(
glm::dquat(dictionary.value<glm::dvec3>(KeyRotation))
);
}
else {
// Must be glm::dmat3 due to specification restriction
_rotationMatrix = dictionary.value<glm::dmat3>(KeyRotation);
}
_rotationMatrix.onChange([this]() { _matrix = _rotationMatrix; });
}
StaticRotation::~StaticRotation() {}
const glm::dmat3& StaticRotation::matrix() const {
return _rotationMatrix;
}
void StaticRotation::update(const UpdateData&) {}
} // namespace openspace
} // namespace openspace

View File

@@ -27,17 +27,20 @@
#include <openspace/scene/rotation.h>
#include <openspace/documentation/documentation.h>
#include <openspace/properties/matrixproperty.h>
namespace openspace {
class StaticRotation: public Rotation {
class StaticRotation : public Rotation {
public:
StaticRotation(const ghoul::Dictionary& dictionary
= ghoul::Dictionary());
virtual ~StaticRotation();
virtual const glm::dmat3& matrix() const;
virtual void update(const UpdateData& data) override;
StaticRotation();
StaticRotation(const ghoul::Dictionary& dictionary);
static openspace::Documentation Documentation();
private:
glm::dmat3 _rotationMatrix;
properties::DMat3Property _rotationMatrix;
};
} // namespace openspace

View File

@@ -35,11 +35,11 @@
#include <openspace/mission/missionmanager.h>
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/screenspacerenderable.h>
#include <openspace/scene/translation.h>
#include <openspace/scene/rotation.h>
#include <openspace/scene/scene.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/scale.h>
#include <openspace/scene/translation.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/scripting/scriptscheduler.h>
#include <openspace/util/spicemanager.h>
@@ -54,7 +54,6 @@ namespace openspace {
void registerCoreClasses(documentation::DocumentationEngine& engine) {
engine.addDocumentation(ConfigurationManager::Documentation());
engine.addDocumentation(Translation::Documentation());
engine.addDocumentation(Mission::Documentation());
engine.addDocumentation(Renderable::Documentation());
engine.addDocumentation(Rotation::Documentation());
@@ -63,6 +62,7 @@ void registerCoreClasses(documentation::DocumentationEngine& engine) {
engine.addDocumentation(SceneGraphNode::Documentation());
engine.addDocumentation(ScreenSpaceRenderable::Documentation());
engine.addDocumentation(TimeRange::Documentation());
engine.addDocumentation(Translation::Documentation());
}
void registerCoreClasses(scripting::ScriptEngine& engine) {

View File

@@ -41,6 +41,16 @@ template struct Vector4Verifier<bool>;
template struct Vector4Verifier<int>;
template struct Vector4Verifier<double>;
template struct Matrix2x2Verifier<double>;
template struct Matrix2x3Verifier<double>;
template struct Matrix2x4Verifier<double>;
template struct Matrix3x2Verifier<double>;
template struct Matrix3x3Verifier<double>;
template struct Matrix3x4Verifier<double>;
template struct Matrix4x2Verifier<double>;
template struct Matrix4x3Verifier<double>;
template struct Matrix4x4Verifier<double>;
template struct LessVerifier<IntVerifier>;
template struct LessVerifier<DoubleVerifier>;
template struct LessEqualVerifier<IntVerifier>;

View File

@@ -79,6 +79,10 @@ bool Rotation::initialize() {
return true;
}
const glm::dmat3& Rotation::matrix() const {
return _matrix;
}
void Rotation::update(const UpdateData& data) {}
} // namespace openspace

View File

@@ -2308,6 +2308,303 @@ TEST_F(DocumentationTest, DoubleVector4Verifier) {
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix2x2Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix2x2Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat2x2(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary { { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix2x3Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix2x3Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat2x3(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary{ { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix2x4Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix2x4Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat2x4(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary{ { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix3x2Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix3x2Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat3x2(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary{ { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix3x3Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix3x3Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat3x3(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary{ { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix3x4Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix3x4Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat3x4(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary{ { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix4x2Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix4x2Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat4x2(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary{ { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix4x3Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix4x3Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat4x3(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary{ { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DoubleMatrix4x4Verifier) {
using namespace openspace::documentation;
Documentation doc {
{ { "a", new DoubleMatrix4x4Verifier } }
};
ghoul::Dictionary positive {
{ "a", glm::dmat4x4(1.0) }
};
TestResult positiveRes = testSpecification(doc, positive);
EXPECT_TRUE(positiveRes.success);
EXPECT_EQ(0, positiveRes.offenses.size());
ghoul::Dictionary negative {
{ "a", ghoul::Dictionary{ { "1", true },{ "2", 1.0 },{ "3", "s" } } }
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "a", true }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::WrongType, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, DeprecatedVerifier) {
using namespace openspace::documentation;
using namespace std::string_literals;