Browse Source

Trade: ensure AbstractImporter::fooForName() returns indices in bounds.

I just accidentally returned a wrong index from a SceneData backwards
compatibility wrapper and realized it'd be good to have that checked
always.
pull/537/head
Vladimír Vondruš 5 years ago
parent
commit
602f08881b
  1. 75
      src/Magnum/Trade/AbstractImporter.cpp
  2. 104
      src/Magnum/Trade/AbstractImporter.h
  3. 332
      src/Magnum/Trade/Test/AbstractImporterTest.cpp

75
src/Magnum/Trade/AbstractImporter.cpp

@ -222,7 +222,10 @@ void AbstractImporter::close() {
Int AbstractImporter::defaultScene() const { Int AbstractImporter::defaultScene() const {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::defaultScene(): no file opened", -1); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::defaultScene(): no file opened", -1);
return doDefaultScene(); const Int id = doDefaultScene();
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doSceneCount(),
"Trade::AbstractImporter::defaultScene(): implementation-returned index" << id << "out of range for" << doSceneCount() << "entries", {});
return id;
} }
Int AbstractImporter::doDefaultScene() const { return -1; } Int AbstractImporter::doDefaultScene() const { return -1; }
@ -236,7 +239,10 @@ UnsignedInt AbstractImporter::doSceneCount() const { return 0; }
Int AbstractImporter::sceneForName(const std::string& name) { Int AbstractImporter::sceneForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::sceneForName(): no file opened", -1); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::sceneForName(): no file opened", -1);
return doSceneForName(name); const Int id = doSceneForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doSceneCount(),
"Trade::AbstractImporter::sceneForName(): implementation-returned index" << id << "out of range for" << doSceneCount() << "entries", {});
return id;
} }
Int AbstractImporter::doSceneForName(const std::string&) { return -1; } Int AbstractImporter::doSceneForName(const std::string&) { return -1; }
@ -278,7 +284,10 @@ UnsignedInt AbstractImporter::doAnimationCount() const { return 0; }
Int AbstractImporter::animationForName(const std::string& name) { Int AbstractImporter::animationForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::animationForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::animationForName(): no file opened", {});
return doAnimationForName(name); const Int id = doAnimationForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doAnimationCount(),
"Trade::AbstractImporter::animationForName(): implementation-returned index" << id << "out of range for" << doAnimationCount() << "entries", {});
return id;
} }
Int AbstractImporter::doAnimationForName(const std::string&) { return -1; } Int AbstractImporter::doAnimationForName(const std::string&) { return -1; }
@ -325,7 +334,10 @@ UnsignedInt AbstractImporter::doLightCount() const { return 0; }
Int AbstractImporter::lightForName(const std::string& name) { Int AbstractImporter::lightForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::lightForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::lightForName(): no file opened", {});
return doLightForName(name); const Int id = doLightForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doLightCount(),
"Trade::AbstractImporter::lightForName(): implementation-returned index" << id << "out of range for" << doLightCount() << "entries", {});
return id;
} }
Int AbstractImporter::doLightForName(const std::string&) { return -1; } Int AbstractImporter::doLightForName(const std::string&) { return -1; }
@ -367,7 +379,10 @@ UnsignedInt AbstractImporter::doCameraCount() const { return 0; }
Int AbstractImporter::cameraForName(const std::string& name) { Int AbstractImporter::cameraForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::cameraForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::cameraForName(): no file opened", {});
return doCameraForName(name); const Int id = doCameraForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doCameraCount(),
"Trade::AbstractImporter::cameraForName(): implementation-returned index" << id << "out of range for" << doCameraCount() << "entries", {});
return id;
} }
Int AbstractImporter::doCameraForName(const std::string&) { return -1; } Int AbstractImporter::doCameraForName(const std::string&) { return -1; }
@ -409,7 +424,10 @@ UnsignedInt AbstractImporter::doObject2DCount() const { return 0; }
Int AbstractImporter::object2DForName(const std::string& name) { Int AbstractImporter::object2DForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::object2DForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::object2DForName(): no file opened", {});
return doObject2DForName(name); const Int id = doObject2DForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doObject2DCount(),
"Trade::AbstractImporter::object2DForName(): implementation-returned index" << id << "out of range for" << doObject2DCount() << "entries", {});
return id;
} }
Int AbstractImporter::doObject2DForName(const std::string&) { return -1; } Int AbstractImporter::doObject2DForName(const std::string&) { return -1; }
@ -451,7 +469,10 @@ UnsignedInt AbstractImporter::doObject3DCount() const { return 0; }
Int AbstractImporter::object3DForName(const std::string& name) { Int AbstractImporter::object3DForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::object3DForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::object3DForName(): no file opened", {});
return doObject3DForName(name); const Int id = doObject3DForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doObject3DCount(),
"Trade::AbstractImporter::object3DForName(): implementation-returned index" << id << "out of range for" << doObject3DCount() << "entries", {});
return id;
} }
Int AbstractImporter::doObject3DForName(const std::string&) { return -1; } Int AbstractImporter::doObject3DForName(const std::string&) { return -1; }
@ -493,7 +514,10 @@ UnsignedInt AbstractImporter::doSkin2DCount() const { return 0; }
Int AbstractImporter::skin2DForName(const std::string& name) { Int AbstractImporter::skin2DForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::skin2DForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::skin2DForName(): no file opened", {});
return doSkin2DForName(name); const Int id = doSkin2DForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doSkin2DCount(),
"Trade::AbstractImporter::skin2DForName(): implementation-returned index" << id << "out of range for" << doSkin2DCount() << "entries", {});
return id;
} }
Int AbstractImporter::doSkin2DForName(const std::string&) { return -1; } Int AbstractImporter::doSkin2DForName(const std::string&) { return -1; }
@ -540,7 +564,10 @@ UnsignedInt AbstractImporter::doSkin3DCount() const { return 0; }
Int AbstractImporter::skin3DForName(const std::string& name) { Int AbstractImporter::skin3DForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::skin3DForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::skin3DForName(): no file opened", {});
return doSkin3DForName(name); const Int id = doSkin3DForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doSkin3DCount(),
"Trade::AbstractImporter::skin3DForName(): implementation-returned index" << id << "out of range for" << doSkin3DCount() << "entries", {});
return id;
} }
Int AbstractImporter::doSkin3DForName(const std::string&) { return -1; } Int AbstractImporter::doSkin3DForName(const std::string&) { return -1; }
@ -597,7 +624,10 @@ UnsignedInt AbstractImporter::doMeshLevelCount(UnsignedInt) { return 1; }
Int AbstractImporter::meshForName(const std::string& name) { Int AbstractImporter::meshForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::meshForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::meshForName(): no file opened", {});
return doMeshForName(name); const Int id = doMeshForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doMeshCount(),
"Trade::AbstractImporter::meshForName(): implementation-returned index" << id << "out of range for" << doMeshCount() << "entries", {});
return id;
} }
Int AbstractImporter::doMeshForName(const std::string&) { return -1; } Int AbstractImporter::doMeshForName(const std::string&) { return -1; }
@ -765,7 +795,10 @@ UnsignedInt AbstractImporter::doMaterialCount() const { return 0; }
Int AbstractImporter::materialForName(const std::string& name) { Int AbstractImporter::materialForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::materialForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::materialForName(): no file opened", {});
return doMaterialForName(name); const Int id = doMaterialForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doMaterialCount(),
"Trade::AbstractImporter::materialForName(): implementation-returned index" << id << "out of range for" << doMaterialCount() << "entries", {});
return id;
} }
Int AbstractImporter::doMaterialForName(const std::string&) { return -1; } Int AbstractImporter::doMaterialForName(const std::string&) { return -1; }
@ -829,7 +862,10 @@ UnsignedInt AbstractImporter::doTextureCount() const { return 0; }
Int AbstractImporter::textureForName(const std::string& name) { Int AbstractImporter::textureForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::textureForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::textureForName(): no file opened", {});
return doTextureForName(name); const Int id = doTextureForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doTextureCount(),
"Trade::AbstractImporter::textureForName(): implementation-returned index" << id << "out of range for" << doTextureCount() << "entries", {});
return id;
} }
Int AbstractImporter::doTextureForName(const std::string&) { return -1; } Int AbstractImporter::doTextureForName(const std::string&) { return -1; }
@ -881,7 +917,10 @@ UnsignedInt AbstractImporter::doImage1DLevelCount(UnsignedInt) { return 1; }
Int AbstractImporter::image1DForName(const std::string& name) { Int AbstractImporter::image1DForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::image1DForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::image1DForName(): no file opened", {});
return doImage1DForName(name); const Int id = doImage1DForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doImage1DCount(),
"Trade::AbstractImporter::image1DForName(): implementation-returned index" << id << "out of range for" << doImage1DCount() << "entries", {});
return id;
} }
Int AbstractImporter::doImage1DForName(const std::string&) { return -1; } Int AbstractImporter::doImage1DForName(const std::string&) { return -1; }
@ -948,7 +987,10 @@ UnsignedInt AbstractImporter::doImage2DLevelCount(UnsignedInt) { return 1; }
Int AbstractImporter::image2DForName(const std::string& name) { Int AbstractImporter::image2DForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::image2DForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::image2DForName(): no file opened", {});
return doImage2DForName(name); const Int id = doImage2DForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doImage2DCount(),
"Trade::AbstractImporter::image2DForName(): implementation-returned index" << id << "out of range for" << doImage2DCount() << "entries", {});
return id;
} }
Int AbstractImporter::doImage2DForName(const std::string&) { return -1; } Int AbstractImporter::doImage2DForName(const std::string&) { return -1; }
@ -1015,7 +1057,10 @@ UnsignedInt AbstractImporter::doImage3DLevelCount(UnsignedInt) { return 1; }
Int AbstractImporter::image3DForName(const std::string& name) { Int AbstractImporter::image3DForName(const std::string& name) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::image3DForName(): no file opened", {}); CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::image3DForName(): no file opened", {});
return doImage3DForName(name); const Int id = doImage3DForName(name);
CORRADE_ASSERT(id == -1 || UnsignedInt(id) < doImage3DCount(),
"Trade::AbstractImporter::image3DForName(): implementation-returned index" << id << "out of range for" << doImage3DCount() << "entries", {});
return id;
} }
Int AbstractImporter::doImage3DForName(const std::string&) { return -1; } Int AbstractImporter::doImage3DForName(const std::string&) { return -1; }

