From b71e3303966974beb31916fdbfa451a0b135eb26 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 11 Feb 2022 00:11:02 +0300 Subject: [PATCH] Fix tests. --- tdactor/test/actors_main.cpp | 32 ++++++++++++++++---------------- tdutils/test/ChainScheduler.cpp | 10 +++++----- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tdactor/test/actors_main.cpp b/tdactor/test/actors_main.cpp index 75bcac77c..2e795d40a 100644 --- a/tdactor/test/actors_main.cpp +++ b/tdactor/test/actors_main.cpp @@ -45,17 +45,17 @@ static td::uint32 slow_pow_mod_uint32(td::uint32 x, td::uint32 p) { return res; } -struct Query { +struct ActorQuery { td::uint32 query_id{}; td::uint32 result{}; td::vector todo; - Query() = default; - Query(const Query &) = delete; - Query &operator=(const Query &) = delete; - Query(Query &&) = default; - Query &operator=(Query &&) = default; - ~Query() { - LOG_CHECK(todo.empty()) << "Query lost"; + ActorQuery() = default; + ActorQuery(const ActorQuery &) = delete; + ActorQuery &operator=(const ActorQuery &) = delete; + ActorQuery(ActorQuery &&) = default; + ActorQuery &operator=(ActorQuery &&) = default; + ~ActorQuery() { + LOG_CHECK(todo.empty()) << "ActorQuery lost"; } int next_pow() { CHECK(!todo.empty()); @@ -68,7 +68,7 @@ struct Query { } }; -static td::uint32 fast_calc(Query &q) { +static td::uint32 fast_calc(ActorQuery &q) { td::uint32 result = q.result; for (auto x : q.todo) { result = fast_pow_mod_uint32(result, x); @@ -104,7 +104,7 @@ class QueryActor final : public td::Actor { Callback(Callback &&) = delete; Callback &operator=(Callback &&) = delete; virtual ~Callback() = default; - virtual void on_result(Query &&query) = 0; + virtual void on_result(ActorQuery &&query) = 0; virtual void on_closed() = 0; }; @@ -118,7 +118,7 @@ class QueryActor final : public td::Actor { workers_ = std::move(workers); } - void query(Query &&query) { + void query(ActorQuery &&query) { td::uint32 x = query.result; td::uint32 p = query.next_pow(); if (td::Random::fast(0, 3) && (p <= 1000 || workers_.empty())) { @@ -171,7 +171,7 @@ class QueryActor final : public td::Actor { private: td::unique_ptr callback_; - std::map, Query>> pending_; + std::map, ActorQuery>> pending_; td::vector> workers_; int threads_n_; }; @@ -179,7 +179,7 @@ class QueryActor final : public td::Actor { class MainQueryActor final : public td::Actor { class QueryActorCallback final : public QueryActor::Callback { public: - void on_result(Query &&query) final { + void on_result(ActorQuery &&query) final { if (query.ready()) { send_closure(parent_id_, &MainQueryActor::on_result, std::move(query)); } else { @@ -229,15 +229,15 @@ class MainQueryActor final : public td::Actor { yield(); } - void on_result(Query &&query) { + void on_result(ActorQuery &&query) { CHECK(query.ready()); CHECK(query.result == expected_[query.query_id]); in_cnt_++; wakeup(); } - Query create_query() { - Query q; + ActorQuery create_query() { + ActorQuery q; q.query_id = (query_id_ += 2); q.result = q.query_id; q.todo = {1, 1, 1, 1, 1, 1, 1, 1, 10000}; diff --git a/tdutils/test/ChainScheduler.cpp b/tdutils/test/ChainScheduler.cpp index 243268a13..a92bd2af2 100644 --- a/tdutils/test/ChainScheduler.cpp +++ b/tdutils/test/ChainScheduler.cpp @@ -98,19 +98,19 @@ TEST(ChainScheduler, Basic) { } } -struct Query; -using QueryPtr = std::shared_ptr; +struct ChainSchedulerQuery; +using QueryPtr = std::shared_ptr; using ChainId = td::ChainScheduler::ChainId; using TaskId = td::ChainScheduler::TaskId; -struct Query { +struct ChainSchedulerQuery { int id{}; TaskId task_id{}; bool is_ok{}; bool skipped{}; }; -static td::StringBuilder &operator<<(td::StringBuilder &sb, const Query &q) { +static td::StringBuilder &operator<<(td::StringBuilder &sb, const ChainSchedulerQuery &q) { return sb << "Q{" << q.id << "}"; } @@ -150,7 +150,7 @@ TEST(ChainScheduler, Stress) { return; } auto query_id = current_query_id++; - auto query = std::make_shared(); + auto query = std::make_shared(); query->id = query_id; int chain_n = rnd.fast(1, ChainsN); td::vector chain_ids(ChainsN);