aboutsummaryrefslogtreecommitdiff
path: root/src/test/AssetTest.cpp
blob: 324a3f125d9c39533c97a91620293d4c96675f94 (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
#include "api/Config.h"
#include <gtest/gtest.h>

#include <crepe/api/Asset.h>

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

class AssetTest : public Test {
public:
	Config & cfg = Config::get_instance();
	void SetUp() override {
		this->cfg.asset.root_pattern = ".crepe-root";
	}
};

TEST_F(AssetTest, Existant) {
	ASSERT_NO_THROW(Asset{"asset/texture/img.png"});
}

TEST_F(AssetTest, Nonexistant) {
	ASSERT_ANY_THROW(Asset{"asset/nonexistant"});
}

TEST_F(AssetTest, Rootless) {
	cfg.asset.root_pattern.clear();

	string arbitrary = "\\/this is / /../passed through as-is";
	Asset asset{arbitrary};
	ASSERT_EQ(arbitrary, asset.get_path());
}