2022-10-17 04:48:29 +02:00
|
|
|
#include "inMemoryFile.h"
|
|
|
|
|
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#include <catch.hpp>
|
|
|
|
#include <irrlicht.h>
|
|
|
|
|
|
|
|
TEST_CASE("load empty gltf file") {
|
|
|
|
irr::IrrlichtDevice* device { irr::createDevice(irr::video::EDT_NULL) };
|
|
|
|
irr::scene::ISceneManager* smgr { device->getSceneManager() };
|
2022-10-17 14:17:07 +02:00
|
|
|
irr::io::InMemoryFile filebuf {"test.gltf", ""};
|
2022-10-17 04:48:29 +02:00
|
|
|
auto* mesh { smgr->getMesh(&filebuf) };
|
2022-10-17 14:34:19 +02:00
|
|
|
|
2022-10-17 14:17:07 +02:00
|
|
|
CHECK(mesh == nullptr);
|
|
|
|
|
|
|
|
device->drop();
|
|
|
|
}
|
|
|
|
|
2022-10-17 14:34:19 +02:00
|
|
|
TEST_CASE("minimal triangle has correct vertices") {
|
2022-10-17 14:17:07 +02:00
|
|
|
irr::IrrlichtDevice* device { irr::createDevice(irr::video::EDT_NULL) };
|
|
|
|
irr::scene::ISceneManager* smgr { device->getSceneManager() };
|
|
|
|
auto* mesh { smgr->getMesh(
|
|
|
|
"source/Irrlicht/tests/assets/minimal_triangle.gltf", "") };
|
2022-10-17 14:34:19 +02:00
|
|
|
|
2022-10-17 14:17:07 +02:00
|
|
|
REQUIRE(mesh != nullptr);
|
2022-10-17 14:34:19 +02:00
|
|
|
REQUIRE(mesh->getMeshBufferCount() == 1);
|
|
|
|
auto* meshbuf { mesh->getMeshBuffer(0) };
|
|
|
|
REQUIRE(meshbuf->getVertexCount() == 3);
|
|
|
|
irr::video::S3DVertex* vertices {
|
|
|
|
reinterpret_cast<irr::video::S3DVertex*>(
|
|
|
|
meshbuf->getVertices()) };
|
|
|
|
CHECK(vertices[0].Pos == irr::core::vector3df {0.0f, 0.0f, 0.0f});
|
2022-10-17 21:27:11 +02:00
|
|
|
CHECK(vertices[1].Pos == irr::core::vector3df {0.0f, 1.0f, 0.0f});
|
|
|
|
CHECK(vertices[2].Pos == irr::core::vector3df {-1.0f, 0.0f, 0.0f});
|
2022-10-17 04:48:29 +02:00
|
|
|
|
|
|
|
device->drop();
|
|
|
|
}
|
|
|
|
|
2022-10-17 15:36:14 +02:00
|
|
|
TEST_CASE("mesh loader returns nullptr when given null file pointer") {
|
|
|
|
irr::IrrlichtDevice* device { irr::createDevice(irr::video::EDT_NULL) };
|
|
|
|
irr::scene::ISceneManager* smgr { device->getSceneManager() };
|
|
|
|
auto* mesh { smgr->getMesh(nullptr) };
|
|
|
|
|
|
|
|
CHECK(mesh == nullptr);
|
|
|
|
|
|
|
|
device->drop();
|
|
|
|
}
|
|
|
|
|