summaryrefslogtreecommitdiffstats
path: root/src/test/dbconnectionpool_test.cpp
blob: cfef128462f7c18302fb497df6b6302c03d713d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <gtest/gtest.h>

#include "test/mixxxtest.h"

#include "database/mixxxdb.h"
#include "util/db/dbconnectionpooler.h"
#include "util/db/dbconnectionpooled.h"

#include "library/dao/settingsdao.h"

#include "util/assert.h"


class DbConnectionPoolTest : public MixxxTest {
  protected:
    DbConnectionPoolTest()
            : m_mixxxDb(config()) {
    }

  protected:
    const MixxxDb m_mixxxDb;
};

TEST_F(DbConnectionPoolTest, MoveSemantics) {
    mixxx::DbConnectionPooler p1(m_mixxxDb.connectionPool());
    EXPECT_TRUE(p1.isPooling());

    // Move construction
    mixxx::DbConnectionPooler p2(std::move(p1));
    EXPECT_FALSE(p1.isPooling());
    EXPECT_TRUE(p2.isPooling());

    // Move assignment
    p1 = std::move(p2);
    EXPECT_TRUE(p1.isPooling());
    EXPECT_FALSE(p2.isPooling());
}