104
src/Magnum/Trade/AbstractImporter.h

@ -681,10 +681,10 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
/** /**
* @brief Default scene * @brief Default scene
* @return Scene ID from range [0, @ref sceneCount()) or @cpp -1 @ce if
* there's no default scene
* *
* When there is more than one scene, returns ID of the default one. * Expects that a file is opened.
* If there is no default scene, returns @cpp -1 @ce. Expects that a
* file is opened.
*/ */
Int defaultScene() const; Int defaultScene() const;
@ -696,10 +696,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt sceneCount() const; UnsignedInt sceneCount() const;
/** /**
* @brief Scene ID for given name * @brief Scene for given name
* @return Scene ID from range [0, @ref sceneCount()) or @cpp -1 @ce if
* no scene for given name exists
* *
* If no scene for given name exists, returns @cpp -1 @ce. Expects that * Expects that a file is opened.
* a file is opened.
* @see @ref sceneName(), @ref scene(const std::string&) * @see @ref sceneName(), @ref scene(const std::string&)
*/ */
Int sceneForName(const std::string& name); Int sceneForName(const std::string& name);
@ -744,10 +745,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt animationCount() const; UnsignedInt animationCount() const;
/** /**
* @brief Animation ID for given name * @brief Animation for given name
* @return Animation ID from range [0, @ref animationCount()) or
* @cpp -1 @ce if no animation for given name exists
* *
* If no animation for given name exists, returns @cpp -1 @ce. Expects * Expects that a file is opened.
* that a file is opened.
* @see @ref animationName(), @ref animation(const std::string&) * @see @ref animationName(), @ref animation(const std::string&)
*/ */
Int animationForName(const std::string& name); Int animationForName(const std::string& name);
@ -792,10 +794,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt lightCount() const; UnsignedInt lightCount() const;
/** /**
* @brief Light ID for given name * @brief Light for given name
* @return Light ID from range [0, @ref lightCount()) or @cpp -1 @ce if
* no light for given name exists
* *
* If no light for given name exists, returns @cpp -1 @ce. Expects that * Expects that a file is opened.
* a file is opened.
* @see @ref lightName(), @ref light(const std::string&) * @see @ref lightName(), @ref light(const std::string&)
*/ */
Int lightForName(const std::string& name); Int lightForName(const std::string& name);
@ -840,10 +843,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt cameraCount() const; UnsignedInt cameraCount() const;
/** /**
* @brief Camera ID for given name * @brief Camera for given name
* @return Camera ID from range [0, @ref cameraCount()) or @cpp -1 @ce
* if no camera for given name exists
* *
* If no camera for given name exists, returns @cpp -1 @ce. Expects * Expects that a file is opened.
* that a file is opened.
* @see @ref cameraName(), @ref camera(const std::string&) * @see @ref cameraName(), @ref camera(const std::string&)
*/ */
Int cameraForName(const std::string& name); Int cameraForName(const std::string& name);
@ -888,10 +892,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt object2DCount() const; UnsignedInt object2DCount() const;
/** /**
* @brief Two-dimensional object ID for given name * @brief Two-dimensional object for given name
* @return Object ID from range [0, @ref object2DCount()) or
* @cpp -1 @ce if no object for given name exists
* *
* If no object for given name exists, returns @cpp -1 @ce. Expects * Expects that a file is opened.
* that a file is opened.
* @see @ref object2DName(), @ref object2D(const std::string&) * @see @ref object2DName(), @ref object2D(const std::string&)
*/ */
Int object2DForName(const std::string& name); Int object2DForName(const std::string& name);
@ -936,10 +941,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt object3DCount() const; UnsignedInt object3DCount() const;
/** /**
* @brief Three-dimensional object ID for given name * @brief Three-dimensional object for given name
* @return Object ID from range [0, @ref object3DCount()) or
* @cpp -1 @ce if no object for given name exists
* *
* If no object for given name exists, returns @cpp -1 @ce. Expects * Expects that a file is opened.
* that a file is opened.
* @see @ref object3DName(), @ref object3D(const std::string&) * @see @ref object3DName(), @ref object3D(const std::string&)
*/ */
Int object3DForName(const std::string& name); Int object3DForName(const std::string& name);
@ -985,11 +991,12 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt skin2DCount() const; UnsignedInt skin2DCount() const;
/** /**
* @brief Two-dimensional skin ID for given name * @brief Two-dimensional skin for given name
* @return Skin ID from range [0, @ref skin2DCount()) or @cpp -1 @ce if
* no skin for given name exists
* @m_since_latest * @m_since_latest
* *
* If no skin for given name exists, returns @cpp -1 @ce. Expects that * Expects that a file is opened.
* a file is opened.
* @see @ref skin2DName(), @ref skin2D(const std::string&) * @see @ref skin2DName(), @ref skin2D(const std::string&)
*/ */
Int skin2DForName(const std::string& name); Int skin2DForName(const std::string& name);
@ -1037,11 +1044,12 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt skin3DCount() const; UnsignedInt skin3DCount() const;
/** /**
* @brief Three-dimensional skin ID for given name * @brief Three-dimensional skin for given name
* @return Skin ID from range [0, @ref skin3DCount()) or @cpp -1 @ce if
* no skin for given name exists
* @m_since_latest * @m_since_latest
* *
* If no skin for given name exists, returns @cpp -1 @ce. Expects that * Expects that a file is opened.
* a file is opened.
* @see @ref skin3DName(), @ref skin3D(const std::string&) * @see @ref skin3DName(), @ref skin3D(const std::string&)
*/ */
Int skin3DForName(const std::string& name); Int skin3DForName(const std::string& name);
@ -1100,11 +1108,12 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt meshLevelCount(UnsignedInt id); UnsignedInt meshLevelCount(UnsignedInt id);
/** /**
* @brief Mesh ID for given name * @brief Mesh for given name
* @return Mesh ID from range [0, @ref meshCount()) or @cpp -1 @ce if
* no mesh for given name exists
* @m_since{2020,06} * @m_since{2020,06}
* *
* If no mesh for given name exists, returns @cpp -1 @ce. Expects that * Expects that a file is opened.
* a file is opened.
* @see @ref meshName(), @ref mesh(const std::string&, UnsignedInt) * @see @ref meshName(), @ref mesh(const std::string&, UnsignedInt)
*/ */
Int meshForName(const std::string& name); Int meshForName(const std::string& name);
@ -1267,10 +1276,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt materialCount() const; UnsignedInt materialCount() const;
/** /**
* @brief Material ID for given name * @brief Material for given name
* @return Material ID from range [0, @ref materialCount()) or
* @cpp -1 @ce if no material for given name exists
* *
* If no material for given name exists, returns @cpp -1 @ce. Expects * Expects that a file is opened.
* that a file is opened.
* @see @ref materialName() * @see @ref materialName()
*/ */
Int materialForName(const std::string& name); Int materialForName(const std::string& name);
@ -1325,10 +1335,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt textureCount() const; UnsignedInt textureCount() const;
/** /**
* @brief Texture ID for given name * @brief Texture for given name
* @return Texture ID from range [0, @ref textureCount()) or
* @cpp -1 @ce if no texture for given name exists
* *
* If no texture for given name exists, returns @cpp -1 @ce. Expects * Expects that a file is opened.
* that a file is opened.
* @see @ref textureName(), @ref texture(const std::string&) * @see @ref textureName(), @ref texture(const std::string&)
*/ */
Int textureForName(const std::string& name); Int textureForName(const std::string& name);
@ -1384,10 +1395,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt image1DLevelCount(UnsignedInt id); UnsignedInt image1DLevelCount(UnsignedInt id);
/** /**
* @brief One-dimensional image ID for given name * @brief One-dimensional image for given name
* @return Image ID from range [0, @ref image1DCount()) or @cpp -1 @ce
* if no image for given name exists
* *
* If no image for given name exists, returns @cpp -1 @ce. Expects that * Expects that a file is opened.
* a file is opened.
* @see @ref image1DName(), @ref image1D(const std::string&, UnsignedInt) * @see @ref image1DName(), @ref image1D(const std::string&, UnsignedInt)
*/ */
Int image1DForName(const std::string& name); Int image1DForName(const std::string& name);
@ -1445,10 +1457,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt image2DLevelCount(UnsignedInt id); UnsignedInt image2DLevelCount(UnsignedInt id);
/** /**
* @brief Two-dimensional image ID for given name * @brief Two-dimensional image for given name
* @return Image ID from range [0, @ref image2DCount()) or @cpp -1 @ce
* if no image for given name exists
* *
* If no image for given name exists, returns @cpp -1 @ce. Expects that * Expects that a file is opened.
* a file is opened.
* @see @ref image2DName(), @ref image2D(const std::string&, UnsignedInt) * @see @ref image2DName(), @ref image2D(const std::string&, UnsignedInt)
*/ */
Int image2DForName(const std::string& name); Int image2DForName(const std::string& name);
@ -1506,10 +1519,11 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
UnsignedInt image3DLevelCount(UnsignedInt id); UnsignedInt image3DLevelCount(UnsignedInt id);
/** /**
* @brief Three-dimensional image ID for given name * @brief Three-dimensional image for given name
* @return Image ID from range [0, @ref image3DCount()) or @cpp -1 @ce
* if no image for given name exists
* *
* If no image for given name exists, returns @cpp -1 @ce. Expects that * Expects that a file is opened.
* a file is opened.
* @see @ref image3DName(), @ref image3D(const std::string&, UnsignedInt) * @see @ref image3DName(), @ref image3D(const std::string&, UnsignedInt)
*/ */
Int image3DForName(const std::string& name); Int image3DForName(const std::string& name);

