aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/AudioTest.cpp8
-rw-r--r--src/test/CMakeLists.txt1
-rw-r--r--src/test/PrivateTest.cpp155
3 files changed, 4 insertions, 160 deletions
diff --git a/src/test/AudioTest.cpp b/src/test/AudioTest.cpp
index 7644ab7..774fdb8 100644
--- a/src/test/AudioTest.cpp
+++ b/src/test/AudioTest.cpp
@@ -16,10 +16,10 @@ class AudioTest : public Test {
private:
class TestSoundContext : public SoundContext {
public:
- MOCK_METHOD(Sound::Handle, play, (Sound & resource), (override));
- MOCK_METHOD(void, stop, (Sound::Handle &), (override));
- MOCK_METHOD(void, set_volume, (Sound::Handle &, float), (override));
- MOCK_METHOD(void, set_loop, (Sound::Handle &, bool), (override));
+ MOCK_METHOD(SoundHandle, play, (Sound & resource), (override));
+ MOCK_METHOD(void, stop, (const SoundHandle &), (override));
+ MOCK_METHOD(void, set_volume, (const SoundHandle &, float), (override));
+ MOCK_METHOD(void, set_loop, (const SoundHandle &, bool), (override));
};
class TestAudioSystem : public AudioSystem {
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 8c4b855..4174926 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -16,5 +16,4 @@ target_sources(test_main PUBLIC
Vector2Test.cpp
ScriptEventTest.cpp
ScriptSceneTest.cpp
- PrivateTest.cpp
)
diff --git a/src/test/PrivateTest.cpp b/src/test/PrivateTest.cpp
deleted file mode 100644
index 454789e..0000000
--- a/src/test/PrivateTest.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-#include <gtest/gtest.h>
-
-#include <crepe/util/Private.h>
-
-using namespace std;
-using namespace crepe;
-using namespace testing;
-
-class PrivateTest : public Test {
-public:
- static unsigned constructors;
- static unsigned destructors;
-
- void SetUp() override {
- PrivateTest::constructors = 0;
- PrivateTest::destructors = 0;
- }
-
- class TestClass {
- public:
- TestClass() { PrivateTest::constructors++; }
- ~TestClass() { PrivateTest::destructors++; }
- };
- class Unrelated {};
-};
-unsigned PrivateTest::constructors;
-unsigned PrivateTest::destructors;
-
-TEST_F(PrivateTest, Empty) {
- { Private foo; }
-
- EXPECT_EQ(PrivateTest::constructors, 0);
- EXPECT_EQ(PrivateTest::destructors, 0);
-}
-
-TEST_F(PrivateTest, WithObject) {
- {
- Private foo;
- foo.set<TestClass>();
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
- }
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 1);
-}
-
-TEST_F(PrivateTest, EmptyException) {
- Private foo;
- EXPECT_THROW(foo.get<TestClass>(), std::out_of_range);
-
- foo.set<TestClass>();
- EXPECT_NO_THROW(foo.get<TestClass>());
-}
-
-TEST_F(PrivateTest, IncorrectTypeException) {
- Private foo;
- foo.set<TestClass>();
-
- EXPECT_THROW(foo.get<Unrelated>(), std::logic_error);
- EXPECT_NO_THROW(foo.get<TestClass>());
-}
-
-TEST_F(PrivateTest, MoveConstructor) {
- {
- Private foo;
- foo.set<TestClass>();
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
-
- Private bar(std::move(foo));
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
- }
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 1);
-}
-
-TEST_F(PrivateTest, MoveOperator) {
- {
- Private foo;
- foo.set<TestClass>();
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
-
- Private bar = std::move(foo);
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
- }
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 1);
-}
-
-TEST_F(PrivateTest, CopyConstructor) {
- {
- Private foo;
- foo.set<TestClass>();
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
-
- Private bar(foo);
-
- EXPECT_TRUE(bar.empty());
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
- }
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 1);
-}
-
-TEST_F(PrivateTest, CopyOperator) {
- {
- Private foo;
- foo.set<TestClass>();
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
-
- Private bar = foo;
-
- EXPECT_TRUE(bar.empty());
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
- }
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 1);
-}
-
-TEST_F(PrivateTest, DoubleAssignment) {
- {
- Private foo;
- foo.set<TestClass>();
-
- EXPECT_EQ(PrivateTest::constructors, 1);
- EXPECT_EQ(PrivateTest::destructors, 0);
-
- foo.set<TestClass>();
-
- EXPECT_EQ(PrivateTest::constructors, 2);
- EXPECT_EQ(PrivateTest::destructors, 1);
- }
-
- EXPECT_EQ(PrivateTest::constructors, 2);
- EXPECT_EQ(PrivateTest::destructors, 2);
-}