From ab0b4923c4f49e7a28f6d17e994d3e013ca344bb Mon Sep 17 00:00:00 2001
From: Loek Le Blansch <loek@pipeframe.xyz>
Date: Thu, 14 Nov 2024 18:04:03 +0100
Subject: more WIP audio system + utilities

---
 src/test/AssetTest.cpp           |  2 +-
 src/test/CMakeLists.txt          |  2 ++
 src/test/OptionalRefTest.cpp     | 16 ++++++++++++++++
 src/test/ResourceManagerTest.cpp | 21 +++++++++++++++++++++
 4 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 src/test/OptionalRefTest.cpp
 create mode 100644 src/test/ResourceManagerTest.cpp

(limited to 'src/test')

diff --git a/src/test/AssetTest.cpp b/src/test/AssetTest.cpp
index 324a3f1..563a253 100644
--- a/src/test/AssetTest.cpp
+++ b/src/test/AssetTest.cpp
@@ -1,7 +1,7 @@
-#include "api/Config.h"
 #include <gtest/gtest.h>
 
 #include <crepe/api/Asset.h>
+#include <crepe/api/Config.h>
 
 using namespace std;
 using namespace crepe;
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 5ea90f7..437c296 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -5,5 +5,7 @@ target_sources(test_main PUBLIC
 	ParticleTest.cpp
 	AudioTest.cpp
 	AssetTest.cpp
+	ResourceManagerTest.cpp
+	OptionalRefTest.cpp
 )
 
diff --git a/src/test/OptionalRefTest.cpp b/src/test/OptionalRefTest.cpp
new file mode 100644
index 0000000..65bd816
--- /dev/null
+++ b/src/test/OptionalRefTest.cpp
@@ -0,0 +1,16 @@
+#include <gtest/gtest.h>
+
+#include <crepe/util/OptionalRef.h>
+
+using namespace std;
+using namespace crepe;
+using namespace testing;
+
+TEST(OptionalRefTest, Explicit) {
+	string value = "foo";
+	OptionalRef<string> ref;
+
+	EXPECT_FALSE(bool(ref));
+	ASSERT_THROW(ref.get(), runtime_error);
+}
+
diff --git a/src/test/ResourceManagerTest.cpp b/src/test/ResourceManagerTest.cpp
new file mode 100644
index 0000000..42b6b5d
--- /dev/null
+++ b/src/test/ResourceManagerTest.cpp
@@ -0,0 +1,21 @@
+#include <gtest/gtest.h>
+
+#include <crepe/api/ResourceManager.h>
+
+using namespace std;
+using namespace crepe;
+using namespace testing;
+
+class ResourceManagerTest : public Test {
+public:
+	ResourceManager & manager = ResourceManager::get_instance();
+
+	void SetUp() override {
+		this->manager.clear();
+	}
+};
+
+TEST_F(ResourceManagerTest, Main) {
+	Sound & sound = this->manager.cache<Sound>("mwe/audio/sfx1.wav");
+}
+
-- 
cgit v1.2.3