aboutsummaryrefslogtreecommitdiff
path: root/src/test/AssetTest.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-11-21 20:40:08 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-11-21 20:40:08 +0100
commitd58a059fd6398527274e77a37b65aa105c8a778b (patch)
tree26d345400739ec685bbe6b26d8d789bbe33b02aa /src/test/AssetTest.cpp
parentfaa9adb84ad3f675587b52fba79cf44b7bdd2034 (diff)
parent115d6f50152dc018073345800ca90b85846ebaa9 (diff)
merge with master
Diffstat (limited to 'src/test/AssetTest.cpp')
-rw-r--r--src/test/AssetTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/AssetTest.cpp b/src/test/AssetTest.cpp
new file mode 100644
index 0000000..8aa7629
--- /dev/null
+++ b/src/test/AssetTest.cpp
@@ -0,0 +1,26 @@
+#include <gtest/gtest.h>
+
+#include <crepe/api/Asset.h>
+#include <crepe/api/Config.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());
+}