/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */ /* Author(s): Anton Deguet Created on: 2004-07-09 (C) Copyright 2004-2018 Johns Hopkins University (JHU), All Rights Reserved. --- begin cisst license - do not edit --- This software is provided "as is" under an open source license, with no warranty. The complete license can be found in license.txt and http://www.cisst.org/cisst/license.txt. --- end cisst license --- */ #include "vctDynamicVectorTest.h" #include "vctGenericContainerTest.h" #include "vctGenericVectorTest.h" #include #include #include #include #include template void vctDynamicVectorTest::TestAssignment(void) { enum {SIZE = 7}; typedef _elementType value_type; vctDynamicVector inputVector(SIZE); vctRandom(inputVector, value_type(-10), value_type(10)); vctDynamicVector outputVector(SIZE); vctGenericVectorTest::TestAssignment(inputVector, outputVector); } void vctDynamicVectorTest::TestAssignmentDouble(void) { TestAssignment(); } void vctDynamicVectorTest::TestAssignmentFloat(void) { TestAssignment(); } void vctDynamicVectorTest::TestAssignmentInt(void) { TestAssignment(); } template void vctDynamicVectorTest::TestSizingMethods(void) { typedef _elementType value_type; const unsigned int size = cmnRandomSequence::GetInstance().ExtractRandomInt(1, 13); const value_type minValue = static_cast<_elementType>(0); const value_type maxValue = static_cast<_elementType>(30); // default constructor, size 0, null pointer vctDynamicVector vector1; CPPUNIT_ASSERT(vector1.size() == 0); CPPUNIT_ASSERT(vector1.Pointer() == 0); // size should be set and pointer should != 0 vector1.SetSize(size); _elementType * pointer1 = vector1.Pointer(); CPPUNIT_ASSERT(vector1.size() == size); CPPUNIT_ASSERT(pointer1 != 0); // same size, pointer shouldn't change vector1.SetSize(size); CPPUNIT_ASSERT(vector1.size() == size); CPPUNIT_ASSERT(vector1.Pointer() == pointer1); // same size, pointer shouldn't change vector1.resize(size); CPPUNIT_ASSERT(vector1.size() == size); CPPUNIT_ASSERT(vector1.Pointer() == pointer1); // different size vector1.SetSize(size * 2); CPPUNIT_ASSERT(vector1.size() == size * 2); // different size with resize vector1.resize(size); CPPUNIT_ASSERT(vector1.size() == size); // try with other constructors vctDynamicVector<_elementType> vector2(size); CPPUNIT_ASSERT(vector2.size() == size); CPPUNIT_ASSERT(vector2.Pointer() != 0); vctDynamicVector<_elementType> vector3(vector1); CPPUNIT_ASSERT(vector3.size() == size); CPPUNIT_ASSERT(vector3.Pointer() != 0); CPPUNIT_ASSERT(vector3.Pointer() != vector1.Pointer()); // test that the resize method preserves the data in the vector object vector1.SetSize(size); vctRandom(vector1, minValue, maxValue); vector3.SetSize(size); vector3.Assign(vector1); CPPUNIT_ASSERT(vector3.Equal(vector1)); vector1.resize(size * 2); vctDynamicConstVectorRef<_elementType> vector1OldSizeOverlay; vector1OldSizeOverlay.SetRef(vector1, 0, size); CPPUNIT_ASSERT(vector3.Equal(vector1OldSizeOverlay)); vector1.resize(size); CPPUNIT_ASSERT(vector3.Equal(vector1)); vctDynamicConstVectorRef<_elementType> subvector3Overlay; subvector3Overlay.SetRef(vector3, 0, size-1); vector1.resize(size-1); CPPUNIT_ASSERT(subvector3Overlay.Equal(vector1)); vector1.resize(size); vector1OldSizeOverlay.SetRef(vector1, 0, size-1); CPPUNIT_ASSERT(vector1OldSizeOverlay.Equal(subvector3Overlay)); // release memory vector1.SetSize(0); CPPUNIT_ASSERT(vector1.size() == 0); CPPUNIT_ASSERT(vector1.Pointer() == 0); vector2.resize(0); CPPUNIT_ASSERT(vector2.size() == 0); CPPUNIT_ASSERT(vector2.Pointer() == 0); // call again to make sure vector1.SetSize(0); CPPUNIT_ASSERT(vector1.size() == 0); CPPUNIT_ASSERT(vector1.Pointer() == 0); vector2.resize(0); CPPUNIT_ASSERT(vector2.size() == 0); CPPUNIT_ASSERT(vector2.Pointer() == 0); } void vctDynamicVectorTest::TestSizingMethodsDouble(void) { TestSizingMethods(); } void vctDynamicVectorTest::TestSizingMethodsFloat(void) { TestSizingMethods(); } void vctDynamicVectorTest::TestSizingMethodsInt(void) { TestSizingMethods(); } /*! Test conversion from fixed-size vector types */ template void vctDynamicVectorTest::TestConversionFromFixedSize(void) { typedef _elementType value_type; enum { LONGSIZE = 7, SHORTSIZE = 4 }; const value_type minValue = static_cast<_elementType>(0); const value_type maxValue = static_cast<_elementType>(30); vctFixedSizeVector<_elementType, LONGSIZE> fixedVector; vctRandom(fixedVector, minValue, maxValue); // make sure that the second and third elements in fixedVector are not equal. // see why below. if (fixedVector[1] == fixedVector[2]) fixedVector[2] = fixedVector[2] + 1; // Test simple creation of dynamic from fixed vctDynamicVector<_elementType> dynamic1(fixedVector); CPPUNIT_ASSERT(dynamic1.size() == fixedVector.size()); CPPUNIT_ASSERT(dynamic1.Equal( vctDynamicConstVectorRef<_elementType>(fixedVector) )); // Test creation of dynamic from non-const fixed overlay vctFixedSizeVectorRef<_elementType, SHORTSIZE, 1> fixedSlice1(fixedVector, 0); vctDynamicVector<_elementType> dynamic2(fixedSlice1); CPPUNIT_ASSERT(dynamic2.size() == fixedSlice1.size()); CPPUNIT_ASSERT(dynamic2.Equal( vctDynamicConstVectorRef<_elementType>(fixedSlice1) )); // Test creation of dynamic from const fixed overlay vctFixedSizeConstVectorRef<_elementType, SHORTSIZE, 2> fixedSlice2(fixedVector.Pointer()); vctDynamicVector<_elementType> dynamic3(fixedSlice2); CPPUNIT_ASSERT(dynamic3.size() == fixedSlice2.size()); CPPUNIT_ASSERT(dynamic3.Equal( vctDynamicConstVectorRef<_elementType>(fixedSlice2) )); // Assert that dynamic3 and dynamic2 are NOT EQUAL because they contain different // subsequences of fixedVector CPPUNIT_ASSERT(!dynamic3.Equal(dynamic2)); } void vctDynamicVectorTest::TestConversionFromFixedSizeDouble(void) { TestConversionFromFixedSize(); } void vctDynamicVectorTest::TestConverstionFromFixedSizeFloat(void) { TestConversionFromFixedSize(); } void vctDynamicVectorTest::TestConversionFromFixedSizeInt(void) { TestConversionFromFixedSize(); } template void vctDynamicVectorTest::TestAccessMethods(void) { enum {SIZE = 7}; typedef _elementType value_type; vctDynamicVector inputVector(SIZE); vctRandom(inputVector, value_type(-10), value_type(10)); vctDynamicConstVectorRef constInputVector(SIZE, inputVector.Pointer()); vctGenericVectorTest::TestAccessMethods(inputVector, constInputVector); } void vctDynamicVectorTest::TestAccessMethodsDouble(void) { TestAccessMethods(); } void vctDynamicVectorTest::TestAccessMethodsFloat(void) { TestAccessMethods(); } void vctDynamicVectorTest::TestAccessMethodsInt(void) { TestAccessMethods(); } template void vctDynamicVectorTest::TestXYZWMethods(void) { vctDynamicVector<_elementType> inputVector1(16); vctRandom(inputVector1, _elementType(-10), _elementType(10)); vctGenericVectorTest::TestConstXYZW(inputVector1); vctGenericVectorTest::TestNonConstXYZW(inputVector1); vctDynamicVectorRef<_elementType> inputVector2(4, inputVector1.Pointer(0), 4); vctGenericVectorTest::TestConstXYZW(inputVector2); vctGenericVectorTest::TestNonConstXYZW(inputVector2); vctDynamicConstVectorRef<_elementType> inputVector3(4, inputVector1.Pointer(1), 2); vctGenericVectorTest::TestConstXYZW(inputVector3); } void vctDynamicVectorTest::TestXYZWMethodsDouble() { TestXYZWMethods(); } void vctDynamicVectorTest::TestXYZWMethodsFloat() { TestXYZWMethods(); } void vctDynamicVectorTest::TestXYZWMethodsInt() { TestXYZWMethods(); } template void vctDynamicVectorTest::TestSelect(void) { enum {INPUT_SIZE = 12, OUTPUT_SIZE = 5}; vctDynamicVector<_elementType> inputVector(INPUT_SIZE); vctDynamicVector<_elementType> outputVector(OUTPUT_SIZE); vctDynamicVector indexVector(OUTPUT_SIZE); vctRandom(inputVector, _elementType(-10), _elementType(10)); vctRandom(indexVector, static_cast(0), static_cast(INPUT_SIZE)); vctGenericVectorTest::TestSelect(inputVector, indexVector, outputVector); } void vctDynamicVectorTest::TestSelectDouble(void) { vctDynamicVectorTest::TestSelect(); } void vctDynamicVectorTest::TestSelectFloat(void) { vctDynamicVectorTest::TestSelect(); } void vctDynamicVectorTest::TestSelectInt(void) { vctDynamicVectorTest::TestSelect(); } template void vctDynamicVectorTest::TestSwapElements(void) { enum {SIZE = 6}; typedef _elementType value_type; typedef vctDynamicVector<_elementType> VectorType; VectorType v1(SIZE); VectorType v2(SIZE); vctRandom(v1, value_type(-10), value_type(10)); vctRandom(v2, value_type(-10), value_type(10)); vctGenericVectorTest::TestSwapElements(v1, v2); typedef vctDynamicVectorRef<_elementType> Sequence1Type; Sequence1Type h1(SIZE/2, v1.Pointer(0), 1); Sequence1Type h2(SIZE/2, v1.Pointer(SIZE/2), 1); vctGenericVectorTest::TestSwapElements(h1, h2); typedef vctDynamicVectorRef<_elementType> Sequence2Type; Sequence2Type s1(SIZE/2, v2.Pointer(0), 2); Sequence2Type s2(SIZE/2, v2.Pointer(1), 2); vctGenericVectorTest::TestSwapElements(s1, s2); } void vctDynamicVectorTest::TestSwapElementsDouble(void) { TestSwapElements(); } void vctDynamicVectorTest::TestSwapElementsFloat(void) { TestSwapElements(); } void vctDynamicVectorTest::TestSwapElementsInt(void) { TestSwapElements(); } template void vctDynamicVectorTest::TestSoViOperations(void) { enum {SIZE = 6}; typedef _elementType value_type; vctDynamicVector vector(SIZE); vctDynamicVector result(SIZE); vctRandom(vector, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiOperations(vector, result); } void vctDynamicVectorTest::TestSoViOperationsDouble(void) { TestSoViOperations(); } void vctDynamicVectorTest::TestSoViOperationsFloat(void) { TestSoViOperations(); } void vctDynamicVectorTest::TestSoViOperationsInt(void) { TestSoViOperations(); } template void vctDynamicVectorTest::TestSoViViOperations(void) { enum {SIZE = 5}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctDynamicVector vector2(SIZE); vctDynamicVector vector3(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiCiOperations(vector1, vector2, vector3); } void vctDynamicVectorTest::TestSoViViOperationsDouble(void) { TestSoViViOperations(); } void vctDynamicVectorTest::TestSoViViOperationsFloat(void) { TestSoViViOperations(); } void vctDynamicVectorTest::TestSoViViOperationsInt(void) { TestSoViViOperations(); } template void vctDynamicVectorTest::TestVioViOperations(void) { enum {SIZE = 8}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctDynamicVector vector2(SIZE); vctDynamicVector result(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); RemoveQuasiZero(vector2); vctGenericContainerTest::TestCioCiOperations(vector1, vector2, result); } void vctDynamicVectorTest::TestVioViOperationsDouble(void) { TestVioViOperations(); } void vctDynamicVectorTest::TestVioViOperationsFloat(void) { TestVioViOperations(); } void vctDynamicVectorTest::TestVioViOperationsInt(void) { TestVioViOperations(); } template void vctDynamicVectorTest::TestVioSiViOperations(void) { enum {SIZE = 8}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); value_type scalar; vctDynamicVector vector2(SIZE); vctDynamicVector result(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-10), value_type(10), scalar); vctRandom(vector2, value_type(-10), value_type(10)); RemoveQuasiZero(vector2); vctGenericContainerTest::TestCioSiCiOperations(vector1, scalar, vector2, result); } void vctDynamicVectorTest::TestVioSiViOperationsDouble(void) { TestVioSiViOperations(); } void vctDynamicVectorTest::TestVioSiViOperationsFloat(void) { TestVioSiViOperations(); } void vctDynamicVectorTest::TestVioSiViOperationsInt(void) { TestVioSiViOperations(); } template void vctDynamicVectorTest::TestVioViViOperations(void) { enum {SIZE = 8}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctDynamicVector vector2(SIZE); vctDynamicVector vector3(SIZE); vctDynamicVector result(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); vctRandom(vector3, value_type(-10), value_type(10)); vctGenericContainerTest::TestCioCiCiOperations(vector1, vector2, vector3, result); } void vctDynamicVectorTest::TestVioViViOperationsDouble(void) { TestVioViViOperations(); } void vctDynamicVectorTest::TestVioViViOperationsFloat(void) { TestVioViViOperations(); } void vctDynamicVectorTest::TestVioViViOperationsInt(void) { TestVioViViOperations(); } template void vctDynamicVectorTest::TestVoViViOperations(void) { enum {SIZE = 4}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctDynamicVector vector2(SIZE); vctDynamicVector result(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); RemoveQuasiZero(vector2); vctGenericContainerTest::TestCoCiCiOperations(vector1, vector2, result); } void vctDynamicVectorTest::TestVoViViOperationsDouble(void) { TestVoViViOperations(); } void vctDynamicVectorTest::TestVoViViOperationsFloat(void) { TestVoViViOperations(); } void vctDynamicVectorTest::TestVoViViOperationsInt(void) { TestVoViViOperations(); } template void vctDynamicVectorTest::TestCrossProduct(void) { enum {SIZE = 3}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctDynamicVector vector2(SIZE); vctDynamicVector result(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); vctGenericVectorTest::TestCrossProduct(vector1, vector2, result); } void vctDynamicVectorTest::TestCrossProductDouble(void) { TestCrossProduct(); } void vctDynamicVectorTest::TestCrossProductFloat(void) { TestCrossProduct(); } void vctDynamicVectorTest::TestCrossProductInt(void) { TestCrossProduct(); } template void vctDynamicVectorTest::TestDotProduct(void) { enum {SIZE = 12}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctDynamicVector vector2(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); vctGenericVectorTest::TestDotProduct(vector1, vector2); } void vctDynamicVectorTest::TestDotProductDouble(void) { TestDotProduct(); } void vctDynamicVectorTest::TestDotProductFloat(void) { TestDotProduct(); } void vctDynamicVectorTest::TestDotProductInt(void) { TestDotProduct(); } template void vctDynamicVectorTest::TestVoViOperations(void) { enum {SIZE = 4}; typedef _elementType value_type; vctDynamicVector vector(SIZE); vctDynamicVector result(SIZE); vctRandom(vector, value_type(-10), value_type(10)); vctGenericContainerTest::TestCoCiOperations(vector, result); } void vctDynamicVectorTest::TestVoViOperationsDouble(void) { TestVoViOperations(); } void vctDynamicVectorTest::TestVoViOperationsFloat(void) { TestVoViOperations(); } void vctDynamicVectorTest::TestVoViOperationsInt(void) { TestVoViOperations(); } template void vctDynamicVectorTest::TestVoViSiOperations(void) { enum {SIZE = 8}; typedef _elementType value_type; value_type scalar; cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-5), value_type(5), scalar); vctDynamicVector vector(SIZE); vctDynamicVector result(SIZE); if ((scalar < value_type(1)) && (scalar > -value_type(1))) { scalar = value_type(3); } vctRandom(vector, value_type(-10), value_type(10)); vctGenericContainerTest::TestCoCiSiOperations(vector, scalar, result); } void vctDynamicVectorTest::TestVoViSiOperationsDouble(void) { TestVoViSiOperations(); } void vctDynamicVectorTest::TestVoViSiOperationsFloat(void) { TestVoViSiOperations(); } void vctDynamicVectorTest::TestVoViSiOperationsInt(void) { TestVoViSiOperations(); } template void vctDynamicVectorTest::TestVoSiViOperations(void) { enum {SIZE = 10}; typedef _elementType value_type; value_type scalar; vctDynamicVector vector(SIZE); vctDynamicVector result(SIZE); cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-5), value_type(5), scalar); vctRandom(vector, value_type(-10), value_type(10)); RemoveQuasiZero(vector); vctGenericContainerTest::TestCoSiCiOperations(scalar, vector, result); } void vctDynamicVectorTest::TestVoSiViOperationsDouble(void) { TestVoSiViOperations(); } void vctDynamicVectorTest::TestVoSiViOperationsFloat(void) { TestVoSiViOperations(); } void vctDynamicVectorTest::TestVoSiViOperationsInt(void) { TestVoSiViOperations(); } template void vctDynamicVectorTest::TestVioSiOperations(void) { enum {SIZE = 9}; typedef _elementType value_type; vctDynamicVector vector(SIZE); vctDynamicVector result(SIZE); value_type scalar; cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-5), value_type(5), scalar); if ((scalar < value_type(1)) && (scalar > -value_type(1))) { scalar = value_type(3); } vctRandom(vector, value_type(-10), value_type(10)); vctGenericContainerTest::TestCioSiOperations(vector, scalar, result); } void vctDynamicVectorTest::TestVioSiOperationsDouble(void) { TestVioSiOperations(); } void vctDynamicVectorTest::TestVioSiOperationsFloat(void) { TestVioSiOperations(); } void vctDynamicVectorTest::TestVioSiOperationsInt(void) { TestVioSiOperations(); } template void vctDynamicVectorTest::TestVioOperations(void) { enum {SIZE = 9}; typedef _elementType value_type; vctDynamicVector vector(SIZE); vctDynamicVector result(SIZE); vctRandom(vector, value_type(-10), value_type(10)); vctGenericContainerTest::TestCioOperations(vector, result); } void vctDynamicVectorTest::TestVioOperationsDouble(void) { TestVioOperations(); } void vctDynamicVectorTest::TestVioOperationsFloat(void) { TestVioOperations(); } void vctDynamicVectorTest::TestVioOperationsInt(void) { TestVioOperations(); } template void vctDynamicVectorTest::TestSoViSiOperations(void) { enum {SIZE = 9}; typedef _elementType value_type; vctDynamicVector vector(SIZE); vctDynamicVector result(SIZE); value_type scalar; cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-5), value_type(5), scalar); vctRandom(vector, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiSiOperations(vector, scalar, result); } void vctDynamicVectorTest::TestSoViSiOperationsDouble(void) { TestSoViSiOperations(); } void vctDynamicVectorTest::TestSoViSiOperationsFloat(void) { TestSoViSiOperations(); } void vctDynamicVectorTest::TestSoViSiOperationsInt(void) { TestSoViSiOperations(); } template void vctDynamicVectorTest::TestMinAndMax(void) { enum {SIZE = 12}; typedef _elementType value_type; vctDynamicVector vector(SIZE); vctRandom(vector, value_type(-50), value_type(50)); vctGenericContainerTest::TestMinAndMax(vector); } void vctDynamicVectorTest::TestMinAndMaxDouble(void) { TestMinAndMax(); } void vctDynamicVectorTest::TestMinAndMaxFloat(void) { TestMinAndMax(); } void vctDynamicVectorTest::TestMinAndMaxInt(void) { TestMinAndMax(); } template void vctDynamicVectorTest::TestIterators(void) { enum {SIZE = 9}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestIterators(vector1); } void vctDynamicVectorTest::TestIteratorsDouble(void) { TestIterators(); } void vctDynamicVectorTest::TestIteratorsFloat(void) { TestIterators(); } void vctDynamicVectorTest::TestIteratorsInt(void) { TestIterators(); } template void vctDynamicVectorTest::TestSTLFunctions(void) { enum {SIZE = 9}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctDynamicVector vector2(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestSTLFunctions(vector1, vector2); } void vctDynamicVectorTest::TestSTLFunctionsDouble(void) { TestSTLFunctions(); } void vctDynamicVectorTest::TestSTLFunctionsFloat(void) { TestSTLFunctions(); } void vctDynamicVectorTest::TestSTLFunctionsInt(void) { TestSTLFunctions(); } template void vctDynamicVectorTest::TestFastCopyOf(void) { enum {SIZE = 7}; typedef _elementType value_type; // dynamic vector vctDynamicVector destination(SIZE); vctDynamicVector validSource(SIZE); vctRandom(validSource, value_type(-10), value_type(10)); vctGenericContainerTest::TestFastCopyOf(validSource, destination); // test for exception if different size vctDynamicVector largerVector(SIZE * 2); vctGenericContainerTest::TestFastCopyOfException(largerVector, destination); // test for not compact vctDynamicVectorRef invalidRef(SIZE, largerVector.Pointer(), 2); CPPUNIT_ASSERT(!destination.FastCopyCompatible(invalidRef)); CPPUNIT_ASSERT(!destination.FastCopyOf(invalidRef)); // safe tests using a larger source and not performing checks CPPUNIT_ASSERT(largerVector.FastCopyOf(destination, false)); // fixed size vector vctFixedSizeVector validSourceFixed; vctRandom(validSourceFixed, value_type(-10), value_type(10)); vctGenericContainerTest::TestFastCopyOf(validSourceFixed, destination); // test for exception if different size typedef vctFixedSizeVector LargerVectorType; LargerVectorType largerVectorFixed; vctGenericContainerTest::TestFastCopyOfException(largerVectorFixed, destination); // test for not compact vctFixedSizeVectorRef invalidRefFixed(largerVectorFixed.Pointer()); CPPUNIT_ASSERT(!destination.FastCopyCompatible(invalidRefFixed)); CPPUNIT_ASSERT(!destination.FastCopyOf(invalidRefFixed)); // test for empty containers validSource.SetSize(0); destination.SetSize(0); CPPUNIT_ASSERT(destination.FastCopyCompatible(validSource)); CPPUNIT_ASSERT(destination.FastCopyOf(validSource)); } void vctDynamicVectorTest::TestFastCopyOfDouble(void) { TestFastCopyOf(); } void vctDynamicVectorTest::TestFastCopyOfFloat(void) { TestFastCopyOf(); } void vctDynamicVectorTest::TestFastCopyOfInt(void) { TestFastCopyOf(); } template void vctDynamicVectorTest::TestZeros(void) { enum {SIZE = 7}; typedef _elementType value_type; // dynamic vector vctDynamicVector destination(2 * SIZE); CPPUNIT_ASSERT(destination.Zeros()); CPPUNIT_ASSERT(destination.Equal(static_cast(0))); // test for not compact (every other element) vctDynamicVectorRef nonCompact(SIZE, destination.Pointer(), 2); CPPUNIT_ASSERT(!nonCompact.Zeros()); CPPUNIT_ASSERT(nonCompact.Equal(static_cast(0))); // test for empty containers destination.SetSize(0); CPPUNIT_ASSERT(destination.Zeros()); } void vctDynamicVectorTest::TestZerosDouble(void) { TestZeros(); } void vctDynamicVectorTest::TestZerosFloat(void) { TestZeros(); } void vctDynamicVectorTest::TestZerosInt(void) { TestZeros(); } template void vctDynamicVectorTest::TestNormalization(void) { enum {SIZE = 9}; typedef _elementType value_type; vctDynamicVector vector1(SIZE); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericVectorTest::TestNormalization(vector1); } void vctDynamicVectorTest::TestNormalizationDouble(void) { TestNormalization(); } void vctDynamicVectorTest::TestNormalizationFloat(void) { TestNormalization(); } CPPUNIT_TEST_SUITE_REGISTRATION(vctDynamicVectorTest);