-
Notifications
You must be signed in to change notification settings - Fork 122
/
ValidatorSignalChangeTest.h
47 lines (38 loc) · 1.47 KB
/
ValidatorSignalChangeTest.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
46
47
#ifndef MANTID_KERNEL_SIGNALCHANGETEST_H_
#define MANTID_KERNEL_SIGNALCHANGETEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/ValidatorSignalChange.h"
#include "MantidKernel/PropertyWithValue.h"
using namespace Mantid;
using namespace Mantid::Kernel;
void actOnPropertyChange(const Property *pProp)
{
int middle_val(1);
int new_val = boost::lexical_cast<int>(pProp->value());
if (new_val>middle_val){
throw(" new prop is bigger");
}else{
throw(std::string(" new prop is smaller"));
}
};
class SignalChangeTest : public CxxTest::TestSuite
{
public:
void test_SendSignal()
{
PropertyWithValue<int> *ipProp = new PropertyWithValue<int>("intProp", 1);
ValidatorSignalChange<int> * pValC = new ValidatorSignalChange<int>(ipProp);
pValC->connect(&actOnPropertyChange);
ipProp->setValue("2");
// value provided to validator function is irrelevant here, as check occurs on ipProp and the number is just to keep the function signaturel
TSM_ASSERT_THROWS("should throw a pointer to ""new prop is bigger""",pValC->isValid(2),const char *);
//
ipProp->setValue("0");
// value provided to validator function is irrelevant here, as check occurs on ipProp and the number is just to keep the function signaturel
TSM_ASSERT_THROWS("should throw a pointer to ""new prop is smaller""",pValC->isValid(2),std::string);
//
delete ipProp;
delete pValC;
}
};
#endif /* MANTID_KERNEL_SIGNALCHANGETEST_H_ */