diff --git a/aether/ae_actions/ping.cpp b/aether/ae_actions/ping.cpp index e3733e58..7c4ef6d2 100644 --- a/aether/ae_actions/ping.cpp +++ b/aether/ae_actions/ping.cpp @@ -55,10 +55,10 @@ UpdateStatus Ping::Update() { } if (state_.get() == State::kWaitResponse) { - return UpdateStatus::Delay(ToSyncTime(WaitResponse())); + return UpdateStatus::Delay(WaitResponse()); } if (state_.get() == State::kWaitInterval) { - return UpdateStatus::Delay(ToSyncTime(WaitInterval())); + return UpdateStatus::Delay(WaitInterval()); } return {}; @@ -76,7 +76,7 @@ void Ping::SendPing() { ping_interval_) .count())); // save the ping request - auto current_time = SystemTime(); + auto current_time = Now(); auto channel_ptr = channel_.Lock(); assert(channel_ptr); auto expected_ping_time = channel_ptr->ResponseTimeout(); @@ -100,8 +100,8 @@ void Ping::SendPing() { state_ = State::kWaitResponse; } -SystemTimePoint Ping::WaitInterval() { - auto current_time = SystemTime(); +TimePoint Ping::WaitInterval() { + auto current_time = Now(); auto const& ping_time = ping_requests_.back().start; if ((ping_time + ping_interval_) > current_time) { return ping_time + ping_interval_; @@ -110,8 +110,8 @@ SystemTimePoint Ping::WaitInterval() { return current_time; } -SystemTimePoint Ping::WaitResponse() { - auto current_time = SystemTime(); +TimePoint Ping::WaitResponse() { + auto current_time = Now(); auto const& expected_ping_time = ping_requests_.back().expected_end; if (expected_ping_time > current_time) { @@ -125,7 +125,7 @@ SystemTimePoint Ping::WaitResponse() { } void Ping::PingResponse(RequestId request_id) { - auto request_time = std::invoke([&]() -> std::optional { + auto request_time = std::invoke([&]() -> std::optional { for (auto const& [time, _, req_id] : ping_requests_) { if (req_id == request_id) { return time; @@ -139,7 +139,7 @@ void Ping::PingResponse(RequestId request_id) { return; } - auto current_time = SystemTime(); + auto current_time = Now(); auto ping_duration = std::chrono::duration_cast(current_time - *request_time); diff --git a/aether/ae_actions/ping.h b/aether/ae_actions/ping.h index aaf49844..6c4c1e61 100644 --- a/aether/ae_actions/ping.h +++ b/aether/ae_actions/ping.h @@ -52,8 +52,8 @@ class Ping : public Action { static constexpr std::uint8_t kMaxStorePingTimes = 10; struct PingRequest { - SystemTimePoint start; - SystemTimePoint expected_end; + TimePoint start; + TimePoint expected_end; RequestId request_id; }; @@ -69,8 +69,8 @@ class Ping : public Action { private: void SendPing(); - SystemTimePoint WaitInterval(); - SystemTimePoint WaitResponse(); + TimePoint WaitInterval(); + TimePoint WaitResponse(); void PingResponse(RequestId request_id); PtrView channel_; diff --git a/aether/ae_actions/time_sync.cpp b/aether/ae_actions/time_sync.cpp index 3e3998bf..15fdb0cc 100644 --- a/aether/ae_actions/time_sync.cpp +++ b/aether/ae_actions/time_sync.cpp @@ -145,11 +145,11 @@ class TimeSyncRequest : public Action { AE_TELED_DEBUG("Make time sync request"); ApiPromisePtr promise = api->get_time_utc(); response_sub_ = promise->StatusEvent().Subscribe( - OnResult{[this, request_time{Clock::now()}](auto& p) { + OnResult{[this, request_time{Now()}](auto& p) { HandleResponse( std::chrono::milliseconds{ static_cast(p.value())}, - request_time, Clock::now()); + request_time, Now()); // time synced state_ = State::kResult; }}); @@ -163,19 +163,19 @@ class TimeSyncRequest : public Action { client_ptr->cloud_connection(), RequestPolicy::MainServer{}); // use raw time to avoid sync jumps - request_time_ = SystemTime(); + request_time_ = Now(); state_ = State::kWaitResponse; } UpdateStatus WaitResponse() { - auto current_time = SystemTime(); + auto current_time = Now(); auto timeout = request_time_ + kRequestTimeout; if (current_time > timeout) { AE_TELED_ERROR("Time sync response timeout"); state_ = State::kFailed; return {}; } - return UpdateStatus::Delay(ToSyncTime(timeout)); + return UpdateStatus::Delay(timeout); } static void HandleResponse(std::chrono::milliseconds server_epoch, @@ -194,14 +194,15 @@ class TimeSyncRequest : public Action { std::chrono::duration_cast(diff_time) .count()); // update diff time - Clock::SyncTimeDiff += - std::chrono::duration_cast(diff_time); + SyncClock::SyncTimeDiff += + std::chrono::duration_cast( + diff_time); AE_TELED_DEBUG("Current time {:%Y-%m-%d %H:%M:%S}", Now()); } PtrView client_; StateMachine state_; - SystemTimePoint request_time_; + TimePoint request_time_; int tries_{}; Subscription link_state_sub_; Subscription response_sub_; @@ -210,7 +211,7 @@ class TimeSyncRequest : public Action { } // namespace time_sync_internal // set end of time - this means last_sync_time is not set -SystemTimePoint TimeSyncAction::last_sync_time = SystemTimePoint::max(); +TimePoint TimeSyncAction::last_sync_time = TimePoint::max(); TimeSyncAction::TimeSyncAction(ActionContext action_context, Ptr const& aether, @@ -273,24 +274,24 @@ void TimeSyncAction::MakeRequest() { uap->RegisterAction(*time_sync_request_); // use raw time to avoid sync jumps - last_sync_time = SystemTime(); + last_sync_time = Now(); state_ = State::kWaitInterval; } UpdateStatus TimeSyncAction::WaitInterval() { // the end of time! - if (last_sync_time == SystemTimePoint::max()) { + if (last_sync_time == TimePoint::max()) { state_ = State::kMakeRequest; return {}; } - auto current_time = SystemTime(); + auto current_time = Now(); auto timeout = last_sync_time + sync_interval_; if (current_time > timeout) { AE_TELED_INFO("Time sync interval timeout, make new request"); state_ = State::kMakeRequest; return {}; } - return UpdateStatus::Delay(ToSyncTime(timeout)); + return UpdateStatus::Delay(timeout); } } // namespace ae diff --git a/aether/ae_actions/time_sync.h b/aether/ae_actions/time_sync.h index f2c72184..2a635b52 100644 --- a/aether/ae_actions/time_sync.h +++ b/aether/ae_actions/time_sync.h @@ -27,7 +27,6 @@ # include "aether/actions/action.h" # include "aether/actions/action_ptr.h" # include "aether/types/state_machine.h" -# include "aether/events/event_subscription.h" namespace ae { class Aether; @@ -60,7 +59,7 @@ class TimeSyncAction : public Action { StateMachine state_; ActionPtr time_sync_request_; - static RTC_STORAGE_ATTR SystemTimePoint last_sync_time; + static RTC_STORAGE_ATTR TimePoint last_sync_time; }; } // namespace ae #endif diff --git a/aether/clock.h b/aether/clock.h index e81e32f1..69cd231d 100644 --- a/aether/clock.h +++ b/aether/clock.h @@ -28,7 +28,7 @@ using std::chrono::duration_cast; using std::chrono::system_clock; template -class Clock { +class SyncClock { public: static RTC_STORAGE_ATTR system_clock::duration SyncTimeDiff; @@ -37,7 +37,7 @@ class Clock { using period = typename ChronoClock::period; using duration = typename ChronoClock::duration; - using time_point = std::chrono::time_point; + using time_point = std::chrono::time_point; static constexpr bool is_steady = ChronoClock::is_steady; @@ -52,15 +52,16 @@ class Clock { * \brief Return sync time */ template - static std::enable_if_t< - std::is_same_v || std::is_same_v, time_point> + static std::enable_if_t || + std::is_same_v, + time_point> sync_time(std::chrono::time_point const& tp) { return time_point{tp.time_since_epoch() + SyncTimeDiff}; } }; template -std::chrono::system_clock::duration Clock::SyncTimeDiff = +std::chrono::system_clock::duration SyncClock::SyncTimeDiff = std::chrono::milliseconds{0}; } // namespace ae::clock_internal @@ -76,19 +77,14 @@ using std::chrono_literals::operator""ns; */ using Duration = std::chrono::duration; using SystemClock = std::chrono::system_clock; -using Clock = clock_internal::Clock; -using TimePoint = typename Clock::time_point; -using SystemTimePoint = typename Clock::internal_clock::time_point; +using SyncClock = clock_internal::SyncClock; +using TimePoint = typename SystemClock::time_point; +using SyncTimePoint = typename SyncClock::time_point; -// synchronised time -inline auto Now() { return Clock::now(); } // current system clock time, without synchorinization -inline auto SystemTime() { return Clock::internal_clock::now(); } -// make non sync time point sync with current time -template -inline auto ToSyncTime(std::chrono::time_point tp) { - return Clock::sync_time(tp); -} +inline auto Now() { return SystemClock::now(); } +// synchronised time +inline auto SyncTime() { return SyncClock::now(); } } // namespace ae #endif // AETHER_CLOCK_H_ diff --git a/aether/meta/arg_at.h b/aether/meta/arg_at.h index c1eb7266..a7e4ec11 100644 --- a/aether/meta/arg_at.h +++ b/aether/meta/arg_at.h @@ -55,7 +55,7 @@ static inline constexpr auto ArgAt_v = ArgAt::value; # include "tests/inline.h" namespace test::arg_at_h { -inline void test_VarAt() { +AE_TEST_INLINE(test_VarAt) { constexpr int x = 42; constexpr double y = 3.14; constexpr bool z = true; @@ -65,22 +65,22 @@ inline void test_VarAt() { static_assert(ae::VarAt<2>(x, y, z)); int a = 10; - float b = 3.14f; + float b = 3.14F; bool c = true; TEST_ASSERT_EQUAL(10, ae::VarAt<0>(a, b, c)); - TEST_ASSERT_EQUAL_FLOAT(3.14f, ae::VarAt<1>(a, b, c)); + TEST_ASSERT_EQUAL_FLOAT(3.14F, ae::VarAt<1>(a, b, c)); TEST_ASSERT_EQUAL(true, ae::VarAt<2>(a, b, c)); } template inline void testTemplateArgs() { TEST_ASSERT_EQUAL(10, (ae::ArgAt_v<0, Args...>)); - TEST_ASSERT_EQUAL_FLOAT(3.14f, (ae::ArgAt_v<1, Args...>)); + TEST_ASSERT_EQUAL_FLOAT(3.14F, (ae::ArgAt_v<1, Args...>)); TEST_ASSERT_EQUAL(true, (ae::ArgAt_v<2, Args...>)); } -inline void test_ArgAt() { +AE_TEST_INLINE(test_ArgAt) { constexpr int x = 42; constexpr double y = 3.14; constexpr bool z = true; @@ -89,15 +89,10 @@ inline void test_ArgAt() { static_assert(ae::ArgAt_v<1, x, y, z> == 3.14); static_assert(ae::ArgAt_v<2, x, y, z>); - testTemplateArgs<10, 3.14f, true>(); + testTemplateArgs<10, 3.14F, true>(); } } // namespace test::arg_at_h - -AE_TEST_INLINE { - RUN_TEST(test::arg_at_h::test_VarAt); - RUN_TEST(test::arg_at_h::test_ArgAt); -} #endif #endif // AETHER_META_ARG_AT_H_ diff --git a/aether/meta/as_type.h b/aether/meta/as_type.h index 904cda23..368ad8cd 100644 --- a/aether/meta/as_type.h +++ b/aether/meta/as_type.h @@ -52,7 +52,7 @@ using ae::as_type; struct Base {}; struct Derived : Base {}; -inline void test_AsType() { +AE_TEST_INLINE(test_AsType) { Derived d; decltype(auto) b1 = as_type(d); static_assert(std::is_same_v); @@ -64,10 +64,7 @@ inline void test_AsType() { static_assert(std::is_same_v); TEST_PASS(); -} +}; } // namespace test::as_type_h - -AE_TEST_INLINE { TEST(test::as_type_h::test_AsType); } - #endif #endif // AETHER_META_AS_TYPE_H_ diff --git a/aether/meta/index_sequence.h b/aether/meta/index_sequence.h index 92f49102..42464305 100644 --- a/aether/meta/index_sequence.h +++ b/aether/meta/index_sequence.h @@ -61,7 +61,7 @@ constexpr auto make_range_sequence() { # include "tests/inline.h" namespace tests::index_sequence_h { -inline void test_ReverseSequence() { +AE_TEST_INLINE(test_ReverseSequence) { constexpr auto rev_indices = ae::reverse_sequence(std::make_index_sequence<10>()); static_assert( @@ -75,9 +75,6 @@ inline void test_ReverseSequence() { TEST_PASS(); } } // namespace tests::index_sequence_h - -AE_TEST_INLINE { RUN_TEST(tests::index_sequence_h::test_ReverseSequence); } - #endif #endif // AETHER_META_INDEX_SEQUENCE_H_ diff --git a/aether/meta/tag_invoke.h b/aether/meta/tag_invoke.h index 05f8fad0..b1002f69 100644 --- a/aether/meta/tag_invoke.h +++ b/aether/meta/tag_invoke.h @@ -102,7 +102,7 @@ struct Bar { } }; -inline void test_TagInvoke() { +AE_TEST_INLINE(test_TagInvoke) { using TestCpoType = ae::tag_t; static_assert(std::is_same_v); using TestGetIntType = ae::tag_t; @@ -133,9 +133,6 @@ inline void test_TagInvoke() { TEST_ASSERT_EQUAL(42, value); } } // namespace test::tag_invoke_h - -AE_TEST_INLINE { TEST(test::tag_invoke_h::test_TagInvoke); } - #endif #endif // AETHER_META_TAG_INVOKE_H_ diff --git a/aether/types/result.h b/aether/types/result.h index f4a3fa65..d3a01ca1 100644 --- a/aether/types/result.h +++ b/aether/types/result.h @@ -23,6 +23,8 @@ #include #include +#include "aether/meta/as_type.h" + namespace ae { template class Result; @@ -192,7 +194,7 @@ using ae::Result; struct G {}; struct E {}; -inline void test_Result() { +AE_TEST_INLINE(test_Result) { auto res = Result{G{}}; // check if concept works static_assert(ae::ResultType); @@ -202,7 +204,7 @@ inline void test_Result() { TEST_ASSERT_TRUE(res_e.IsErr()); } -inline void test_Monadic() { +AE_TEST_INLINE(test_Monadic) { auto ret_good = []() -> Result { return Ok{G{}}; }; auto ret_bad = []() -> Result { return Error{E{}}; }; @@ -228,7 +230,7 @@ inline void test_Monadic() { TEST_ASSERT_TRUE(res_ce2.IsOk()); } -inline void test_Macros() { +AE_TEST_INLINE(test_Macros) { auto try_value = [](int v, int n) -> Result { if (v > n) { return Ok{G{}}; @@ -263,11 +265,5 @@ inline void test_Macros() { } // namespace test::result_h_ -AE_TEST_INLINE { - TEST(test::result_h_::test_Result); - TEST(test::result_h_::test_Monadic); - TEST(test::result_h_::test_Macros); -} - #endif #endif // AETHER_TYPES_RESULT_H_ diff --git a/aether/uap/uap.cpp b/aether/uap/uap.cpp index 56dedf67..3311d9e3 100644 --- a/aether/uap/uap.cpp +++ b/aether/uap/uap.cpp @@ -20,18 +20,25 @@ #include #include "aether/aether.h" +#include "aether/actions/timer_action.h" #include "aether/tele/tele.h" namespace ae { Duration Uap::IntervalState::remaining() const { - return std::chrono::duration_cast(until() - Now()); -} + auto interval_end = until(); + auto current_time = SyncTime(); + auto diff = interval_end - current_time; + AE_TELED_DEBUG( + "Calculate remaining end {:%Y-%m-%d %H:%M:%S} current {:%Y-%m-%d " + "%H:%M:%S} diff {:%S}", + interval_end, current_time, diff); -TimePoint Uap::IntervalState::until() const { - return start_time + interval.duration; + return std::chrono::duration_cast(diff); } +SyncTimePoint Uap::IntervalState::until() const { return end_time; } + Uap::Timer::Timer(Uap::ptr uap) : uap_{std::move(uap)} {} Uap::IntervalState Uap::Timer::interval(Duration time_offset) const { @@ -41,14 +48,15 @@ Uap::IntervalState Uap::Timer::interval(Duration time_offset) const { .value_or(Uap::IntervalState{}); } -Uap::Uap() { start_time_ = Now(); } +Uap::Uap() { start_time_ = SyncTime(); } Uap::Uap(ObjProp prop, ObjPtr aether, std::initializer_list const& interval_list) : Obj{prop}, aether_{std::move(aether)}, intervals_{std::begin(interval_list), std::end(interval_list)} { - start_time_ = Now(); + start_time_ = SyncTime(); + WindowWatcher(); } Uap::~Uap() = default; @@ -91,6 +99,8 @@ void Uap::RegisterAction(IAction& action) { }); } +void Uap::Loaded() { WindowWatcher(); } + void Uap::GoToSleep() { if (intervals_.empty()) { return; @@ -103,7 +113,7 @@ Uap::IntervalState Uap::UpdateInterval(Duration time_offset) { next_interval_index_ = (current_interval_index_ + 1) % intervals_.size(); auto interval_duration = intervals_[current_interval_index_].duration; - auto current_time = Now() + time_offset; + auto current_time = SyncTime() + time_offset; auto time_elapsed = current_time - start_time_; AE_TELED_DEBUG( "Update interval\n start_time {:%Y-%m-%d %H:%M:%S}\n current_time " @@ -145,9 +155,28 @@ Uap::IntervalState Uap::UpdateInterval(Duration time_offset) { next_interval_index_ = (index + 1) % intervals_.size(); } AE_TELED_DEBUG( - "Current interval {}, next interval {}, start_time {:%Y-%m-%d %H:%M:%S}", - current_interval_index_, next_interval_index_, start_time_); - return IntervalState{intervals_[current_interval_index_], start_time_}; + "Current interval {}, next interval {}, start_time {:%Y-%m-%d %H:%M:%S} " + "current_time {:%Y-%m-%d %H:%M:%S}", + current_interval_index_, next_interval_index_, start_time_, current_time); + return IntervalState{ + .interval = intervals_[current_interval_index_], + .end_time = start_time_ + intervals_[current_interval_index_].duration, + }; +} + +void Uap::WindowWatcher() { + if (intervals_.empty()) { + return; + } + auto& current = intervals_[current_interval_index_]; + if (current.window == Duration::zero()) { + return; + } + + aether_.WithLoaded([this, w{current.window}](auto const& a) { + auto timer_action = ActionPtr{*a, w}; + RegisterAction(*timer_action); + }); } void Uap::AllActionsFinished() { diff --git a/aether/uap/uap.h b/aether/uap/uap.h index 64f38ce9..fb293452 100644 --- a/aether/uap/uap.h +++ b/aether/uap/uap.h @@ -35,30 +35,32 @@ enum class IntervalType : char { * All the network staff should be created only for sending data. */ kSendOnly, + /** + * \brief Send and receive interval. + * This activation window might be used for both sending and receiving data. + */ + kSendReceive, /** * \brief Receive only interval. * All the network staff should be created only for receiving data at this * activation window. */ kReceiveOnly, - /** - * \brief Send and receive interval. - * This activation window might be used for both sending and receiving data. - */ - kSendReceive, }; /** * \brief Basic interval type. * This shows the duration between two activation windows. * E.g. 10 seconds interval means the application should wake up, do its job, + * stay active at least for window duration, * and go to sleep for the time remaining from this 10 seconds. */ struct Interval { - AE_REFLECT_MEMBERS(type, duration) + AE_REFLECT_MEMBERS(type, duration, window) IntervalType type; Duration duration; + Duration window = Duration::zero(); //< by default the window size is 0 }; class Uap final : public Obj { @@ -67,10 +69,10 @@ class Uap final : public Obj { struct IntervalState { Interval interval; - TimePoint start_time; + SyncTimePoint end_time; Duration remaining() const; - TimePoint until() const; + SyncTimePoint until() const; }; public: @@ -100,6 +102,7 @@ class Uap final : public Obj { template void Load(CurrentVersion, Dnv& dnv) { dnv(base_, aether_, current_interval_index_, intervals_); + Loaded(); } template void Save(CurrentVersion, Dnv& dnv) const { @@ -134,12 +137,16 @@ class Uap final : public Obj { void RegisterAction(IAction& action); private: + void Loaded(); + void GoToSleep(); /** * \brief Get updated interval state \see Timer */ IntervalState UpdateInterval(Duration time_offset); + // starts a special watcher to block GoToSleep on window duration + void WindowWatcher(); // called when all registered actions is finished void AllActionsFinished(); @@ -149,7 +156,7 @@ class Uap final : public Obj { std::vector intervals_; std::size_t current_interval_index_{}; std::size_t next_interval_index_{}; - TimePoint start_time_; + SyncTimePoint start_time_; MultiSubscription wait_actions_subs_; std::size_t wait_actions_cnt_{}; bool ready_to_sleep_{false}; diff --git a/tests/inline_tests/tests/inline.h b/tests/inline_tests/tests/inline.h index c0b01600..9c160bf5 100644 --- a/tests/inline_tests/tests/inline.h +++ b/tests/inline_tests/tests/inline.h @@ -17,36 +17,54 @@ #ifndef TESTS_INLINE_H_ #define TESTS_INLINE_H_ +#include #include +#include +#include #include "unity.h" #include "tests/crc.h" -template -void setup_inline_test_function() {}; +namespace inline_tests { +struct TestFunction { + std::string_view func_name; + int file_line; + void (*test_func)(); +}; -template -void teardown_inline_test_function() {}; +struct TestRegistry { + std::array test_functions; + std::size_t next = 0; +}; -template -void run_inline_test_function() {}; +[[maybe_unused]] static inline TestRegistry test_registry{}; -#define AE_SETUP_INLINE \ - template <> \ - inline void setup_inline_test_function< \ - ::inline_tests::crc32::checksum_from_literal(__FILE__)>() {} +static inline auto add_test([[maybe_unused]] std::string_view name, + [[maybe_unused]] void (*test_func)(), + [[maybe_unused]] std::source_location sl = + std::source_location::current()) { +#ifdef TEST_FILE + printf("source file %s test file %s\n", sl.file_name(), TEST_FILE); + if (std::string_view{sl.file_name()} == TEST_FILE) { + TestFunction tf{name, static_cast(sl.line()), test_func}; + test_registry.test_functions[test_registry.next++] = tf; + } +#endif + return true; +} +} // namespace inline_tests -#define AE_TEARDOWN_INLINE \ - template <> \ - inline void teardown_inline_test_function< \ - ::inline_tests::crc32::checksum_from_literal(__FILE__)>() {} - -#define AE_TEST_INLINE \ - template <> \ - inline void run_inline_test_function< \ - ::inline_tests::crc32::checksum_from_literal(__FILE__)>() - -#define TEST(Function) RUN_TEST(Function) +#define _AE_CAT_IMPL(a, b) a##b +#define _AE_CAT(a, b) _AE_CAT_IMPL(a, b) +#ifdef TEST_FILE +# define AE_TEST_INLINE(NAME) \ + static void NAME(); \ + static inline const auto _AE_CAT(__add_test__, __LINE__) = \ + ::inline_tests ::add_test(#NAME, NAME); \ + void NAME() +#else +# define AE_TEST_INLINE(NAME) static inline void NAME() +#endif #endif // TESTS_INLINE_H_ diff --git a/tests/inline_tests/tests/main.cpp.in b/tests/inline_tests/tests/main.cpp.in index eb86fc90..964ed7e8 100644 --- a/tests/inline_tests/tests/main.cpp.in +++ b/tests/inline_tests/tests/main.cpp.in @@ -29,12 +29,18 @@ inline constexpr auto kFileId = inline_tests::crc32::checksum_from_literal(TEST_FILE); -void setUp() { setup_inline_test_function(); } -void tearDown() { teardown_inline_test_function(); } +void setUp() {} +void tearDown() {} int main() { - UNITY_BEGIN(); + UnityBegin(TEST_FILE); TEST_MESSAGE("Run inline test for " TEST_FILE); - run_inline_test_function(); - return UNITY_END(); + using inline_tests ::test_registry; + printf("test count %zu\n", test_registry.next); + for (std::size_t i = 0; i < test_registry.next; ++i) { + UnityDefaultTestRun(test_registry.test_functions[i].test_func, + test_registry.test_functions[i].func_name.data(), + test_registry.test_functions[i].file_line); + } + return UnityEnd(); } diff --git a/tests/test-object-system/test-obj-create.cpp b/tests/test-object-system/test-obj-create.cpp index a8cdefbf..1957af11 100644 --- a/tests/test-object-system/test-obj-create.cpp +++ b/tests/test-object-system/test-obj-create.cpp @@ -33,8 +33,8 @@ namespace ae::test_obj_create { void test_createFoo() { // create objects auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; - Domain domain2{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; + Domain domain2{ae::Now(), facility}; { Foo::ptr foo = Foo::ptr::Create(CreateWith{domain}.with_id(1)); @@ -73,7 +73,7 @@ void test_createFoo() { void test_createBob() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; { Bob::ptr bob = Bob::ptr::Create(CreateWith{domain}.with_id(1)); @@ -106,7 +106,7 @@ void test_createBob() { void test_cloneFoo() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; auto foo_prefab = Foo::ptr::Create(CreateWith{domain}.with_id(100)); TEST_ASSERT(foo_prefab); foo_prefab.Save(); @@ -128,7 +128,7 @@ void test_cloneFoo() { void test_createBobsMother() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; { BobsMother::ptr bobs_mother = @@ -152,7 +152,7 @@ void test_createBobsMother() { void test_createBobsFather() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; { BobsFather::ptr bobs_father = @@ -179,7 +179,7 @@ void test_createBobsFather() { void test_createCollector() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; { Collector::ptr collector = Collector::ptr::Create(CreateWith{domain}.with_id(1)); @@ -211,7 +211,7 @@ void test_createCollector() { void test_cyclePoopaLoopa() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; Poopa::DeleteCount = 0; Loopa::DeleteCount = 0; @@ -251,7 +251,7 @@ void test_cyclePoopaLoopa() { void test_cyclePoopaLoopaReverse() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; Poopa::DeleteCount = 0; Loopa::DeleteCount = 0; @@ -286,7 +286,7 @@ void test_cyclePoopaLoopaReverse() { void test_Family() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; // create child and test is father and obj saved too { Child::ptr child = Child::ptr::Create(CreateWith{domain}.with_id(1)); diff --git a/tests/test-object-system/test-update-objects.cpp b/tests/test-object-system/test-update-objects.cpp index ca9ab71f..d1aa99f2 100644 --- a/tests/test-object-system/test-update-objects.cpp +++ b/tests/test-object-system/test-update-objects.cpp @@ -43,7 +43,7 @@ void remove_class_id(MapDomainStorage& facility, std::uint32_t class_id) { void test_increaseVersion() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; // the oldest version { Friday0::ptr friday = Friday0::ptr::Create(CreateWith{domain}.with_id(1)); @@ -90,7 +90,7 @@ void test_increaseVersion() { void test_decreaseVersion() { auto facility = MapDomainStorage{}; - Domain domain{ae::Clock::now(), facility}; + Domain domain{ae::Now(), facility}; // the newest version { Friday3::ptr friday = Friday3::ptr::Create(CreateWith{domain}.with_id(1)); diff --git a/tests/test-tele-statistics/test-tele-statistics.cpp b/tests/test-tele-statistics/test-tele-statistics.cpp index dd096205..c444af90 100644 --- a/tests/test-tele-statistics/test-tele-statistics.cpp +++ b/tests/test-tele-statistics/test-tele-statistics.cpp @@ -50,7 +50,7 @@ namespace ae::tele::test { void test_StatisticsRotation() { auto ram_ds = RamDomainStorage{}; ram_ds.CleanUp(); - auto domain = ae::Domain{ae::Clock::now(), ram_ds}; + auto domain = ae::Domain{ae::Now(), ram_ds}; TeleStatistics::ptr tele_statistics = TeleStatistics::ptr::Create(CreateWith{domain}.with_id(1)); @@ -78,7 +78,7 @@ void test_StatisticsRotation() { void test_SaveLoadTeleStatistics() { auto ram_ds = RamDomainStorage{}; ram_ds.CleanUp(); - auto domain = ae::Domain{ae::Clock::now(), ram_ds}; + auto domain = ae::Domain{ae::Now(), ram_ds}; AE_TELE_ENV(); @@ -100,7 +100,7 @@ void test_SaveLoadTeleStatistics() { tele_statistics.Save(); // load stored object in new instance - auto domain2 = ae::Domain{ae::Clock::now(), ram_ds}; + auto domain2 = ae::Domain{ae::Now(), ram_ds}; auto tele_statistics2 = TeleStatistics::ptr::Declare(CreateWith{domain2}.with_id(1)); tele_statistics2.Load();