From 274192974d95fe0ec0ae0135ad9acf372c651570 Mon Sep 17 00:00:00 2001 From: Nick Draper <nick.draper@stfc.ac.uk> Date: Tue, 4 Jul 2017 12:02:31 +0100 Subject: [PATCH] clang format re #15164 --- .../Kernel/inc/MantidKernel/PropertyHelper.h | 27 +++--- Framework/Kernel/inc/MantidKernel/Strings.h | 14 ++-- Framework/Kernel/test/ArrayPropertyTest.h | 83 ++++++++----------- Framework/Kernel/test/StringsTest.h | 22 ++--- 4 files changed, 65 insertions(+), 81 deletions(-) diff --git a/Framework/Kernel/inc/MantidKernel/PropertyHelper.h b/Framework/Kernel/inc/MantidKernel/PropertyHelper.h index bb22da4b44e..9eb129f5821 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyHelper.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyHelper.h @@ -33,35 +33,36 @@ template <typename T> std::string toString(const boost::shared_ptr<T> &value) { * This simply concatenates the values using a delimiter */ template <typename T> -std::string toString(const std::vector<T> &value, - const std::string &delimiter = ",", - typename std::enable_if<!(std::is_integral<T>::value && std::is_arithmetic<T>::value)>::type* = 0) { +std::string +toString(const std::vector<T> &value, const std::string &delimiter = ",", + typename std::enable_if<!(std::is_integral<T>::value && + std::is_arithmetic<T>::value)>::type * = 0) { return Strings::join(value.begin(), value.end(), delimiter); } /** Specialization for a property of type std::vector of integral types. -* This will catch Vectors of int, long, long long etc +* This will catch Vectors of int, long, long long etc * including signed and unsigned types of these. -* This concatenates the values using a delimiter, -* adjacent items that are precisely 1 away from each other +* This concatenates the values using a delimiter, +* adjacent items that are precisely 1 away from each other * will be compressed into a list syntax e.g. 1-5. */ template <typename T> -std::string toString(const std::vector<T> &value, - const std::string &delimiter = ",", - typename std::enable_if<std::is_integral<T>::value && std::is_arithmetic<T>::value>::type* = 0) { +std::string +toString(const std::vector<T> &value, const std::string &delimiter = ",", + typename std::enable_if<std::is_integral<T>::value && + std::is_arithmetic<T>::value>::type * = 0) { return Strings::joinCompress(value.begin(), value.end(), delimiter, "-"); } - /** Explicit specialization for a property of type std::vector<bool>. * This will catch Vectors of char, double, float etc. * This simply concatenates the values using a delimiter */ template <> -std::string toString(const std::vector<bool> &value, - const std::string &delimiter, - typename std::enable_if<std::is_same<bool,bool>::value>::type*) { +std::string +toString(const std::vector<bool> &value, const std::string &delimiter, + typename std::enable_if<std::is_same<bool, bool>::value>::type *) { return Strings::join(value.begin(), value.end(), delimiter); } diff --git a/Framework/Kernel/inc/MantidKernel/Strings.h b/Framework/Kernel/inc/MantidKernel/Strings.h index b08da50d4f4..086d992cce4 100644 --- a/Framework/Kernel/inc/MantidKernel/Strings.h +++ b/Framework/Kernel/inc/MantidKernel/Strings.h @@ -73,8 +73,8 @@ DLLExport std::string join(ITERATOR_TYPE begin, ITERATOR_TYPE end, //------------------------------------------------------------------------------------------------ /** Join a set or vector of (something that turns into a string) together -* into one string, separated by a separator, -* adjacent items that are precisely 1 away from each other +* into one string, separated by a separator, +* adjacent items that are precisely 1 away from each other * will be compressed into a list syntax e.g. 1-5. * Returns an empty string if the range is null. * Does not add the separator after the LAST item. @@ -90,8 +90,8 @@ DLLExport std::string join(ITERATOR_TYPE begin, ITERATOR_TYPE end, */ template <typename ITERATOR_TYPE> DLLExport std::string joinCompress(ITERATOR_TYPE begin, ITERATOR_TYPE end, - const std::string &separator = ",", - const std::string &listSeparator = "-") { + const std::string &separator = ",", + const std::string &listSeparator = "-") { std::stringstream result; @@ -101,15 +101,15 @@ DLLExport std::string joinCompress(ITERATOR_TYPE begin, ITERATOR_TYPE end, for (i = begin; i != end;) { // was this one higher than the last value if (i == begin) { - //Special case, always include the first value + // Special case, always include the first value result << *i; } else { - //if it is one higher than the last value + // if it is one higher than the last value if (*i == (*previousValue + 1)) { currentSeparator = listSeparator; } else { if (currentSeparator == listSeparator) { - //add the last value that was the end of the list + // add the last value that was the end of the list result << currentSeparator; result << *previousValue; currentSeparator = separator; diff --git a/Framework/Kernel/test/ArrayPropertyTest.h b/Framework/Kernel/test/ArrayPropertyTest.h index a55aa5a06fa..7a14e268c7a 100644 --- a/Framework/Kernel/test/ArrayPropertyTest.h +++ b/Framework/Kernel/test/ArrayPropertyTest.h @@ -27,7 +27,7 @@ public: TS_ASSERT(typeid(std::vector<int>) == *iProp->type_info()) TS_ASSERT(iProp->isDefault()) TS_ASSERT(iProp->operator()().empty()); - + TS_ASSERT(!dProp->name().compare("doubleProp")) TS_ASSERT(!dProp->documentation().compare("")) TS_ASSERT(typeid(std::vector<double>) == *dProp->type_info()) @@ -303,65 +303,52 @@ public: void testListShortening() { std::vector<std::string> inputList{ - "1,2,3", - "-1,0,1", - "356,366,367,368,370,371,372,375", - "7,6,5,6,7,8,10", - "1-9998, 9999, 2000, 20002-29999" - }; - std::vector<std::string> resultList{ - "1-3", - "-1-1", - "356,366-368,370-372,375", - "7,6,5-8,10", - "1-9999,2000,20002-29999" - }; - - TSM_ASSERT("Test Failed for vectors of int", listShorteningwithType<int>(inputList, resultList)); - TSM_ASSERT("Test Failed for vectors of long", listShorteningwithType<long>(inputList, resultList)); - TSM_ASSERT("Test Failed for vectors of long long", listShorteningwithType<long long>(inputList, resultList)); + "1,2,3", "-1,0,1", "356,366,367,368,370,371,372,375", "7,6,5,6,7,8,10", + "1-9998, 9999, 2000, 20002-29999"}; + std::vector<std::string> resultList{"1-3", "-1-1", + "356,366-368,370-372,375", "7,6,5-8,10", + "1-9999,2000,20002-29999"}; + + TSM_ASSERT("Test Failed for vectors of int", + listShorteningwithType<int>(inputList, resultList)); + TSM_ASSERT("Test Failed for vectors of long", + listShorteningwithType<long>(inputList, resultList)); + TSM_ASSERT("Test Failed for vectors of long long", + listShorteningwithType<long long>(inputList, resultList)); // explicit test for in32_t with matches det_id_t and spec_id_t - TSM_ASSERT("Test Failed for vectors of int32_t", listShorteningwithType<int32_t>(inputList, resultList)); + TSM_ASSERT("Test Failed for vectors of int32_t", + listShorteningwithType<int32_t>(inputList, resultList)); - //unsigned types + // unsigned types std::vector<std::string> inputListUnsigned{ - "1,2,3", - "356,366,367,368,370,371,372,375", - "7,6,5,6,7,8,10", - "1-9998, 9999, 2000, 20002-29999" - }; + "1,2,3", "356,366,367,368,370,371,372,375", "7,6,5,6,7,8,10", + "1-9998, 9999, 2000, 20002-29999"}; std::vector<std::string> resultListUnsigned{ - "1-3", - "356,366-368,370-372,375", - "7,6,5-8,10", - "1-9999,2000,20002-29999" - }; - TSM_ASSERT("Test Failed for vectors of unsigned int", - listShorteningwithType<unsigned int>(inputListUnsigned, resultListUnsigned)); - TSM_ASSERT("Test Failed for vectors of size_t", - listShorteningwithType<size_t>(inputListUnsigned, resultListUnsigned)); - - //check shortening does not happen for floating point types + "1-3", "356,366-368,370-372,375", "7,6,5-8,10", + "1-9999,2000,20002-29999"}; + TSM_ASSERT("Test Failed for vectors of unsigned int", + listShorteningwithType<unsigned int>(inputListUnsigned, + resultListUnsigned)); + TSM_ASSERT( + "Test Failed for vectors of size_t", + listShorteningwithType<size_t>(inputListUnsigned, resultListUnsigned)); + + // check shortening does not happen for floating point types std::vector<std::string> inputListFloat{ - "1.0,2.0,3.0", - "1.0,1.5,2.0,3.0", - "-1,0,1", + "1.0,2.0,3.0", "1.0,1.5,2.0,3.0", "-1,0,1", }; std::vector<std::string> resultListFloat{ - "1,2,3", - "1,1.5,2,3", - "-1,0,1", + "1,2,3", "1,1.5,2,3", "-1,0,1", }; TSM_ASSERT("Test Failed for vectors of float", - listShorteningwithType<float>(inputListFloat, resultListFloat)); + listShorteningwithType<float>(inputListFloat, resultListFloat)); TSM_ASSERT("Test Failed for vectors of double", - listShorteningwithType<double>(inputListFloat, resultListFloat)); - + listShorteningwithType<double>(inputListFloat, resultListFloat)); } - + template <typename T> - bool listShorteningwithType(const std::vector<std::string>& inputList, - const std::vector<std::string>& resultList) { + bool listShorteningwithType(const std::vector<std::string> &inputList, + const std::vector<std::string> &resultList) { bool success = true; for (size_t i = 0; i < inputList.size(); i++) { diff --git a/Framework/Kernel/test/StringsTest.h b/Framework/Kernel/test/StringsTest.h index d3dcc1ef92c..f6429f13cd1 100644 --- a/Framework/Kernel/test/StringsTest.h +++ b/Framework/Kernel/test/StringsTest.h @@ -270,23 +270,19 @@ public: void test_joinCompress() { std::vector<std::vector<int>> inputList{ - {1,2,3}, - {-1,0,1}, - {356,366,367,368,370,371,372,375}, - {7,6,5,6,7,8,10} - }; + {1, 2, 3}, + {-1, 0, 1}, + {356, 366, 367, 368, 370, 371, 372, 375}, + {7, 6, 5, 6, 7, 8, 10}}; std::vector<std::string> resultList{ - "1-3", - "-1-1", - "356,366-368,370-372,375", - "7,6,5-8,10" - }; + "1-3", "-1-1", "356,366-368,370-372,375", "7,6,5-8,10"}; for (size_t i = 0; i < inputList.size(); i++) { - const auto& inputVector = inputList[i]; - TS_ASSERT_EQUALS(joinCompress(inputVector.begin(), inputVector.end(),",","-"), resultList[i]); + const auto &inputVector = inputList[i]; + TS_ASSERT_EQUALS( + joinCompress(inputVector.begin(), inputVector.end(), ",", "-"), + resultList[i]); } - } void test_endsWithInt() { -- GitLab