Add utility tests
This commit is contained in:
parent
979bf2cc80
commit
b8e017aa25
|
|
@ -0,0 +1,40 @@
|
|||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
std::filesystem::path GetResourceDir();
|
||||
|
||||
SCENARIO("Images", "[Utility][Image]")
|
||||
{
|
||||
WHEN("Loading PNG files")
|
||||
{
|
||||
GIVEN("Logo.png")
|
||||
{
|
||||
std::shared_ptr<Nz::Image> logo = Nz::Image::LoadFromFile(GetResourceDir() / "Logo.png");
|
||||
REQUIRE(logo);
|
||||
|
||||
CHECK(logo->GetWidth() == 765);
|
||||
CHECK(logo->GetHeight() == 212);
|
||||
CHECK(logo->GetLevelCount() == 1);
|
||||
CHECK(logo->GetPixelColor(165, 139) == Nz::Color(51, 58, 100));
|
||||
CHECK(logo->GetFormat() == Nz::PixelFormat::RGBA8);
|
||||
CHECK(logo->HasAlpha());
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Loading JPG files")
|
||||
{
|
||||
GIVEN("stars-background.jpg")
|
||||
{
|
||||
std::shared_ptr<Nz::Image> background = Nz::Image::LoadFromFile(GetResourceDir() / "stars-background.jpg");
|
||||
REQUIRE(background);
|
||||
|
||||
CHECK(background->GetWidth() == 1920);
|
||||
CHECK(background->GetHeight() == 1200);
|
||||
CHECK(background->GetLevelCount() == 1);
|
||||
CHECK(background->GetPixelColor(1377, 372) == Nz::Color(171, 152, 233));
|
||||
CHECK(background->GetFormat() == Nz::PixelFormat::RGBA8);
|
||||
CHECK(!background->HasAlpha());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <catch2/catch.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
std::filesystem::path GetResourceDir();
|
||||
|
||||
SCENARIO("Meshes", "[Utility][Mesh]")
|
||||
{
|
||||
WHEN("Loading OJB files")
|
||||
{
|
||||
GIVEN("Spaceship/spaceship.obj")
|
||||
{
|
||||
std::shared_ptr<Nz::Mesh> spaceship = Nz::Mesh::LoadFromFile(GetResourceDir() / "Spaceship/spaceship.obj");
|
||||
REQUIRE(spaceship);
|
||||
|
||||
CHECK(!spaceship->IsAnimable());
|
||||
CHECK(spaceship->GetSubMeshCount() == 2);
|
||||
CHECK(spaceship->GetMaterialCount() == 2);
|
||||
CHECK(spaceship->GetTriangleCount() == 6814);
|
||||
CHECK(spaceship->GetVertexCount() == 8713);
|
||||
}
|
||||
|
||||
GIVEN("SpaceStation/space_station.obj")
|
||||
{
|
||||
std::shared_ptr<Nz::Mesh> spacestation = Nz::Mesh::LoadFromFile(GetResourceDir() / "SpaceStation/space_station.obj");
|
||||
REQUIRE(spacestation);
|
||||
|
||||
CHECK(!spacestation->IsAnimable());
|
||||
CHECK(spacestation->GetSubMeshCount() == 1);
|
||||
CHECK(spacestation->GetMaterialCount() == 1);
|
||||
CHECK(spacestation->GetTriangleCount() == 422);
|
||||
CHECK(spacestation->GetVertexCount() == 516);
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Loading MD2 files")
|
||||
{
|
||||
GIVEN("drfreak.md2")
|
||||
{
|
||||
std::shared_ptr<Nz::Mesh> drfreak = Nz::Mesh::LoadFromFile(GetResourceDir() / "drfreak.md2");
|
||||
CHECK(drfreak);
|
||||
|
||||
CHECK(!drfreak->IsAnimable()); //< non-skeletal animations are not supported
|
||||
CHECK(drfreak->GetSubMeshCount() == 1);
|
||||
CHECK(drfreak->GetMaterialCount() == 1);
|
||||
CHECK(drfreak->GetTriangleCount() == 593);
|
||||
CHECK(drfreak->GetVertexCount() == 496);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,11 +7,12 @@
|
|||
#include <Nazara/Network/Network.hpp>
|
||||
#include <Nazara/Physics2D/Physics2D.hpp>
|
||||
#include <Nazara/Shader/Shader.hpp>
|
||||
#include <Nazara/Utility/Utility.hpp>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Nz::Modules<Nz::Network, Nz::Physics2D, Nz::Shader> nazaza;
|
||||
Nz::Modules<Nz::Network, Nz::Physics2D, Nz::Shader, Nz::Utility> nazaza;
|
||||
|
||||
if (!glslang::InitializeProcess())
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue