summaryrefslogtreecommitdiff
path: root/test/test-obj.cpp
blob: 4adc961a4cf12285c1ad05ccf690f18e7a0759ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define BOOST_TEST_MODULE test_obj

#include <boost/test/unit_test.hpp>

#include <gfx/models/obj.h>
#include <gfx/models/vertex.hpp>
#include <glm/glm.hpp>
#include <memory>
#include <utility>
#include <vector>

BOOST_AUTO_TEST_CASE(objparse)
{
	ObjParser op {"/home/randomdan/dev/game/res/brush47.obj"};
	BOOST_CHECK_EQUAL(48, op.vertices.size());
	BOOST_CHECK_EQUAL(104, op.texCoords.size());
	BOOST_CHECK_EQUAL(25, op.normals.size());
	BOOST_CHECK_EQUAL(3, op.objects.size());
	const auto & object {op.objects.front()};
	BOOST_CHECK_EQUAL("Body", object.first);
	BOOST_CHECK_EQUAL(18, object.second.size());
	BOOST_CHECK_EQUAL(6, object.second[0].size());
	BOOST_CHECK_EQUAL(6, object.second[1].size());
	BOOST_CHECK_EQUAL(4, object.second[12].size());
}

BOOST_AUTO_TEST_CASE(create_meshes)
{
	ObjParser op {"/home/randomdan/dev/game/res/brush47.obj"};
	const auto ms = op.createMeshData();
	BOOST_REQUIRE_EQUAL(3, ms.size());
	BOOST_REQUIRE_EQUAL("Body", ms.front().first);
	BOOST_REQUIRE_EQUAL(76, ms.front().second.first.size());
	const auto & v = ms.front().second.first.front();
	BOOST_REQUIRE_CLOSE(1.345, v.pos.x, 1);
	BOOST_REQUIRE_EQUAL(120, ms.front().second.second.size());
}