https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GeochemistrySortedIndicesTest.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "gtest/gtest.h"
11
13
14TEST(GeochemistrySortedIndicesTest, sortedIndices)
15{
16 std::vector<Real> vec = {1, 2, 5, 3, -2};
17
18 std::vector<unsigned> ind = GeochemistrySortedIndices::sortedIndices(vec, true);
19 std::vector<unsigned> gold = {4, 0, 1, 3, 2};
20 for (unsigned i = 0; i < 5; ++i)
21 EXPECT_EQ(ind[i], gold[i]);
22
24 gold = {2, 3, 1, 0, 4};
25 for (unsigned i = 0; i < 5; ++i)
26 EXPECT_EQ(ind[i], gold[i]);
27}
TEST(GeochemistrySortedIndicesTest, sortedIndices)
std::vector< unsigned > sortedIndices(const std::vector< Real > &to_sort, bool ascending)
Produces a vector of indices corresponding to the smallest-to-biggest entries in to_sort (or biggest-...