8 #ifndef TEST_BASE_POSTTIMER_H_
9 #define TEST_BASE_POSTTIMER_H_
14 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
16 #include "eckit/config/LocalConfiguration.h"
17 #include "eckit/testing/Test.h"
21 #include "oops/util/Logger.h"
27 const util::DateTime winbgn(
"2020-01-01T00:00:00Z");
28 const util::DateTime winend(
"2020-01-02T00:00:00Z");
29 const util::Duration step(
"PT1H");
35 EXPECT(timer.
itIsTime(winbgn+step/2));
38 EXPECT(!timer.
itIsTime(winbgn-step));
39 EXPECT(!timer.
itIsTime(winend+step));
44 const util::DateTime winbgn(
"2020-01-01T00:00:00Z");
45 const util::DateTime winend(
"2020-01-02T00:00:00Z");
46 const util::Duration step(
"PT1H");
54 EXPECT(!timer1.
itIsTime(winbgn+step/2));
55 EXPECT(timer1.
itIsTime(winbgn+step));
57 EXPECT(!timer1.
itIsTime(winbgn-step));
58 EXPECT(!timer1.
itIsTime(winend+step));
66 EXPECT(!timer2.
itIsTime(winbgn+step/2));
67 EXPECT(timer2.
itIsTime(winbgn+step));
69 EXPECT(timer2.
itIsTime(winbgn-step));
70 EXPECT(timer2.
itIsTime(winend+step));
75 const util::DateTime winbgn(
"2020-01-01T00:00:00Z");
76 const util::DateTime winend(
"2020-01-02T00:00:00Z");
77 const util::Duration step(
"PT1H");
79 eckit::LocalConfiguration test1;
85 EXPECT(timer1.
itIsTime(winbgn+step/2));
86 EXPECT(timer1.
itIsTime(winbgn+step));
88 EXPECT(!timer1.
itIsTime(winbgn-step));
89 EXPECT(!timer1.
itIsTime(winend+step));
91 const std::string freq = (step/2).toString();
92 test1.set(
"frequency", freq);
99 EXPECT(timer2.
itIsTime(winbgn+step/2));
100 EXPECT(!timer2.
itIsTime(winbgn+step/4));
101 EXPECT(timer2.
itIsTime(winbgn+step));
103 EXPECT(!timer2.
itIsTime(winbgn-step));
104 EXPECT(!timer2.
itIsTime(winend+step));
106 eckit::LocalConfiguration test2;
107 const std::string first = step.toString();
108 test2.set(
"first", first);
115 EXPECT(!timer3.
itIsTime(winbgn+step/2));
116 EXPECT(timer3.
itIsTime(winbgn+step));
117 EXPECT(timer3.
itIsTime(winbgn+step*2));
119 EXPECT(!timer3.
itIsTime(winbgn-step));
120 EXPECT(!timer3.
itIsTime(winend+step));
122 eckit::LocalConfiguration test3;
123 std::vector<std::string> steps{
"2020-01-01T00:00:00Z",
"2020-01-01T04:00:00Z",
124 "2020-01-01T08:00:00Z"};
125 test3.set(
"steps", steps);
132 EXPECT(!timer4.
itIsTime(winbgn+step));
134 EXPECT(!timer4.
itIsTime(winbgn-step));
135 EXPECT(!timer4.
itIsTime(winend+step));
136 for (
auto step : steps) {
137 EXPECT(timer4.
itIsTime(util::DateTime(step)));
143 std::string
testid()
const override {
return "test::PostTimer";}
146 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
148 ts.emplace_back(
CASE(
"util/PostTimer/defaultCtor") {
151 ts.emplace_back(
CASE(
"util/PostTimer/bgnEndCtor") {
154 ts.emplace_back(
CASE(
"util/PostTimer/confCtor") {
Handles timing of post-processing and similar actions.
bool itIsTime(const util::DateTime &)
void initialize(const util::DateTime &, const util::DateTime &)
std::string testid() const override
void register_tests() const override
void clear() const override
CASE("test_linearmodelparameterswrapper_valid_name")