332
src/Magnum/Trade/Test/AbstractImporterTest.cpp

@ -101,15 +101,18 @@ struct AbstractImporterTest: TestSuite::Tester {
void defaultScene(); void defaultScene();
void defaultSceneNotImplemented(); void defaultSceneNotImplemented();
void defaultSceneOutOfRange();
void scene(); void scene();
void sceneNameNotImplemented(); void sceneNameNotImplemented();
void sceneForNameOutOfRange();
void sceneNameOutOfRange(); void sceneNameOutOfRange();
void sceneNotImplemented(); void sceneNotImplemented();
void sceneOutOfRange(); void sceneOutOfRange();
void animation(); void animation();
void animationNameNotImplemented(); void animationNameNotImplemented();
void animationForNameOutOfRange();
void animationNameOutOfRange(); void animationNameOutOfRange();
void animationNotImplemented(); void animationNotImplemented();
void animationOutOfRange(); void animationOutOfRange();
@ -120,30 +123,35 @@ struct AbstractImporterTest: TestSuite::Tester {
void light(); void light();
void lightNameNotImplemented(); void lightNameNotImplemented();
void lightForNameOutOfRange();
void lightNameOutOfRange(); void lightNameOutOfRange();
void lightNotImplemented(); void lightNotImplemented();
void lightOutOfRange(); void lightOutOfRange();
void camera(); void camera();
void cameraNameNotImplemented(); void cameraNameNotImplemented();
void cameraForNameOutOfRange();
void cameraNameOutOfRange(); void cameraNameOutOfRange();
void cameraNotImplemented(); void cameraNotImplemented();
void cameraOutOfRange(); void cameraOutOfRange();
void object2D(); void object2D();
void object2DNameNotImplemented(); void object2DNameNotImplemented();
void object2DForNameOutOfRange();
void object2DNameOutOfRange(); void object2DNameOutOfRange();
void object2DNotImplemented(); void object2DNotImplemented();
void object2DOutOfRange(); void object2DOutOfRange();
void object3D(); void object3D();
void object3DNameNotImplemented(); void object3DNameNotImplemented();
void object3DForNameOutOfRange();
void object3DNameOutOfRange(); void object3DNameOutOfRange();
void object3DNotImplemented(); void object3DNotImplemented();
void object3DOutOfRange(); void object3DOutOfRange();
void skin2D(); void skin2D();
void skin2DNameNotImplemented(); void skin2DNameNotImplemented();
void skin2DForNameOutOfRange();
void skin2DNameOutOfRange(); void skin2DNameOutOfRange();
void skin2DNotImplemented(); void skin2DNotImplemented();
void skin2DOutOfRange(); void skin2DOutOfRange();
@ -153,6 +161,7 @@ struct AbstractImporterTest: TestSuite::Tester {
void skin3D(); void skin3D();
void skin3DNameNotImplemented(); void skin3DNameNotImplemented();
void skin3DForNameOutOfRange();
void skin3DNameOutOfRange(); void skin3DNameOutOfRange();
void skin3DNotImplemented(); void skin3DNotImplemented();
void skin3DOutOfRange(); void skin3DOutOfRange();
@ -167,6 +176,7 @@ struct AbstractImporterTest: TestSuite::Tester {
void meshLevelCountNotImplemented(); void meshLevelCountNotImplemented();
void meshLevelCountOutOfRange(); void meshLevelCountOutOfRange();
void meshLevelCountZero(); void meshLevelCountZero();
void meshForNameOutOfRange();
void meshNameNotImplemented(); void meshNameNotImplemented();
void meshNameOutOfRange(); void meshNameOutOfRange();
void meshNotImplemented(); void meshNotImplemented();
@ -212,6 +222,7 @@ struct AbstractImporterTest: TestSuite::Tester {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
void materialDeprecatedFallback(); void materialDeprecatedFallback();
#endif #endif
void materialForNameOutOfRange();
void materialNameNotImplemented(); void materialNameNotImplemented();
void materialNameOutOfRange(); void materialNameOutOfRange();
void materialNotImplemented(); void materialNotImplemented();
@ -221,6 +232,7 @@ struct AbstractImporterTest: TestSuite::Tester {
void materialCustomLayerDataDeleter(); void materialCustomLayerDataDeleter();
void texture(); void texture();
void textureForNameOutOfRange();
void textureNameNotImplemented(); void textureNameNotImplemented();
void textureNameOutOfRange(); void textureNameOutOfRange();
void textureNotImplemented(); void textureNotImplemented();
@ -230,6 +242,7 @@ struct AbstractImporterTest: TestSuite::Tester {
void image1DLevelCountNotImplemented(); void image1DLevelCountNotImplemented();
void image1DLevelCountOutOfRange(); void image1DLevelCountOutOfRange();
void image1DLevelCountZero(); void image1DLevelCountZero();
void image1DForNameOutOfRange();
void image1DNameNotImplemented(); void image1DNameNotImplemented();
void image1DNameOutOfRange(); void image1DNameOutOfRange();
void image1DNotImplemented(); void image1DNotImplemented();
@ -243,6 +256,7 @@ struct AbstractImporterTest: TestSuite::Tester {
void image2DLevelCountNotImplemented(); void image2DLevelCountNotImplemented();
void image2DLevelCountOutOfRange(); void image2DLevelCountOutOfRange();
void image2DLevelCountZero(); void image2DLevelCountZero();
void image2DForNameOutOfRange();
void image2DNameNotImplemented(); void image2DNameNotImplemented();
void image2DNameOutOfRange(); void image2DNameOutOfRange();
void image2DNotImplemented(); void image2DNotImplemented();
@ -256,6 +270,7 @@ struct AbstractImporterTest: TestSuite::Tester {
void image3DLevelCountNotImplemented(); void image3DLevelCountNotImplemented();
void image3DLevelCountOutOfRange(); void image3DLevelCountOutOfRange();
void image3DLevelCountZero(); void image3DLevelCountZero();
void image3DForNameOutOfRange();
void image3DNameNotImplemented(); void image3DNameNotImplemented();
void image3DNameOutOfRange(); void image3DNameOutOfRange();
void image3DNotImplemented(); void image3DNotImplemented();
@ -326,15 +341,18 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::thingNoFile, &AbstractImporterTest::thingNoFile,
&AbstractImporterTest::defaultScene, &AbstractImporterTest::defaultScene,
&AbstractImporterTest::defaultSceneOutOfRange,
&AbstractImporterTest::defaultSceneNotImplemented, &AbstractImporterTest::defaultSceneNotImplemented,
&AbstractImporterTest::scene, &AbstractImporterTest::scene,
&AbstractImporterTest::sceneForNameOutOfRange,
&AbstractImporterTest::sceneNameNotImplemented, &AbstractImporterTest::sceneNameNotImplemented,
&AbstractImporterTest::sceneNameOutOfRange, &AbstractImporterTest::sceneNameOutOfRange,
&AbstractImporterTest::sceneNotImplemented, &AbstractImporterTest::sceneNotImplemented,
&AbstractImporterTest::sceneOutOfRange, &AbstractImporterTest::sceneOutOfRange,
&AbstractImporterTest::animation, &AbstractImporterTest::animation,
&AbstractImporterTest::animationForNameOutOfRange,
&AbstractImporterTest::animationNameNotImplemented, &AbstractImporterTest::animationNameNotImplemented,
&AbstractImporterTest::animationNameOutOfRange, &AbstractImporterTest::animationNameOutOfRange,
&AbstractImporterTest::animationNotImplemented, &AbstractImporterTest::animationNotImplemented,
@ -345,30 +363,35 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::animationCustomTrackDeleter, &AbstractImporterTest::animationCustomTrackDeleter,
&AbstractImporterTest::light, &AbstractImporterTest::light,
&AbstractImporterTest::lightForNameOutOfRange,
&AbstractImporterTest::lightNameNotImplemented, &AbstractImporterTest::lightNameNotImplemented,
&AbstractImporterTest::lightNameOutOfRange, &AbstractImporterTest::lightNameOutOfRange,
&AbstractImporterTest::lightNotImplemented, &AbstractImporterTest::lightNotImplemented,
&AbstractImporterTest::lightOutOfRange, &AbstractImporterTest::lightOutOfRange,
&AbstractImporterTest::camera, &AbstractImporterTest::camera,
&AbstractImporterTest::cameraForNameOutOfRange,
&AbstractImporterTest::cameraNameNotImplemented, &AbstractImporterTest::cameraNameNotImplemented,
&AbstractImporterTest::cameraNameOutOfRange, &AbstractImporterTest::cameraNameOutOfRange,
&AbstractImporterTest::cameraNotImplemented, &AbstractImporterTest::cameraNotImplemented,
&AbstractImporterTest::cameraOutOfRange, &AbstractImporterTest::cameraOutOfRange,
&AbstractImporterTest::object2D, &AbstractImporterTest::object2D,
&AbstractImporterTest::object2DForNameOutOfRange,
&AbstractImporterTest::object2DNameNotImplemented, &AbstractImporterTest::object2DNameNotImplemented,
&AbstractImporterTest::object2DNameOutOfRange, &AbstractImporterTest::object2DNameOutOfRange,
&AbstractImporterTest::object2DNotImplemented, &AbstractImporterTest::object2DNotImplemented,
&AbstractImporterTest::object2DOutOfRange, &AbstractImporterTest::object2DOutOfRange,
&AbstractImporterTest::object3D, &AbstractImporterTest::object3D,
&AbstractImporterTest::object3DForNameOutOfRange,
&AbstractImporterTest::object3DNameNotImplemented, &AbstractImporterTest::object3DNameNotImplemented,
&AbstractImporterTest::object3DNameOutOfRange, &AbstractImporterTest::object3DNameOutOfRange,
&AbstractImporterTest::object3DNotImplemented, &AbstractImporterTest::object3DNotImplemented,
&AbstractImporterTest::object3DOutOfRange, &AbstractImporterTest::object3DOutOfRange,
&AbstractImporterTest::skin2D, &AbstractImporterTest::skin2D,
&AbstractImporterTest::skin2DForNameOutOfRange,
&AbstractImporterTest::skin2DNameNotImplemented, &AbstractImporterTest::skin2DNameNotImplemented,
&AbstractImporterTest::skin2DNameOutOfRange, &AbstractImporterTest::skin2DNameOutOfRange,
&AbstractImporterTest::skin2DNotImplemented, &AbstractImporterTest::skin2DNotImplemented,
@ -378,6 +401,7 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::skin2DCustomInverseBindMatrixDataDeleter, &AbstractImporterTest::skin2DCustomInverseBindMatrixDataDeleter,
&AbstractImporterTest::skin3D, &AbstractImporterTest::skin3D,
&AbstractImporterTest::skin3DForNameOutOfRange,
&AbstractImporterTest::skin3DNameNotImplemented, &AbstractImporterTest::skin3DNameNotImplemented,
&AbstractImporterTest::skin3DNameOutOfRange, &AbstractImporterTest::skin3DNameOutOfRange,
&AbstractImporterTest::skin3DNotImplemented, &AbstractImporterTest::skin3DNotImplemented,
@ -393,6 +417,7 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::meshLevelCountNotImplemented, &AbstractImporterTest::meshLevelCountNotImplemented,
&AbstractImporterTest::meshLevelCountOutOfRange, &AbstractImporterTest::meshLevelCountOutOfRange,
&AbstractImporterTest::meshLevelCountZero, &AbstractImporterTest::meshLevelCountZero,
&AbstractImporterTest::meshForNameOutOfRange,
&AbstractImporterTest::meshNameNotImplemented, &AbstractImporterTest::meshNameNotImplemented,
&AbstractImporterTest::meshNameOutOfRange, &AbstractImporterTest::meshNameOutOfRange,
&AbstractImporterTest::meshNotImplemented, &AbstractImporterTest::meshNotImplemented,
@ -438,6 +463,7 @@ AbstractImporterTest::AbstractImporterTest() {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
&AbstractImporterTest::materialDeprecatedFallback, &AbstractImporterTest::materialDeprecatedFallback,
#endif #endif
&AbstractImporterTest::materialForNameOutOfRange,
&AbstractImporterTest::materialNameNotImplemented, &AbstractImporterTest::materialNameNotImplemented,
&AbstractImporterTest::materialNameOutOfRange, &AbstractImporterTest::materialNameOutOfRange,
&AbstractImporterTest::materialNotImplemented, &AbstractImporterTest::materialNotImplemented,
@ -447,6 +473,7 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::materialCustomLayerDataDeleter, &AbstractImporterTest::materialCustomLayerDataDeleter,
&AbstractImporterTest::texture, &AbstractImporterTest::texture,
&AbstractImporterTest::textureForNameOutOfRange,
&AbstractImporterTest::textureNameNotImplemented, &AbstractImporterTest::textureNameNotImplemented,
&AbstractImporterTest::textureNameOutOfRange, &AbstractImporterTest::textureNameOutOfRange,
&AbstractImporterTest::textureNotImplemented, &AbstractImporterTest::textureNotImplemented,
@ -456,6 +483,7 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::image1DLevelCountNotImplemented, &AbstractImporterTest::image1DLevelCountNotImplemented,
&AbstractImporterTest::image1DLevelCountOutOfRange, &AbstractImporterTest::image1DLevelCountOutOfRange,
&AbstractImporterTest::image1DLevelCountZero, &AbstractImporterTest::image1DLevelCountZero,
&AbstractImporterTest::image1DForNameOutOfRange,
&AbstractImporterTest::image1DNameNotImplemented, &AbstractImporterTest::image1DNameNotImplemented,
&AbstractImporterTest::image1DNameOutOfRange, &AbstractImporterTest::image1DNameOutOfRange,
&AbstractImporterTest::image1DNotImplemented, &AbstractImporterTest::image1DNotImplemented,
@ -469,6 +497,7 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::image2DLevelCountNotImplemented, &AbstractImporterTest::image2DLevelCountNotImplemented,
&AbstractImporterTest::image2DLevelCountOutOfRange, &AbstractImporterTest::image2DLevelCountOutOfRange,
&AbstractImporterTest::image2DLevelCountZero, &AbstractImporterTest::image2DLevelCountZero,
&AbstractImporterTest::image2DForNameOutOfRange,
&AbstractImporterTest::image2DNameNotImplemented, &AbstractImporterTest::image2DNameNotImplemented,
&AbstractImporterTest::image2DNameOutOfRange, &AbstractImporterTest::image2DNameOutOfRange,
&AbstractImporterTest::image2DNotImplemented, &AbstractImporterTest::image2DNotImplemented,
@ -482,6 +511,7 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::image3DLevelCountNotImplemented, &AbstractImporterTest::image3DLevelCountNotImplemented,
&AbstractImporterTest::image3DLevelCountOutOfRange, &AbstractImporterTest::image3DLevelCountOutOfRange,
&AbstractImporterTest::image3DLevelCountZero, &AbstractImporterTest::image3DLevelCountZero,
&AbstractImporterTest::image3DForNameOutOfRange,
&AbstractImporterTest::image3DNameNotImplemented, &AbstractImporterTest::image3DNameNotImplemented,
&AbstractImporterTest::image3DNameOutOfRange, &AbstractImporterTest::image3DNameOutOfRange,
&AbstractImporterTest::image3DNotImplemented, &AbstractImporterTest::image3DNotImplemented,
@ -1446,6 +1476,7 @@ void AbstractImporterTest::defaultScene() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
UnsignedInt doSceneCount() const override { return 43; }
Int doDefaultScene() const override { return 42; } Int doDefaultScene() const override { return 42; }
} importer; } importer;
@ -1462,6 +1493,26 @@ void AbstractImporterTest::defaultSceneNotImplemented() {
CORRADE_COMPARE(importer.defaultScene(), -1); CORRADE_COMPARE(importer.defaultScene(), -1);
} }
void AbstractImporterTest::defaultSceneOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doSceneCount() const override { return 8; }
Int doDefaultScene() const override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.defaultScene();
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::defaultScene(): implementation-returned index 8 out of range for 8 entries\n");
}
int state; int state;
void AbstractImporterTest::scene() { void AbstractImporterTest::scene() {
@ -1500,6 +1551,26 @@ void AbstractImporterTest::scene() {
} }
} }
void AbstractImporterTest::sceneForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doSceneCount() const override { return 8; }
Int doSceneForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.sceneForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::sceneForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::sceneNameNotImplemented() { void AbstractImporterTest::sceneNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -1613,6 +1684,26 @@ void AbstractImporterTest::animation() {
} }
} }
void AbstractImporterTest::animationForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doAnimationCount() const override { return 8; }
Int doAnimationForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.animationForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::animationForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::animationNameNotImplemented() { void AbstractImporterTest::animationNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -1816,6 +1907,26 @@ void AbstractImporterTest::light() {
} }
} }
void AbstractImporterTest::lightForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doLightCount() const override { return 8; }
Int doLightForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.lightForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::lightForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::lightNameNotImplemented() { void AbstractImporterTest::lightNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -1924,6 +2035,26 @@ void AbstractImporterTest::camera() {
} }
} }
void AbstractImporterTest::cameraForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doCameraCount() const override { return 8; }
Int doCameraForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.cameraForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::cameraForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::cameraNameNotImplemented() { void AbstractImporterTest::cameraNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -2032,6 +2163,26 @@ void AbstractImporterTest::object2D() {
} }
} }
void AbstractImporterTest::object2DForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doObject2DCount() const override { return 8; }
Int doObject2DForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.object2DForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::object2DForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::object2DNameNotImplemented() { void AbstractImporterTest::object2DNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -2140,6 +2291,26 @@ void AbstractImporterTest::object3D() {
} }
} }
void AbstractImporterTest::object3DForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doObject3DCount() const override { return 8; }
Int doObject3DForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.object3DForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::object3DForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::object3DNameNotImplemented() { void AbstractImporterTest::object3DNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -2250,6 +2421,26 @@ void AbstractImporterTest::skin2D() {
} }
} }
void AbstractImporterTest::skin2DForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doSkin2DCount() const override { return 8; }
Int doSkin2DForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.skin2DForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::skin2DForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::skin2DNameNotImplemented() { void AbstractImporterTest::skin2DNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -2442,6 +2633,27 @@ void AbstractImporterTest::skin3D() {
} }
} }
void AbstractImporterTest::skin3DForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doSkin3DCount() const override { return 8; }
Int doSkin3DForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.skin3DForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::skin3DForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::skin3DNameNotImplemented() { void AbstractImporterTest::skin3DNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -2736,6 +2948,26 @@ void AbstractImporterTest::meshLevelCountZero() {
"Trade::AbstractImporter::mesh(): implementation reported zero levels\n"); "Trade::AbstractImporter::mesh(): implementation reported zero levels\n");
} }
void AbstractImporterTest::meshForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doMeshCount() const override { return 8; }
Int doMeshForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.meshForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::meshForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::meshNameNotImplemented() { void AbstractImporterTest::meshNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -3544,6 +3776,26 @@ void AbstractImporterTest::materialDeprecatedFallback() {
} }
#endif #endif
void AbstractImporterTest::materialForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doMaterialCount() const override { return 8; }
Int doMaterialForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.materialForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::materialForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::materialNameNotImplemented() { void AbstractImporterTest::materialNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -3735,6 +3987,26 @@ void AbstractImporterTest::texture() {
} }
} }
void AbstractImporterTest::textureForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doTextureCount() const override { return 8; }
Int doTextureForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.textureForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::textureForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::textureNameNotImplemented() { void AbstractImporterTest::textureNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -3907,6 +4179,26 @@ void AbstractImporterTest::image1DLevelCountZero() {
"Trade::AbstractImporter::image1D(): implementation reported zero levels\n"); "Trade::AbstractImporter::image1D(): implementation reported zero levels\n");
} }
void AbstractImporterTest::image1DForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doImage1DCount() const override { return 8; }
Int doImage1DForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.image1DForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image1DForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::image1DNameNotImplemented() { void AbstractImporterTest::image1DNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -4168,6 +4460,26 @@ void AbstractImporterTest::image2DLevelCountZero() {
"Trade::AbstractImporter::image2D(): implementation reported zero levels\n"); "Trade::AbstractImporter::image2D(): implementation reported zero levels\n");
} }
void AbstractImporterTest::image2DForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doImage2DCount() const override { return 8; }
Int doImage2DForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.image2DForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image2DForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::image2DNameNotImplemented() { void AbstractImporterTest::image2DNameNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -4370,6 +4682,26 @@ void AbstractImporterTest::image3D() {
} }
} }
void AbstractImporterTest::image3DForNameOutOfRange() {
#ifdef CORRADE_NO_ASSERT
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions");
#endif
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return true; }
void doClose() override {}
UnsignedInt doImage3DCount() const override { return 8; }
Int doImage3DForName(const std::string&) override { return 8; }
} importer;
std::ostringstream out;
Error redirectError{&out};
importer.image3DForName("");
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image3DForName(): implementation-returned index 8 out of range for 8 entries\n");
}
void AbstractImporterTest::image3DLevelCountNotImplemented() { void AbstractImporterTest::image3DLevelCountNotImplemented() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }

Loading…
Cancel
Save