1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
|
// --------------------------------------------------------------------------
// OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
//
// This software is released under a three-clause BSD license:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of any author or any participating institution
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// --------------------------------------------------------------------------
// $Maintainer: Erhan Kenar $
// $Authors: $
// --------------------------------------------------------------------------
#include <OpenMS/CONCEPT/ClassTest.h>
#include <OpenMS/KERNEL/StandardTypes.h>
#include <OpenMS/KERNEL/Peak2D.h>
///////////////////////////
#include <OpenMS/DATASTRUCTURES/ConstRefVector.h>
///////////////////////////
using namespace OpenMS;
using namespace std;
typedef std::vector< Peak1D > PeakArrayType;
typedef std::vector< Peak2D > PeakArray2DType;
START_TEST(ConstRefVector, "$Id: ConstRefVector_test.C 10915 2013-04-04 20:14:57Z aiche $")
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
ConstRefVector<PeakArrayType>* ptr = 0;
ConstRefVector<PeakArrayType>* nullPointer = 0;
START_SECTION((ConstRefVector()))
ptr = new ConstRefVector<PeakArrayType>();
TEST_NOT_EQUAL(ptr, nullPointer)
END_SECTION
START_SECTION((~ConstRefVector()))
delete ptr;
END_SECTION
START_SECTION((ConstRefVector(const ConstRefVector& p)))
ConstRefVector<PeakArrayType> pl;
Peak1D peak1;
Peak1D peak2;
peak1.setIntensity(1.0f);
pl.push_back(peak1);
peak2.setIntensity(2.0f);
pl.push_back(peak2);
ConstRefVector<PeakArrayType> pl2(pl);
TEST_EQUAL(pl2.size(), 2)
TEST_REAL_SIMILAR(pl2[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl2[1].getIntensity(), 2.0)
END_SECTION
START_SECTION((ConstRefVector& operator=(const ConstRefVector &rhs)))
ConstRefVector<PeakArrayType> pl;
Peak1D peak1;
Peak1D peak2;
peak1.setIntensity(1.0f);
pl.push_back(peak1);
peak2.setIntensity(2.0f);
pl.push_back(peak2);
ConstRefVector<PeakArrayType> pl2;
pl2 = pl;
TEST_EQUAL(pl2.size(), 2)
TEST_REAL_SIMILAR(pl2[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl2[1].getIntensity(), 2.0)
END_SECTION
ConstRefVector<PeakArrayType> pl;
Peak1D peak1;
peak1.setPosition(2.0);
peak1.setIntensity(1.0f);
Peak1D peak2;
peak2.setPosition(0.0);
peak2.setIntensity(0.5f);
Peak1D peak3;
peak3.setPosition(10.5);
peak3.setIntensity(0.01f);
// ConstRefVectorConstIterator tests added (ek)
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D>* c_ptr = 0;
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D>* c_nullPointer = 0;
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator()))
c_ptr = new ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D>();
TEST_NOT_EQUAL(c_ptr, c_nullPointer)
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ~ConstRefVectorConstIterator()))
delete c_ptr;
END_SECTION
std::vector<Peak1D*> p_vec;
p_vec.push_back(&peak1);
p_vec.push_back(&peak2);
p_vec.push_back(&peak3);
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator(const typename std::vector< ValueType * > *vec, unsigned int position)))
const std::vector<Peak1D*> p_vec_const(p_vec);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec_const, 1);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator(typename std::vector< ValueType * > *vec, unsigned int position)))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator(const ConstRefVectorConstIterator &it)))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> copy_it(tmp_c_it);
TEST_REAL_SIMILAR(copy_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(copy_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator& operator=(const ConstRefVectorConstIterator &rhs)))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 2);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> assign_it;
assign_it = tmp_c_it;
TEST_REAL_SIMILAR(assign_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(assign_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] bool operator<(const ConstRefVectorConstIterator &it) const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it1(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it2(&p_vec, 2);
TEST_EQUAL(tmp_c_it1 < tmp_c_it2, 1);
TEST_EQUAL(tmp_c_it2 < tmp_c_it1, 0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] bool operator>(const ConstRefVectorConstIterator &it) const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it1(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it2(&p_vec, 2);
TEST_EQUAL(tmp_c_it1 > tmp_c_it2, 0);
TEST_EQUAL(tmp_c_it2 > tmp_c_it1, 1);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] bool operator<=(const ConstRefVectorConstIterator &it) const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it1(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it2(&p_vec, 2);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it3(&p_vec, 2);
TEST_EQUAL(tmp_c_it1 <= tmp_c_it2, 1);
TEST_EQUAL(tmp_c_it2 <= tmp_c_it3, 1);
TEST_EQUAL(tmp_c_it2 <= tmp_c_it1, 0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] bool operator>=(const ConstRefVectorConstIterator &it) const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it1(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it2(&p_vec, 2);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it3(&p_vec, 0);
TEST_EQUAL(tmp_c_it1 >= tmp_c_it2, 0);
TEST_EQUAL(tmp_c_it2 >= tmp_c_it1, 1);
TEST_EQUAL(tmp_c_it3 >= tmp_c_it1, 1);
END_SECTION
std::vector<Peak1D*> p_vec2;
p_vec2.push_back(&peak1);
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] bool operator==(const ConstRefVectorConstIterator &it) const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it1(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it2(&p_vec, 2);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it3(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it4(&p_vec2, 0);
TEST_EQUAL(tmp_c_it1 == tmp_c_it2, 0);
TEST_EQUAL(tmp_c_it2 == tmp_c_it3, 0);
TEST_EQUAL(tmp_c_it3 == tmp_c_it1, 1);
TEST_EQUAL(tmp_c_it4 == tmp_c_it1, 0);
TEST_EQUAL(tmp_c_it4 == tmp_c_it3, 0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] bool operator!=(const ConstRefVectorConstIterator &it) const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it1(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it2(&p_vec, 2);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it3(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it4(&p_vec2, 0);
TEST_EQUAL(tmp_c_it1 != tmp_c_it2, 1);
TEST_EQUAL(tmp_c_it2 != tmp_c_it3, 1);
TEST_EQUAL(tmp_c_it3 != tmp_c_it1, 0);
TEST_EQUAL(tmp_c_it4 != tmp_c_it1, 1);
TEST_EQUAL(tmp_c_it4 != tmp_c_it3, 1);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator& operator++()))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 0);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
++tmp_c_it;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
++tmp_c_it;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator operator++(int)))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 0);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
tmp_c_it++;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
tmp_c_it++;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator& operator--()))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
--tmp_c_it;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
--tmp_c_it;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator operator--(int)))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
tmp_c_it--;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
tmp_c_it--;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator operator-(difference_type n) const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
unsigned int diff = 2;
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> result_it = tmp_c_it - diff;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
TEST_REAL_SIMILAR(result_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(result_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator operator+(difference_type n) const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 0);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
unsigned int diff = 2;
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> result_it = tmp_c_it + diff;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
TEST_REAL_SIMILAR(result_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(result_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator& operator-=(difference_type n)))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
unsigned int diff = 2;
tmp_c_it -= diff;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] ConstRefVectorConstIterator& operator+=(difference_type n)))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 0);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
unsigned int diff = 2;
tmp_c_it += diff;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] reference operator*()))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 1);
Peak1D orig_peak((*tmp_c_it));
TEST_REAL_SIMILAR(orig_peak.getMZ(), tmp_c_it->getMZ());
TEST_REAL_SIMILAR(orig_peak.getIntensity(), tmp_c_it->getIntensity());
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] pointer operator->()))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 2);
DoubleReal mz = tmp_c_it->getMZ();
DoubleReal Int = tmp_c_it->getIntensity();
TEST_REAL_SIMILAR(mz, 10.5);
TEST_REAL_SIMILAR(Int, 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorConstIterator] pointer operator->() const))
ConstRefVector<PeakArrayType>::ConstRefVectorConstIterator<Peak1D> tmp_c_it(&p_vec, 2);
DoubleReal mz = tmp_c_it->getMZ();
DoubleReal Int = tmp_c_it->getIntensity();
TEST_REAL_SIMILAR(mz, 10.5);
TEST_REAL_SIMILAR(Int, 0.01);
END_SECTION
///////////////////////////////////////////
// ConstRefVectorIterator tests added (ek)
///////////////////////////////////////////
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D>* m_ptr = 0;
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D>* m_nullPointer = 0;
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator()))
m_ptr = new ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D>();
TEST_NOT_EQUAL(m_ptr, m_nullPointer)
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ~ConstRefVectorIterator()))
delete m_ptr;
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator(typename std::vector< ValueType * > *vec, unsigned int position)))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator(const ConstRefVectorIterator< ValueType > &it)))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 0);
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> copy_it(tmp_c_it);
TEST_REAL_SIMILAR(copy_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(copy_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator& operator++()))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 0);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
++tmp_c_it;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
++tmp_c_it;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator operator++(int)))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 0);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
tmp_c_it++;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
tmp_c_it++;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator& operator--()))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
--tmp_c_it;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
--tmp_c_it;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator operator--(int)))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
tmp_c_it--;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 0.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.5);
tmp_c_it--;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator operator-(typename ConstRefVectorIterator::difference_type n) const ))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
unsigned int diff = 2;
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> result_it = tmp_c_it - diff;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
TEST_REAL_SIMILAR(result_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(result_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator operator+(typename ConstRefVectorIterator::difference_type n) const ))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 0);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
unsigned int diff = 2;
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> result_it = tmp_c_it + diff;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
TEST_REAL_SIMILAR(result_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(result_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator& operator-=(typename ConstRefVectorIterator::difference_type n)))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 2);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
unsigned int diff = 2;
tmp_c_it -= diff;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] ConstRefVectorIterator& operator+=(typename ConstRefVectorIterator::difference_type n)))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 0);
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 2.0);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 1.0);
unsigned int diff = 2;
tmp_c_it += diff;
TEST_REAL_SIMILAR(tmp_c_it->getMZ(), 10.5);
TEST_REAL_SIMILAR(tmp_c_it->getIntensity(), 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] reference operator*()))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 1);
Peak1D orig_peak((*tmp_c_it));
TEST_REAL_SIMILAR(orig_peak.getMZ(), tmp_c_it->getMZ());
TEST_REAL_SIMILAR(orig_peak.getIntensity(), tmp_c_it->getIntensity());
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] pointer operator->()))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 2);
DoubleReal mz = tmp_c_it->getMZ();
DoubleReal Int = tmp_c_it->getIntensity();
TEST_REAL_SIMILAR(mz, 10.5);
TEST_REAL_SIMILAR(Int, 0.01);
END_SECTION
START_SECTION(([ConstRefVector::ConstRefVectorIterator] pointer operator->() const))
ConstRefVector<PeakArrayType>::ConstRefVectorIterator<Peak1D> tmp_c_it(&p_vec, 2);
DoubleReal mz = tmp_c_it->getMZ();
DoubleReal Int = tmp_c_it->getIntensity();
TEST_REAL_SIMILAR(mz, 10.5);
TEST_REAL_SIMILAR(Int, 0.01);
END_SECTION
////////////////////////////////
START_SECTION((size_type size() const))
TEST_EQUAL(pl.size(), 0)
pl.push_back(peak1);
TEST_EQUAL(pl.size(), 1)
END_SECTION
START_SECTION((void push_back(const ValueType &x)))
pl.push_back(peak2);
TEST_EQUAL(pl.size(), 2)
END_SECTION
START_SECTION((size_type max_size() const))
ConstRefVector<PeakArrayType>::size_type max = pl.max_size();
pl.push_back(peak3);
TEST_EQUAL(pl.max_size() == max, true)
END_SECTION
START_SECTION((bool empty() const))
TEST_EQUAL(pl.empty(), false)
END_SECTION
START_SECTION([EXTRA] ConstIterator begin() const)
const ConstRefVector<PeakArrayType>& c_pl(pl);
TEST_EQUAL(c_pl.size(), 3)
ABORT_IF(c_pl.size() != 3)
TEST_REAL_SIMILAR(c_pl.begin()->getIntensity(), peak1.getIntensity())
TEST_REAL_SIMILAR(c_pl.begin()->getPosition()[0], peak1.getPosition()[0])
END_SECTION
START_SECTION([EXTRA] ConstIterator end() const)
const ConstRefVector<PeakArrayType>& c_pl(pl);
TEST_EQUAL(c_pl.size(), 3)
ABORT_IF(c_pl.size() != 3)
bool result = (c_pl.begin() == c_pl.end());
TEST_EQUAL(result, false)
const ConstRefVector<PeakArrayType> empty;
result = (empty.begin() == empty.end());
TEST_EQUAL(result, true)
std::vector<Peak1D> v(c_pl.size());
std::copy(c_pl.begin(), c_pl.end(), v.begin());
TEST_EQUAL(v.size(), 3)
ABORT_IF(v.size() != 3)
TEST_REAL_SIMILAR(v[0].getIntensity(), peak1.getIntensity())
TEST_REAL_SIMILAR(v[0].getPosition()[0], peak1.getPosition()[0])
TEST_REAL_SIMILAR(v[1].getIntensity(), peak2.getIntensity())
TEST_REAL_SIMILAR(v[1].getPosition()[0], peak2.getPosition()[0])
TEST_REAL_SIMILAR(v[2].getIntensity(), peak3.getIntensity())
TEST_REAL_SIMILAR(v[2].getPosition()[0], peak3.getPosition()[0])
END_SECTION
START_SECTION((void sortByIntensity(bool reverse=false)))
ConstRefVector<PeakArrayType> pl2(pl);
pl2.sortByIntensity();
TEST_EQUAL(pl2.size(), 3)
std::vector<Peak1D> v(pl2.size());
std::copy(pl2.begin(), pl2.end(), v.begin());
TEST_EQUAL(v.size(), 3)
ABORT_IF(v.size() != 3)
TEST_REAL_SIMILAR(v[2].getIntensity(), peak1.getIntensity())
TEST_REAL_SIMILAR(v[2].getPosition()[0], peak1.getPosition()[0])
TEST_REAL_SIMILAR(v[1].getIntensity(), peak2.getIntensity())
TEST_REAL_SIMILAR(v[1].getPosition()[0], peak2.getPosition()[0])
TEST_REAL_SIMILAR(v[0].getIntensity(), peak3.getIntensity())
TEST_REAL_SIMILAR(v[0].getPosition()[0], peak3.getPosition()[0])
END_SECTION
ConstRefVector<PeakArray2DType> pl2;
Peak2D peak4;
peak4.getPosition()[0] = 2.0;
peak4.getPosition()[1] = 3.0;
peak4.setIntensity(1.0f);
pl2.push_back(peak4);
Peak2D peak5;
peak5.getPosition()[0] = 0.0;
peak5.getPosition()[1] = 2.5;
peak5.setIntensity(0.5f);
pl2.push_back(peak5);
Peak2D peak6;
peak6.getPosition()[0] = 10.5;
peak6.getPosition()[1] = 0.0;
peak6.setIntensity(0.01f);
pl2.push_back(peak6);
START_SECTION((Iterator begin()))
ConstRefVector<PeakArrayType>::Iterator it = pl.begin();
TEST_REAL_SIMILAR(it->getIntensity(), 1.0)
TEST_REAL_SIMILAR(it->getPosition()[0], 2.0)
END_SECTION
START_SECTION((Iterator end()))
ConstRefVector<PeakArrayType>::Iterator it = pl.end()-1;
TEST_REAL_SIMILAR(it->getIntensity(), 0.01)
TEST_REAL_SIMILAR(it->getPosition()[0], 10.5)
END_SECTION
START_SECTION((ConstIterator begin() const))
ConstRefVector<PeakArrayType>::ConstIterator it = pl.begin();
TEST_REAL_SIMILAR(it->getIntensity(), 1.0)
TEST_REAL_SIMILAR(it->getPosition()[0], 2.0)
END_SECTION
START_SECTION((ConstIterator end() const))
ConstRefVector<PeakArrayType>::ConstIterator it = pl.end();
--it;
TEST_REAL_SIMILAR(it->getIntensity(), 0.01)
TEST_REAL_SIMILAR(it->getPosition()[0], 10.5)
END_SECTION
START_SECTION((ReverseIterator rbegin()))
ConstRefVector<PeakArrayType>::ReverseIterator it = pl.rbegin();
TEST_REAL_SIMILAR(it->getIntensity(), 0.01)
TEST_REAL_SIMILAR(it->getPosition()[0], 10.5)
END_SECTION
START_SECTION((ReverseIterator rend()))
ConstRefVector<PeakArrayType>::ReverseIterator it = pl.rend()-1;
TEST_REAL_SIMILAR(it->getIntensity(), 1.0)
TEST_REAL_SIMILAR(it->getPosition()[0], 2.0)
END_SECTION
START_SECTION((ConstReverseIterator rbegin() const))
ConstRefVector<PeakArrayType>::ConstReverseIterator it = pl.rbegin();
TEST_REAL_SIMILAR(it->getIntensity(), 0.01)
TEST_REAL_SIMILAR(it->getPosition()[0], 10.5)
END_SECTION
START_SECTION((ConstReverseIterator rend() const))
ConstRefVector<PeakArrayType>::ConstReverseIterator it = pl.rend()-1;
TEST_REAL_SIMILAR(it->getIntensity(), 1.0)
TEST_REAL_SIMILAR(it->getPosition()[0], 2.0)
END_SECTION
START_SECTION((size_type capacity() const))
TEST_EQUAL(pl.capacity(), 3)
TEST_EQUAL(pl.size(), 3)
END_SECTION
Peak1D peak7;
peak7.getPosition()[0] = 1.1;
peak7.setIntensity(1.1f);
START_SECTION((void reserve(size_type n)))
pl.reserve(4);
TEST_EQUAL(pl.size(), 3)
TEST_EQUAL(pl.capacity(), 4)
pl.push_back(peak7);
TEST_EQUAL(pl.size(), 4)
TEST_EQUAL(pl.capacity(), 4)
END_SECTION
START_SECTION((const_reference operator [](size_type n) const))
TEST_REAL_SIMILAR(pl[2].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl[2].getPosition()[0], 10.5)
TEST_REAL_SIMILAR(pl[3].getIntensity(), 1.1)
TEST_REAL_SIMILAR(pl[3].getPosition()[0], 1.1)
END_SECTION
START_SECTION((ConstRefVector(size_type n)))
ConstRefVector<PeakArrayType> pl2(2);
TEST_EQUAL(pl2.size(), 2)
END_SECTION
START_SECTION((ConstRefVector(size_type n, const ValueType &element)))
Peak2D peak;
peak.getPosition()[0] = 1.1;
peak.setIntensity(5.1f);
ConstRefVector<PeakArray2DType> pl2(3, peak);
TEST_EQUAL(pl2.size(), 3)
TEST_REAL_SIMILAR(pl2[0].getIntensity(), 5.1)
TEST_REAL_SIMILAR(pl2[1].getIntensity(), 5.1)
TEST_REAL_SIMILAR(pl2[2].getIntensity(), 5.1)
END_SECTION
START_SECTION((const_reference front() const))
Peak1D peak;
peak = pl.front();
TEST_REAL_SIMILAR(peak.getIntensity(), 1.0)
TEST_REAL_SIMILAR(peak.getPosition()[0], 2)
END_SECTION
START_SECTION((const_reference back() const))
Peak1D peak;
peak = pl.back();
TEST_REAL_SIMILAR(peak.getIntensity(), 1.1)
TEST_REAL_SIMILAR(peak.getPosition()[0], 1.1)
END_SECTION
START_SECTION((void pop_back()))
TEST_EQUAL(pl.size(), 4)
pl.pop_back();
TEST_EQUAL(pl.size(), 3)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 0.01)
END_SECTION
Peak1D peak8;
peak8.getPosition()[0] = 2.0;
peak8.setIntensity(1.0f);
Peak1D peak9;
peak9.getPosition()[0] = 0.0;
peak9.setIntensity(2.5f);
START_SECTION((void swap(ConstRefVector &array)))
ConstRefVector<PeakArrayType> pl2;
pl2.push_back(peak8);
pl2.push_back(peak9);
TEST_REAL_SIMILAR(pl2[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl2[1].getIntensity(), 2.5)
TEST_EQUAL(pl2.size(), 2)
TEST_EQUAL(pl.size(), 3)
pl.swap(pl2);
TEST_EQUAL(pl2.size(), 3)
TEST_EQUAL(pl.size(), 2)
TEST_REAL_SIMILAR(pl2[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl2[1].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl2[2].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 2.5)
swap(pl,pl2);
TEST_EQUAL(pl.size(), 3)
TEST_EQUAL(pl2.size(), 2)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl2[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl2[1].getIntensity(), 2.5)
END_SECTION
Peak1D peak10;
peak10.setIntensity(4712.0);
START_SECTION((Iterator insert(Iterator pos, const ValueType &element)))
TEST_EQUAL(pl.size(), 3)
pl.insert(pl.end(),peak10);
TEST_EQUAL(pl.size(), 4)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl[3].getIntensity(), 4712.0)
END_SECTION
START_SECTION((Iterator erase(Iterator pos)))
TEST_EQUAL(pl.size(), 4)
pl.erase(pl.end()-1);
TEST_EQUAL(pl.size(), 3)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 0.01)
END_SECTION
START_SECTION((void insert(Iterator pos, size_type n, const ValueType &element)))
peak10.setIntensity(4714.0);
TEST_EQUAL(pl.size(), 3)
pl.insert(pl.begin(),3,peak10);
TEST_EQUAL(pl.size(), 6)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 4714.0)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 4714.0)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 4714.0)
TEST_REAL_SIMILAR(pl[3].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl[4].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl[5].getIntensity(), 0.01)
END_SECTION
START_SECTION((template <class InputIterator> void insert(Iterator pos, InputIterator f, InputIterator l)))
pl.erase(pl.begin(),pl.begin()+3);
TEST_EQUAL(pl.size(), 3)
pl.insert(pl.begin(),pl.begin()+1,pl.end());
TEST_EQUAL(pl.size(), 5)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl[3].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl[4].getIntensity(), 0.01)
END_SECTION
START_SECTION((template <class InputIterator> ConstRefVector(InputIterator f, InputIterator l)))
ConstRefVector<PeakArrayType> pl2(pl.begin()+1,pl.end()-1);
TEST_EQUAL(pl2.size(), 3)
TEST_REAL_SIMILAR(pl2[0].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl2[1].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl2[2].getIntensity(), 0.5)
END_SECTION
START_SECTION((bool operator==(const ConstRefVector &array) const))
ConstRefVector<PeakArrayType> pl2(pl);
TEST_EQUAL(pl.size(), pl2.size())
TEST_EQUAL(pl == pl2 , true)
END_SECTION
START_SECTION((bool operator!=(const ConstRefVector &array) const))
ConstRefVector<PeakArrayType> pl2(pl);
TEST_EQUAL(pl.size(), pl2.size())
TEST_EQUAL(pl != pl2 , false)
END_SECTION
START_SECTION((bool operator<(const ConstRefVector &array) const))
ConstRefVector<PeakArrayType> pl2(pl);
TEST_EQUAL(pl < pl2, false)
pl2.push_back(Peak1D());
TEST_EQUAL(pl < pl2 , true)
END_SECTION
START_SECTION((bool operator>(const ConstRefVector &array) const))
ConstRefVector<PeakArrayType> pl2(pl);
TEST_EQUAL(pl > pl2, false)
pl2.erase(pl2.end()-1);
TEST_EQUAL(pl > pl2 , true)
END_SECTION
START_SECTION((bool operator<=(const ConstRefVector &array) const))
ConstRefVector<PeakArrayType> pl2(pl);
TEST_EQUAL(pl <= pl2, true)
pl2.push_back(Peak1D());
TEST_EQUAL(pl <= pl2 , true)
pl2.erase(pl2.begin()+1,pl2.end()-2);
TEST_EQUAL(pl <= pl2 , false)
END_SECTION
START_SECTION((bool operator>=(const ConstRefVector &array) const))
ConstRefVector<PeakArrayType> pl2(pl);
TEST_EQUAL(pl >= pl2, true)
pl2.erase(pl2.end()-1);
TEST_EQUAL(pl >= pl2 , true)
pl2.insert(pl2.end(),2,pl2.front());
TEST_EQUAL(pl >= pl2 , false)
END_SECTION
START_SECTION((void clear()))
pl.clear();
TEST_EQUAL(pl.size(), 0)
END_SECTION
Peak1D peak11;
peak11.setIntensity(4713.0);
START_SECTION((void resize(size_type new_size)))
pl.resize(4,peak11);
TEST_EQUAL(pl.size(), 4)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 4713.0)
TEST_REAL_SIMILAR(pl[3].getIntensity(), 4713.0)
END_SECTION
START_SECTION((void resize(size_type new_size, const ValueType &t)))
ConstRefVector<PeakArrayType> pl;
Peak1D peak;
peak.getPosition()[0] = 0.0;
peak.setIntensity(2.5f);
pl.resize(2,peak);
TEST_EQUAL(pl.size(), 2)
TEST_EQUAL(pl[0].getIntensity() == peak.getIntensity(),true)
TEST_EQUAL(pl[0].getPosition() == peak.getPosition(),true)
TEST_EQUAL(pl[1].getIntensity() == peak.getIntensity(),true)
TEST_EQUAL(pl[1].getPosition() == peak.getPosition(),true)
END_SECTION
START_SECTION((ConstRefVector(ContainerType &p)))
PeakArrayType pa(5);
ConstRefVector<PeakArrayType> pl(pa);
for (Size i=0; i<pa.size(); ++i)
{
TEST_EQUAL(pa[i]== pl[i],true)
}
END_SECTION
START_SECTION((template <class InputIterator> void assign(InputIterator f , InputIterator l)))
ConstRefVector<PeakArrayType> dpa2;
dpa2.push_back(peak1);
dpa2.push_back(peak2);
dpa2.push_back(peak3);
TEST_EQUAL(pl.size(), 4)
pl.assign(dpa2.begin(),dpa2.end());
TEST_EQUAL(pl.size(), 3)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 1.0)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 0.5)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 0.01)
END_SECTION
START_SECTION((void assign(size_type n, const ValueType &x)))
pl.assign(5,peak3);
TEST_EQUAL(pl.size(), 5)
TEST_REAL_SIMILAR(pl[0].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl[1].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl[2].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl[3].getIntensity(), 0.01)
TEST_REAL_SIMILAR(pl[4].getIntensity(), 0.01)
END_SECTION
START_SECTION((Iterator erase(Iterator first,Iterator last)))
TEST_EQUAL(pl.size(), 5)
pl.erase(pl.begin(),pl.end());
TEST_EQUAL(pl.size(), 0)
END_SECTION
START_SECTION((void sortByPosition()))
ConstRefVector<PeakArray2DType> dpa2;
Peak2D p1(peak4);
p1.setIntensity(1.0f);
Peak2D p2(peak5);
p2.setIntensity(2.0f);
Peak2D p3(peak6);
p3.setIntensity(3.0f);
Peak2D p4;
p4.getPosition()[0]=4.3;
p4.getPosition()[1]=4711;
p4.setIntensity(4.0f);
Peak2D p5;
p5.getPosition()[1]=4711;
p5.setIntensity(5.0f);
Peak2D p6;
p6.getPosition()[1]=4711;
p6.setIntensity(6.0f);
dpa2.push_back(p1);
dpa2.push_back(p2);
dpa2.push_back(p3);
dpa2.push_back(p4);
dpa2.push_back(p5);
dpa2.push_back(p6);
dpa2.sortByPosition();
TEST_REAL_SIMILAR(dpa2[0].getIntensity(), 2.0)
TEST_REAL_SIMILAR(dpa2[1].getIntensity(), 5.0)
TEST_REAL_SIMILAR(dpa2[2].getIntensity(), 6.0)
TEST_REAL_SIMILAR(dpa2[3].getIntensity(), 1.0)
TEST_REAL_SIMILAR(dpa2[4].getIntensity(), 4.0)
TEST_REAL_SIMILAR(dpa2[5].getIntensity(), 3.0)
END_SECTION
START_SECTION((template <typename ComparatorType> void sortByComparator(ComparatorType const &comparator=ComparatorType())))
pl2.sortByComparator<Peak2D::PositionLess>();
TEST_EQUAL(pl2.size(), 3)
TEST_REAL_SIMILAR(pl2[1].getIntensity(), peak4.getIntensity())
TEST_REAL_SIMILAR(pl2[1].getPosition()[0], peak4.getPosition()[0])
TEST_REAL_SIMILAR(pl2[1].getPosition()[1], peak4.getPosition()[1])
TEST_REAL_SIMILAR(pl2[0].getIntensity(), peak5.getIntensity())
TEST_REAL_SIMILAR(pl2[0].getPosition()[0], peak5.getPosition()[0])
TEST_REAL_SIMILAR(pl2[0].getPosition()[1], peak5.getPosition()[1])
TEST_REAL_SIMILAR(pl2[2].getIntensity(), peak6.getIntensity())
TEST_REAL_SIMILAR(pl2[2].getPosition()[0], peak6.getPosition()[0])
TEST_REAL_SIMILAR(pl2[2].getPosition()[1], peak6.getPosition()[1])
// ----------------
ConstRefVector<PeakArray2DType> dpa2;
Peak2D p1(peak4);
p1.setIntensity(1.0f);
Peak2D p2(peak5);
p2.setIntensity(2.0f);
Peak2D p3(peak6);
p3.setIntensity(3.0f);
Peak2D p4;
p4.getPosition()[0]=4.3;
p4.getPosition()[1]=4711;
p4.setIntensity(4.0f);
Peak2D p5;
p5.getPosition()[1]=4711;
p5.setIntensity(5.0f);
Peak2D p6;
p6.getPosition()[1]=4711;
p6.setIntensity(6.0f);
dpa2.push_back(p1);
dpa2.push_back(p2);
dpa2.push_back(p3);
dpa2.push_back(p4);
dpa2.push_back(p5);
dpa2.push_back(p6);
dpa2.sortByComparator<Peak2D::MZLess >(Peak2D::MZLess());
TEST_REAL_SIMILAR(dpa2[0].getIntensity(), 3.0)
TEST_REAL_SIMILAR(dpa2[1].getIntensity(), 2.0)
TEST_REAL_SIMILAR(dpa2[2].getIntensity(), 1.0)
TEST_REAL_SIMILAR(dpa2[3].getIntensity(), 4.0)
TEST_REAL_SIMILAR(dpa2[4].getIntensity(), 5.0)
TEST_REAL_SIMILAR(dpa2[5].getIntensity(), 6.0)
END_SECTION
START_SECTION([EXTRA] Container without special members for sorting)
vector<Int> vec(5);
ConstRefVector<vector<Int> > ref_vec(vec);
TEST_EQUAL(ref_vec.size(),5)
END_SECTION
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST
|