ENH: perform case insensitive comparison on test names

This commit is contained in:
Sebastien Barre 2002-03-28 11:43:53 -05:00
parent b63d6ee7dd
commit e081345595
1 changed files with 28 additions and 7 deletions

View File

@ -58,6 +58,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
fout << fout <<
"#include <stdio.h>\n" "#include <stdio.h>\n"
"#include <stdlib.h>\n"
"#include <string.h>\n" "#include <string.h>\n"
"\n" "\n"
"// Forward declare test functions\n" "// Forward declare test functions\n"
@ -112,6 +113,25 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
fout << fout <<
"};\n" "};\n"
"\n" "\n"
"// Allocate and create a lowercased copy of string\n"
"\n"
"char* lowercase(const char *string)\n"
"{\n"
" char *new_string = new char[strlen(string) + 1];\n"
" if (!new_string)\n"
" {\n"
" return NULL;\n"
" }\n"
" strcpy(new_string, string);\n"
" char *p = new_string;\n"
" while (*p != NULL)\n"
" {\n"
" *p = tolower(*p);\n"
" ++p;\n"
" }\n"
" return new_string;\n"
"}\n"
"\n"
"int main(int ac, char** av)\n" "int main(int ac, char** av)\n"
"{\n" "{\n"
" int NumTests = " << numTests << ";\n" " int NumTests = " << numTests << ";\n"
@ -151,20 +171,21 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
" return -1;\n" " return -1;\n"
" }\n" " }\n"
" \n" " \n"
" // A test name was given, try to find it\n" " char *arg = lowercase(av[1 + partial_match]);\n"
" for (i =0; i < NumTests; ++i)\n" " for (i =0; i < NumTests; ++i)\n"
" {\n" " {\n"
" if (partial_match && \n" " char *test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);\n"
" strstr(cmakeGeneratedFunctionMapEntries[i].name, av[2]) != NULL)\n" " if (partial_match && strstr(test_name, arg) != NULL)\n"
" {\n" " {\n"
" return (*cmakeGeneratedFunctionMapEntries[i].func)(ac - 2, av + 2);\n" " return (*cmakeGeneratedFunctionMapEntries[i].func)(ac - 2, av + 2);\n"
" }\n" " }\n"
" else if (!partial_match && \n" " else if (!partial_match && strcmp(test_name, arg) == 0)\n"
" strcmp(cmakeGeneratedFunctionMapEntries[i].name, av[1]) == 0)\n"
" {\n" " {\n"
" return (*cmakeGeneratedFunctionMapEntries[i].func)(ac - 1, av + 1);\n" " return (*cmakeGeneratedFunctionMapEntries[i].func)(ac - 1, av + 1);\n"
" }\n" " }\n"
" delete [] test_name;\n"
" }\n" " }\n"
" delete [] arg;\n"
" \n" " \n"
" // If the test was not found but there is only one test, then\n" " // If the test was not found but there is only one test, then\n"
" // run it with the arguments\n" " // run it with the arguments\n"