Changeset d40b96
- Timestamp:
- Oct 5, 2009, 9:14:28 PM (16 years ago)
- Children:
- dcbdf2
- Parents:
- 4bc937
- Location:
- molecuilder/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/ActOnAllUnitTest.cpp
r4bc937 rd40b96 40 40 }; 41 41 42 /** UnitTest for VectorList::ActOnAll Vectors() and Vector::AddVector(), Vector::SubtractVector(),42 /** UnitTest for VectorList::ActOnAll() and Vector::AddVector(), Vector::SubtractVector(), 43 43 */ 44 44 void ActOnAllTest::AddSubtractTest() … … 47 47 48 48 // adding, subtracting 49 VL.ActOnAll Vectors( &Vector::AddVector, &test );49 VL.ActOnAll( &Vector::AddVector, &test ); 50 50 CPPUNIT_ASSERT_EQUAL( VL == Ref , false ); 51 VL.ActOnAll Vectors( &Vector::SubtractVector, &test );51 VL.ActOnAll( &Vector::SubtractVector, &test ); 52 52 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 53 53 }; 54 54 55 /** UnitTest for VectorList::ActOnAll Vectors()55 /** UnitTest for VectorList::ActOnAll() 56 56 */ 57 57 void ActOnAllTest::ScaleTest() … … 61 61 62 62 // scaling by value 63 VL.ActOnAll Vectors( (void (Vector::*)(double)) &Vector::Scale, 2. );63 VL.ActOnAll( (void (Vector::*)(double)) &Vector::Scale, 2. ); 64 64 CPPUNIT_ASSERT_EQUAL( VL == Ref , false ); 65 65 66 VL.ActOnAll Vectors( (void (Vector::*)(double)) &Vector::Scale, 0.5 );66 VL.ActOnAll( (void (Vector::*)(double)) &Vector::Scale, 0.5 ); 67 67 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 68 68 69 69 // scaling by ref 70 VL.ActOnAll Vectors( (void (Vector::*)(double *)) &Vector::Scale, &factor );70 VL.ActOnAll( (void (Vector::*)(double *)) &Vector::Scale, &factor ); 71 71 CPPUNIT_ASSERT_EQUAL( VL == Ref , false ); 72 72 73 VL.ActOnAll Vectors( (void (Vector::*)(double *)) &Vector::Scale, &inverse );73 VL.ActOnAll( (void (Vector::*)(double *)) &Vector::Scale, &inverse ); 74 74 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 75 75 … … 81 81 inverses[i] = 1./factors[i]; 82 82 } 83 VL.ActOnAll Vectors( (void (Vector::*)(double **)) &Vector::Scale, &factors );83 VL.ActOnAll( (void (Vector::*)(double **)) &Vector::Scale, &factors ); 84 84 CPPUNIT_ASSERT_EQUAL( VL == Ref , false ); 85 85 86 VL.ActOnAll Vectors( (void (Vector::*)(double **)) &Vector::Scale, &inverses );86 VL.ActOnAll( (void (Vector::*)(double **)) &Vector::Scale, &inverses ); 87 87 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 88 88 }; 89 89 90 /** UnitTest for VectorList::ActOnAll Vectors() and Vector::MakeNormalVector()90 /** UnitTest for VectorList::ActOnAll() and Vector::MakeNormalVector() 91 91 */ 92 92 void ActOnAllTest::NormalizeTest() … … 97 97 // normalize with respect to x and y axis 98 98 bool (Vector::*f)(const Vector *, const Vector *) = &Vector::MakeNormalVector; 99 VL.ActOnAll Vectors( f, &xaxis, &yaxis );99 VL.ActOnAll( f, &xaxis, &yaxis ); 100 100 CPPUNIT_ASSERT_EQUAL( VL == Ref , false ); 101 101 -
molecuilder/src/ActOnAlltest.hpp
r4bc937 rd40b96 26 26 void EmptyList(); 27 27 28 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t );29 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u );30 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v);28 template <typename klasse, typename res, typename T> void ActOnAll( res (klasse::*f)(T), T t ); 29 template <typename klasse, typename res, typename T, typename U> void ActOnAll( res (klasse::*f)(T, U), T t, U u ); 30 template <typename klasse, typename res, typename T, typename U, typename V> void ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v); 31 31 32 32 bool operator == (VectorList &rhs); … … 70 70 VectorList::~VectorList() { }; 71 71 72 template <typename res, typename T> void VectorList::ActOnAllVectors( res (Vector::*f)(T), T t )72 template <typename klasse, typename res, typename T> void VectorList::ActOnAll( res (klasse::*f)(T), T t ) 73 73 { 74 Vector *test = NULL; 75 for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) { 76 test = *Runner; 77 (test->*f)(t); 78 } 74 for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) 75 ((*Runner)->*f)(t); 79 76 }; 80 77 81 template <typename res, typename T, typename U> void VectorList::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u )78 template <typename klasse, typename res, typename T, typename U> void VectorList::ActOnAll( res (klasse::*f)(T, U), T t, U u ) 82 79 { 83 Vector *test = NULL; 84 for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) { 85 test = *Runner; 86 (test->*f)(t, u); 87 } 80 for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) 81 ((*Runner)->*f)(t, u); 88 82 }; 89 83 90 template <typename res, typename T, typename U, typename V> void VectorList::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v)84 template <typename klasse, typename res, typename T, typename U, typename V> void VectorList::ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v) 91 85 { 92 Vector *test = NULL; 93 for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) { 94 test = *Runner; 95 (test->*f)(t, u, v); 96 } 86 for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) 87 ((*Runner)->*f)(t, u, v); 97 88 }; 98 89
Note:
See TracChangeset
for help on using the changeset viewer.