aboutsummaryrefslogtreecommitdiff
path: root/src/test/ScriptECSTest.cpp
blob: 4477e5582ec894839f0795c0a3957c90bbb82976 (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
38
39
40
41
42
#include <gtest/gtest.h>

#define protected public

#include <crepe/api/BehaviorScript.h>
#include <crepe/api/GameObject.h>
#include <crepe/api/Script.h>
#include <crepe/api/Metadata.h>
#include <crepe/manager/ComponentManager.h>
#include <crepe/system/ScriptSystem.h>

#include "ScriptTest.h"

using namespace std;
using namespace crepe;
using namespace testing;

class ScriptECSTest : public ScriptTest {
public:
	class TestComponent : public Component {
		using Component::Component;
	};
};

TEST_F(ScriptECSTest, GetOwnComponent) {
	MyScript & script = this->script;
	Metadata & metadata = script.get_component<Metadata>();

	EXPECT_EQ(metadata.name, OBJ_NAME);
}

TEST_F(ScriptECSTest, GetOwnComponents) {
	const unsigned COUNT = 4;

	for (unsigned i = 0; i < COUNT; i++)
		entity.add_component<TestComponent>();

	MyScript & script = this->script;
	RefVector<TestComponent> components = script.get_components<TestComponent>();

	EXPECT_EQ(components.size(), COUNT);
}