mirror of https://github.com/mosra/magnum.git
12 changed files with 1030 additions and 25 deletions
@ -0,0 +1,121 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Trade/CameraData.h" |
||||
|
||||
namespace Magnum { namespace Trade { namespace Test { |
||||
|
||||
struct CameraDataTest: TestSuite::Tester { |
||||
explicit CameraDataTest(); |
||||
|
||||
void construct(); |
||||
void constructDefaults(); |
||||
void constructCopy(); |
||||
void constructMove(); |
||||
}; |
||||
|
||||
namespace { |
||||
|
||||
using namespace Math::Literals; |
||||
|
||||
enum: std::size_t { ConstructDefaultsDataCount = 3 }; |
||||
|
||||
struct { |
||||
const char* name; |
||||
Rad fov, expectedFov; |
||||
Float near, expectedNear; |
||||
Float far, expectedFar; |
||||
} ConstructDefaultsData[ConstructDefaultsDataCount]{ |
||||
{"fov", Rad{Constants::nan()}, 35.0_degf, 0.5f, 0.5f, 120.0f, 120.0f}, |
||||
{"near", 25.0_degf, 25.0_degf, Constants::nan(), 0.01f, 120.0f, 120.0f}, |
||||
{"far", 25.0_degf, 25.0_degf, 0.5f, 0.5f, Constants::nan(), 100.0f} |
||||
}; |
||||
|
||||
} |
||||
|
||||
CameraDataTest::CameraDataTest() { |
||||
addTests({&CameraDataTest::construct}); |
||||
|
||||
addInstancedTests({&CameraDataTest::constructDefaults}, ConstructDefaultsDataCount); |
||||
|
||||
addTests({&CameraDataTest::constructCopy, |
||||
&CameraDataTest::constructMove}); |
||||
} |
||||
|
||||
void CameraDataTest::construct() { |
||||
const int a{}; |
||||
CameraData data{25.0_degf, 0.001f, 1000.0f, &a}; |
||||
|
||||
CORRADE_COMPARE(data.fov(), 25.0_degf); |
||||
CORRADE_COMPARE(data.near(), 0.001f); |
||||
CORRADE_COMPARE(data.far(), 1000.0f); |
||||
CORRADE_COMPARE(data.importerState(), &a); |
||||
} |
||||
|
||||
void CameraDataTest::constructDefaults() { |
||||
setTestCaseDescription(ConstructDefaultsData[testCaseInstanceId()].name); |
||||
|
||||
const int a{}; |
||||
CameraData data{ |
||||
ConstructDefaultsData[testCaseInstanceId()].fov, |
||||
ConstructDefaultsData[testCaseInstanceId()].near, |
||||
ConstructDefaultsData[testCaseInstanceId()].far, |
||||
&a}; |
||||
|
||||
CORRADE_COMPARE(data.fov(), ConstructDefaultsData[testCaseInstanceId()].expectedFov); |
||||
CORRADE_COMPARE(data.near(), ConstructDefaultsData[testCaseInstanceId()].expectedNear); |
||||
CORRADE_COMPARE(data.far(), ConstructDefaultsData[testCaseInstanceId()].expectedFar); |
||||
CORRADE_COMPARE(data.importerState(), &a); |
||||
} |
||||
|
||||
void CameraDataTest::constructCopy() { |
||||
CORRADE_VERIFY(!(std::is_constructible<CameraData, const CameraData&>{})); |
||||
CORRADE_VERIFY(!(std::is_assignable<CameraData, const CameraData&>{})); |
||||
} |
||||
|
||||
void CameraDataTest::constructMove() { |
||||
const int a{}; |
||||
CameraData data{25.0_degf, 0.001f, 1000.0f, &a}; |
||||
|
||||
CameraData b{std::move(data)}; |
||||
CORRADE_COMPARE(b.fov(), 25.0_degf); |
||||
CORRADE_COMPARE(b.near(), 0.001f); |
||||
CORRADE_COMPARE(b.far(), 1000.0f); |
||||
CORRADE_COMPARE(b.importerState(), &a); |
||||
|
||||
const int c{}; |
||||
CameraData d{75.0_degf, 0.5f, 10.0f, &c}; |
||||
d = std::move(b); |
||||
CORRADE_COMPARE(d.fov(), 25.0_degf); |
||||
CORRADE_COMPARE(d.near(), 0.001f); |
||||
CORRADE_COMPARE(d.far(), 1000.0f); |
||||
CORRADE_COMPARE(d.importerState(), &a); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Trade::Test::CameraDataTest) |
||||
@ -0,0 +1,143 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Mesh.h" |
||||
#include "Magnum/Math/Vector2.h" |
||||
#include "Magnum/Trade/MeshData2D.h" |
||||
|
||||
namespace Magnum { namespace Trade { namespace Test { |
||||
|
||||
struct MeshData2DTest: TestSuite::Tester { |
||||
explicit MeshData2DTest(); |
||||
|
||||
void construct(); |
||||
void constructNonIndexed(); |
||||
void constructNoTexCoords(); |
||||
void constructCopy(); |
||||
void constructMove(); |
||||
}; |
||||
|
||||
MeshData2DTest::MeshData2DTest() { |
||||
addTests({&MeshData2DTest::construct, |
||||
&MeshData2DTest::constructNonIndexed, |
||||
&MeshData2DTest::constructNoTexCoords, |
||||
&MeshData2DTest::constructCopy, |
||||
&MeshData2DTest::constructMove}); |
||||
} |
||||
|
||||
void MeshData2DTest::construct() { |
||||
const int a{}; |
||||
const MeshData2D data{MeshPrimitive::Lines, {12, 1, 0}, |
||||
{{{0.5f, 1.0f}, {-1.0f, 0.3f}}, |
||||
{{1.4f, 0.2f}, {1.1f, 0.13f}}}, |
||||
{{{0.0f, 0.0f}, {0.3f, 0.7f}}, |
||||
{{0.1f, 0.2f}, {0.7f, 1.0f}}, |
||||
{{0.0f, 0.0f}, {1.0f, 1.0f}}}, |
||||
&a}; |
||||
|
||||
CORRADE_COMPARE(data.primitive(), MeshPrimitive::Lines); |
||||
|
||||
CORRADE_VERIFY(data.isIndexed()); |
||||
CORRADE_COMPARE(data.indices(), (std::vector<UnsignedInt>{12, 1, 0})); |
||||
|
||||
CORRADE_COMPARE(data.positionArrayCount(), 2); |
||||
CORRADE_COMPARE(data.positions(0), (std::vector<Vector2>{{0.5f, 1.0f}, {-1.0f, 0.3f}})); |
||||
CORRADE_COMPARE(data.positions(1), (std::vector<Vector2>{{1.4f, 0.2f}, {1.1f, 0.13f}})); |
||||
|
||||
CORRADE_VERIFY(data.hasTextureCoords2D()); |
||||
CORRADE_COMPARE(data.textureCoords2DArrayCount(), 3); |
||||
CORRADE_COMPARE(data.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}})); |
||||
CORRADE_COMPARE(data.textureCoords2D(1), (std::vector<Vector2>{{0.1f, 0.2f}, {0.7f, 1.0f}})); |
||||
CORRADE_COMPARE(data.textureCoords2D(2), (std::vector<Vector2>{{0.0f, 0.0f}, {1.0f, 1.0f}})); |
||||
|
||||
CORRADE_COMPARE(data.importerState(), &a); |
||||
} |
||||
|
||||
void MeshData2DTest::constructNonIndexed() { |
||||
const int a{}; |
||||
const MeshData2D data{MeshPrimitive::Lines, {}, |
||||
{{{0.5f, 1.0f}, {-1.0f, 0.3f}}}, |
||||
{{{0.0f, 0.0f}, {0.3f, 0.7f}}}, |
||||
&a}; |
||||
|
||||
CORRADE_VERIFY(!data.isIndexed()); |
||||
} |
||||
|
||||
void MeshData2DTest::constructNoTexCoords() { |
||||
const int a{}; |
||||
const MeshData2D data{MeshPrimitive::Lines, {12, 1, 0}, |
||||
{{{0.5f, 1.0f}, {-1.0f, 0.3f}}, |
||||
{{1.4f, 0.2f}, {1.1f, 0.13f}}}, |
||||
{}, |
||||
&a}; |
||||
|
||||
CORRADE_VERIFY(!data.hasTextureCoords2D()); |
||||
CORRADE_COMPARE(data.textureCoords2DArrayCount(), 0); |
||||
} |
||||
|
||||
void MeshData2DTest::constructCopy() { |
||||
CORRADE_VERIFY(!(std::is_constructible<MeshData2D, const MeshData2D&>{})); |
||||
CORRADE_VERIFY(!(std::is_assignable<MeshData2D, const MeshData2D&>{})); |
||||
} |
||||
|
||||
void MeshData2DTest::constructMove() { |
||||
const int a{}; |
||||
MeshData2D data{MeshPrimitive::LineStrip, {12, 1, 0}, |
||||
{{{0.5f, 1.0f}, {-1.0f, 0.3f}}}, |
||||
{{{0.0f, 0.0f}, {0.3f, 0.7f}}}, |
||||
&a}; |
||||
|
||||
MeshData2D b{std::move(data)}; |
||||
|
||||
CORRADE_COMPARE(b.primitive(), MeshPrimitive::LineStrip); |
||||
CORRADE_VERIFY(b.isIndexed()); |
||||
CORRADE_COMPARE(b.indices(), (std::vector<UnsignedInt>{12, 1, 0})); |
||||
CORRADE_COMPARE(b.positionArrayCount(), 1); |
||||
CORRADE_COMPARE(b.positions(0), (std::vector<Vector2>{{0.5f, 1.0f}, {-1.0f, 0.3f}})); |
||||
CORRADE_COMPARE(b.textureCoords2DArrayCount(), 1); |
||||
CORRADE_COMPARE(b.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}})); |
||||
CORRADE_COMPARE(b.importerState(), &a); |
||||
|
||||
const int c{}; |
||||
MeshData2D d{MeshPrimitive::TriangleFan, {}, |
||||
{{}}, |
||||
{}, |
||||
&c}; |
||||
d = std::move(b); |
||||
CORRADE_COMPARE(d.primitive(), MeshPrimitive::LineStrip); |
||||
CORRADE_VERIFY(d.isIndexed()); |
||||
CORRADE_COMPARE(d.indices(), (std::vector<UnsignedInt>{12, 1, 0})); |
||||
CORRADE_COMPARE(d.positionArrayCount(), 1); |
||||
CORRADE_COMPARE(d.positions(0), (std::vector<Vector2>{{0.5f, 1.0f}, {-1.0f, 0.3f}})); |
||||
CORRADE_COMPARE(d.textureCoords2DArrayCount(), 1); |
||||
CORRADE_COMPARE(d.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}})); |
||||
CORRADE_COMPARE(d.importerState(), &a); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Trade::Test::MeshData2DTest) |
||||
@ -0,0 +1,169 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Mesh.h" |
||||
#include "Magnum/Math/Vector3.h" |
||||
#include "Magnum/Trade/MeshData3D.h" |
||||
|
||||
namespace Magnum { namespace Trade { namespace Test { |
||||
|
||||
struct MeshData3DTest: TestSuite::Tester { |
||||
explicit MeshData3DTest(); |
||||
|
||||
void construct(); |
||||
void constructNonIndexed(); |
||||
void constructNoNormals(); |
||||
void constructNoTexCoords(); |
||||
void constructCopy(); |
||||
void constructMove(); |
||||
}; |
||||
|
||||
MeshData3DTest::MeshData3DTest() { |
||||
addTests({&MeshData3DTest::construct, |
||||
&MeshData3DTest::constructNonIndexed, |
||||
&MeshData3DTest::constructNoNormals, |
||||
&MeshData3DTest::constructNoTexCoords, |
||||
&MeshData3DTest::constructCopy, |
||||
&MeshData3DTest::constructMove}); |
||||
} |
||||
|
||||
void MeshData3DTest::construct() { |
||||
const int a{}; |
||||
const MeshData3D data{MeshPrimitive::Lines, {12, 1, 0}, |
||||
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}}, |
||||
{{1.4f, 0.2f, 0.5f}, {1.1f, 0.13f, -0.3f}}}, |
||||
{{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}}, |
||||
{{{0.0f, 0.0f}, {0.3f, 0.7f}}, |
||||
{{0.1f, 0.2f}, {0.7f, 1.0f}}, |
||||
{{0.0f, 0.0f}, {1.0f, 1.0f}}}, |
||||
&a}; |
||||
|
||||
CORRADE_COMPARE(data.primitive(), MeshPrimitive::Lines); |
||||
|
||||
CORRADE_VERIFY(data.isIndexed()); |
||||
CORRADE_COMPARE(data.indices(), (std::vector<UnsignedInt>{12, 1, 0})); |
||||
|
||||
CORRADE_COMPARE(data.positionArrayCount(), 2); |
||||
CORRADE_COMPARE(data.positions(0), (std::vector<Vector3>{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}})); |
||||
CORRADE_COMPARE(data.positions(1), (std::vector<Vector3>{{1.4f, 0.2f, 0.5f}, {1.1f, 0.13f, -0.3f}})); |
||||
|
||||
CORRADE_VERIFY(data.hasNormals()); |
||||
CORRADE_COMPARE(data.normalArrayCount(), 1); |
||||
CORRADE_COMPARE(data.normals(0), (std::vector<Vector3>{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}})); |
||||
|
||||
CORRADE_VERIFY(data.hasTextureCoords2D()); |
||||
CORRADE_COMPARE(data.textureCoords2DArrayCount(), 3); |
||||
CORRADE_COMPARE(data.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}})); |
||||
CORRADE_COMPARE(data.textureCoords2D(1), (std::vector<Vector2>{{0.1f, 0.2f}, {0.7f, 1.0f}})); |
||||
CORRADE_COMPARE(data.textureCoords2D(2), (std::vector<Vector2>{{0.0f, 0.0f}, {1.0f, 1.0f}})); |
||||
|
||||
CORRADE_COMPARE(data.importerState(), &a); |
||||
} |
||||
|
||||
void MeshData3DTest::constructNonIndexed() { |
||||
const int a{}; |
||||
const MeshData3D data{MeshPrimitive::Lines, {}, |
||||
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}}}, |
||||
{{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}}, |
||||
{{{0.0f, 0.0f}, {0.3f, 0.7f}}}, |
||||
&a}; |
||||
|
||||
CORRADE_VERIFY(!data.isIndexed()); |
||||
} |
||||
|
||||
void MeshData3DTest::constructNoNormals() { |
||||
const int a{}; |
||||
const MeshData3D data{MeshPrimitive::Lines, {12, 1, 0}, |
||||
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}}}, |
||||
{}, |
||||
{{{0.0f, 0.0f}, {0.3f, 0.7f}}}, |
||||
&a}; |
||||
|
||||
CORRADE_VERIFY(!data.hasNormals()); |
||||
CORRADE_COMPARE(data.normalArrayCount(), 0); |
||||
} |
||||
|
||||
void MeshData3DTest::constructNoTexCoords() { |
||||
const int a{}; |
||||
const MeshData3D data{MeshPrimitive::Lines, {12, 1, 0}, |
||||
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}}}, |
||||
{{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}}, |
||||
{}, |
||||
&a}; |
||||
|
||||
CORRADE_VERIFY(!data.hasTextureCoords2D()); |
||||
CORRADE_COMPARE(data.textureCoords2DArrayCount(), 0); |
||||
} |
||||
|
||||
void MeshData3DTest::constructCopy() { |
||||
CORRADE_VERIFY(!(std::is_constructible<MeshData3D, const MeshData3D&>{})); |
||||
CORRADE_VERIFY(!(std::is_assignable<MeshData3D, const MeshData3D&>{})); |
||||
} |
||||
|
||||
void MeshData3DTest::constructMove() { |
||||
const int a{}; |
||||
MeshData3D data{MeshPrimitive::LineStrip, {12, 1, 0}, |
||||
{{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}}}, |
||||
{{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}}}, |
||||
{{{0.0f, 0.0f}, {0.3f, 0.7f}}}, |
||||
&a}; |
||||
|
||||
MeshData3D b{std::move(data)}; |
||||
|
||||
CORRADE_COMPARE(b.primitive(), MeshPrimitive::LineStrip); |
||||
CORRADE_VERIFY(b.isIndexed()); |
||||
CORRADE_COMPARE(b.indices(), (std::vector<UnsignedInt>{12, 1, 0})); |
||||
CORRADE_COMPARE(b.positionArrayCount(), 1); |
||||
CORRADE_COMPARE(b.positions(0), (std::vector<Vector3>{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}})); |
||||
CORRADE_COMPARE(b.normalArrayCount(), 1); |
||||
CORRADE_COMPARE(b.normals(0), (std::vector<Vector3>{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}})); |
||||
CORRADE_COMPARE(b.textureCoords2DArrayCount(), 1); |
||||
CORRADE_COMPARE(b.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}})); |
||||
CORRADE_COMPARE(b.importerState(), &a); |
||||
|
||||
const int c{}; |
||||
MeshData3D d{MeshPrimitive::TriangleFan, {}, |
||||
{{}}, |
||||
{}, |
||||
{{}}, |
||||
&c}; |
||||
d = std::move(b); |
||||
CORRADE_COMPARE(d.primitive(), MeshPrimitive::LineStrip); |
||||
CORRADE_VERIFY(d.isIndexed()); |
||||
CORRADE_COMPARE(d.indices(), (std::vector<UnsignedInt>{12, 1, 0})); |
||||
CORRADE_COMPARE(d.positionArrayCount(), 1); |
||||
CORRADE_COMPARE(d.positions(0), (std::vector<Vector3>{{0.5f, 1.0f, 0.1f}, {-1.0f, 0.3f, -1.0f}})); |
||||
CORRADE_COMPARE(d.normalArrayCount(), 1); |
||||
CORRADE_COMPARE(d.normals(0), (std::vector<Vector3>{{0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}})); |
||||
CORRADE_COMPARE(d.textureCoords2DArrayCount(), 1); |
||||
CORRADE_COMPARE(d.textureCoords2D(0), (std::vector<Vector2>{{0.0f, 0.0f}, {0.3f, 0.7f}})); |
||||
CORRADE_COMPARE(d.importerState(), &a); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Trade::Test::MeshData3DTest) |
||||
@ -0,0 +1,82 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Trade/SceneData.h" |
||||
#include "Magnum/Magnum.h" |
||||
|
||||
namespace Magnum { namespace Trade { namespace Test { |
||||
|
||||
struct SceneDataTest: TestSuite::Tester { |
||||
explicit SceneDataTest(); |
||||
|
||||
void construct(); |
||||
void constructCopy(); |
||||
void constructMove(); |
||||
}; |
||||
|
||||
SceneDataTest::SceneDataTest() { |
||||
addTests({&SceneDataTest::construct, |
||||
&SceneDataTest::constructCopy, |
||||
&SceneDataTest::constructMove}); |
||||
} |
||||
|
||||
void SceneDataTest::construct() { |
||||
const int a{}; |
||||
const SceneData data{{0, 1, 4}, {2, 5}, &a}; |
||||
|
||||
CORRADE_COMPARE(data.children2D(), (std::vector<UnsignedInt>{0, 1, 4})); |
||||
CORRADE_COMPARE(data.children3D(), (std::vector<UnsignedInt>{2, 5})); |
||||
CORRADE_COMPARE(data.importerState(), &a); |
||||
} |
||||
|
||||
void SceneDataTest::constructCopy() { |
||||
CORRADE_VERIFY(!(std::is_constructible<SceneData, const SceneData&>{})); |
||||
CORRADE_VERIFY(!(std::is_assignable<SceneData, const SceneData&>{})); |
||||
} |
||||
|
||||
void SceneDataTest::constructMove() { |
||||
const int a{}; |
||||
SceneData data{{0, 1, 4}, {2, 5}, &a}; |
||||
|
||||
SceneData b{std::move(data)}; |
||||
|
||||
CORRADE_COMPARE(b.children2D(), (std::vector<UnsignedInt>{0, 1, 4})); |
||||
CORRADE_COMPARE(b.children3D(), (std::vector<UnsignedInt>{2, 5})); |
||||
CORRADE_COMPARE(b.importerState(), &a); |
||||
|
||||
const int c{}; |
||||
SceneData d{{1, 3}, {1, 4, 5}, &c}; |
||||
d = std::move(b); |
||||
|
||||
CORRADE_COMPARE(d.children2D(), (std::vector<UnsignedInt>{0, 1, 4})); |
||||
CORRADE_COMPARE(d.children3D(), (std::vector<UnsignedInt>{2, 5})); |
||||
CORRADE_COMPARE(d.importerState(), &a); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Trade::Test::SceneDataTest) |
||||
Loading…
Reference in new issue