#include "mitkTestingMacros.h"#include <mitkWeakPointer.h>#include <itkObject.h>Go to the source code of this file.
Functions | |
| int | mitkWeakPointerTest (int, char *[]) |
| int mitkWeakPointerTest | ( | int | , |
| char * | [] | ||
| ) |
Definition at line 23 of file mitkWeakPointerTest.cpp.
References mitk::WeakPointer< TObjectType >::IsNull(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, and MITK_TEST_END.
{
MITK_TEST_BEGIN("WeakPointer")
mitk::WeakPointer<itk::Object> weakPointer;
mitk::WeakPointer<itk::Object> weakPointer2;
// Testing constructors and reference counting
itk::Object::Pointer smartPointer = itk::Object::New();
mitk::WeakPointer<itk::Object> weakPointer3(smartPointer);
mitk::WeakPointer<itk::Object> weakPointer4(weakPointer);
{
itk::Object::Pointer tmpSmartPointer(weakPointer);
itk::Object::Pointer tmpSmartPointer2(weakPointer2);
MITK_TEST_CONDITION_REQUIRED(tmpSmartPointer.GetPointer() == tmpSmartPointer2.GetPointer(), "Testing equal pointers");
}
weakPointer = smartPointer;
weakPointer2 = weakPointer;
MITK_TEST_CONDITION_REQUIRED(1 == smartPointer->GetReferenceCount(), "Testing reference count");
smartPointer = 0;
MITK_TEST_CONDITION_REQUIRED(weakPointer.IsNull(), "Testing expired weak pointer (smart pointer assignment)");
MITK_TEST_CONDITION_REQUIRED(weakPointer2.IsNull(), "Testing expired weak pointer (weak pointer assignment)");
MITK_TEST_CONDITION_REQUIRED(weakPointer3.IsNull(), "Testing expired weak pointer (smart pointer constructor)");
MITK_TEST_CONDITION_REQUIRED(weakPointer4.IsNull(), "Testing expired weak pointer (copy constructor)")
MITK_TEST_END()
}
1.7.2