diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-29 17:30:45 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-29 17:30:45 +0100 |
commit | 693355f55193cb2ea4c29616073227e37665afc1 (patch) | |
tree | 37d2bd3e916b909fbac58ae836e8001166edf384 /src/test/PrivateTest.cpp | |
parent | c59d460f12e1393e0ddbaaa1c6f5522eb12f8ff9 (diff) |
more audio system WIP
Diffstat (limited to 'src/test/PrivateTest.cpp')
-rw-r--r-- | src/test/PrivateTest.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/test/PrivateTest.cpp b/src/test/PrivateTest.cpp index f0d2b1a..0ea67d6 100644 --- a/src/test/PrivateTest.cpp +++ b/src/test/PrivateTest.cpp @@ -64,3 +64,95 @@ TEST_F(PrivateTest, IncorrectTypeException) { 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); +} + |