Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SingletonTest.cpp « mert - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 36acbeec29d55ee04d14df22f906a3b0dbc15026 (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
#include "Singleton.h"

#define BOOST_TEST_MODULE MertSingleton
#include <boost/test/unit_test.hpp>

using namespace MosesTuning;

namespace
{

static int g_count = 0;

class Instance
{
public:
  Instance() {
    ++g_count;
  }
  ~Instance() {}
};

} // namespace

BOOST_AUTO_TEST_CASE(singleton_basic)
{
  Instance* instance1 = Singleton<Instance>::GetInstance();
  Instance* instance2 = Singleton<Instance>::GetInstance();
  Instance* instance3 = Singleton<Instance>::GetInstance();
  BOOST_REQUIRE(instance1 == instance2);
  BOOST_REQUIRE(instance2 == instance3);
  BOOST_CHECK_EQUAL(1, g_count);

  Singleton<Instance>::Delete();
}