#include <ctype.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include "mitkLog.h"Go to the source code of this file.
Classes | |
| struct | functionMapEntry |
Typedefs | |
| typedef int(* | MainFuncPointer )(int, char *[]) |
Functions | |
| int | mitkFactoryRegistrationTest (int, char *[]) |
| char * | lowercase (const char *string) |
| int | main (int ac, char *av[]) |
Variables | |
| functionMapEntry | cmakeGeneratedFunctionMapEntries [] |
| typedef int(* MainFuncPointer)(int, char *[]) |
Definition at line 16 of file MitkDiffusionImagingTestDriver.cpp.
| char* lowercase | ( | const char * | string ) |
Definition at line 35 of file MitkDiffusionImagingTestDriver.cpp.
{
char *new_string, *p;
#ifdef __cplusplus
new_string = static_cast<char *>(malloc(sizeof(char) *
static_cast<size_t>(strlen(string) + 1)));
#else
new_string = (char *)(malloc(sizeof(char) * (size_t)(strlen(string) + 1)));
#endif
if (!new_string)
{
return 0;
}
strcpy(new_string, string);
p = new_string;
while (*p != 0)
{
#ifdef __cplusplus
*p = static_cast<char>(tolower(*p));
#else
*p = (char)(tolower(*p));
#endif
++p;
}
return new_string;
}
| int main | ( | int | ac, |
| char * | av[] | ||
| ) |
Definition at line 65 of file MitkDiffusionImagingTestDriver.cpp.
References functionMapEntry::func, lowercase(), functionMapEntry::name, mitk::LoggingBackend::Register(), and mitk::LoggingBackend::Unregister().
{
int i, NumTests, testNum, partial_match;
char *arg, *test_name;
int count;
int testToRun = -1;
for(count =0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++)
{
}
NumTests = count;
/* If no test name was given */
/* process command line with user function. */
if (ac < 2)
{
/* Ask for a test. */
printf("Available tests:\n");
for (i =0; i < NumTests; ++i)
{
printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name);
}
printf("To run a test, enter the test number: ");
fflush(stdout);
testNum = 0;
if( scanf("%d", &testNum) != 1 )
{
printf("Couldn't parse that input as a number\n");
return -1;
}
if (testNum >= NumTests)
{
printf("%3d is an invalid test number.\n", testNum);
return -1;
}
testToRun = testNum;
ac--;
av++;
}
partial_match = 0;
arg = 0;
/* If partial match is requested. */
if(testToRun == -1 && ac > 1)
{
partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
}
if (partial_match && ac < 3)
{
printf("-R needs an additional parameter.\n");
return -1;
}
if(testToRun == -1)
{
arg = lowercase(av[1 + partial_match]);
}
for (i =0; i < NumTests && testToRun == -1; ++i)
{
test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
if (partial_match && strstr(test_name, arg) != NULL)
{
testToRun = i;
ac -=2;
av += 2;
}
else if (!partial_match && strcmp(test_name, arg) == 0)
{
testToRun = i;
ac--;
av++;
}
free(test_name);
}
if(arg)
{
free(arg);
}
if(testToRun != -1)
{
int result;
mitk::LoggingBackend::Register(); ;
result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av);
mitk::LoggingBackend::Unregister();
return result;
}
/* Nothing was run, display the test names. */
printf("Available tests:\n");
for (i =0; i < NumTests; ++i)
{
printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name);
}
printf("Failed: %s is an invalid test name.\n", av[1]);
return -1;
}
| int mitkFactoryRegistrationTest | ( | int | , |
| char * | [] | ||
| ) |
Documentation Test for factory registration
Definition at line 27 of file mitkFactoryRegistrationTest.cpp.
References mitk::CoreObjectFactory::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::DiffusionImage< TPixelType >::New(), and RegisterDiffusionImagingObjectFactory().
{
// always start with this!
MITK_TEST_BEGIN("FactoryRegistrationTest");
RegisterDiffusionImagingObjectFactory();
bool canWrite = false;
mitk::DiffusionImage<short>::Pointer img = mitk::DiffusionImage<short>::New();
mitk::CoreObjectFactory::FileWriterList fileWriters = mitk::CoreObjectFactory::GetInstance()->GetFileWriters();
for (mitk::CoreObjectFactory::FileWriterList::iterator it = fileWriters.begin() ; it != fileWriters.end() ; ++it)
{
if ( (*it)->CanWriteDataType(img.GetPointer()) ) {
canWrite = true;
break;
}
}
MITK_TEST_CONDITION_REQUIRED(canWrite,"Testing factory registration");
// always end with this!
MITK_TEST_END();
}
{
{
"mitkFactoryRegistrationTest",
mitkFactoryRegistrationTest
},
{0,0}
}
Definition at line 23 of file MitkDiffusionImagingTestDriver.cpp.
1.7.2