00001 #include <UnitTest++.h>
00002 #include "cddefines.h"
00003 #include <functional>
00004
00005 namespace {
00006
00007
00008 long m1 = -1L;
00009
00010 template<mem_layout ALLOC,bool lgBC>
00011 struct LongInt2DFixtureGeneric
00012 {
00013 multi_arr<long,2,ALLOC,lgBC> arr;
00014 LongInt2DFixtureGeneric()
00015 {
00016 arr.alloc(10,9);
00017 for (int i=0; i<10; ++i)
00018 for (int j=0; j<9; ++j)
00019 arr[i][j] = i*10+j;
00020 }
00021 ~LongInt2DFixtureGeneric() {}
00022 };
00023
00024 typedef LongInt2DFixtureGeneric<ARPA_TYPE,false> LongInt2DFixture;
00025 typedef LongInt2DFixtureGeneric<ARPA_TYPE,true> LongInt2DFixtureBC;
00026 typedef LongInt2DFixtureGeneric<C_TYPE,false> LongInt2DFixtureCType;
00027 typedef LongInt2DFixtureGeneric<C_TYPE,true> LongInt2DFixtureCTypeBC;
00028
00029 template<mem_layout ALLOC,bool lgBC>
00030 struct LongInt3DFixtureGeneric
00031 {
00032 multi_arr<long,3,ALLOC,lgBC> arr;
00033 LongInt3DFixtureGeneric()
00034 {
00035 arr.alloc(10,9,8);
00036 for (int i=0; i<10; ++i)
00037 for (int j=0; j<9; ++j)
00038 for (int k=0; k<8; ++k)
00039 arr[i][j][k] = i*100+j*10+k;
00040 }
00041 ~LongInt3DFixtureGeneric() {}
00042 };
00043
00044 typedef LongInt3DFixtureGeneric<ARPA_TYPE,false> LongInt3DFixture;
00045 typedef LongInt3DFixtureGeneric<ARPA_TYPE,true> LongInt3DFixtureBC;
00046 typedef LongInt3DFixtureGeneric<C_TYPE,false> LongInt3DFixtureCType;
00047 typedef LongInt3DFixtureGeneric<C_TYPE,true> LongInt3DFixtureCTypeBC;
00048
00049 struct RealNum3DFixture
00050 {
00051 multi_arr<realnum,3,ARPA_TYPE,false> arr;
00052 RealNum3DFixture()
00053 {
00054 arr.alloc(10,9,8);
00055 }
00056 ~RealNum3DFixture() {}
00057 };
00058
00059 struct Double3DFixture
00060 {
00061 multi_arr<double,3,ARPA_TYPE,false> arr;
00062 Double3DFixture()
00063 {
00064 arr.alloc(10,9,8);
00065 }
00066 ~Double3DFixture() {}
00067 };
00068
00069 template<mem_layout ALLOC>
00070 struct StructWithConstructor3DFixtureGeneric
00071 {
00072 struct a
00073 {
00074 long n;
00075 a() { n = 23; }
00076 ~a() {}
00077 };
00078 multi_arr<a,3,ALLOC,false> arr;
00079 StructWithConstructor3DFixtureGeneric()
00080 {
00081 arr.alloc(2,3,4);
00082 }
00083 ~StructWithConstructor3DFixtureGeneric() {}
00084 };
00085
00086 typedef StructWithConstructor3DFixtureGeneric<ARPA_TYPE> StructWithConstructor3DFixture;
00087 typedef StructWithConstructor3DFixtureGeneric<C_TYPE> StructWithConstructor3DFixtureCType;
00088
00089 template<mem_layout ALLOC,bool lgBC>
00090 struct LongInt4DFixtureGeneric
00091 {
00092 multi_arr<long,4,ALLOC,lgBC> arr;
00093 LongInt4DFixtureGeneric()
00094 {
00095 arr.alloc(10,9,8,7);
00096 for (int i=0; i<10; ++i)
00097 for (int j=0; j<9; ++j)
00098 for (int k=0; k<8; ++k)
00099 for (int l=0; l<7; ++l)
00100 arr[i][j][k][l] = i*1000+j*100+k*10+l;
00101 }
00102 ~LongInt4DFixtureGeneric() {}
00103 };
00104
00105 typedef LongInt4DFixtureGeneric<ARPA_TYPE,false> LongInt4DFixture;
00106 typedef LongInt4DFixtureGeneric<ARPA_TYPE,true> LongInt4DFixtureBC;
00107 typedef LongInt4DFixtureGeneric<C_TYPE,false> LongInt4DFixtureCType;
00108 typedef LongInt4DFixtureGeneric<C_TYPE,true> LongInt4DFixtureCTypeBC;
00109
00110 template<mem_layout ALLOC,bool lgBC>
00111 struct LongInt5DFixtureGeneric
00112 {
00113 multi_arr<long,5,ALLOC,lgBC> arr;
00114 LongInt5DFixtureGeneric()
00115 {
00116 arr.alloc(10,9,8,7,6);
00117 for (int i=0; i<10; ++i)
00118 for (int j=0; j<9; ++j)
00119 for (int k=0; k<8; ++k)
00120 for (int l=0; l<7; ++l)
00121 for (int m=0; m<6; ++m)
00122 arr[i][j][k][l][m] = i*10000+j*1000+k*100+l*10+m;
00123 }
00124 ~LongInt5DFixtureGeneric() {}
00125 };
00126
00127 typedef LongInt5DFixtureGeneric<ARPA_TYPE,false> LongInt5DFixture;
00128 typedef LongInt5DFixtureGeneric<ARPA_TYPE,true> LongInt5DFixtureBC;
00129 typedef LongInt5DFixtureGeneric<C_TYPE,false> LongInt5DFixtureCType;
00130 typedef LongInt5DFixtureGeneric<C_TYPE,true> LongInt5DFixtureCTypeBC;
00131
00132 template<mem_layout ALLOC,bool lgBC>
00133 struct LongInt6DFixtureGeneric
00134 {
00135 multi_arr<long,6,ALLOC,lgBC> arr;
00136 LongInt6DFixtureGeneric()
00137 {
00138 arr.alloc(10,9,8,7,6,5);
00139 for (int i=0; i<10; ++i)
00140 for (int j=0; j<9; ++j)
00141 for (int k=0; k<8; ++k)
00142 for (int l=0; l<7; ++l)
00143 for (int m=0; m<6; ++m)
00144 for (int n=0; n<5; ++n)
00145 arr[i][j][k][l][m][n] =
00146 i*100000+j*10000+k*1000+l*100+m*10+n;
00147 }
00148 ~LongInt6DFixtureGeneric() {}
00149 };
00150
00151 typedef LongInt6DFixtureGeneric<ARPA_TYPE,false> LongInt6DFixture;
00152 typedef LongInt6DFixtureGeneric<ARPA_TYPE,true> LongInt6DFixtureBC;
00153 typedef LongInt6DFixtureGeneric<C_TYPE,false> LongInt6DFixtureCType;
00154 typedef LongInt6DFixtureGeneric<C_TYPE,true> LongInt6DFixtureCTypeBC;
00155
00156 struct LongInt6DFixtureExplicitReserve
00157 {
00158 multi_arr<long,6,ARPA_TYPE,true> arr;
00159 LongInt6DFixtureExplicitReserve()
00160 {
00161 arr.reserve(10);
00162 for (int i=0; i<10; ++i)
00163 {
00164 arr.reserve(i,9);
00165 for (int j=0; j<9; ++j)
00166 {
00167 arr.reserve(i,j,8);
00168 for (int k=0; k<8; ++k)
00169 {
00170 arr.reserve(i,j,k,7);
00171 for (int l=0; l<7; ++l)
00172 {
00173 arr.reserve(i,j,k,l,6);
00174 for (int m=0; m<6; ++m)
00175 {
00176 arr.reserve(i,j,k,l,m,5);
00177 }
00178 }
00179 }
00180 }
00181 }
00182 arr.alloc();
00183 }
00184 ~LongInt6DFixtureExplicitReserve() {}
00185 };
00186
00187 struct TestAllocFixture
00188 {
00189 TestAllocFixture() {}
00190 ~TestAllocFixture() {}
00191 long mytest()
00192 {
00193 multi_arr<long,2,ARPA_TYPE,true> a2(2,3);
00194 multi_arr<long,3,ARPA_TYPE,true> a3(2,3,4);
00195 multi_arr<long,4,ARPA_TYPE,true> a4(2,3,4,5);
00196 multi_arr<long,5,ARPA_TYPE,true> a5(2,3,4,5,6);
00197 multi_arr<long,6,ARPA_TYPE,true> a6(2,3,4,5,6,7);
00198
00199 multi_arr<long,2,ARPA_TYPE,true>::iterator p2;
00200 multi_arr<long,3,ARPA_TYPE,true>::iterator p3;
00201 multi_arr<long,4,ARPA_TYPE,true>::iterator p4;
00202 multi_arr<long,5,ARPA_TYPE,true>::iterator p5;
00203 multi_arr<long,6,ARPA_TYPE,true>::iterator p6;
00204
00205 a2.zero();
00206 a3.zero();
00207 a4.zero();
00208 a5.zero();
00209 a6.zero();
00210
00211 long res = 0;
00212 for (int i=0; i<2; ++i)
00213 for (int j=0; j<3; ++j)
00214 {
00215 p2 = a2.ptr(i,j);
00216 res += ( *p2 != 0 );
00217 for (int k=0; k<4; ++k)
00218 {
00219 p3 = a3.ptr(i,j,k);
00220 res += ( *p3 != 0 );
00221 for (int l=0; l<5; ++l)
00222 {
00223 p4 = a4.ptr(i,j,k,l);
00224 res += ( *p4 != 0 );
00225 for (int m=0; m<6; ++m)
00226 {
00227 p5 = a5.ptr(i,j,k,l,m);
00228 res += ( *p5 != 0 );
00229 for (int n=0; n<7; ++n)
00230 {
00231 p6 = a6.ptr(i,j,k,l,m,n);
00232 res += ( *p6 != 0 );
00233 }
00234 }
00235 }
00236 }
00237 }
00238
00239 return res;
00240 }
00241 };
00242
00243 struct LongInt3DCLayoutFixture
00244 {
00245 multi_arr<long,3,C_TYPE,false> arr;
00246 LongInt3DCLayoutFixture()
00247 {
00248 arr.alloc(10,10,10);
00249 for (int i=0; i<10; ++i)
00250 for (int j=0; j<10; ++j)
00251 for (int k=0; k<10; ++k)
00252 arr[i][j][k] = 100*i+10*j+k;
00253 }
00254 ~LongInt3DCLayoutFixture() {}
00255 long mytest(const long a[][10][10])
00256 {
00257 long res = 0;
00258 for (int i=0; i<10; ++i)
00259 for (int j=0; j<10; ++j)
00260 for (int k=0; k<10; ++k)
00261 res += ( a[i][j][k] != 100*i+10*j+k );
00262
00263 return res;
00264 }
00265 };
00266
00267 template<mem_layout ALLOC>
00268 struct LongInt3DCloneFixtureGeneric
00269 {
00270 multi_arr<long,3,ALLOC,true> arr;
00271 LongInt3DCloneFixtureGeneric()
00272 {
00273 arr.reserve(10);
00274 for (int i=0; i<10; ++i)
00275 {
00276 arr.reserve(i,i+1);
00277 for (int j=0; j<i+1; ++j)
00278 arr.reserve(i,j,j+1);
00279 }
00280 arr.alloc();
00281 }
00282 ~LongInt3DCloneFixtureGeneric() {}
00283 };
00284
00285 typedef LongInt3DCloneFixtureGeneric<ARPA_TYPE> LongInt3DCloneFixture;
00286 typedef LongInt3DCloneFixtureGeneric<C_TYPE> LongInt3DCloneFixtureCType;
00287
00288 template<mem_layout ALLOC>
00289 struct LongInt2DEmptyDimGeneric
00290 {
00291 multi_arr<long,2,ALLOC,true> arr;
00292 LongInt2DEmptyDimGeneric()
00293 {
00294 arr.reserve(2);
00295 for (int i=1; i<2; ++i)
00296 {
00297 arr.reserve(i,2);
00298 }
00299 arr.alloc();
00300 }
00301 ~LongInt2DEmptyDimGeneric() {}
00302 };
00303
00304 typedef LongInt2DEmptyDimGeneric<ARPA_TYPE> LongInt2DEmptyDim;
00305 typedef LongInt2DEmptyDimGeneric<C_TYPE> LongInt2DEmptyDimCType;
00306
00307 template<mem_layout ALLOC>
00308 struct LongInt3DEmptyDimGeneric
00309 {
00310 multi_arr<long,3,ALLOC,true> arr;
00311 LongInt3DEmptyDimGeneric()
00312 {
00313 arr.reserve(2);
00314 for (int i=0; i<2; ++i)
00315 {
00316 arr.reserve(i,2);
00317 for (int j=1; j<2; ++j)
00318 {
00319 arr.reserve(i,j,2);
00320 }
00321 }
00322 arr.alloc();
00323 }
00324 ~LongInt3DEmptyDimGeneric() {}
00325 };
00326
00327 typedef LongInt3DEmptyDimGeneric<ARPA_TYPE> LongInt3DEmptyDim;
00328 typedef LongInt3DEmptyDimGeneric<C_TYPE> LongInt3DEmptyDimCType;
00329
00330 template<mem_layout ALLOC>
00331 struct LongInt4DEmptyDimGeneric
00332 {
00333 multi_arr<long,4,ALLOC,true> arr;
00334 LongInt4DEmptyDimGeneric()
00335 {
00336 arr.reserve(2);
00337 for (int i=0; i<2; ++i)
00338 {
00339 arr.reserve(i,2);
00340 for (int j=0; j<2; ++j)
00341 {
00342 arr.reserve(i,j,2);
00343 for (int k=1; k<2; ++k)
00344 {
00345 arr.reserve(i,j,k,2);
00346 }
00347 }
00348 }
00349 arr.alloc();
00350 }
00351 ~LongInt4DEmptyDimGeneric() {}
00352 };
00353
00354 typedef LongInt4DEmptyDimGeneric<ARPA_TYPE> LongInt4DEmptyDim;
00355 typedef LongInt4DEmptyDimGeneric<C_TYPE> LongInt4DEmptyDimCType;
00356
00357 template<mem_layout ALLOC>
00358 struct LongInt5DEmptyDimGeneric
00359 {
00360 multi_arr<long,5,ALLOC,true> arr;
00361 LongInt5DEmptyDimGeneric()
00362 {
00363 arr.reserve(2);
00364 for (int i=0; i<2; ++i)
00365 {
00366 arr.reserve(i,2);
00367 for (int j=0; j<2; ++j)
00368 {
00369 arr.reserve(i,j,2);
00370 for (int k=0; k<2; ++k)
00371 {
00372 arr.reserve(i,j,k,2);
00373 for (int l=1; l<2; ++l)
00374 {
00375 arr.reserve(i,j,k,l,2);
00376 }
00377 }
00378 }
00379 }
00380 arr.alloc();
00381 }
00382 ~LongInt5DEmptyDimGeneric() {}
00383 };
00384
00385 typedef LongInt5DEmptyDimGeneric<ARPA_TYPE> LongInt5DEmptyDim;
00386 typedef LongInt5DEmptyDimGeneric<C_TYPE> LongInt5DEmptyDimCType;
00387
00388 template<mem_layout ALLOC>
00389 struct LongInt6DEmptyDimGeneric
00390 {
00391 multi_arr<long,6,ALLOC,true> arr;
00392 LongInt6DEmptyDimGeneric()
00393 {
00394 arr.reserve(2);
00395 for (int i=0; i<2; ++i)
00396 {
00397 arr.reserve(i,2);
00398 for (int j=0; j<2; ++j)
00399 {
00400 arr.reserve(i,j,2);
00401 for (int k=0; k<2; ++k)
00402 {
00403 arr.reserve(i,j,k,2);
00404 for (int l=0; l<2; ++l)
00405 {
00406 arr.reserve(i,j,k,l,2);
00407 for (int m=1; m<2; ++m)
00408 {
00409 arr.reserve(i,j,k,l,m,2);
00410 }
00411 }
00412 }
00413 }
00414 }
00415 arr.alloc();
00416 }
00417 ~LongInt6DEmptyDimGeneric() {}
00418 };
00419
00420 typedef LongInt6DEmptyDimGeneric<ARPA_TYPE> LongInt6DEmptyDim;
00421 typedef LongInt6DEmptyDimGeneric<C_TYPE> LongInt6DEmptyDimCType;
00422
00423
00424 TEST_FIXTURE(LongInt2DFixture,TestIteratorPostIncrement)
00425 {
00426 multi_arr<long,2,ARPA_TYPE,false>::iterator p;
00427 p = arr.ptr(5,6);
00428 p++;
00429 CHECK_EQUAL(57,*p);
00430 }
00431 TEST_FIXTURE(LongInt2DFixture,TestIteratorPreIncrement)
00432 {
00433 multi_arr<long,2,ARPA_TYPE,false>::iterator p;
00434 p = arr.ptr(5,6);
00435 ++p;
00436 CHECK_EQUAL(57,*p);
00437 }
00438 TEST_FIXTURE(LongInt2DFixture,TestIteratorPostDecrement)
00439 {
00440 multi_arr<long,2,ARPA_TYPE,false>::iterator p;
00441 p = arr.ptr(5,6);
00442 p--;
00443 CHECK_EQUAL(55,*p);
00444 }
00445 TEST_FIXTURE(LongInt2DFixture,TestIteratorPreDecrement)
00446 {
00447 multi_arr<long,2,ARPA_TYPE,false>::iterator p;
00448 p = arr.ptr(5,6);
00449 --p;
00450 CHECK_EQUAL(55,*p);
00451 }
00452 TEST_FIXTURE(LongInt2DFixture,TestIteratorAddition1)
00453 {
00454 multi_arr<long,2,ARPA_TYPE,false>::iterator p;
00455 p = arr.ptr(5,6);
00456 p += 2;
00457 CHECK_EQUAL(58,*p);
00458 }
00459 TEST_FIXTURE(LongInt2DFixture,TestIteratorSubtraction1)
00460 {
00461 multi_arr<long,2,ARPA_TYPE,false>::iterator p;
00462 p = arr.ptr(5,6);
00463 p -= 2;
00464 CHECK_EQUAL(54,*p);
00465 }
00466 TEST_FIXTURE(LongInt2DFixture,TestIteratorAddition2)
00467 {
00468 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00469 p = arr.ptr(5,6);
00470 q = p + 2;
00471 CHECK_EQUAL(58,*q);
00472 }
00473 TEST_FIXTURE(LongInt2DFixture,TestIteratorSubtraction2)
00474 {
00475 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00476 p = arr.ptr(5,6);
00477 q = p - 2;
00478 CHECK_EQUAL(54,*q);
00479 }
00480 TEST_FIXTURE(LongInt2DFixture,TestIteratorAddition3)
00481 {
00482 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00483 p = arr.ptr(5,6);
00484 q = 2 + p;
00485 CHECK_EQUAL(58,*q);
00486 }
00487 TEST_FIXTURE(LongInt2DFixture,TestIteratorSubtraction3)
00488 {
00489 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00490 p = arr.ptr(5,6);
00491 q = p - 2;
00492 CHECK_EQUAL(2,p-q);
00493 }
00494 TEST_FIXTURE(LongInt2DFixture,TestIteratorBrackets)
00495 {
00496 multi_arr<long,2,ARPA_TYPE,false>::iterator p;
00497 p = arr.ptr(5,6);
00498 CHECK_EQUAL(57,p[1]);
00499 }
00500
00501
00502 TEST_FIXTURE(LongInt2DFixture,TestIteratorComparison1)
00503 {
00504 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00505 p = arr.ptr(5,6);
00506 q = ++p;
00507 CHECK(p == q);
00508 }
00509 TEST_FIXTURE(LongInt2DFixture,TestIteratorComparison2)
00510 {
00511 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00512 p = arr.ptr(5,6);
00513 q = p++;
00514 CHECK(p != q);
00515 }
00516 TEST_FIXTURE(LongInt2DFixture,TestIteratorComparison3)
00517 {
00518 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00519 p = arr.ptr(5,6);
00520 q = p--;
00521 CHECK(p < q);
00522 }
00523 TEST_FIXTURE(LongInt2DFixture,TestIteratorComparison4)
00524 {
00525 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00526 p = arr.ptr(5,6);
00527 q = --p;
00528 CHECK(p <= q);
00529 }
00530 TEST_FIXTURE(LongInt2DFixture,TestIteratorComparison5)
00531 {
00532 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00533 p = arr.ptr(5,6);
00534 q = p++;
00535 CHECK(p > q);
00536 }
00537 TEST_FIXTURE(LongInt2DFixture,TestIteratorComparison6)
00538 {
00539 multi_arr<long,2,ARPA_TYPE,false>::iterator p, q;
00540 p = arr.ptr(5,6);
00541 q = --p;
00542 CHECK(p >= q);
00543 }
00544
00545
00546 TEST_FIXTURE(LongInt2DFixtureBC,TestIteratorBoundsCheck)
00547 {
00548 multi_arr<long,2,ARPA_TYPE,true>::iterator p;
00549 p = arr.ptr(5,8);
00550 CHECK_THROW(( *++p == 59 ),out_of_range);
00551 }
00552
00553
00554 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorPostIncrement)
00555 {
00556 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p;
00557 p = arr.ptr(5,6);
00558 p++;
00559 CHECK_EQUAL(57,*p);
00560 }
00561 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorPreIncrement)
00562 {
00563 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p;
00564 p = arr.ptr(5,6);
00565 ++p;
00566 CHECK_EQUAL(57,*p);
00567 }
00568 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorPostDecrement)
00569 {
00570 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p;
00571 p = arr.ptr(5,6);
00572 p--;
00573 CHECK_EQUAL(55,*p);
00574 }
00575 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorPreDecrement)
00576 {
00577 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p;
00578 p = arr.ptr(5,6);
00579 --p;
00580 CHECK_EQUAL(55,*p);
00581 }
00582 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorAddition1)
00583 {
00584 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p;
00585 p = arr.ptr(5,6);
00586 p += 2;
00587 CHECK_EQUAL(58,*p);
00588 }
00589 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorSubtraction1)
00590 {
00591 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p;
00592 p = arr.ptr(5,6);
00593 p -= 2;
00594 CHECK_EQUAL(54,*p);
00595 }
00596 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorAddition2)
00597 {
00598 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00599 p = arr.ptr(5,6);
00600 q = p + 2;
00601 CHECK_EQUAL(58,*q);
00602 }
00603 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorSubtraction2)
00604 {
00605 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00606 p = arr.ptr(5,6);
00607 q = p - 2;
00608 CHECK_EQUAL(54,*q);
00609 }
00610 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorAddition3)
00611 {
00612 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00613 p = arr.ptr(5,6);
00614 q = 2 + p;
00615 CHECK_EQUAL(58,*q);
00616 }
00617 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorSubtraction3)
00618 {
00619 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00620 p = arr.ptr(5,6);
00621 q = p - 2;
00622 CHECK_EQUAL(2,p-q);
00623 }
00624 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorBrackets)
00625 {
00626 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p;
00627 p = arr.ptr(5,6);
00628 CHECK_EQUAL(57,p[1]);
00629 }
00630
00631 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorComparison1)
00632 {
00633 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00634 p = arr.ptr(5,6);
00635 q = ++p;
00636 CHECK(p == q);
00637 }
00638 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorComparison2)
00639 {
00640 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00641 p = arr.ptr(5,6);
00642 q = p++;
00643 CHECK(p != q);
00644 }
00645 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorComparison3)
00646 {
00647 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00648 p = arr.ptr(5,6);
00649 q = p--;
00650 CHECK(p < q);
00651 }
00652 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorComparison4)
00653 {
00654 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00655 p = arr.ptr(5,6);
00656 q = --p;
00657 CHECK(p <= q);
00658 }
00659 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorComparison5)
00660 {
00661 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00662 p = arr.ptr(5,6);
00663 q = p++;
00664 CHECK(p > q);
00665 }
00666 TEST_FIXTURE(LongInt2DFixture,TestConstIteratorComparison6)
00667 {
00668 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p, q;
00669 p = arr.ptr(5,6);
00670 q = --p;
00671 CHECK(p >= q);
00672 }
00673
00674 TEST_FIXTURE(LongInt2DFixtureBC,TestConstIteratorBoundsCheck)
00675 {
00676 multi_arr<long,2,ARPA_TYPE,true>::const_iterator p;
00677 p = arr.ptr(5,8);
00678 CHECK_THROW(( *++p == 59 ),out_of_range);
00679 }
00680
00681 TEST_FIXTURE(LongInt3DFixture,TestDataEmpty)
00682 {
00683 arr.clear();
00684
00685 arr.alloc();
00686 CHECK_EQUAL( 0UL, arr.size() );
00687 CHECK( NULL == arr.data() );
00688 }
00689
00690
00691 TEST_FIXTURE(LongInt3DFixture,TestFill)
00692 {
00693 arr.zero();
00694 for (int i=0; i<10; ++i)
00695 for (int j=0; j<9; ++j)
00696 for (int k=0; k<8; ++k)
00697 CHECK_EQUAL(0,arr[i][j][k]);
00698 arr.invalidate();
00699 for (int i=0; i<10; ++i)
00700 for (int j=0; j<9; ++j)
00701 for (int k=0; k<8; ++k)
00702 CHECK_EQUAL(-1,arr[i][j][k]);
00703 arr.clear();
00704
00705 arr.zero();
00706 arr.invalidate();
00707 }
00708
00709
00710 TEST_FIXTURE(LongInt3DFixtureCTypeBC,TestFillCType)
00711 {
00712 arr.zero();
00713 for (int i=0; i<10; ++i)
00714 for (int j=0; j<9; ++j)
00715 for (int k=0; k<8; ++k)
00716 CHECK_EQUAL(0.,arr[i][j][k]);
00717 arr.invalidate();
00718 for (int i=0; i<10; ++i)
00719 for (int j=0; j<9; ++j)
00720 for (int k=0; k<8; ++k)
00721 CHECK_EQUAL(-1,arr[i][j][k]);
00722 }
00723
00724 TEST_FIXTURE(RealNum3DFixture,TestInvalidRealNum)
00725 {
00726 arr.invalidate();
00727 for (int i=0; i<10; ++i)
00728 for (int j=0; j<9; ++j)
00729 for (int k=0; k<8; ++k)
00730 CHECK(isnan(arr[i][j][k]));
00731 arr.clear();
00732
00733 arr.invalidate();
00734 }
00735 TEST_FIXTURE(Double3DFixture,TestInvalidDouble)
00736 {
00737 arr.invalidate();
00738 for (int i=0; i<10; ++i)
00739 for (int j=0; j<9; ++j)
00740 for (int k=0; k<8; ++k)
00741 CHECK(isnan(arr[i][j][k]));
00742 arr.clear();
00743
00744 arr.invalidate();
00745 }
00746
00747 TEST_FIXTURE(LongInt3DFixture,TestStateDo)
00748 {
00749 const char *fnam = "tma.872GqS";
00750 FILE *io = fopen( fnam, "wb" );
00751 CHECK( io != NULL );
00752 arr.state_do( io, false );
00753 fclose( io );
00754 arr.invalidate();
00755 io = fopen( fnam, "rb" );
00756 CHECK( io != NULL );
00757 arr.state_do( io, true );
00758 fclose( io );
00759 remove(fnam);
00760 CHECK_EQUAL(304,arr[3][0][4]);
00761 }
00762
00763 TEST_FIXTURE(LongInt3DFixtureCType,TestStateDoCType)
00764 {
00765 const char *fnam = "tma.872GqS";
00766 FILE *io = fopen( fnam, "wb" );
00767 CHECK( io != NULL );
00768 arr.state_do( io, false );
00769 fclose( io );
00770 arr.invalidate();
00771 io = fopen( fnam, "rb" );
00772 CHECK( io != NULL );
00773 arr.state_do( io, true );
00774 fclose( io );
00775 remove(fnam);
00776 CHECK_EQUAL(304,arr[3][0][4]);
00777 }
00778
00779
00780
00781 TEST_FIXTURE(LongInt2DFixture,Test2DIndexedValue)
00782 {
00783 CHECK_EQUAL(98,arr[9][8]);
00784 CHECK_EQUAL(37,*arr.ptr(3,7));
00785 const multi_arr<long,2,ARPA_TYPE,false>* carr = &arr;
00786 multi_arr<long,2,ARPA_TYPE,false>::const_iterator p = carr->ptr(4,6);
00787 CHECK_EQUAL(46,*p);
00788 const long& q = (*carr)[7][5];
00789 CHECK_EQUAL(75,q);
00790 }
00791 TEST_FIXTURE(LongInt3DFixture,Test3DIndexedValue)
00792 {
00793 CHECK_EQUAL(987,arr[9][8][7]);
00794 CHECK_EQUAL(137,*arr.ptr(1,3,7));
00795 const multi_arr<long,3,ARPA_TYPE,false>* carr = &arr;
00796 multi_arr<long,3,ARPA_TYPE,false>::const_iterator p = carr->ptr(4,6,2);
00797 CHECK_EQUAL(462,*p);
00798 const long& q = (*carr)[7][5][6];
00799 CHECK_EQUAL(756,q);
00800 }
00801 TEST_FIXTURE(LongInt4DFixture,Test4DIndexedValue)
00802 {
00803 CHECK_EQUAL(9876,arr[9][8][7][6]);
00804 CHECK_EQUAL(1342,*arr.ptr(1,3,4,2));
00805 const multi_arr<long,4,ARPA_TYPE,false>* carr = &arr;
00806 multi_arr<long,4,ARPA_TYPE,false>::const_iterator p = carr->ptr(4,6,2,0);
00807 CHECK_EQUAL(4620,*p);
00808 const long& q = (*carr)[7][5][6][3];
00809 CHECK_EQUAL(7563,q);
00810 }
00811 TEST_FIXTURE(LongInt5DFixture,Test5DIndexedValue)
00812 {
00813 CHECK_EQUAL(98765,arr[9][8][7][6][5]);
00814 CHECK_EQUAL(10342,*arr.ptr(1,0,3,4,2));
00815 const multi_arr<long,5,ARPA_TYPE,false>* carr = &arr;
00816 multi_arr<long,5,ARPA_TYPE,false>::const_iterator p = carr->ptr(4,6,2,0,1);
00817 CHECK_EQUAL(46201,*p);
00818 const long& q = (*carr)[7][5][6][3][2];
00819 CHECK_EQUAL(75632,q);
00820 }
00821 TEST_FIXTURE(LongInt6DFixture,Test6DIndexedValue)
00822 {
00823 CHECK_EQUAL(987654,arr[9][8][7][6][5][4]);
00824 CHECK_EQUAL(106423,*arr.ptr(1,0,6,4,2,3));
00825 const multi_arr<long,6,ARPA_TYPE,false>* carr = &arr;
00826 multi_arr<long,6,ARPA_TYPE,false>::const_iterator p = carr->ptr(4,6,2,0,1,3);
00827 CHECK_EQUAL(462013,*p);
00828 const long& q = (*carr)[7][5][6][3][2][1];
00829 CHECK_EQUAL(756321,q);
00830 }
00831
00832
00833
00834
00835 TEST_FIXTURE(LongInt2DFixture,Test2DAtOutOfBounds)
00836 {
00837 CHECK_THROW(arr.at(m1,1),out_of_range);
00838 CHECK_THROW(arr.at(10,1),out_of_range);
00839 CHECK_THROW(arr.at(7,m1),out_of_range);
00840 CHECK_THROW(arr.at(7,9),out_of_range);
00841 const multi_arr<long,2,ARPA_TYPE,false>* carr = &arr;
00842 CHECK_THROW(carr->at(m1,1),out_of_range);
00843 CHECK_THROW(carr->at(10,1),out_of_range);
00844 CHECK_THROW(carr->at(7,m1),out_of_range);
00845 CHECK_THROW(carr->at(7,9),out_of_range);
00846 }
00847 TEST_FIXTURE(LongInt3DFixture,Test3DAtOutOfBounds)
00848 {
00849 CHECK_THROW(arr.at(m1,1,2),out_of_range);
00850 CHECK_THROW(arr.at(10,1,2),out_of_range);
00851 CHECK_THROW(arr.at(7,m1,3),out_of_range);
00852 CHECK_THROW(arr.at(7,9,3),out_of_range);
00853 CHECK_THROW(arr.at(7,3,m1),out_of_range);
00854 CHECK_THROW(arr.at(7,3,8),out_of_range);
00855 const multi_arr<long,3,ARPA_TYPE,false>* carr = &arr;
00856 CHECK_THROW(carr->at(m1,1,2),out_of_range);
00857 CHECK_THROW(carr->at(10,1,2),out_of_range);
00858 CHECK_THROW(carr->at(7,m1,3),out_of_range);
00859 CHECK_THROW(carr->at(7,9,3),out_of_range);
00860 CHECK_THROW(carr->at(7,3,m1),out_of_range);
00861 CHECK_THROW(carr->at(7,3,8),out_of_range);
00862 }
00863 TEST_FIXTURE(LongInt4DFixture,Test4DAtOutOfBounds)
00864 {
00865 CHECK_THROW(arr.at(m1,1,2,3),out_of_range);
00866 CHECK_THROW(arr.at(10,1,2,3),out_of_range);
00867 CHECK_THROW(arr.at(7,m1,3,2),out_of_range);
00868 CHECK_THROW(arr.at(7,9,3,2),out_of_range);
00869 CHECK_THROW(arr.at(7,3,m1,1),out_of_range);
00870 CHECK_THROW(arr.at(7,3,8,1),out_of_range);
00871 CHECK_THROW(arr.at(7,3,1,m1),out_of_range);
00872 CHECK_THROW(arr.at(7,3,1,7),out_of_range);
00873 const multi_arr<long,4,ARPA_TYPE,false>* carr = &arr;
00874 CHECK_THROW(carr->at(m1,1,2,3),out_of_range);
00875 CHECK_THROW(carr->at(10,1,2,3),out_of_range);
00876 CHECK_THROW(carr->at(7,m1,3,2),out_of_range);
00877 CHECK_THROW(carr->at(7,9,3,2),out_of_range);
00878 CHECK_THROW(carr->at(7,3,m1,1),out_of_range);
00879 CHECK_THROW(carr->at(7,3,8,1),out_of_range);
00880 CHECK_THROW(carr->at(7,3,1,m1),out_of_range);
00881 CHECK_THROW(carr->at(7,3,1,7),out_of_range);
00882 }
00883 TEST_FIXTURE(LongInt5DFixture,Test5DAtOutOfBounds)
00884 {
00885 CHECK_THROW(arr.at(m1,1,2,3,4),out_of_range);
00886 CHECK_THROW(arr.at(10,1,2,3,4),out_of_range);
00887 CHECK_THROW(arr.at(7,m1,3,2,4),out_of_range);
00888 CHECK_THROW(arr.at(7,9,3,2,4),out_of_range);
00889 CHECK_THROW(arr.at(7,3,m1,1,0),out_of_range);
00890 CHECK_THROW(arr.at(7,3,8,1,0),out_of_range);
00891 CHECK_THROW(arr.at(7,3,1,m1,2),out_of_range);
00892 CHECK_THROW(arr.at(7,3,1,7,2),out_of_range);
00893 CHECK_THROW(arr.at(7,3,1,2,m1),out_of_range);
00894 CHECK_THROW(arr.at(7,3,1,2,6),out_of_range);
00895 const multi_arr<long,5,ARPA_TYPE,false>* carr = &arr;
00896 CHECK_THROW(carr->at(m1,1,2,3,4),out_of_range);
00897 CHECK_THROW(carr->at(10,1,2,3,4),out_of_range);
00898 CHECK_THROW(carr->at(7,m1,3,2,4),out_of_range);
00899 CHECK_THROW(carr->at(7,9,3,2,4),out_of_range);
00900 CHECK_THROW(carr->at(7,3,m1,1,0),out_of_range);
00901 CHECK_THROW(carr->at(7,3,8,1,0),out_of_range);
00902 CHECK_THROW(carr->at(7,3,1,m1,2),out_of_range);
00903 CHECK_THROW(carr->at(7,3,1,7,2),out_of_range);
00904 CHECK_THROW(carr->at(7,3,1,2,m1),out_of_range);
00905 CHECK_THROW(carr->at(7,3,1,2,6),out_of_range);
00906 }
00907 TEST_FIXTURE(LongInt6DFixture,Test6DAtOutOfBounds)
00908 {
00909 CHECK_THROW(arr.at(m1,1,2,3,4,0),out_of_range);
00910 CHECK_THROW(arr.at(10,1,2,3,4,0),out_of_range);
00911 CHECK_THROW(arr.at(7,m1,3,2,4,1),out_of_range);
00912 CHECK_THROW(arr.at(7,9,3,2,4,1),out_of_range);
00913 CHECK_THROW(arr.at(7,3,m1,1,0,2),out_of_range);
00914 CHECK_THROW(arr.at(7,3,8,1,0,2),out_of_range);
00915 CHECK_THROW(arr.at(7,3,1,m1,2,0),out_of_range);
00916 CHECK_THROW(arr.at(7,3,1,7,2,0),out_of_range);
00917 CHECK_THROW(arr.at(7,4,1,2,m1,3),out_of_range);
00918 CHECK_THROW(arr.at(7,4,1,2,6,3),out_of_range);
00919 CHECK_THROW(arr.at(7,4,1,2,3,m1),out_of_range);
00920 CHECK_THROW(arr.at(7,4,1,2,3,5),out_of_range);
00921 const multi_arr<long,6,ARPA_TYPE,false>* carr = &arr;
00922 CHECK_THROW(carr->at(m1,1,2,3,4,0),out_of_range);
00923 CHECK_THROW(carr->at(10,1,2,3,4,0),out_of_range);
00924 CHECK_THROW(carr->at(7,m1,3,2,4,1),out_of_range);
00925 CHECK_THROW(carr->at(7,9,3,2,4,1),out_of_range);
00926 CHECK_THROW(carr->at(7,3,m1,1,0,2),out_of_range);
00927 CHECK_THROW(carr->at(7,3,8,1,0,2),out_of_range);
00928 CHECK_THROW(carr->at(7,3,1,m1,2,0),out_of_range);
00929 CHECK_THROW(carr->at(7,3,1,7,2,0),out_of_range);
00930 CHECK_THROW(carr->at(7,4,1,2,m1,3),out_of_range);
00931 CHECK_THROW(carr->at(7,4,1,2,6,3),out_of_range);
00932 CHECK_THROW(carr->at(7,4,1,2,3,m1),out_of_range);
00933 CHECK_THROW(carr->at(7,4,1,2,3,5),out_of_range);
00934 }
00935
00936 TEST_FIXTURE(LongInt2DFixtureBC,Test2DOutOfBounds)
00937 {
00938 CHECK_THROW(arr[m1][1],out_of_range);
00939 CHECK_THROW(arr[10][1],out_of_range);
00940 CHECK_THROW(arr[7][m1],out_of_range);
00941 CHECK_THROW(arr[7][9],out_of_range);
00942 CHECK_THROW(arr.ptr(m1,1),out_of_range);
00943 CHECK_THROW(arr.ptr(10,1),out_of_range);
00944 const multi_arr<long,2,ARPA_TYPE,true>* carr = &arr;
00945 CHECK_THROW((*carr)[m1][1],out_of_range);
00946 CHECK_THROW((*carr)[10][1],out_of_range);
00947 CHECK_THROW((*carr)[7][m1],out_of_range);
00948 CHECK_THROW((*carr)[7][9],out_of_range);
00949 }
00950 TEST_FIXTURE(LongInt3DFixtureBC,Test3DOutOfBounds)
00951 {
00952 CHECK_THROW(arr[m1][1][2],out_of_range);
00953 CHECK_THROW(arr[10][1][2],out_of_range);
00954 CHECK_THROW(arr[7][m1][3],out_of_range);
00955 CHECK_THROW(arr[7][9][3],out_of_range);
00956 CHECK_THROW(arr[7][3][m1],out_of_range);
00957 CHECK_THROW(arr[7][3][8],out_of_range);
00958 CHECK_THROW(arr.ptr(m1,1,2),out_of_range);
00959 CHECK_THROW(arr.ptr(10,1,2),out_of_range);
00960 CHECK_THROW(arr.ptr(7,m1,3),out_of_range);
00961 CHECK_THROW(arr.ptr(7,9,3),out_of_range);
00962 const multi_arr<long,3,ARPA_TYPE,true>* carr = &arr;
00963 CHECK_THROW((*carr)[m1][1][2],out_of_range);
00964 CHECK_THROW((*carr)[10][1][2],out_of_range);
00965 CHECK_THROW((*carr)[7][m1][3],out_of_range);
00966 CHECK_THROW((*carr)[7][9][3],out_of_range);
00967 CHECK_THROW((*carr)[7][3][m1],out_of_range);
00968 CHECK_THROW((*carr)[7][3][8],out_of_range);
00969 }
00970 TEST_FIXTURE(LongInt4DFixtureBC,Test4DOutOfBounds)
00971 {
00972 CHECK_THROW(arr[m1][1][2][3],out_of_range);
00973 CHECK_THROW(arr[10][1][2][3],out_of_range);
00974 CHECK_THROW(arr[7][m1][3][2],out_of_range);
00975 CHECK_THROW(arr[7][9][3][2],out_of_range);
00976 CHECK_THROW(arr[7][3][m1][1],out_of_range);
00977 CHECK_THROW(arr[7][3][8][1],out_of_range);
00978 CHECK_THROW(arr[7][3][1][m1],out_of_range);
00979 CHECK_THROW(arr[7][3][1][7],out_of_range);
00980 CHECK_THROW(arr.ptr(m1,1,2,3),out_of_range);
00981 CHECK_THROW(arr.ptr(10,1,2,3),out_of_range);
00982 CHECK_THROW(arr.ptr(7,m1,3,2),out_of_range);
00983 CHECK_THROW(arr.ptr(7,9,3,2),out_of_range);
00984 CHECK_THROW(arr.ptr(7,3,m1,1),out_of_range);
00985 CHECK_THROW(arr.ptr(7,3,8,1),out_of_range);
00986 const multi_arr<long,4,ARPA_TYPE,true>* carr = &arr;
00987 CHECK_THROW((*carr)[m1][1][2][3],out_of_range);
00988 CHECK_THROW((*carr)[10][1][2][3],out_of_range);
00989 CHECK_THROW((*carr)[7][m1][3][2],out_of_range);
00990 CHECK_THROW((*carr)[7][9][3][2],out_of_range);
00991 CHECK_THROW((*carr)[7][3][m1][1],out_of_range);
00992 CHECK_THROW((*carr)[7][3][8][1],out_of_range);
00993 CHECK_THROW((*carr)[7][3][1][m1],out_of_range);
00994 CHECK_THROW((*carr)[7][3][1][7],out_of_range);
00995 }
00996 TEST_FIXTURE(LongInt5DFixtureBC,Test5DOutOfBounds)
00997 {
00998 CHECK_THROW(arr[m1][1][2][3][4],out_of_range);
00999 CHECK_THROW(arr[10][1][2][3][4],out_of_range);
01000 CHECK_THROW(arr[7][m1][3][2][4],out_of_range);
01001 CHECK_THROW(arr[7][9][3][2][4],out_of_range);
01002 CHECK_THROW(arr[7][3][m1][1][0],out_of_range);
01003 CHECK_THROW(arr[7][3][8][1][0],out_of_range);
01004 CHECK_THROW(arr[7][3][1][m1][2],out_of_range);
01005 CHECK_THROW(arr[7][3][1][7][2],out_of_range);
01006 CHECK_THROW(arr[7][3][1][2][m1],out_of_range);
01007 CHECK_THROW(arr[7][3][1][2][6],out_of_range);
01008 CHECK_THROW(arr.ptr(m1,1,2,3,4),out_of_range);
01009 CHECK_THROW(arr.ptr(10,1,2,3,4),out_of_range);
01010 CHECK_THROW(arr.ptr(7,m1,3,2,4),out_of_range);
01011 CHECK_THROW(arr.ptr(7,9,3,2,4),out_of_range);
01012 CHECK_THROW(arr.ptr(7,3,m1,1,0),out_of_range);
01013 CHECK_THROW(arr.ptr(7,3,8,1,0),out_of_range);
01014 CHECK_THROW(arr.ptr(7,3,1,m1,2),out_of_range);
01015 CHECK_THROW(arr.ptr(7,3,1,7,2),out_of_range);
01016 const multi_arr<long,5,ARPA_TYPE,true>* carr = &arr;
01017 CHECK_THROW((*carr)[m1][1][2][3][4],out_of_range);
01018 CHECK_THROW((*carr)[10][1][2][3][4],out_of_range);
01019 CHECK_THROW((*carr)[7][m1][3][2][4],out_of_range);
01020 CHECK_THROW((*carr)[7][9][3][2][4],out_of_range);
01021 CHECK_THROW((*carr)[7][3][m1][1][0],out_of_range);
01022 CHECK_THROW((*carr)[7][3][8][1][0],out_of_range);
01023 CHECK_THROW((*carr)[7][3][1][m1][2],out_of_range);
01024 CHECK_THROW((*carr)[7][3][1][7][2],out_of_range);
01025 CHECK_THROW((*carr)[7][3][1][2][m1],out_of_range);
01026 CHECK_THROW((*carr)[7][3][1][2][6],out_of_range);
01027 }
01028 TEST_FIXTURE(LongInt6DFixtureBC,Test6DOutOfBounds)
01029 {
01030 CHECK_THROW(arr[m1][1][2][3][4][0],out_of_range);
01031 CHECK_THROW(arr[10][1][2][3][4][0],out_of_range);
01032 CHECK_THROW(arr[7][m1][3][2][4][1],out_of_range);
01033 CHECK_THROW(arr[7][9][3][2][4][1],out_of_range);
01034 CHECK_THROW(arr[7][3][m1][1][0][2],out_of_range);
01035 CHECK_THROW(arr[7][3][8][1][0][2],out_of_range);
01036 CHECK_THROW(arr[7][3][1][m1][2][0],out_of_range);
01037 CHECK_THROW(arr[7][3][1][7][2][0],out_of_range);
01038 CHECK_THROW(arr[7][4][1][2][m1][3],out_of_range);
01039 CHECK_THROW(arr[7][4][1][2][6][3],out_of_range);
01040 CHECK_THROW(arr[7][4][1][2][3][m1],out_of_range);
01041 CHECK_THROW(arr[7][4][1][2][3][5],out_of_range);
01042 CHECK_THROW(arr.ptr(m1,1,2,3,4,0),out_of_range);
01043 CHECK_THROW(arr.ptr(10,1,2,3,4,0),out_of_range);
01044 CHECK_THROW(arr.ptr(7,m1,3,2,4,1),out_of_range);
01045 CHECK_THROW(arr.ptr(7,9,3,2,4,1),out_of_range);
01046 CHECK_THROW(arr.ptr(7,3,m1,1,0,2),out_of_range);
01047 CHECK_THROW(arr.ptr(7,3,8,1,0,2),out_of_range);
01048 CHECK_THROW(arr.ptr(7,3,1,m1,2,0),out_of_range);
01049 CHECK_THROW(arr.ptr(7,3,1,7,2,0),out_of_range);
01050 CHECK_THROW(arr.ptr(7,4,1,2,m1,3),out_of_range);
01051 CHECK_THROW(arr.ptr(7,4,1,2,6,3),out_of_range);
01052 const multi_arr<long,6,ARPA_TYPE,true>* carr = &arr;
01053 CHECK_THROW((*carr)[m1][1][2][3][4][0],out_of_range);
01054 CHECK_THROW((*carr)[10][1][2][3][4][0],out_of_range);
01055 CHECK_THROW((*carr)[7][m1][3][2][4][1],out_of_range);
01056 CHECK_THROW((*carr)[7][9][3][2][4][1],out_of_range);
01057 CHECK_THROW((*carr)[7][3][m1][1][0][2],out_of_range);
01058 CHECK_THROW((*carr)[7][3][8][1][0][2],out_of_range);
01059 CHECK_THROW((*carr)[7][3][1][m1][2][0],out_of_range);
01060 CHECK_THROW((*carr)[7][3][1][7][2][0],out_of_range);
01061 CHECK_THROW((*carr)[7][4][1][2][m1][3],out_of_range);
01062 CHECK_THROW((*carr)[7][4][1][2][6][3],out_of_range);
01063 CHECK_THROW((*carr)[7][4][1][2][3][m1],out_of_range);
01064 CHECK_THROW((*carr)[7][4][1][2][3][5],out_of_range);
01065 }
01066
01067
01068 TEST_FIXTURE(LongInt2DFixtureCType,Test2DIndexedValueCType)
01069 {
01070 CHECK_EQUAL(98,arr[9][8]);
01071 CHECK_EQUAL(37,*arr.ptr(3,7));
01072 const multi_arr<long,2,C_TYPE,false>* carr = &arr;
01073 multi_arr<long,2,C_TYPE,false>::const_iterator p = carr->ptr(4,6);
01074 CHECK_EQUAL(46,*p);
01075 const long& q = (*carr)[7][5];
01076 CHECK_EQUAL(75,q);
01077 }
01078 TEST_FIXTURE(LongInt3DFixtureCType,Test3DIndexedValueCType)
01079 {
01080 CHECK_EQUAL(987,arr[9][8][7]);
01081 CHECK_EQUAL(137,*arr.ptr(1,3,7));
01082 const multi_arr<long,3,C_TYPE,false>* carr = &arr;
01083 multi_arr<long,3,C_TYPE,false>::const_iterator p = carr->ptr(4,6,2);
01084 CHECK_EQUAL(462,*p);
01085 const long& q = (*carr)[7][5][6];
01086 CHECK_EQUAL(756,q);
01087 }
01088 TEST_FIXTURE(LongInt4DFixtureCType,Test4DIndexedValueCType)
01089 {
01090 CHECK_EQUAL(9876,arr[9][8][7][6]);
01091 CHECK_EQUAL(1342,*arr.ptr(1,3,4,2));
01092 const multi_arr<long,4,C_TYPE,false>* carr = &arr;
01093 multi_arr<long,4,C_TYPE,false>::const_iterator p = carr->ptr(4,6,2,0);
01094 CHECK_EQUAL(4620,*p);
01095 const long& q = (*carr)[7][5][6][3];
01096 CHECK_EQUAL(7563,q);
01097 }
01098 TEST_FIXTURE(LongInt5DFixtureCType,Test5DIndexedValueCType)
01099 {
01100 CHECK_EQUAL(98765,arr[9][8][7][6][5]);
01101 CHECK_EQUAL(10342,*arr.ptr(1,0,3,4,2));
01102 const multi_arr<long,5,C_TYPE,false>* carr = &arr;
01103 multi_arr<long,5,C_TYPE,false>::const_iterator p = carr->ptr(4,6,2,0,1);
01104 CHECK_EQUAL(46201,*p);
01105 const long& q = (*carr)[7][5][6][3][2];
01106 CHECK_EQUAL(75632,q);
01107 }
01108 TEST_FIXTURE(LongInt6DFixtureCType,Test6DIndexedValueCType)
01109 {
01110 CHECK_EQUAL(987654,arr[9][8][7][6][5][4]);
01111 CHECK_EQUAL(106423,*arr.ptr(1,0,6,4,2,3));
01112 const multi_arr<long,6,C_TYPE,false>* carr = &arr;
01113 multi_arr<long,6,C_TYPE,false>::const_iterator p = carr->ptr(4,6,2,0,1,3);
01114 CHECK_EQUAL(462013,*p);
01115 const long& q = (*carr)[7][5][6][3][2][1];
01116 CHECK_EQUAL(756321,q);
01117 }
01118
01119 TEST_FIXTURE(LongInt2DFixtureCType,Test2DAtOutOfBoundsCType)
01120 {
01121 CHECK_THROW(arr.at(m1,1),out_of_range);
01122 CHECK_THROW(arr.at(10,1),out_of_range);
01123 CHECK_THROW(arr.at(7,m1),out_of_range);
01124 CHECK_THROW(arr.at(7,9),out_of_range);
01125 const multi_arr<long,2,C_TYPE,false>* carr = &arr;
01126 CHECK_THROW(carr->at(m1,1),out_of_range);
01127 CHECK_THROW(carr->at(10,1),out_of_range);
01128 CHECK_THROW(carr->at(7,m1),out_of_range);
01129 CHECK_THROW(carr->at(7,9),out_of_range);
01130 }
01131 TEST_FIXTURE(LongInt3DFixtureCType,Test3DAtOutOfBoundsCType)
01132 {
01133 CHECK_THROW(arr.at(m1,1,2),out_of_range);
01134 CHECK_THROW(arr.at(10,1,2),out_of_range);
01135 CHECK_THROW(arr.at(7,m1,3),out_of_range);
01136 CHECK_THROW(arr.at(7,9,3),out_of_range);
01137 CHECK_THROW(arr.at(7,3,m1),out_of_range);
01138 CHECK_THROW(arr.at(7,3,8),out_of_range);
01139 const multi_arr<long,3,C_TYPE,false>* carr = &arr;
01140 CHECK_THROW(carr->at(m1,1,2),out_of_range);
01141 CHECK_THROW(carr->at(10,1,2),out_of_range);
01142 CHECK_THROW(carr->at(7,m1,3),out_of_range);
01143 CHECK_THROW(carr->at(7,9,3),out_of_range);
01144 CHECK_THROW(carr->at(7,3,m1),out_of_range);
01145 CHECK_THROW(carr->at(7,3,8),out_of_range);
01146 }
01147 TEST_FIXTURE(LongInt4DFixtureCType,Test4DAtOutOfBoundsCType)
01148 {
01149 CHECK_THROW(arr.at(m1,1,2,3),out_of_range);
01150 CHECK_THROW(arr.at(10,1,2,3),out_of_range);
01151 CHECK_THROW(arr.at(7,m1,3,2),out_of_range);
01152 CHECK_THROW(arr.at(7,9,3,2),out_of_range);
01153 CHECK_THROW(arr.at(7,3,m1,1),out_of_range);
01154 CHECK_THROW(arr.at(7,3,8,1),out_of_range);
01155 CHECK_THROW(arr.at(7,3,1,m1),out_of_range);
01156 CHECK_THROW(arr.at(7,3,1,7),out_of_range);
01157 const multi_arr<long,4,C_TYPE,false>* carr = &arr;
01158 CHECK_THROW(carr->at(m1,1,2,3),out_of_range);
01159 CHECK_THROW(carr->at(10,1,2,3),out_of_range);
01160 CHECK_THROW(carr->at(7,m1,3,2),out_of_range);
01161 CHECK_THROW(carr->at(7,9,3,2),out_of_range);
01162 CHECK_THROW(carr->at(7,3,m1,1),out_of_range);
01163 CHECK_THROW(carr->at(7,3,8,1),out_of_range);
01164 CHECK_THROW(carr->at(7,3,1,m1),out_of_range);
01165 CHECK_THROW(carr->at(7,3,1,7),out_of_range);
01166 }
01167 TEST_FIXTURE(LongInt5DFixtureCType,Test5DAtOutOfBoundsCType)
01168 {
01169 CHECK_THROW(arr.at(m1,1,2,3,4),out_of_range);
01170 CHECK_THROW(arr.at(10,1,2,3,4),out_of_range);
01171 CHECK_THROW(arr.at(7,m1,3,2,4),out_of_range);
01172 CHECK_THROW(arr.at(7,9,3,2,4),out_of_range);
01173 CHECK_THROW(arr.at(7,3,m1,1,0),out_of_range);
01174 CHECK_THROW(arr.at(7,3,8,1,0),out_of_range);
01175 CHECK_THROW(arr.at(7,3,1,m1,2),out_of_range);
01176 CHECK_THROW(arr.at(7,3,1,7,2),out_of_range);
01177 CHECK_THROW(arr.at(7,3,1,2,m1),out_of_range);
01178 CHECK_THROW(arr.at(7,3,1,2,6),out_of_range);
01179 const multi_arr<long,5,C_TYPE,false>* carr = &arr;
01180 CHECK_THROW(carr->at(m1,1,2,3,4),out_of_range);
01181 CHECK_THROW(carr->at(10,1,2,3,4),out_of_range);
01182 CHECK_THROW(carr->at(7,m1,3,2,4),out_of_range);
01183 CHECK_THROW(carr->at(7,9,3,2,4),out_of_range);
01184 CHECK_THROW(carr->at(7,3,m1,1,0),out_of_range);
01185 CHECK_THROW(carr->at(7,3,8,1,0),out_of_range);
01186 CHECK_THROW(carr->at(7,3,1,m1,2),out_of_range);
01187 CHECK_THROW(carr->at(7,3,1,7,2),out_of_range);
01188 CHECK_THROW(carr->at(7,3,1,2,m1),out_of_range);
01189 CHECK_THROW(carr->at(7,3,1,2,6),out_of_range);
01190 }
01191 TEST_FIXTURE(LongInt6DFixtureCType,Test6DAtOutOfBoundsCType)
01192 {
01193 CHECK_THROW(arr.at(m1,1,2,3,4,0),out_of_range);
01194 CHECK_THROW(arr.at(10,1,2,3,4,0),out_of_range);
01195 CHECK_THROW(arr.at(7,m1,3,2,4,1),out_of_range);
01196 CHECK_THROW(arr.at(7,9,3,2,4,1),out_of_range);
01197 CHECK_THROW(arr.at(7,3,m1,1,0,2),out_of_range);
01198 CHECK_THROW(arr.at(7,3,8,1,0,2),out_of_range);
01199 CHECK_THROW(arr.at(7,3,1,m1,2,0),out_of_range);
01200 CHECK_THROW(arr.at(7,3,1,7,2,0),out_of_range);
01201 CHECK_THROW(arr.at(7,4,1,2,m1,3),out_of_range);
01202 CHECK_THROW(arr.at(7,4,1,2,6,3),out_of_range);
01203 CHECK_THROW(arr.at(7,4,1,2,3,m1),out_of_range);
01204 CHECK_THROW(arr.at(7,4,1,2,3,5),out_of_range);
01205 const multi_arr<long,6,C_TYPE,false>* carr = &arr;
01206 CHECK_THROW(carr->at(m1,1,2,3,4,0),out_of_range);
01207 CHECK_THROW(carr->at(10,1,2,3,4,0),out_of_range);
01208 CHECK_THROW(carr->at(7,m1,3,2,4,1),out_of_range);
01209 CHECK_THROW(carr->at(7,9,3,2,4,1),out_of_range);
01210 CHECK_THROW(carr->at(7,3,m1,1,0,2),out_of_range);
01211 CHECK_THROW(carr->at(7,3,8,1,0,2),out_of_range);
01212 CHECK_THROW(carr->at(7,3,1,m1,2,0),out_of_range);
01213 CHECK_THROW(carr->at(7,3,1,7,2,0),out_of_range);
01214 CHECK_THROW(carr->at(7,4,1,2,m1,3),out_of_range);
01215 CHECK_THROW(carr->at(7,4,1,2,6,3),out_of_range);
01216 CHECK_THROW(carr->at(7,4,1,2,3,m1),out_of_range);
01217 CHECK_THROW(carr->at(7,4,1,2,3,5),out_of_range);
01218 }
01219
01220 TEST_FIXTURE(LongInt2DFixtureCTypeBC,Test2DOutOfBoundsCType)
01221 {
01222 CHECK_THROW(arr[m1][1],out_of_range);
01223 CHECK_THROW(arr[10][1],out_of_range);
01224 CHECK_THROW(arr[7][m1],out_of_range);
01225 CHECK_THROW(arr[7][9],out_of_range);
01226 CHECK_THROW(arr.ptr(m1,1),out_of_range);
01227 CHECK_THROW(arr.ptr(10,1),out_of_range);
01228 const multi_arr<long,2,C_TYPE,true>* carr = &arr;
01229 CHECK_THROW((*carr)[m1][1],out_of_range);
01230 CHECK_THROW((*carr)[10][1],out_of_range);
01231 CHECK_THROW((*carr)[7][m1],out_of_range);
01232 CHECK_THROW((*carr)[7][9],out_of_range);
01233 }
01234 TEST_FIXTURE(LongInt3DFixtureCTypeBC,Test3DOutOfBoundsCType)
01235 {
01236 CHECK_THROW(arr[m1][1][2],out_of_range);
01237 CHECK_THROW(arr[10][1][2],out_of_range);
01238 CHECK_THROW(arr[7][m1][3],out_of_range);
01239 CHECK_THROW(arr[7][9][3],out_of_range);
01240 CHECK_THROW(arr[7][3][m1],out_of_range);
01241 CHECK_THROW(arr[7][3][8],out_of_range);
01242 CHECK_THROW(arr.ptr(m1,1,2),out_of_range);
01243 CHECK_THROW(arr.ptr(10,1,2),out_of_range);
01244 CHECK_THROW(arr.ptr(7,m1,3),out_of_range);
01245 CHECK_THROW(arr.ptr(7,9,3),out_of_range);
01246 const multi_arr<long,3,C_TYPE,true>* carr = &arr;
01247 CHECK_THROW((*carr)[m1][1][2],out_of_range);
01248 CHECK_THROW((*carr)[10][1][2],out_of_range);
01249 CHECK_THROW((*carr)[7][m1][3],out_of_range);
01250 CHECK_THROW((*carr)[7][9][3],out_of_range);
01251 CHECK_THROW((*carr)[7][3][m1],out_of_range);
01252 CHECK_THROW((*carr)[7][3][8],out_of_range);
01253 }
01254 TEST_FIXTURE(LongInt4DFixtureCTypeBC,Test4DOutOfBoundsCType)
01255 {
01256 CHECK_THROW(arr[m1][1][2][3],out_of_range);
01257 CHECK_THROW(arr[10][1][2][3],out_of_range);
01258 CHECK_THROW(arr[7][m1][3][2],out_of_range);
01259 CHECK_THROW(arr[7][9][3][2],out_of_range);
01260 CHECK_THROW(arr[7][3][m1][1],out_of_range);
01261 CHECK_THROW(arr[7][3][8][1],out_of_range);
01262 CHECK_THROW(arr[7][3][1][m1],out_of_range);
01263 CHECK_THROW(arr[7][3][1][7],out_of_range);
01264 CHECK_THROW(arr.ptr(m1,1,2,3),out_of_range);
01265 CHECK_THROW(arr.ptr(10,1,2,3),out_of_range);
01266 CHECK_THROW(arr.ptr(7,m1,3,2),out_of_range);
01267 CHECK_THROW(arr.ptr(7,9,3,2),out_of_range);
01268 CHECK_THROW(arr.ptr(7,3,m1,1),out_of_range);
01269 CHECK_THROW(arr.ptr(7,3,8,1),out_of_range);
01270 const multi_arr<long,4,C_TYPE,true>* carr = &arr;
01271 CHECK_THROW((*carr)[m1][1][2][3],out_of_range);
01272 CHECK_THROW((*carr)[10][1][2][3],out_of_range);
01273 CHECK_THROW((*carr)[7][m1][3][2],out_of_range);
01274 CHECK_THROW((*carr)[7][9][3][2],out_of_range);
01275 CHECK_THROW((*carr)[7][3][m1][1],out_of_range);
01276 CHECK_THROW((*carr)[7][3][8][1],out_of_range);
01277 CHECK_THROW((*carr)[7][3][1][m1],out_of_range);
01278 CHECK_THROW((*carr)[7][3][1][7],out_of_range);
01279 }
01280 TEST_FIXTURE(LongInt5DFixtureCTypeBC,Test5DOutOfBoundsCType)
01281 {
01282 CHECK_THROW(arr[m1][1][2][3][4],out_of_range);
01283 CHECK_THROW(arr[10][1][2][3][4],out_of_range);
01284 CHECK_THROW(arr[7][m1][3][2][4],out_of_range);
01285 CHECK_THROW(arr[7][9][3][2][4],out_of_range);
01286 CHECK_THROW(arr[7][3][m1][1][0],out_of_range);
01287 CHECK_THROW(arr[7][3][8][1][0],out_of_range);
01288 CHECK_THROW(arr[7][3][1][m1][2],out_of_range);
01289 CHECK_THROW(arr[7][3][1][7][2],out_of_range);
01290 CHECK_THROW(arr[7][3][1][2][m1],out_of_range);
01291 CHECK_THROW(arr[7][3][1][2][6],out_of_range);
01292 CHECK_THROW(arr.ptr(m1,1,2,3,4),out_of_range);
01293 CHECK_THROW(arr.ptr(10,1,2,3,4),out_of_range);
01294 CHECK_THROW(arr.ptr(7,m1,3,2,4),out_of_range);
01295 CHECK_THROW(arr.ptr(7,9,3,2,4),out_of_range);
01296 CHECK_THROW(arr.ptr(7,3,m1,1,0),out_of_range);
01297 CHECK_THROW(arr.ptr(7,3,8,1,0),out_of_range);
01298 CHECK_THROW(arr.ptr(7,3,1,m1,2),out_of_range);
01299 CHECK_THROW(arr.ptr(7,3,1,7,2),out_of_range);
01300 const multi_arr<long,5,C_TYPE,true>* carr = &arr;
01301 CHECK_THROW((*carr)[m1][1][2][3][4],out_of_range);
01302 CHECK_THROW((*carr)[10][1][2][3][4],out_of_range);
01303 CHECK_THROW((*carr)[7][m1][3][2][4],out_of_range);
01304 CHECK_THROW((*carr)[7][9][3][2][4],out_of_range);
01305 CHECK_THROW((*carr)[7][3][m1][1][0],out_of_range);
01306 CHECK_THROW((*carr)[7][3][8][1][0],out_of_range);
01307 CHECK_THROW((*carr)[7][3][1][m1][2],out_of_range);
01308 CHECK_THROW((*carr)[7][3][1][7][2],out_of_range);
01309 CHECK_THROW((*carr)[7][3][1][2][m1],out_of_range);
01310 CHECK_THROW((*carr)[7][3][1][2][6],out_of_range);
01311 }
01312 TEST_FIXTURE(LongInt6DFixtureCTypeBC,Test6DOutOfBoundsCType)
01313 {
01314 CHECK_THROW(arr[m1][1][2][3][4][0],out_of_range);
01315 CHECK_THROW(arr[10][1][2][3][4][0],out_of_range);
01316 CHECK_THROW(arr[7][m1][3][2][4][1],out_of_range);
01317 CHECK_THROW(arr[7][9][3][2][4][1],out_of_range);
01318 CHECK_THROW(arr[7][3][m1][1][0][2],out_of_range);
01319 CHECK_THROW(arr[7][3][8][1][0][2],out_of_range);
01320 CHECK_THROW(arr[7][3][1][m1][2][0],out_of_range);
01321 CHECK_THROW(arr[7][3][1][7][2][0],out_of_range);
01322 CHECK_THROW(arr[7][4][1][2][m1][3],out_of_range);
01323 CHECK_THROW(arr[7][4][1][2][6][3],out_of_range);
01324 CHECK_THROW(arr[7][4][1][2][3][m1],out_of_range);
01325 CHECK_THROW(arr[7][4][1][2][3][5],out_of_range);
01326 CHECK_THROW(arr.ptr(m1,1,2,3,4,0),out_of_range);
01327 CHECK_THROW(arr.ptr(10,1,2,3,4,0),out_of_range);
01328 CHECK_THROW(arr.ptr(7,m1,3,2,4,1),out_of_range);
01329 CHECK_THROW(arr.ptr(7,9,3,2,4,1),out_of_range);
01330 CHECK_THROW(arr.ptr(7,3,m1,1,0,2),out_of_range);
01331 CHECK_THROW(arr.ptr(7,3,8,1,0,2),out_of_range);
01332 CHECK_THROW(arr.ptr(7,3,1,m1,2,0),out_of_range);
01333 CHECK_THROW(arr.ptr(7,3,1,7,2,0),out_of_range);
01334 CHECK_THROW(arr.ptr(7,4,1,2,m1,3),out_of_range);
01335 CHECK_THROW(arr.ptr(7,4,1,2,6,3),out_of_range);
01336 const multi_arr<long,6,C_TYPE,true>* carr = &arr;
01337 CHECK_THROW((*carr)[m1][1][2][3][4][0],out_of_range);
01338 CHECK_THROW((*carr)[10][1][2][3][4][0],out_of_range);
01339 CHECK_THROW((*carr)[7][m1][3][2][4][1],out_of_range);
01340 CHECK_THROW((*carr)[7][9][3][2][4][1],out_of_range);
01341 CHECK_THROW((*carr)[7][3][m1][1][0][2],out_of_range);
01342 CHECK_THROW((*carr)[7][3][8][1][0][2],out_of_range);
01343 CHECK_THROW((*carr)[7][3][1][m1][2][0],out_of_range);
01344 CHECK_THROW((*carr)[7][3][1][7][2][0],out_of_range);
01345 CHECK_THROW((*carr)[7][4][1][2][m1][3],out_of_range);
01346 CHECK_THROW((*carr)[7][4][1][2][6][3],out_of_range);
01347 CHECK_THROW((*carr)[7][4][1][2][3][m1],out_of_range);
01348 CHECK_THROW((*carr)[7][4][1][2][3][5],out_of_range);
01349 }
01350
01351
01352
01353 TEST_FIXTURE(StructWithConstructor3DFixture,TestConstructorExecuted)
01354 {
01355 multi_arr<a,3,ARPA_TYPE,false>::iterator p1 = arr.ptr(1,0,3);
01356 CHECK_EQUAL(23,p1->n);
01357 multi_arr<a,3,ARPA_TYPE,false>::const_iterator p2 = arr.ptr(1,2,0);
01358 CHECK_EQUAL(23,p2->n);
01359 }
01360 TEST_FIXTURE(StructWithConstructor3DFixtureCType,TestConstructorExecutedCType)
01361 {
01362 multi_arr<a,3,C_TYPE,false>::iterator p1 = arr.ptr(1,0,3);
01363 CHECK_EQUAL(23,p1->n);
01364 multi_arr<a,3,C_TYPE,false>::const_iterator p2 = arr.ptr(1,2,0);
01365 CHECK_EQUAL(23,p2->n);
01366 }
01367
01368
01369 TEST_FIXTURE(LongInt3DFixtureBC,TestSize)
01370 {
01371 CHECK_EQUAL((size_t)(10*9*8),arr.size());
01372 arr.clear();
01373 CHECK(arr.empty());
01374
01375 arr.alloc(10,11,12);
01376 CHECK_EQUAL((size_t)(10*11*12),arr.capacity());
01377 arr.zero();
01378
01379
01380
01381 for (int i=0; i<10; ++i)
01382 for (int j=0; j<11; ++j)
01383 {
01384 multi_arr<long,3,ARPA_TYPE,true>::const_iterator p = arr.begin(i,j);
01385 for (int k=0; k<12; ++k)
01386 CHECK_EQUAL(0,p[k]);
01387 }
01388 }
01389
01390
01391
01392 TEST_FIXTURE(LongInt3DFixtureBC,TestSizeAlgorithm)
01393 {
01394 arr.clear();
01395 arr.alloc(10,11,12);
01396 arr.zero();
01397
01398 for (int i=0; i<10; ++i)
01399 for (int j=0; j<11; ++j)
01400 {
01401 CHECK_EQUAL(0,count_if(arr.begin(i,j),arr.end(i,j),
01402 bind1st(not_equal_to<long>(),0)));
01403 }
01404 }
01405
01406 TEST_FIXTURE(LongInt3DFixtureCTypeBC,TestSizeCType)
01407 {
01408 CHECK_EQUAL((size_t)(10*9*8),arr.size());
01409 arr.clear();
01410 CHECK(arr.empty());
01411
01412 arr.alloc(10,11,12);
01413 CHECK_EQUAL((size_t)(10*11*12),arr.capacity());
01414 arr.zero();
01415
01416
01417
01418 for (int i=0; i<10; ++i)
01419 for (int j=0; j<11; ++j)
01420 {
01421 multi_arr<long,3,C_TYPE,true>::const_iterator p = arr.begin(i,j);
01422 for (int k=0; k<12; ++k)
01423 CHECK_EQUAL(0,p[k]);
01424 }
01425 }
01426
01427
01428 TEST_FIXTURE(LongInt6DFixtureExplicitReserve,TestExplicitReserve)
01429 {
01430 arr.zero();
01431 for (int i=0; i<10; ++i)
01432 for (int j=0; j<9; ++j)
01433 for (int k=0; k<8; ++k)
01434 for (int l=0; l<7; ++l)
01435 for (int m=0; m<6; ++m)
01436 for (int n=0; n<5; ++n)
01437 CHECK_EQUAL(0,arr[i][j][k][l][m][n]);
01438
01439 CHECK_THROW(arr.reserve(2),bad_assert);
01440 }
01441
01442
01443
01444 TEST_FIXTURE(TestAllocFixture,TestVariantAlloc)
01445 {
01446 CHECK_EQUAL(0,mytest());
01447 }
01448
01449
01450
01451 TEST_FIXTURE(LongInt3DFixture,TestData)
01452 {
01453 CHECK_EQUAL(&arr[0][0][0],arr.data());
01454 arr[0][0][0] = 1234;
01455 CHECK_EQUAL(1234,*arr.data());
01456 const multi_arr<long,3,ARPA_TYPE,false>* carr = &arr;
01457 CHECK_EQUAL(&arr[0][0][0],carr->data());
01458 }
01459 TEST_FIXTURE(LongInt3DFixtureCType,TestDataCType)
01460 {
01461 CHECK_EQUAL(&arr[0][0][0],arr.data());
01462 arr[0][0][0] = 1234;
01463 CHECK_EQUAL(1234,*arr.data());
01464 const multi_arr<long,3,C_TYPE,false>* carr = &arr;
01465 CHECK_EQUAL(&arr[0][0][0],carr->data());
01466 }
01467
01468 TEST_FIXTURE(LongInt6DFixture,TestCopyOperator)
01469 {
01470 multi_arr<long,6,ARPA_TYPE,false> arr2(1,2,3,4,5,6);
01471 CHECK( arr.size() != arr2.size() );
01472 arr2.zero();
01473 CHECK_EQUAL(0,arr2[0][1][2][3][4][5]);
01474 arr2 = arr;
01475 CHECK( arr.size() == arr2.size() );
01476
01477 CHECK( &arr[0][1][2][3][4][5] != &arr2[0][1][2][3][4][5] );
01478 for (int i=0; i<10; ++i)
01479 for (int j=0; j<9; ++j)
01480 for (int k=0; k<8; ++k)
01481 for (int l=0; l<7; ++l)
01482 for (int m=0; m<6; ++m)
01483 for (int n=0; n<5; ++n)
01484 {
01485 long z = i*100000+j*10000+k*1000+l*100+m*10+n;
01486 CHECK_EQUAL(z,arr2[i][j][k][l][m][n]);
01487 }
01488
01489
01490 arr2 = arr2;
01491
01492 CHECK_EQUAL(712344,arr2[7][1][2][3][4][4]);
01493
01494
01495 multi_arr<long,6,ARPA_TYPE,false> arr3 = arr;
01496 CHECK( arr.size() == arr3.size() );
01497
01498 CHECK( &arr[7][1][2][3][4][4] != &arr3[7][1][2][3][4][4] );
01499 CHECK_EQUAL(arr[7][1][2][3][4][4],arr3[7][1][2][3][4][4]);
01500
01501 arr.clear();
01502
01503 arr2 = arr;
01504 CHECK(arr2.empty());
01505
01506 multi_arr<long,6,ARPA_TYPE,false> arr4( arr );
01507 CHECK(arr4.empty());
01508 }
01509
01510 TEST_FIXTURE(LongInt6DFixtureBC,TestCopyOperatorBC)
01511 {
01512 multi_arr<long,6,ARPA_TYPE,true> arr2(1,2,3,4,5,6);
01513 CHECK( arr.size() != arr2.size() );
01514 arr2.zero();
01515 CHECK_EQUAL(0,arr2[0][1][2][3][4][5]);
01516 arr2 = arr;
01517 CHECK( arr.size() == arr2.size() );
01518 for (int i=0; i<10; ++i)
01519 for (int j=0; j<9; ++j)
01520 for (int k=0; k<8; ++k)
01521 for (int l=0; l<7; ++l)
01522 for (int m=0; m<6; ++m)
01523 for (int n=0; n<5; ++n)
01524 {
01525 long z = i*100000+j*10000+k*1000+l*100+m*10+n;
01526 CHECK_EQUAL(z,arr2[i][j][k][l][m][n]);
01527 }
01528
01529 CHECK_THROW(arr2[m1][1][2][3][4][0],out_of_range);
01530 CHECK_THROW(arr2[10][1][2][3][4][0],out_of_range);
01531 CHECK_THROW(arr2[7][m1][3][2][4][1],out_of_range);
01532 CHECK_THROW(arr2[7][9][3][2][4][1],out_of_range);
01533 CHECK_THROW(arr2[7][3][m1][1][0][2],out_of_range);
01534 CHECK_THROW(arr2[7][3][8][1][0][2],out_of_range);
01535 CHECK_THROW(arr2[7][3][1][m1][2][0],out_of_range);
01536 CHECK_THROW(arr2[7][3][1][7][2][0],out_of_range);
01537 CHECK_THROW(arr2[7][4][1][2][m1][3],out_of_range);
01538 CHECK_THROW(arr2[7][4][1][2][6][3],out_of_range);
01539 CHECK_THROW(arr2[7][4][1][2][3][m1],out_of_range);
01540 CHECK_THROW(arr2[7][4][1][2][3][5],out_of_range);
01541
01542
01543 arr2 = arr2;
01544
01545 CHECK_EQUAL(712344,arr2[7][1][2][3][4][4]);
01546
01547 arr.clear();
01548 arr2 = arr;
01549 CHECK(arr2.empty());
01550
01551 multi_arr<long,6,ARPA_TYPE,true> arr4( arr );
01552 CHECK(arr4.empty());
01553 }
01554
01555 TEST_FIXTURE(LongInt6DFixtureCType,TestCopyOperatorCType)
01556 {
01557 multi_arr<long,6,C_TYPE,false> arr2(1,2,3,4,5,6);
01558 CHECK( arr.size() != arr2.size() );
01559 arr2.zero();
01560 CHECK_EQUAL(0,arr2[0][1][2][3][4][5]);
01561 arr2 = arr;
01562 CHECK( arr.size() == arr2.size() );
01563 for (int i=0; i<10; ++i)
01564 for (int j=0; j<9; ++j)
01565 for (int k=0; k<8; ++k)
01566 for (int l=0; l<7; ++l)
01567 for (int m=0; m<6; ++m)
01568 for (int n=0; n<5; ++n)
01569 {
01570 long z = i*100000+j*10000+k*1000+l*100+m*10+n;
01571 CHECK_EQUAL(z,arr2[i][j][k][l][m][n]);
01572 }
01573
01574
01575 arr2 = arr2;
01576
01577 CHECK_EQUAL(712344,arr2[7][1][2][3][4][4]);
01578
01579 arr.clear();
01580 arr2 = arr;
01581 CHECK(arr2.empty());
01582
01583 multi_arr<long,6,C_TYPE,false> arr4( arr );
01584 CHECK(arr4.empty());
01585 }
01586
01587 TEST_FIXTURE(LongInt6DFixtureCTypeBC,TestCopyOperatorCTypeBC)
01588 {
01589 multi_arr<long,6,C_TYPE,true> arr2(1,2,3,4,5,6);
01590 CHECK( arr.size() != arr2.size() );
01591 arr2.zero();
01592 CHECK_EQUAL(0,arr2[0][1][2][3][4][5]);
01593 arr2 = arr;
01594 CHECK( arr.size() == arr2.size() );
01595 for (int i=0; i<10; ++i)
01596 for (int j=0; j<9; ++j)
01597 for (int k=0; k<8; ++k)
01598 for (int l=0; l<7; ++l)
01599 for (int m=0; m<6; ++m)
01600 for (int n=0; n<5; ++n)
01601 {
01602 long z = i*100000+j*10000+k*1000+l*100+m*10+n;
01603 CHECK_EQUAL(z,arr2[i][j][k][l][m][n]);
01604 }
01605
01606 CHECK_THROW(arr2[m1][1][2][3][4][0],out_of_range);
01607 CHECK_THROW(arr2[10][1][2][3][4][0],out_of_range);
01608 CHECK_THROW(arr2[7][m1][3][2][4][1],out_of_range);
01609 CHECK_THROW(arr2[7][9][3][2][4][1],out_of_range);
01610 CHECK_THROW(arr2[7][3][m1][1][0][2],out_of_range);
01611 CHECK_THROW(arr2[7][3][8][1][0][2],out_of_range);
01612 CHECK_THROW(arr2[7][3][1][m1][2][0],out_of_range);
01613 CHECK_THROW(arr2[7][3][1][7][2][0],out_of_range);
01614 CHECK_THROW(arr2[7][4][1][2][m1][3],out_of_range);
01615 CHECK_THROW(arr2[7][4][1][2][6][3],out_of_range);
01616 CHECK_THROW(arr2[7][4][1][2][3][m1],out_of_range);
01617 CHECK_THROW(arr2[7][4][1][2][3][5],out_of_range);
01618
01619
01620 arr2 = arr2;
01621
01622 CHECK_EQUAL(712344,arr2[7][1][2][3][4][4]);
01623
01624 arr.clear();
01625 arr2 = arr;
01626 CHECK(arr2.empty());
01627
01628 multi_arr<long,6,C_TYPE,true> arr4( arr );
01629 CHECK(arr4.empty());
01630 }
01631
01632
01633 TEST_FIXTURE(LongInt3DCLayoutFixture,TestCLayout)
01634 {
01635 CHECK_EQUAL(0L,mytest((long(*)[10][10])arr.data()));
01636 }
01637
01638
01639 TEST_FIXTURE(LongInt3DCloneFixture,TestCloning)
01640 {
01641
01642 multi_arr<bool,3,ARPA_TYPE,true> dolly( arr.clone() );
01643 CHECK_THROW(dolly[10][0][0],out_of_range);
01644 for (int i=0; i<10; ++i)
01645 {
01646 CHECK_THROW(dolly[i][i+1][0],out_of_range);
01647 for (int j=0; j<i+1; ++j)
01648 CHECK_THROW(dolly[i][j][j+1],out_of_range);
01649 }
01650
01651 multi_arr<long,4,ARPA_TYPE,false> arr2;
01652 multi_arr<bool,4,ARPA_TYPE,false> dolly2( arr2.clone() );
01653 CHECK(dolly2.empty());
01654
01655 multi_arr<long,5,ARPA_TYPE,false> arr3(3,3,3,3,3);
01656 arr3.alloc( arr3.clone() );
01657
01658 CHECK_EQUAL(243UL,arr3.size());
01659 }
01660
01661
01662 TEST_FIXTURE(LongInt3DCloneFixtureCType,TestCloningCType)
01663 {
01664
01665 multi_arr<bool,3,C_TYPE,true> dolly( arr.clone() );
01666 CHECK_THROW(dolly[10][0][0],out_of_range);
01667 for (int i=0; i<10; ++i)
01668 {
01669 CHECK_THROW(dolly[i][i+1][0],out_of_range);
01670 for (int j=0; j<i+1; ++j)
01671 CHECK_THROW(dolly[i][j][j+1],out_of_range);
01672 }
01673
01674 multi_arr<long,4,C_TYPE,false> arr2;
01675 multi_arr<bool,4,C_TYPE,false> dolly2( arr2.clone() );
01676 CHECK(dolly2.empty());
01677
01678 multi_arr<long,5,ARPA_TYPE,false> arr3(3,3,3,3,3);
01679 arr3.alloc( arr3.clone() );
01680
01681 CHECK_EQUAL(243UL,arr3.size());
01682 }
01683
01684 TEST_FIXTURE(LongInt2DFixture,Test2DBeginEnd)
01685 {
01686 CHECK( arr.begin(2) == arr.ptr(2,0) );
01687 CHECK( arr.end(2) == arr.ptr(2,9) );
01688 CHECK_EQUAL(20L,arr.front(2));
01689 CHECK_EQUAL(28L,arr.back(2));
01690 const multi_arr<long,2,ARPA_TYPE,false>* carr = &arr;
01691 CHECK( carr->begin(2) == carr->ptr(2,0) );
01692 CHECK( carr->end(2) == carr->ptr(2,9) );
01693 CHECK_EQUAL(20L,carr->front(2));
01694 CHECK_EQUAL(28L,carr->back(2));
01695 }
01696 TEST_FIXTURE(LongInt3DFixture,Test3DBeginEnd)
01697 {
01698 CHECK( arr.begin(2,4) == arr.ptr(2,4,0) );
01699 CHECK( arr.end(2,4) == arr.ptr(2,4,8) );
01700 CHECK_EQUAL(240L,arr.front(2,4));
01701 CHECK_EQUAL(247L,arr.back(2,4));
01702 const multi_arr<long,3,ARPA_TYPE,false>* carr = &arr;
01703 CHECK( carr->begin(2,4) == carr->ptr(2,4,0) );
01704 CHECK( carr->end(2,4) == carr->ptr(2,4,8) );
01705 CHECK_EQUAL(240L,carr->front(2,4));
01706 CHECK_EQUAL(247L,carr->back(2,4));
01707 }
01708 TEST_FIXTURE(LongInt4DFixture,Test4DBeginEnd)
01709 {
01710 CHECK( arr.begin(2,4,7) == arr.ptr(2,4,7,0) );
01711 CHECK( arr.end(2,4,7) == arr.ptr(2,4,7,7) );
01712 CHECK_EQUAL(2470L,arr.front(2,4,7));
01713 CHECK_EQUAL(2476L,arr.back(2,4,7));
01714 const multi_arr<long,4,ARPA_TYPE,false>* carr = &arr;
01715 CHECK( carr->begin(2,4,7) == carr->ptr(2,4,7,0) );
01716 CHECK( carr->end(2,4,7) == carr->ptr(2,4,7,7) );
01717 CHECK_EQUAL(2470L,carr->front(2,4,7));
01718 CHECK_EQUAL(2476L,carr->back(2,4,7));
01719 }
01720 TEST_FIXTURE(LongInt5DFixture,Test5DBeginEnd)
01721 {
01722 CHECK( arr.begin(2,4,7,5) == arr.ptr(2,4,7,5,0) );
01723 CHECK( arr.end(2,4,7,5) == arr.ptr(2,4,7,5,6) );
01724 CHECK_EQUAL(24750L,arr.front(2,4,7,5));
01725 CHECK_EQUAL(24755L,arr.back(2,4,7,5));
01726 const multi_arr<long,5,ARPA_TYPE,false>* carr = &arr;
01727 CHECK( carr->begin(2,4,7,5) == carr->ptr(2,4,7,5,0) );
01728 CHECK( carr->end(2,4,7,5) == carr->ptr(2,4,7,5,6) );
01729 CHECK_EQUAL(24750L,carr->front(2,4,7,5));
01730 CHECK_EQUAL(24755L,carr->back(2,4,7,5));
01731 }
01732 TEST_FIXTURE(LongInt6DFixture,Test6DBeginEnd)
01733 {
01734 CHECK( arr.begin(2,4,7,5,1) == arr.ptr(2,4,7,5,1,0) );
01735 CHECK( arr.end(2,4,7,5,1) == arr.ptr(2,4,7,5,1,5) );
01736 CHECK_EQUAL(247510L,arr.front(2,4,7,5,1));
01737 CHECK_EQUAL(247514L,arr.back(2,4,7,5,1));
01738 const multi_arr<long,6,ARPA_TYPE,false>* carr = &arr;
01739 CHECK( carr->begin(2,4,7,5,1) == carr->ptr(2,4,7,5,1,0) );
01740 CHECK( carr->end(2,4,7,5,1) == carr->ptr(2,4,7,5,1,5) );
01741 CHECK_EQUAL(247510L,carr->front(2,4,7,5,1));
01742 CHECK_EQUAL(247514L,carr->back(2,4,7,5,1));
01743 }
01744
01745 TEST_FIXTURE(LongInt2DFixtureCTypeBC,Test2DBeginEndCTypeBC)
01746 {
01747 CHECK( arr.begin(2) == arr.ptr(2,0) );
01748 CHECK( arr.end(2) == arr.ptr(2,9) );
01749 CHECK_EQUAL(20L,arr.front(2));
01750 CHECK_EQUAL(28L,arr.back(2));
01751 const multi_arr<long,2,C_TYPE,true>* carr = &arr;
01752 CHECK( carr->begin(2) == carr->ptr(2,0) );
01753 CHECK( carr->end(2) == carr->ptr(2,9) );
01754 CHECK_EQUAL(20L,carr->front(2));
01755 CHECK_EQUAL(28L,carr->back(2));
01756 }
01757 TEST_FIXTURE(LongInt3DFixtureCTypeBC,Test3DBeginEndCTypeBC)
01758 {
01759 CHECK( arr.begin(2,4) == arr.ptr(2,4,0) );
01760 CHECK( arr.end(2,4) == arr.ptr(2,4,8) );
01761 CHECK_EQUAL(240L,arr.front(2,4));
01762 CHECK_EQUAL(247L,arr.back(2,4));
01763 const multi_arr<long,3,C_TYPE,true>* carr = &arr;
01764 CHECK( carr->begin(2,4) == carr->ptr(2,4,0) );
01765 CHECK( carr->end(2,4) == carr->ptr(2,4,8) );
01766 CHECK_EQUAL(240L,carr->front(2,4));
01767 CHECK_EQUAL(247L,carr->back(2,4));
01768 }
01769 TEST_FIXTURE(LongInt4DFixtureCTypeBC,Test4DBeginEndCTypeBC)
01770 {
01771 CHECK( arr.begin(2,4,7) == arr.ptr(2,4,7,0) );
01772 CHECK( arr.end(2,4,7) == arr.ptr(2,4,7,7) );
01773 CHECK_EQUAL(2470L,arr.front(2,4,7));
01774 CHECK_EQUAL(2476L,arr.back(2,4,7));
01775 const multi_arr<long,4,C_TYPE,true>* carr = &arr;
01776 CHECK( carr->begin(2,4,7) == carr->ptr(2,4,7,0) );
01777 CHECK( carr->end(2,4,7) == carr->ptr(2,4,7,7) );
01778 CHECK_EQUAL(2470L,carr->front(2,4,7));
01779 CHECK_EQUAL(2476L,carr->back(2,4,7));
01780 }
01781 TEST_FIXTURE(LongInt5DFixtureCTypeBC,Test5DBeginEndCTypeBC)
01782 {
01783 CHECK( arr.begin(2,4,7,5) == arr.ptr(2,4,7,5,0) );
01784 CHECK( arr.end(2,4,7,5) == arr.ptr(2,4,7,5,6) );
01785 CHECK_EQUAL(24750L,arr.front(2,4,7,5));
01786 CHECK_EQUAL(24755L,arr.back(2,4,7,5));
01787 const multi_arr<long,5,C_TYPE,true>* carr = &arr;
01788 CHECK( carr->begin(2,4,7,5) == carr->ptr(2,4,7,5,0) );
01789 CHECK( carr->end(2,4,7,5) == carr->ptr(2,4,7,5,6) );
01790 CHECK_EQUAL(24750L,carr->front(2,4,7,5));
01791 CHECK_EQUAL(24755L,carr->back(2,4,7,5));
01792 }
01793 TEST_FIXTURE(LongInt6DFixtureCTypeBC,Test6DBeginEndCTypeBC)
01794 {
01795 CHECK( arr.begin(2,4,7,5,1) == arr.ptr(2,4,7,5,1,0) );
01796 CHECK( arr.end(2,4,7,5,1) == arr.ptr(2,4,7,5,1,5) );
01797 CHECK_EQUAL(247510L,arr.front(2,4,7,5,1));
01798 CHECK_EQUAL(247514L,arr.back(2,4,7,5,1));
01799 const multi_arr<long,6,C_TYPE,true>* carr = &arr;
01800 CHECK( carr->begin(2,4,7,5,1) == carr->ptr(2,4,7,5,1,0) );
01801 CHECK( carr->end(2,4,7,5,1) == carr->ptr(2,4,7,5,1,5) );
01802 CHECK_EQUAL(247510L,carr->front(2,4,7,5,1));
01803 CHECK_EQUAL(247514L,carr->back(2,4,7,5,1));
01804 }
01805
01806
01807 TEST_FIXTURE(LongInt3DFixture,Test3DVarLengthArgument)
01808 {
01809 char buf[100];
01810 sprintf( buf, "%ld", arr[2][3][4] );
01811 long res;
01812 sscanf( buf, "%ld", &res );
01813 CHECK_EQUAL(234L,res);
01814 }
01815
01816 TEST_FIXTURE(LongInt3DFixtureCType,Test3DVarLengthArgumentCType)
01817 {
01818 char buf[100];
01819 sprintf( buf, "%ld", arr[2][3][4] );
01820 long res;
01821 sscanf( buf, "%ld", &res );
01822 CHECK_EQUAL(234L,res);
01823 }
01824
01825 TEST_FIXTURE(LongInt2DEmptyDim,Test2DEmptyDimIterator)
01826 {
01827
01828 multi_arr<long,2,ARPA_TYPE,true>::const_iterator p = arr.begin(0);
01829
01830 CHECK( p == p );
01831 }
01832
01833 TEST_FIXTURE(LongInt3DEmptyDim,Test3DEmptyDimIterator)
01834 {
01835
01836 multi_arr<long,3,ARPA_TYPE,true>::const_iterator p = arr.begin(0,0);
01837
01838 CHECK( p == p );
01839 }
01840
01841 TEST_FIXTURE(LongInt4DEmptyDim,Test4DEmptyDimIterator)
01842 {
01843
01844 multi_arr<long,4,ARPA_TYPE,true>::const_iterator p = arr.begin(0,0,0);
01845
01846 CHECK( p == p );
01847 }
01848
01849 TEST_FIXTURE(LongInt5DEmptyDim,Test5DEmptyDimIterator)
01850 {
01851
01852 multi_arr<long,5,ARPA_TYPE,true>::const_iterator p = arr.begin(0,0,0,0);
01853
01854 CHECK( p == p );
01855 }
01856
01857 TEST_FIXTURE(LongInt6DEmptyDim,Test6DEmptyDimIterator)
01858 {
01859
01860 multi_arr<long,6,ARPA_TYPE,true>::const_iterator p = arr.begin(0,0,0,0,0);
01861
01862 CHECK( p == p );
01863 }
01864
01865 TEST_FIXTURE(LongInt2DEmptyDimCType,Test2DEmptyDimIteratorCType)
01866 {
01867
01868 multi_arr<long,2,C_TYPE,true>::const_iterator p = arr.begin(0);
01869
01870 CHECK( p == p );
01871 }
01872
01873 TEST_FIXTURE(LongInt3DEmptyDimCType,Test3DEmptyDimIteratorCType)
01874 {
01875
01876 multi_arr<long,3,C_TYPE,true>::const_iterator p = arr.begin(0,0);
01877
01878 CHECK( p == p );
01879 }
01880
01881 TEST_FIXTURE(LongInt4DEmptyDimCType,Test4DEmptyDimIteratorCType)
01882 {
01883
01884 multi_arr<long,4,C_TYPE,true>::const_iterator p = arr.begin(0,0,0);
01885
01886 CHECK( p == p );
01887 }
01888
01889 TEST_FIXTURE(LongInt5DEmptyDimCType,Test5DEmptyDimIteratorCType)
01890 {
01891
01892 multi_arr<long,5,C_TYPE,true>::const_iterator p = arr.begin(0,0,0,0);
01893
01894 CHECK( p == p );
01895 }
01896
01897 TEST_FIXTURE(LongInt6DEmptyDimCType,Test6DEmptyDimIteratorCType)
01898 {
01899
01900 multi_arr<long,6,C_TYPE,true>::const_iterator p = arr.begin(0,0,0,0,0);
01901
01902 CHECK( p == p );
01903 }
01904 }