TEST(Peak, SortMagnitudeDescendingPositionDescending) { Real positions [] = {1, 0, 1, 4, 5}; Real magnitudes[] = {2, 2, 3, 1, 6}; vector<util::Peak> peaks = realsToPeaks(arrayToVector<Real>(positions), arrayToVector<Real>(magnitudes)); sort(peaks.begin(), peaks.end(), ComparePeakMagnitude<std::greater<Real>, std::greater<Real> >()); Real expectedPos[] = {5,1,1,0,4}; Real expectedMag[] = {6,3,2,2,1}; vector<util::Peak> expectedPeaks= realsToPeaks(arrayToVector<Real>(expectedPos), arrayToVector<Real>(expectedMag)); EXPECT_VEC_EQ(peaks, expectedPeaks); }
TEST(Peak, SortPositionAscendingMagnitudeAscending) { Real positions [] = {1, 0, 1, 4, 5}; Real magnitudes[] = {2, 2, 3, 1, 6}; vector<util::Peak> peaks = realsToPeaks(arrayToVector<Real>(positions), arrayToVector<Real>(magnitudes)); sort(peaks.begin(), peaks.end(), ComparePeakPosition<std::less<Real>, std::less<Real> >()); Real expectedPos[] = {0,1,1,4,5}; Real expectedMag[] = {2,2,3,1,6}; vector<util::Peak> expectedPeaks= realsToPeaks(arrayToVector<Real>(expectedPos), arrayToVector<Real>(expectedMag)); EXPECT_VEC_EQ(peaks, expectedPeaks); }
TEST(Peak, RealsToPeaks) { Real positionsArray [] = {1, 0, 1, 4, 5}; Real magnitudesArray [] = {2, 2, 3, 1, 6}; util::Peak peaksArray [] = {util::Peak(1,2),util::Peak(0,2),util::Peak(1,3),util::Peak(4,1),util::Peak(5,6)}; vector<Real> positions = arrayToVector<Real>(positionsArray); vector<Real> magnitudes = arrayToVector<Real>(magnitudesArray); vector<util::Peak> peaks = realsToPeaks(positions, magnitudes); EXPECT_VEC_EQ(peaks, arrayToVector<util::Peak>(peaksArray)); }