Browse Source

stringapi: Use strings for test names

Ben Boeckel 11 years ago
parent
commit
83a5e453f8

+ 2 - 3
Source/cmCTest.cxx

@@ -2126,7 +2126,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
   if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1)
     {
     i++;
-    this->AddCTestConfigurationOverwrite(args[i].c_str());
+    this->AddCTestConfigurationOverwrite(args[i]);
     }
   if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1)
     {
@@ -2840,9 +2840,8 @@ void cmCTest::AddSubmitFile(Part part, const char* name)
 }
 
 //----------------------------------------------------------------------
-void cmCTest::AddCTestConfigurationOverwrite(const char* encstr)
+void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr)
 {
-  std::string overStr = encstr;
   size_t epos = overStr.find("=");
   if ( epos == overStr.npos )
     {

+ 3 - 3
Source/cmCTest.h

@@ -70,8 +70,8 @@ public:
   {
     PartInfo(): Enabled(false) {}
 
-    void SetName(const char* name) { this->Name = name; }
-    const char* GetName() const { return this->Name.c_str(); }
+    void SetName(const std::string& name) { this->Name = name; }
+    const std::string& GetName() const { return this->Name; }
 
     void Enable() { this->Enabled = true; }
     operator bool() const { return this->Enabled; }
@@ -349,7 +349,7 @@ public:
 
   //! Add overwrite to ctest configuration.
   // The format is key=value
-  void AddCTestConfigurationOverwrite(const char* encstr);
+  void AddCTestConfigurationOverwrite(const std::string& encstr);
 
   //! Create XML file that contains all the notes specified
   int GenerateNotesFile(const std::vector<cmStdString> &files);

+ 7 - 14
Source/cmMakefile.cxx

@@ -3852,34 +3852,27 @@ cmTarget* cmMakefile::FindTarget(const std::string& name,
 }
 
 //----------------------------------------------------------------------------
-cmTest* cmMakefile::CreateTest(const char* testName)
+cmTest* cmMakefile::CreateTest(const std::string& testName)
 {
-  if ( !testName )
-    {
-    return 0;
-    }
   cmTest* test = this->GetTest(testName);
   if ( test )
     {
     return test;
     }
   test = new cmTest(this);
-  test->SetName(testName);
+  test->SetName(testName.c_str());
   this->Tests[testName] = test;
   return test;
 }
 
 //----------------------------------------------------------------------------
-cmTest* cmMakefile::GetTest(const char* testName) const
+cmTest* cmMakefile::GetTest(const std::string& testName) const
 {
-  if(testName)
+  std::map<cmStdString, cmTest*>::const_iterator
+    mi = this->Tests.find(testName);
+  if(mi != this->Tests.end())
     {
-    std::map<cmStdString, cmTest*>::const_iterator
-      mi = this->Tests.find(testName);
-    if(mi != this->Tests.end())
-      {
-      return mi->second;
-      }
+    return mi->second;
     }
   return 0;
 }

+ 2 - 2
Source/cmMakefile.h

@@ -782,12 +782,12 @@ public:
   void AddMacro(const char* name, const char* signature);
 
   ///! Add a new cmTest to the list of tests for this makefile.
-  cmTest* CreateTest(const char* testName);
+  cmTest* CreateTest(const std::string& testName);
 
   /** Get a cmTest pointer for a given test name, if the name is
    *  not found, then a null pointer is returned.
    */
-  cmTest* GetTest(const char* testName) const;
+  cmTest* GetTest(const std::string& testName) const;
 
   /**
    * Get a list of macros as a ; separated string

+ 1 - 1
Source/cmSetTestsPropertiesCommand.cxx

@@ -91,7 +91,7 @@ bool cmSetTestsPropertiesCommand
 
 
 bool cmSetTestsPropertiesCommand
-::SetOneTest(const char *tname,
+::SetOneTest(const std::string& tname,
              std::vector<std::string> &propertyPairs,
              cmMakefile *mf, std::string &errors)
 {

+ 1 - 1
Source/cmSetTestsPropertiesCommand.h

@@ -36,7 +36,7 @@ public:
 
   cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);
 
-  static bool SetOneTest(const char *tname,
+  static bool SetOneTest(const std::string& tname,
                          std::vector<std::string> &propertyPairs,
                          cmMakefile *mf,
                          std::string &errors);

+ 1 - 5
Source/cmTest.cxx

@@ -38,12 +38,8 @@ cmListFileBacktrace const& cmTest::GetBacktrace() const
 }
 
 //----------------------------------------------------------------------------
-void cmTest::SetName(const char* name)
+void cmTest::SetName(const std::string& name)
 {
-  if ( !name )
-    {
-    name = "";
-    }
   this->Name = name;
 }
 

+ 2 - 2
Source/cmTest.h

@@ -31,8 +31,8 @@ public:
   ~cmTest();
 
   ///! Set the test name
-  void SetName(const char* name);
-  const char* GetName() const { return this->Name.c_str(); }
+  void SetName(const std::string& name);
+  std::string GetName() const { return this->Name; }
 
   void SetCommand(std::vector<std::string> const& command);
   std::vector<std::string> const& GetCommand() const