aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 13:57:13 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 13:57:13 +0100
commit07adbf48e0781cd8c95983c1871a84b6160ee5bf (patch)
treee3a55673b20ebaa3baec6665c107c177bd59ff14 /src/test
parent01c09a196c3f3e5cefaa4119a95a1cdeb7b9c263 (diff)
implement asset + more WIP audio system
Diffstat (limited to 'src/test')
-rw-r--r--src/test/AssetTest.cpp33
-rw-r--r--src/test/AudioTest.cpp4
-rw-r--r--src/test/CMakeLists.txt1
-rw-r--r--src/test/ParticleTest.cpp2
4 files changed, 37 insertions, 3 deletions
diff --git a/src/test/AssetTest.cpp b/src/test/AssetTest.cpp
new file mode 100644
index 0000000..c3ff158
--- /dev/null
+++ b/src/test/AssetTest.cpp
@@ -0,0 +1,33 @@
+#include "api/Config.h"
+#include <gtest/gtest.h>
+
+#include <crepe/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());
+}
+
diff --git a/src/test/AudioTest.cpp b/src/test/AudioTest.cpp
index 6e2706c..e181de9 100644
--- a/src/test/AudioTest.cpp
+++ b/src/test/AudioTest.cpp
@@ -1,9 +1,9 @@
-#include "system/AudioSystem.h"
#include <gtest/gtest.h>
#include <crepe/ComponentManager.h>
#include <crepe/api/AudioSource.h>
#include <crepe/api/GameObject.h>
+#include <crepe/system/AudioSystem.h>
using namespace std;
using namespace crepe;
@@ -17,7 +17,7 @@ public:
void SetUp() override {
auto & mgr = this->component_manager;
GameObject entity = mgr.new_object("name");
- entity.add_component<AudioSource>("../mwe/audio/sfx1.wav");
+ entity.add_component<AudioSource>("mwe/audio/sfx1.wav");
}
};
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 1a986bd..5ea90f7 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -4,5 +4,6 @@ target_sources(test_main PUBLIC
ScriptTest.cpp
ParticleTest.cpp
AudioTest.cpp
+ AssetTest.cpp
)
diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp
index 1a89e3a..cd2ec2a 100644
--- a/src/test/ParticleTest.cpp
+++ b/src/test/ParticleTest.cpp
@@ -29,7 +29,7 @@ public:
Color color(0, 0, 0, 0);
Sprite test_sprite = game_object.add_component<Sprite>(
- make_shared<Texture>("../asset/texture/img.png"), color,
+ make_shared<Texture>("asset/texture/img.png"), color,
FlipSettings{true, true});
game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{