#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 | mitkPropertySerializationTest (int, char *[]) |
Test for all PropertySerializer and PropertyDeserializer classes. | |
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 SceneSerializationBaseTestDriver.cpp.
char* lowercase | ( | const char * | string ) |
Definition at line 35 of file SceneSerializationBaseTestDriver.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 SceneSerializationBaseTestDriver.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 mitkPropertySerializationTest | ( | int | , |
char * | [] | ||
) |
Test for all PropertySerializer and PropertyDeserializer classes.
Documentation
Definition at line 80 of file mitkPropertySerializationTest.cpp.
References MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::VtkWidgetRendering::New(), mitk::Surface::New(), mitk::Image::New(), mitk::PointSet::New(), mitk::DataNode::New(), mitk::LookupTableProperty::New(), mitk::LookupTable::New(), mitk::LevelWindowProperty::New(), mitk::GroupTagProperty::New(), mitk::StringLookupTableProperty::New(), mitk::IntLookupTableProperty::New(), mitk::FloatLookupTableProperty::New(), mitk::BoolLookupTableProperty::New(), mitk::VtkVolumeRenderingProperty::New(), mitk::VtkScalarModeProperty::New(), mitk::VtkResliceInterpolationProperty::New(), mitk::VtkRepresentationProperty::New(), mitk::VtkInterpolationProperty::New(), mitk::ShaderProperty::New(), mitk::PlaneOrientationProperty::New(), mitk::ModalityProperty::New(), mitk::ColorProperty::New(), mitk::ClippingProperty::New(), mitk::AnnotationProperty::New(), mitk::Vector3DProperty::New(), mitk::Point4dProperty::New(), mitk::Point3iProperty::New(), mitk::Point3dProperty::New(), mitk::StringProperty::New(), mitk::DoubleProperty::New(), mitk::FloatProperty::New(), mitk::IntProperty::New(), mitk::BoolProperty::New(), mitk::PropertyList::New(), mitk::PropertyListSerializer::New(), mitk::GenericLookupTable< T >::SetTableValue(), and TestAllProperties().
{ MITK_TEST_BEGIN("PropertySerializationTest"); mitk::PropertyListSerializer::Pointer serializer = mitk::PropertyListSerializer::New(); // make sure something from the lib is actually used (registration of serializers/deserializers) /* build list of properties that will be serialized and deserialized */ mitk::PropertyList::Pointer propList = mitk::PropertyList::New(); propList->SetProperty("booltrue", mitk::BoolProperty::New(true)); propList->SetProperty("boolfalse", mitk::BoolProperty::New(false)); propList->SetProperty("int", mitk::IntProperty::New(-32)); propList->SetProperty("float", mitk::FloatProperty::New(-31.337)); propList->SetProperty("double", mitk::DoubleProperty::New(-31.337)); propList->SetProperty("string", mitk::StringProperty::New("Hello MITK")); mitk::Point3D p3d; mitk::FillVector3D(p3d, 1.0, 2.2, -3.3); propList->SetProperty("p3d", mitk::Point3dProperty::New(p3d)); mitk::Point3I p3i; mitk::FillVector3D(p3i, 1, 2, -3); propList->SetProperty("p3i", mitk::Point3iProperty::New(p3i)); mitk::Point4D p4d; mitk::FillVector4D(p4d, 1.5, 2.6, -3.7, 4.44); propList->SetProperty("p4d", mitk::Point4dProperty::New(p4d)); mitk::Vector3D v3d; mitk::FillVector3D(v3d, 1.0, 2.2, -3.3); propList->SetProperty("v3d", mitk::Vector3DProperty::New(v3d)); propList->SetProperty("annotation", mitk::AnnotationProperty::New("My Annotation", p3d)); propList->SetProperty("clipping", mitk::ClippingProperty::New(p3d, v3d)); propList->SetProperty("color", mitk::ColorProperty::New(1.0, 0.2, 0.2)); //mitk::EnumerationProperty::Pointer en = mitk::EnumerationProperty::New(); //en->AddEnum("PC", 1); en->AddEnum("Playstation", 2); en->AddEnum("Wii", 111); en->AddEnum("XBox", 7); //en->SetValue("XBox"); //propList->SetProperty("enum", en); /* propList->SetProperty("gridrep", mitk::GridRepresentationProperty::New(2)); propList->SetProperty("gridvol", mitk::GridVolumeMapperProperty::New(0)); propList->SetProperty("OrganTypeProperty", mitk::OrganTypeProperty::New("Larynx")); */ propList->SetProperty("modality", mitk::ModalityProperty::New("Color Doppler")); //propList->SetProperty("OdfNormalizationMethodProperty", mitk::OdfNormalizationMethodProperty::New("Global Maximum")); //propList->SetProperty("OdfScaleByProperty", mitk::OdfScaleByProperty::New("Principal Curvature")); propList->SetProperty("PlaneOrientationProperty", mitk::PlaneOrientationProperty::New("Arrows in positive direction")); propList->SetProperty("ShaderProperty", mitk::ShaderProperty::New("fixed")); propList->SetProperty("VtkInterpolationProperty", mitk::VtkInterpolationProperty::New("Gouraud")); propList->SetProperty("VtkRepresentationProperty", mitk::VtkRepresentationProperty::New("Surface")); propList->SetProperty("VtkResliceInterpolationProperty", mitk::VtkResliceInterpolationProperty::New("Cubic")); propList->SetProperty("VtkScalarModeProperty", mitk::VtkScalarModeProperty::New("PointFieldData")); propList->SetProperty("VtkVolumeRenderingProperty", mitk::VtkVolumeRenderingProperty::New("COMPOSITE")); mitk::BoolLookupTable blt; blt.SetTableValue(0, true); blt.SetTableValue(1, false); blt.SetTableValue(2, true); propList->SetProperty("BoolLookupTableProperty", mitk::BoolLookupTableProperty::New(blt)); mitk::FloatLookupTable flt; flt.SetTableValue(0, 3.1); flt.SetTableValue(1, 3.3); flt.SetTableValue(2, 7.0); propList->SetProperty("FloatLookupTableProperty", mitk::FloatLookupTableProperty::New(flt)); mitk::IntLookupTable ilt; ilt.SetTableValue(0, 3); ilt.SetTableValue(1, 2); ilt.SetTableValue(2, 11); propList->SetProperty("IntLookupTableProperty", mitk::IntLookupTableProperty::New(ilt)); mitk::StringLookupTable slt; slt.SetTableValue(0, "Hello"); slt.SetTableValue(1, "MITK"); slt.SetTableValue(2, "world"); propList->SetProperty("StringLookupTableProperty", mitk::StringLookupTableProperty::New(slt)); propList->SetProperty("GroupTagProperty", mitk::GroupTagProperty::New()); propList->SetProperty("LevelWindowProperty", mitk::LevelWindowProperty::New(mitk::LevelWindow(100.0, 50.0))); mitk::LookupTable::Pointer lt = mitk::LookupTable::New(); lt->ChangeOpacityForAll(0.25); lt->ChangeOpacity(17, 0.88); propList->SetProperty("LookupTableProperty", mitk::LookupTableProperty::New(lt)); propList->SetProperty("StringProperty", mitk::StringProperty::New("Oh why, gruel world")); //mitk::TransferFunction::Pointer tf = mitk::TransferFunction::New(); //tf->SetTransferFunctionMode(1); //propList->SetProperty("TransferFunctionProperty", mitk::TransferFunctionProperty::New(tf)); MITK_TEST_CONDITION_REQUIRED(propList->GetMap()->size() > 0, "Initialize PropertyList"); TestAllProperties(propList); /* test default property lists of basedata objects */ // activate the following tests after MaterialProperty is deleted mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(mitk::PointSet::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Image::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Surface::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::VtkWidgetRendering::New()); TestAllProperties(node->GetPropertyList()); /* node->SetData(mitk::Contour::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::ContourSet::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::PointData::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Mesh::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Cone::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Cuboid::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Cylinder::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Ellipsoid::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::ExtrudedContour::New()); TestAllProperties(node->GetPropertyList()); node->SetData(mitk::Plane::New()); TestAllProperties(node->GetPropertyList()); //node->SetData(mitk::TrackingVolume::New()); // TrackingVolume is in IGT Module, it does not have special properties, therefore we skip it here //TestAllProperties(node->GetPropertyList()); node->SetData(mitk::UnstructuredGrid::New()); TestAllProperties(node->GetPropertyList()); */ /* untested base data types: BaseDataTestImplementation RenderWindowFrame mitk::DiffusionImage< TPixelType > GeometryData mitk::Geometry2DData GradientBackground ItkBaseDataAdapter ManufacturerLogo SlicedData QBallImage SeedsImage TensorImage BoundingObject BoundingObjectGroup */ MITK_TEST_END(); }
{ { "mitkPropertySerializationTest", mitkPropertySerializationTest }, {0,0} }
Definition at line 23 of file SceneSerializationBaseTestDriver.cpp.