Skip to content

Commit

Permalink
Re #11035. Applied clang-format corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Oct 15, 2015
1 parent ffe2db5 commit e531389
Show file tree
Hide file tree
Showing 29 changed files with 119 additions and 135 deletions.
2 changes: 1 addition & 1 deletion Framework/API/inc/MantidAPI/CommonBinsValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Mantid {
namespace API {

/**
/**
A validator which provides a <I>TENTATIVE</I> check that a workspace
contains common bins in each spectrum.
For efficiency reasons, it only checks that the first and last spectra have
Expand Down
2 changes: 1 addition & 1 deletion Framework/API/inc/MantidAPI/HistogramValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Mantid {
namespace API {

/**
/**
A validator which checks that a workspace contains histogram data (the
default) or point data as required.
Expand Down
3 changes: 1 addition & 2 deletions Framework/API/inc/MantidAPI/IncreasingAxisValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Mantid {
namespace API {

/**
/**
A validator which checks that the X axis of a workspace is increasing from
left to right.
Expand Down Expand Up @@ -43,7 +43,6 @@ class MANTID_API_DLL IncreasingAxisValidator : public MatrixWorkspaceValidator {
std::string checkValidity(const MatrixWorkspace_sptr &value) const;
};


} // namespace API
} // namespace Mantid

Expand Down
1 change: 0 additions & 1 deletion Framework/API/inc/MantidAPI/InstrumentValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class MANTID_API_DLL InstrumentValidator
unsigned int m_requires;
};


} // namespace API
} // namespace Mantid

Expand Down
1 change: 0 additions & 1 deletion Framework/API/inc/MantidAPI/MatrixWorkspaceValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace API {
class MANTID_API_DLL MatrixWorkspaceValidator
: public Kernel::TypedValidator<MatrixWorkspace_sptr> {};


} // namespace API
} // namespace Mantid

Expand Down
1 change: 0 additions & 1 deletion Framework/API/inc/MantidAPI/NumericAxisValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class MANTID_API_DLL NumericAxisValidator : public MatrixWorkspaceValidator {
const int m_axisNumber;
};


} // namespace API
} // namespace Mantid

Expand Down
1 change: 0 additions & 1 deletion Framework/API/inc/MantidAPI/RawCountValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class MANTID_API_DLL RawCountValidator : public MatrixWorkspaceValidator {
const bool m_mustNotBeDistribution;
};


} // namespace API
} // namespace Mantid

Expand Down
1 change: 0 additions & 1 deletion Framework/API/inc/MantidAPI/SampleValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class MANTID_API_DLL SampleValidator : public MatrixWorkspaceValidator {
unsigned int m_requires;
};


} // namespace API
} // namespace Mantid

Expand Down
3 changes: 1 addition & 2 deletions Framework/API/inc/MantidAPI/WorkspaceUnitValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Mantid {
namespace API {

/**
/**
A validator which checks that the unit of the workspace referred to
by a WorkspaceProperty is the expected one.
Expand Down Expand Up @@ -47,7 +47,6 @@ class MANTID_API_DLL WorkspaceUnitValidator : public MatrixWorkspaceValidator {
const std::string m_unitID;
};


} // namespace API
} // namespace Mantid

Expand Down
3 changes: 2 additions & 1 deletion Framework/API/src/CommonBinsValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Kernel::IValidator_sptr CommonBinsValidator::clone() const {
* @param value :: The workspace to test
* @return A message for users saying that bins are different, otherwise ""
*/
std::string CommonBinsValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
std::string
CommonBinsValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
if (!value)
return "Enter an existing workspace";
if (value->isCommonBins())
Expand Down
5 changes: 3 additions & 2 deletions Framework/API/src/HistogramValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace API {
* (false).
*/
HistogramValidator::HistogramValidator(const bool &mustBeHistogram)
: MatrixWorkspaceValidator(), m_mustBeHistogram(mustBeHistogram) {}
: MatrixWorkspaceValidator(), m_mustBeHistogram(mustBeHistogram) {}

/// Clone the current state
Kernel::IValidator_sptr HistogramValidator::clone() const {
Expand All @@ -23,7 +23,8 @@ Kernel::IValidator_sptr HistogramValidator::clone() const {
* @param value :: The workspace to test
* @return A user level description if a problem exists or ""
*/
std::string HistogramValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
std::string
HistogramValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
if (m_mustBeHistogram) {
if (value->isHistogramData())
return "";
Expand Down
5 changes: 3 additions & 2 deletions Framework/API/src/IncreasingAxisValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Kernel::IValidator_sptr IncreasingAxisValidator::clone() const {
* @param value The workspace to check
* @return "" if is valid, otherwise a user level description of a problem
*/
std::string IncreasingAxisValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
std::string IncreasingAxisValidator::checkValidity(
const MatrixWorkspace_sptr &value) const {
// 0 for X axis
Axis *xAxis = value->getAxis(0);

Expand All @@ -24,7 +25,7 @@ std::string IncreasingAxisValidator::checkValidity(const MatrixWorkspace_sptr &v
if (xAxis->length() > 1 &&
xAxis->getValue(0) >= xAxis->getValue(xAxis->length() - 1))
return "X axis of the workspace should be increasing from left to "
"right";
"right";
else
return "";
}
Expand Down
6 changes: 4 additions & 2 deletions Framework/API/src/NumericAxisValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace API {
/** Class constructor with parameter.
* @param axisNumber :: set the axis number to validate
*/
NumericAxisValidator::NumericAxisValidator(const int &axisNumber) : m_axisNumber(axisNumber) {}
NumericAxisValidator::NumericAxisValidator(const int &axisNumber)
: m_axisNumber(axisNumber) {}

/// Clone the current state
Kernel::IValidator_sptr NumericAxisValidator::clone() const {
Expand All @@ -18,7 +19,8 @@ Kernel::IValidator_sptr NumericAxisValidator::clone() const {
* @param value :: The workspace to test
* @return A message for users with negative results, otherwise ""
*/
std::string NumericAxisValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
std::string
NumericAxisValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
Mantid::API::Axis *axis = value->getAxis(m_axisNumber);
if (axis->isNumeric())
return "";
Expand Down
6 changes: 4 additions & 2 deletions Framework/API/src/RawCountValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace API {

/** Constructor
* @param mustNotBeDistribution :: Flag indicating whether the check is that
* a workspace should not be a distribution (true, default) or should be (false).
* a workspace should not be a distribution (true, default) or should be
* (false).
*/
RawCountValidator::RawCountValidator(const bool &mustNotBeDistribution)
: m_mustNotBeDistribution(mustNotBeDistribution) {}
Expand All @@ -21,7 +22,8 @@ Kernel::IValidator_sptr RawCountValidator::clone() const {
* @return A user level description of any problem that exists or "" no
* problem
*/
std::string RawCountValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
std::string
RawCountValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
if (m_mustNotBeDistribution) {
if (!value->isDistribution())
return "";
Expand Down
6 changes: 4 additions & 2 deletions Framework/API/src/SpectraAxisValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace API {
/** Class constructor with parameter.
* @param axisNumber :: set the axis number to validate
*/
SpectraAxisValidator::SpectraAxisValidator(const int &axisNumber) : m_axisNumber(axisNumber) {}
SpectraAxisValidator::SpectraAxisValidator(const int &axisNumber)
: m_axisNumber(axisNumber) {}

/// Clone the current validator
Kernel::IValidator_sptr SpectraAxisValidator::clone() const {
Expand All @@ -18,7 +19,8 @@ Kernel::IValidator_sptr SpectraAxisValidator::clone() const {
* @param value :: The workspace to test
* @return A message for users with negative results, otherwise ""
*/
std::string SpectraAxisValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
std::string
SpectraAxisValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
Mantid::API::Axis *axis = value->getAxis(m_axisNumber);
if (axis->isSpectra())
return "";
Expand Down
17 changes: 9 additions & 8 deletions Framework/API/src/WorkspaceUnitValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace API {
WorkspaceUnitValidator::WorkspaceUnitValidator(const std::string &unitID)
: MatrixWorkspaceValidator(), m_unitID(unitID) {}

/**
/**
* Clone the current state
*/
Kernel::IValidator_sptr WorkspaceUnitValidator::clone() const {
Expand All @@ -27,26 +27,27 @@ Kernel::IValidator_sptr WorkspaceUnitValidator::clone() const {
* @param value :: The workspace to test
* @return A user level description of the error or "" for no error
*/
std::string WorkspaceUnitValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
std::string
WorkspaceUnitValidator::checkValidity(const MatrixWorkspace_sptr &value) const {
// This effectively checks for single-valued workspaces
if (value->axes() == 0)
return "A single valued workspace has no unit, which is required for "
"this algorithm";
"this algorithm";

Kernel::Unit_const_sptr unit = value->getAxis(0)->unit();
// If m_unitID is empty it means that the workspace must have units, which
// can be anything
if (m_unitID.empty()) {
return (unit && (!boost::dynamic_pointer_cast<const Kernel::Units::Empty>(
unit))
? ""
: "The workspace must have units");
return (
unit && (!boost::dynamic_pointer_cast<const Kernel::Units::Empty>(unit))
? ""
: "The workspace must have units");
}
// now check if the units of the workspace is correct
else {
if ((!unit) || (unit->unitID().compare(m_unitID))) {
return "The workspace must have units of " +
m_unitID; //+ "; its unit is: " + unit->caption();
m_unitID; //+ "; its unit is: " + unit->caption();
} else
return "";
}
Expand Down
46 changes: 21 additions & 25 deletions Framework/API/test/CommonBinsValidatorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,49 @@ class CommonBinsValidatorTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static CommonBinsValidatorTest *createSuite() { return new CommonBinsValidatorTest(); }
static void destroySuite( CommonBinsValidatorTest *suite ) { delete suite; }
static CommonBinsValidatorTest *createSuite() {
return new CommonBinsValidatorTest();
}
static void destroySuite(CommonBinsValidatorTest *suite) { delete suite; }

void test_empty()
{
void test_empty() {
auto ws = boost::make_shared<WorkspaceTester>();
CommonBinsValidator validator;
TS_ASSERT_EQUALS(validator.isValid(ws), "");
}

void xtest_zero_length_bins()
{
void xtest_zero_length_bins() {
auto ws = boost::make_shared<WorkspaceTester>();
ws->init(2, 11, 10);
CommonBinsValidator validator;
TS_ASSERT_EQUALS(validator.isValid(ws), "");
}

void test_common_bins()
{
void test_common_bins() {
auto ws = boost::make_shared<WorkspaceTester>();
ws->init(3, 11, 10);
for(size_t k = 0; k < 3; ++k)
for(size_t i = 0; i < 11; ++i)
{
auto di = double(i);
ws->dataX(k)[i] = di * (1.0 + 0.001 * di);
}
for (size_t k = 0; k < 3; ++k)
for (size_t i = 0; i < 11; ++i) {
auto di = double(i);
ws->dataX(k)[i] = di * (1.0 + 0.001 * di);
}
CommonBinsValidator validator;
TS_ASSERT_EQUALS(validator.isValid(ws), "");
}

void test_diff_bins()
{
void test_diff_bins() {
auto ws = boost::make_shared<WorkspaceTester>();
ws->init(3, 11, 10);
for(size_t k = 0; k < 3; ++k)
for(size_t i = 0; i < 11; ++i)
{
auto di = double(i + k);
ws->dataX(k)[i] = di * (1.0 + 0.001 * di);
}
for (size_t k = 0; k < 3; ++k)
for (size_t i = 0; i < 11; ++i) {
auto di = double(i + k);
ws->dataX(k)[i] = di * (1.0 + 0.001 * di);
}
CommonBinsValidator validator;
TS_ASSERT_EQUALS(validator.isValid(ws), "The workspace must have common bin boundaries for all histograms");
TS_ASSERT_EQUALS(
validator.isValid(ws),
"The workspace must have common bin boundaries for all histograms");
}

};


#endif /* MANTID_API_COMMONBINSVALIDATORTEST_H_ */
19 changes: 8 additions & 11 deletions Framework/API/test/HistogramValidatorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,25 @@ class HistogramValidatorTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static HistogramValidatorTest *createSuite() { return new HistogramValidatorTest(); }
static void destroySuite( HistogramValidatorTest *suite ) { delete suite; }

static HistogramValidatorTest *createSuite() {
return new HistogramValidatorTest();
}
static void destroySuite(HistogramValidatorTest *suite) { delete suite; }

void test_success()
{
void test_success() {
auto ws = boost::make_shared<WorkspaceTester>();
ws->init(2, 11, 10);
HistogramValidator validator;
TS_ASSERT_EQUALS(validator.isValid(ws), "");
}

void test_fail()
{
void test_fail() {
auto ws = boost::make_shared<WorkspaceTester>();
ws->init(2, 10, 10);
HistogramValidator validator;
TS_ASSERT_EQUALS(validator.isValid(ws), "The workspace must contain histogram data");
TS_ASSERT_EQUALS(validator.isValid(ws),
"The workspace must contain histogram data");
}


};


#endif /* MANTID_API_HISTOGRAMVALIDATORTEST_H_ */
22 changes: 11 additions & 11 deletions Framework/API/test/InstrumentValidatorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ class InstrumentValidatorTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static InstrumentValidatorTest *createSuite() { return new InstrumentValidatorTest(); }
static void destroySuite( InstrumentValidatorTest *suite ) { delete suite; }
static InstrumentValidatorTest *createSuite() {
return new InstrumentValidatorTest();
}
static void destroySuite(InstrumentValidatorTest *suite) { delete suite; }

void test_success()
{
void test_success() {
auto ws = boost::make_shared<WorkspaceTester>();
auto instr = boost::make_shared<Mantid::Geometry::Instrument>("TestInstrument");
auto instr =
boost::make_shared<Mantid::Geometry::Instrument>("TestInstrument");
ws->setInstrument(instr);
// Define a sample as a simple sphere
auto sample = new Mantid::Geometry::ObjComponent(
Expand All @@ -35,15 +37,13 @@ class InstrumentValidatorTest : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(validator.checkValidity(ws), "");
}

void test_fail()
{
void test_fail() {
auto ws = boost::make_shared<WorkspaceTester>();
InstrumentValidator validator;
TS_ASSERT_EQUALS(validator.checkValidity(ws), "The instrument is missing the following components: sample holder");
TS_ASSERT_EQUALS(
validator.checkValidity(ws),
"The instrument is missing the following components: sample holder");
}


};


#endif /* MANTID_API_INSTRUMENTVALIDATORTEST_H_ */

0 comments on commit e531389

Please sign in to comment.