forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WriteLockTest.h
45 lines (38 loc) · 1.37 KB
/
WriteLockTest.h
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
38
39
40
41
42
43
44
45
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidKernel/WriteLock.h"
#include "MantidKernel/DataItem.h"
#include <cxxtest/TestSuite.h>
using namespace Mantid;
using namespace Mantid::Kernel;
class MockDataItem : public DataItem {
public:
const std::string id() const override { return "MockDataItem"; }
/// The name of the object
const std::string &getName() const override { return m_name; }
/// Can this object be accessed from multiple threads safely
bool threadSafe() const override { return true; }
/// Serializes the object to a string
const std::string toString() const override { return "Nothing"; }
friend class WriteLockTest;
private:
std::string m_name{"Noone"};
};
class WriteLockTest : public CxxTest::TestSuite {
public:
void test_Scoped_WriteLock() {
MockDataItem item;
WriteLock lock(item);
// Can't directly check the underlying lock object as it is private...
}
void test_new_doesNotCompile() {
MockDataItem item;
// The next line does not compile, which is what we want!
// WriteLock * lock = new WriteLock(item);
}
};