8 #ifndef TEST_IODA_DESCENDINGSORT_H_
9 #define TEST_IODA_DESCENDINGSORT_H_
14 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
16 #include "eckit/config/LocalConfiguration.h"
17 #include "eckit/testing/Test.h"
19 #include "oops/mpi/mpi.h"
20 #include "oops/runs/Test.h"
21 #include "oops/test/TestEnvironment.h"
22 #include "oops/util/Expect.h"
24 #include "ioda/IodaTrait.h"
33 util::DateTime bgn(conf.getString(
"window begin"));
34 util::DateTime end(conf.getString(
"window end"));
35 const eckit::LocalConfiguration obsSpaceConf(conf,
"obs space");
36 ioda::ObsData obsdata(obsSpaceConf, oops::mpi::world(), bgn, end, oops::mpi::myself());
40 throw eckit::BadValue(
"Must set sort_order to descending", Here());
43 throw eckit::BadValue(
"Must set group_variable", Here());
47 const size_t nlocs = obsdata.
nlocs();
50 std::vector <int> expectedIndicesAll;
51 expectedIndicesAll.assign(nlocs, 0);
52 obsdata.
get_db(
"MetaData",
"expected_indices", expectedIndicesAll);
55 const std::vector <size_t> recnums = obsdata.
recnum();
60 for (
size_t rn = 0; rn < recnumList.size(); ++rn) {
62 std::vector <size_t> expectedRecordIndices;
63 for (
size_t rnindex = 0; rnindex < nlocs; ++rnindex)
64 if (recnums[rnindex] == rn)
65 expectedRecordIndices.emplace_back(expectedIndicesAll[rnindex]);
68 const std::vector<size_t> recordIndices = obsdata.
recidx_vector(rn);
71 const bool equal = std::equal(recordIndices.begin(),
73 expectedRecordIndices.begin());
80 std::string
testid()
const override {
return "ioda::test::DescendingSort";}
83 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
85 const eckit::LocalConfiguration conf(::test::TestEnvironment::config());
86 for (
const std::string & testCaseName : conf.keys())
88 const eckit::LocalConfiguration testCaseConf(::test::TestEnvironment::config(), testCaseName);
89 ts.emplace_back(CASE(
"ioda/DescendingSort/" + testCaseName, testCaseConf)
102 #endif // TEST_IODA_DESCENDINGSORT_H_