From 3556ae250b65a5f287be7bc6c2495f7089511a1b Mon Sep 17 00:00:00 2001
From: Elliot Oram <Elliot.Oram@stfc.ac.uk>
Date: Wed, 5 Aug 2015 10:49:23 +0100
Subject: [PATCH] New empty case test added. Clang formatting throughout.

Refs #13300
---
 .../Kernel/src/StringContainsValidator.cpp    | 50 +++++++++----------
 .../Kernel/test/StringContainsValidatorTest.h | 14 +++++-
 2 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/Code/Mantid/Framework/Kernel/src/StringContainsValidator.cpp b/Code/Mantid/Framework/Kernel/src/StringContainsValidator.cpp
index d56eb4255f9..4bbeaf2fa01 100644
--- a/Code/Mantid/Framework/Kernel/src/StringContainsValidator.cpp
+++ b/Code/Mantid/Framework/Kernel/src/StringContainsValidator.cpp
@@ -31,33 +31,33 @@ void StringContainsValidator::setRequiredStrings(
  *  @return An empty string if the value is valid or an string containing
  *          a description of the error otherwise
  */
-std::string StringContainsValidator::checkValidity(const std::string &value) const {
-	std::string error("");
-	if(m_requiredStrings.empty() && !value.empty()){
-		return "";
-	}else{
-		if(value.empty()){
-			error += "A value must be entered for this parameter.\n";
-		}else{
-			int validityCount = 0;
-			const int total = m_requiredStrings.size();
-			for(int i = 0; i < total; i++){
-				auto position = value.find(m_requiredStrings.at(i));
-				if(position != std::string::npos){
-					validityCount++;
-				}
-			}
-			if(validityCount != total){
-				error += "Error not all the required substrings were contained within the input '" + value + "'.";
-			}
-		}
-	}
-	return error;
+std::string
+StringContainsValidator::checkValidity(const std::string &value) const {
+  std::string error("");
+  if (m_requiredStrings.empty() && !value.empty()) {
+    return "";
+  } else {
+    if (value.empty()) {
+      error += "A value must be entered for this parameter.";
+    } else {
+      int validityCount = 0;
+      const int total = m_requiredStrings.size();
+      for (int i = 0; i < total; i++) {
+        auto position = value.find(m_requiredStrings.at(i));
+        if (position != std::string::npos) {
+          validityCount++;
+        }
+      }
+      if (validityCount != total) {
+        error += "Error not all the required substrings were contained within "
+                 "the input '" +
+                 value + "'.";
+      }
+    }
+  }
+  return error;
 }
 
-
-
-
 /** Destructor
  */
 StringContainsValidator::~StringContainsValidator() {}
diff --git a/Code/Mantid/Framework/Kernel/test/StringContainsValidatorTest.h b/Code/Mantid/Framework/Kernel/test/StringContainsValidatorTest.h
index 583f10b3690..ac64416273b 100644
--- a/Code/Mantid/Framework/Kernel/test/StringContainsValidatorTest.h
+++ b/Code/Mantid/Framework/Kernel/test/StringContainsValidatorTest.h
@@ -55,7 +55,7 @@ public:
   }
 
   void
-  test_that_error_is_produced_if_string_does_not_contain_any_of_substrings() {
+  test_that_error_is_produced_if_string_does_not_contain_all_the_required_substrings() {
     StringContainsValidator validator;
     auto required = std::vector<std::string>();
     required.push_back("not");
@@ -69,7 +69,7 @@ public:
   }
 
   void
-  test_that_error_is_produced_if_string_does_not_contain_every_substrings() {
+  test_that_error_is_produced_if_string_only_contains_some_of_the_substrings() {
     StringContainsValidator validator;
     auto required = std::vector<std::string>();
     required.push_back("not");
@@ -90,6 +90,16 @@ public:
     const std::string input = "This, is a test string";
     TS_ASSERT_EQUALS("", validator.isValid(input));
   }
+
+  void test_that_an_empty_string_produces_an_error() {
+    StringContainsValidator validator;
+    auto required = std::vector<std::string>();
+    required.push_back(",");
+    validator.setRequiredStrings(required);
+    const std::string input = "";
+    const std::string error = "A value must be entered for this parameter.";
+    TS_ASSERT_EQUALS(error, validator.isValid(input));
+  }
 };
 
 #endif /* MANTID_KERNEL_STRINGCONTAINSVALIDATORTEST_H_ */
\ No newline at end of file
-- 
GitLab