Update clag-format to the latest (190926/r372920) version.
GitOrigin-RevId: 7861ae8ad28eb1f6a06ff3c6f56eff3f67b1d24c
This commit is contained in:
parent
c7811a01b6
commit
0b6c1d226f
@ -3,16 +3,20 @@ Language: Cpp
|
||||
# BasedOnStyle: Google
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None # All
|
||||
AllowShortIfStatementsOnASingleLine: false # true
|
||||
AllowShortIfStatementsOnASingleLine: Never # WithoutElse
|
||||
AllowShortLambdasOnASingleLine: Inline # All
|
||||
AllowShortLoopsOnASingleLine: false # true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
@ -21,6 +25,7 @@ AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
@ -60,6 +65,7 @@ ForEachMacros:
|
||||
- Q_FOREACH_THIS_LIST_MUST_BE_NON_EMPTY
|
||||
IncludeBlocks: Preserve
|
||||
IndentCaseLabels: true
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
@ -87,6 +93,7 @@ ReflowComments: false # true
|
||||
SortIncludes: false # disabled, because we need case insensitive sort
|
||||
SortUsingDeclarations: false # true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
@ -94,6 +101,7 @@ SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
|
@ -222,15 +222,13 @@ class CreateFileBench : public Benchmark {
|
||||
}
|
||||
}
|
||||
void tear_down() override {
|
||||
td::walk_path("A/",
|
||||
[&](CSlice path, auto type) {
|
||||
if (type == td::WalkPath::Type::ExitDir) {
|
||||
rmdir(path).ignore();
|
||||
} else if (type == td::WalkPath::Type::NotDir) {
|
||||
unlink(path).ignore();
|
||||
}
|
||||
})
|
||||
.ignore();
|
||||
td::walk_path("A/", [&](CSlice path, auto type) {
|
||||
if (type == td::WalkPath::Type::ExitDir) {
|
||||
rmdir(path).ignore();
|
||||
} else if (type == td::WalkPath::Type::NotDir) {
|
||||
unlink(path).ignore();
|
||||
}
|
||||
}).ignore();
|
||||
}
|
||||
};
|
||||
|
||||
@ -246,26 +244,22 @@ class WalkPathBench : public Benchmark {
|
||||
}
|
||||
void run(int n) override {
|
||||
int cnt = 0;
|
||||
td::walk_path("A/",
|
||||
[&](CSlice path, auto type) {
|
||||
if (type == td::WalkPath::Type::EnterDir) {
|
||||
return;
|
||||
}
|
||||
stat(path).ok();
|
||||
cnt++;
|
||||
})
|
||||
.ignore();
|
||||
td::walk_path("A/", [&](CSlice path, auto type) {
|
||||
if (type == td::WalkPath::Type::EnterDir) {
|
||||
return;
|
||||
}
|
||||
stat(path).ok();
|
||||
cnt++;
|
||||
}).ignore();
|
||||
}
|
||||
void tear_down() override {
|
||||
td::walk_path("A/",
|
||||
[&](CSlice path, auto type) {
|
||||
if (type == td::WalkPath::Type::ExitDir) {
|
||||
rmdir(path).ignore();
|
||||
} else if (type == td::WalkPath::Type::NotDir) {
|
||||
unlink(path).ignore();
|
||||
}
|
||||
})
|
||||
.ignore();
|
||||
td::walk_path("A/", [&](CSlice path, auto type) {
|
||||
if (type == td::WalkPath::Type::ExitDir) {
|
||||
rmdir(path).ignore();
|
||||
} else if (type == td::WalkPath::Type::NotDir) {
|
||||
unlink(path).ignore();
|
||||
}
|
||||
}).ignore();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,9 @@ td::Result<TlsInfo> test_tls(const td::string &url) {
|
||||
|
||||
td::string request;
|
||||
|
||||
auto add_string = [&](td::Slice data) { request.append(data.data(), data.size()); };
|
||||
auto add_string = [&](td::Slice data) {
|
||||
request.append(data.data(), data.size());
|
||||
};
|
||||
auto add_random = [&](size_t length) {
|
||||
while (length-- > 0) {
|
||||
request += static_cast<char>(td::Random::secure_int32());
|
||||
|
@ -41,9 +41,9 @@ extern void *__libc_stack_end;
|
||||
static void *get_bp() {
|
||||
void *bp;
|
||||
#if defined(__i386__)
|
||||
__asm__ volatile("movl %%ebp, %[r]" : [r] "=r"(bp));
|
||||
__asm__ volatile("movl %%ebp, %[r]" : [ r ] "=r"(bp));
|
||||
#elif defined(__x86_64__)
|
||||
__asm__ volatile("movq %%rbp, %[r]" : [r] "=r"(bp));
|
||||
__asm__ volatile("movq %%rbp, %[r]" : [ r ] "=r"(bp));
|
||||
#endif
|
||||
return bp;
|
||||
}
|
||||
|
@ -202,7 +202,9 @@ class SessionConnection
|
||||
auto set_buffer_slice(BufferSlice *buffer_slice) TD_WARN_UNUSED_RESULT {
|
||||
auto old_buffer_slice = current_buffer_slice_;
|
||||
current_buffer_slice_ = buffer_slice;
|
||||
return ScopeExit() + [&to = current_buffer_slice_, from = old_buffer_slice] { to = from; };
|
||||
return ScopeExit() + [&to = current_buffer_slice_, from = old_buffer_slice] {
|
||||
to = from;
|
||||
};
|
||||
}
|
||||
|
||||
Status parse_message(TlParser &parser, MsgInfo *info, Slice *packet, bool crypto_flag = true) TD_WARN_UNUSED_RESULT;
|
||||
|
@ -987,7 +987,9 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
|
||||
shared_config.set_option_string("photo_search_bot_username", config->img_search_username_);
|
||||
}
|
||||
|
||||
auto fix_timeout_ms = [](int32 timeout_ms) { return clamp(timeout_ms, 1000, 86400 * 1000); };
|
||||
auto fix_timeout_ms = [](int32 timeout_ms) {
|
||||
return clamp(timeout_ms, 1000, 86400 * 1000);
|
||||
};
|
||||
|
||||
shared_config.set_option_integer("online_update_period_ms", fix_timeout_ms(config->online_update_period_ms_));
|
||||
|
||||
|
@ -27065,13 +27065,17 @@ void MessagesManager::suffix_load_add_query(Dialog *d,
|
||||
|
||||
void MessagesManager::suffix_load_till_date(Dialog *d, int32 date, Promise<> promise) {
|
||||
LOG(INFO) << "Load suffix of " << d->dialog_id << " till date " << date;
|
||||
auto condition = [date](const Message *m) { return m != nullptr && m->date < date; };
|
||||
auto condition = [date](const Message *m) {
|
||||
return m != nullptr && m->date < date;
|
||||
};
|
||||
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
|
||||
}
|
||||
|
||||
void MessagesManager::suffix_load_till_message_id(Dialog *d, MessageId message_id, Promise<> promise) {
|
||||
LOG(INFO) << "Load suffix of " << d->dialog_id << " till " << message_id;
|
||||
auto condition = [message_id](const Message *m) { return m != nullptr && m->message_id.get() < message_id.get(); };
|
||||
auto condition = [message_id](const Message *m) {
|
||||
return m != nullptr && m->message_id.get() < message_id.get();
|
||||
};
|
||||
suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition)));
|
||||
}
|
||||
|
||||
|
@ -1662,7 +1662,9 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise
|
||||
[&](telegram_api::encryptedFileEmpty &) {
|
||||
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(
|
||||
telegram_api::inputEncryptedFileEmpty());
|
||||
get_file = [] { return telegram_api::make_object<telegram_api::encryptedFileEmpty>(); };
|
||||
get_file = [] {
|
||||
return telegram_api::make_object<telegram_api::encryptedFileEmpty>();
|
||||
};
|
||||
},
|
||||
[&](telegram_api::encryptedFile &file) {
|
||||
state->message->file = logevent::EncryptedInputFile::from_input_encrypted_file(
|
||||
|
@ -1551,7 +1551,9 @@ int32 UpdatesManager::get_short_update_date() const {
|
||||
|
||||
tl_object_ptr<td_api::ChatAction> UpdatesManager::convert_send_message_action(
|
||||
tl_object_ptr<telegram_api::SendMessageAction> action) {
|
||||
auto fix_progress = [](int32 progress) { return progress <= 0 || progress > 100 ? 0 : progress; };
|
||||
auto fix_progress = [](int32 progress) {
|
||||
return progress <= 0 || progress > 100 ? 0 : progress;
|
||||
};
|
||||
|
||||
switch (action->get_id()) {
|
||||
case telegram_api::sendMessageCancelAction::ID:
|
||||
|
@ -106,35 +106,33 @@ void scan_fs(CancellationToken &token, CallbackT &&callback) {
|
||||
continue;
|
||||
}
|
||||
auto files_dir = get_files_dir(file_type);
|
||||
walk_path(files_dir,
|
||||
[&](CSlice path, WalkPath::Type type) {
|
||||
if (token) {
|
||||
return WalkPath::Action::Abort;
|
||||
}
|
||||
if (type != WalkPath::Type::NotDir) {
|
||||
return WalkPath::Action::Continue;
|
||||
}
|
||||
auto r_stat = stat(path);
|
||||
if (r_stat.is_error()) {
|
||||
LOG(WARNING) << "Stat in files gc failed: " << r_stat.error();
|
||||
return WalkPath::Action::Continue;
|
||||
}
|
||||
auto stat = r_stat.move_as_ok();
|
||||
if (ends_with(path, "/.nomedia") && stat.size_ == 0) {
|
||||
// skip .nomedia file
|
||||
return WalkPath::Action::Continue;
|
||||
}
|
||||
walk_path(files_dir, [&](CSlice path, WalkPath::Type type) {
|
||||
if (token) {
|
||||
return WalkPath::Action::Abort;
|
||||
}
|
||||
if (type != WalkPath::Type::NotDir) {
|
||||
return WalkPath::Action::Continue;
|
||||
}
|
||||
auto r_stat = stat(path);
|
||||
if (r_stat.is_error()) {
|
||||
LOG(WARNING) << "Stat in files gc failed: " << r_stat.error();
|
||||
return WalkPath::Action::Continue;
|
||||
}
|
||||
auto stat = r_stat.move_as_ok();
|
||||
if (ends_with(path, "/.nomedia") && stat.size_ == 0) {
|
||||
// skip .nomedia file
|
||||
return WalkPath::Action::Continue;
|
||||
}
|
||||
|
||||
FsFileInfo info;
|
||||
info.path = path.str();
|
||||
info.size = stat.size_;
|
||||
info.file_type = file_type;
|
||||
info.atime_nsec = stat.atime_nsec_;
|
||||
info.mtime_nsec = stat.mtime_nsec_;
|
||||
callback(info);
|
||||
return WalkPath::Action::Continue;
|
||||
})
|
||||
.ignore();
|
||||
FsFileInfo info;
|
||||
info.path = path.str();
|
||||
info.size = stat.size_;
|
||||
info.file_type = file_type;
|
||||
info.atime_nsec = stat.atime_nsec_;
|
||||
info.mtime_nsec = stat.mtime_nsec_;
|
||||
callback(info);
|
||||
return WalkPath::Action::Continue;
|
||||
}).ignore();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
@ -228,7 +228,9 @@ bool PartsManager::is_part_in_streaming_limit(int part_i) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto is_intersect_with = [&](int64 begin, int64 end) { return max(begin, offset_begin) < min(end, offset_end); };
|
||||
auto is_intersect_with = [&](int64 begin, int64 end) {
|
||||
return max(begin, offset_begin) < min(end, offset_end);
|
||||
};
|
||||
|
||||
auto streaming_begin = streaming_offset_;
|
||||
auto streaming_end = streaming_offset_ + streaming_limit_;
|
||||
|
@ -135,11 +135,9 @@ Result<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_connection(DcId dc_id, b
|
||||
<< tag("prefer_ipv6", prefer_ipv6));
|
||||
}
|
||||
|
||||
auto last_error_at = std::min_element(options.begin(), options.end(),
|
||||
[](const auto &a_option, const auto &b_option) {
|
||||
return a_option.stat->error_at > b_option.stat->error_at;
|
||||
})
|
||||
->stat->error_at;
|
||||
auto last_error_at = std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
|
||||
return a_option.stat->error_at > b_option.stat->error_at;
|
||||
})->stat->error_at;
|
||||
|
||||
auto result = *std::min_element(options.begin(), options.end(), [](const auto &a_option, const auto &b_option) {
|
||||
auto &a = *a_option.stat;
|
||||
|
@ -229,37 +229,40 @@ void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, c
|
||||
|
||||
template <ActorSendType send_type, class EventT>
|
||||
void Scheduler::send_lambda(ActorRef actor_ref, EventT &&lambda) {
|
||||
return send_impl<send_type>(actor_ref.get(),
|
||||
[&](ActorInfo *actor_info) {
|
||||
event_context_ptr_->link_token = actor_ref.token();
|
||||
lambda();
|
||||
},
|
||||
[&]() {
|
||||
auto event = Event::lambda(std::forward<EventT>(lambda));
|
||||
event.set_link_token(actor_ref.token());
|
||||
return event;
|
||||
});
|
||||
return send_impl<send_type>(
|
||||
actor_ref.get(),
|
||||
[&](ActorInfo *actor_info) {
|
||||
event_context_ptr_->link_token = actor_ref.token();
|
||||
lambda();
|
||||
},
|
||||
[&]() {
|
||||
auto event = Event::lambda(std::forward<EventT>(lambda));
|
||||
event.set_link_token(actor_ref.token());
|
||||
return event;
|
||||
});
|
||||
}
|
||||
|
||||
template <ActorSendType send_type, class EventT>
|
||||
void Scheduler::send_closure(ActorRef actor_ref, EventT &&closure) {
|
||||
return send_impl<send_type>(actor_ref.get(),
|
||||
[&](ActorInfo *actor_info) {
|
||||
event_context_ptr_->link_token = actor_ref.token();
|
||||
closure.run(static_cast<typename EventT::ActorType *>(actor_info->get_actor_unsafe()));
|
||||
},
|
||||
[&]() {
|
||||
auto event = Event::immediate_closure(std::forward<EventT>(closure));
|
||||
event.set_link_token(actor_ref.token());
|
||||
return event;
|
||||
});
|
||||
return send_impl<send_type>(
|
||||
actor_ref.get(),
|
||||
[&](ActorInfo *actor_info) {
|
||||
event_context_ptr_->link_token = actor_ref.token();
|
||||
closure.run(static_cast<typename EventT::ActorType *>(actor_info->get_actor_unsafe()));
|
||||
},
|
||||
[&]() {
|
||||
auto event = Event::immediate_closure(std::forward<EventT>(closure));
|
||||
event.set_link_token(actor_ref.token());
|
||||
return event;
|
||||
});
|
||||
}
|
||||
|
||||
template <ActorSendType send_type>
|
||||
void Scheduler::send(ActorRef actor_ref, Event &&event) {
|
||||
event.set_link_token(actor_ref.token());
|
||||
return send_impl<send_type>(actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); },
|
||||
[&]() { return std::move(event); });
|
||||
return send_impl<send_type>(
|
||||
actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); },
|
||||
[&]() { return std::move(event); });
|
||||
}
|
||||
|
||||
inline void Scheduler::subscribe(PollableFd fd, PollFlags flags) {
|
||||
|
@ -77,13 +77,14 @@ class BinlogKeyValue : public KeyValueSyncInterface {
|
||||
}
|
||||
|
||||
binlog_ = std::make_shared<BinlogT>();
|
||||
TRY_STATUS(binlog_->init(name,
|
||||
[&](const BinlogEvent &binlog_event) {
|
||||
Event event;
|
||||
event.parse(TlParser(binlog_event.data_));
|
||||
map_.emplace(event.key.str(), std::make_pair(event.value.str(), binlog_event.id_));
|
||||
},
|
||||
std::move(db_key), DbKey::empty(), scheduler_id));
|
||||
TRY_STATUS(binlog_->init(
|
||||
name,
|
||||
[&](const BinlogEvent &binlog_event) {
|
||||
Event event;
|
||||
event.parse(TlParser(binlog_event.data_));
|
||||
map_.emplace(event.key.str(), std::make_pair(event.value.str(), binlog_event.id_));
|
||||
},
|
||||
std::move(db_key), DbKey::empty(), scheduler_id));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,9 @@ Result<bool> SqliteKeyValue::init(string path) {
|
||||
}
|
||||
|
||||
Status SqliteKeyValue::init_with_connection(SqliteDb connection, string table_name) {
|
||||
auto init_guard = ScopeExit() + [&]() { close(); };
|
||||
auto init_guard = ScopeExit() + [&]() {
|
||||
close();
|
||||
};
|
||||
db_ = std::move(connection);
|
||||
table_name_ = std::move(table_name);
|
||||
TRY_STATUS(init(db_, table_name_));
|
||||
|
@ -56,7 +56,9 @@ class SqliteStatement {
|
||||
void reset();
|
||||
|
||||
auto guard() {
|
||||
return ScopeExit{} + [this] { this->reset(); };
|
||||
return ScopeExit{} + [this] {
|
||||
this->reset();
|
||||
};
|
||||
}
|
||||
|
||||
// TODO get row
|
||||
|
@ -28,19 +28,20 @@ int main(int argc, char *argv[]) {
|
||||
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR));
|
||||
td::Binlog binlog;
|
||||
binlog
|
||||
.init(argv[1],
|
||||
[&](auto &event) {
|
||||
info[0].compressed_size += event.raw_event_.size();
|
||||
info[event.type_].compressed_size += event.raw_event_.size();
|
||||
},
|
||||
td::DbKey::raw_key("cucumber"), td::DbKey::empty(), -1,
|
||||
[&](auto &event) mutable {
|
||||
info[0].full_size += event.raw_event_.size();
|
||||
info[event.type_].full_size += event.raw_event_.size();
|
||||
LOG(PLAIN) << "LogEvent[" << td::tag("id", td::format::as_hex(event.id_)) << td::tag("type", event.type_)
|
||||
<< td::tag("flags", event.flags_) << td::tag("size", event.data_.size())
|
||||
<< td::tag("data", td::format::escaped(event.data_)) << "]\n";
|
||||
})
|
||||
.init(
|
||||
argv[1],
|
||||
[&](auto &event) {
|
||||
info[0].compressed_size += event.raw_event_.size();
|
||||
info[event.type_].compressed_size += event.raw_event_.size();
|
||||
},
|
||||
td::DbKey::raw_key("cucumber"), td::DbKey::empty(), -1,
|
||||
[&](auto &event) mutable {
|
||||
info[0].full_size += event.raw_event_.size();
|
||||
info[event.type_].full_size += event.raw_event_.size();
|
||||
LOG(PLAIN) << "LogEvent[" << td::tag("id", td::format::as_hex(event.id_)) << td::tag("type", event.type_)
|
||||
<< td::tag("flags", event.flags_) << td::tag("size", event.data_.size())
|
||||
<< td::tag("data", td::format::escaped(event.data_)) << "]\n";
|
||||
})
|
||||
.ensure();
|
||||
|
||||
for (auto &it : info) {
|
||||
|
@ -224,7 +224,9 @@ class SslStreamImpl {
|
||||
if (ssl_ctx == nullptr) {
|
||||
return create_openssl_error(-7, "Failed to create an SSL context");
|
||||
}
|
||||
auto ssl_ctx_guard = ScopeExit() + [&]() { SSL_CTX_free(ssl_ctx); };
|
||||
auto ssl_ctx_guard = ScopeExit() + [&]() {
|
||||
SSL_CTX_free(ssl_ctx);
|
||||
};
|
||||
long options = 0;
|
||||
#ifdef SSL_OP_NO_SSLv2
|
||||
options |= SSL_OP_NO_SSLv2;
|
||||
|
@ -22,7 +22,9 @@ namespace td {
|
||||
template <int id>
|
||||
static FileFd &get_file_fd() {
|
||||
static FileFd result = FileFd::from_native_fd(NativeFd(id, true));
|
||||
static auto guard = ScopeExit() + [&] { result.move_as_native_fd().release(); };
|
||||
static auto guard = ScopeExit() + [&] {
|
||||
result.move_as_native_fd().release();
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -42,7 +44,9 @@ static FileFd &get_file_fd() {
|
||||
static auto handle = GetStdHandle(id);
|
||||
LOG_IF(FATAL, handle == INVALID_HANDLE_VALUE) << "Failed to GetStdHandle " << id;
|
||||
static FileFd result = FileFd::from_native_fd(NativeFd(handle, true));
|
||||
static auto guard = ScopeExit() + [&] { result.move_as_native_fd().release(); };
|
||||
static auto guard = ScopeExit() + [&] {
|
||||
result.move_as_native_fd().release();
|
||||
};
|
||||
#else
|
||||
static FileFd result;
|
||||
#endif
|
||||
|
@ -31,9 +31,7 @@ class ThreadPthread {
|
||||
ThreadPthread() = default;
|
||||
ThreadPthread(const ThreadPthread &other) = delete;
|
||||
ThreadPthread &operator=(const ThreadPthread &other) = delete;
|
||||
ThreadPthread(ThreadPthread &&other) noexcept
|
||||
: is_inited_(std::move(other.is_inited_))
|
||||
, thread_(other.thread_) {
|
||||
ThreadPthread(ThreadPthread &&other) noexcept : is_inited_(std::move(other.is_inited_)), thread_(other.thread_) {
|
||||
}
|
||||
ThreadPthread &operator=(ThreadPthread &&other) {
|
||||
join();
|
||||
|
@ -153,7 +153,8 @@ TEST(Misc, get_last_argument) {
|
||||
}
|
||||
|
||||
TEST(Misc, call_n_arguments) {
|
||||
auto f = [](int, int) {};
|
||||
auto f = [](int, int) {
|
||||
};
|
||||
call_n_arguments<2>(f, 1, 3, 4);
|
||||
}
|
||||
|
||||
@ -757,8 +758,12 @@ TEST(Misc, uint128) {
|
||||
static_cast<int64>(std::numeric_limits<int32>::min()) - 1};
|
||||
|
||||
#if TD_HAVE_INT128
|
||||
auto to_intrinsic = [](uint128_emulated num) { return uint128_intrinsic(num.hi(), num.lo()); };
|
||||
auto eq = [](uint128_emulated a, uint128_intrinsic b) { return a.hi() == b.hi() && a.lo() == b.lo(); };
|
||||
auto to_intrinsic = [](uint128_emulated num) {
|
||||
return uint128_intrinsic(num.hi(), num.lo());
|
||||
};
|
||||
auto eq = [](uint128_emulated a, uint128_intrinsic b) {
|
||||
return a.hi() == b.hi() && a.lo() == b.lo();
|
||||
};
|
||||
auto ensure_eq = [&](uint128_emulated a, uint128_intrinsic b) {
|
||||
if (!eq(a, b)) {
|
||||
LOG(FATAL) << "[" << a.hi() << ";" << a.lo() << "] vs [" << b.hi() << ";" << b.lo() << "]";
|
||||
|
@ -41,44 +41,38 @@ TEST(Port, files) {
|
||||
int cnt = 0;
|
||||
const int ITER_COUNT = 1000;
|
||||
for (int i = 0; i < ITER_COUNT; i++) {
|
||||
walk_path(main_dir,
|
||||
[&](CSlice name, WalkPath::Type type) {
|
||||
if (type == WalkPath::Type::NotDir) {
|
||||
ASSERT_TRUE(name == fd_path || name == fd2_path);
|
||||
}
|
||||
cnt++;
|
||||
})
|
||||
.ensure();
|
||||
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||
if (type == WalkPath::Type::NotDir) {
|
||||
ASSERT_TRUE(name == fd_path || name == fd2_path);
|
||||
}
|
||||
cnt++;
|
||||
}).ensure();
|
||||
}
|
||||
ASSERT_EQ((5 * 2 + 2) * ITER_COUNT, cnt);
|
||||
bool was_abort = false;
|
||||
walk_path(main_dir,
|
||||
[&](CSlice name, WalkPath::Type type) {
|
||||
CHECK(!was_abort);
|
||||
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << TD_DIR_SLASH << "B")) {
|
||||
was_abort = true;
|
||||
return WalkPath::Action::Abort;
|
||||
}
|
||||
return WalkPath::Action::Continue;
|
||||
})
|
||||
.ensure();
|
||||
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||
CHECK(!was_abort);
|
||||
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << TD_DIR_SLASH << "B")) {
|
||||
was_abort = true;
|
||||
return WalkPath::Action::Abort;
|
||||
}
|
||||
return WalkPath::Action::Continue;
|
||||
}).ensure();
|
||||
CHECK(was_abort);
|
||||
|
||||
cnt = 0;
|
||||
bool is_first_dir = true;
|
||||
walk_path(main_dir,
|
||||
[&](CSlice name, WalkPath::Type type) {
|
||||
cnt++;
|
||||
if (type == WalkPath::Type::EnterDir) {
|
||||
if (is_first_dir) {
|
||||
is_first_dir = false;
|
||||
} else {
|
||||
return WalkPath::Action::SkipDir;
|
||||
}
|
||||
}
|
||||
return WalkPath::Action::Continue;
|
||||
})
|
||||
.ensure();
|
||||
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||
cnt++;
|
||||
if (type == WalkPath::Type::EnterDir) {
|
||||
if (is_first_dir) {
|
||||
is_first_dir = false;
|
||||
} else {
|
||||
return WalkPath::Action::SkipDir;
|
||||
}
|
||||
}
|
||||
return WalkPath::Action::Continue;
|
||||
}).ensure();
|
||||
ASSERT_EQ(6, cnt);
|
||||
|
||||
ASSERT_EQ(0u, fd.get_size().move_as_ok());
|
||||
|
22
test/db.cpp
22
test/db.cpp
@ -47,11 +47,17 @@ TEST(DB, binlog_encryption_bug) {
|
||||
auto empty = DbKey::empty();
|
||||
{
|
||||
Binlog binlog;
|
||||
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber).ensure();
|
||||
binlog
|
||||
.init(
|
||||
binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber)
|
||||
.ensure();
|
||||
}
|
||||
{
|
||||
Binlog binlog;
|
||||
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber).ensure();
|
||||
binlog
|
||||
.init(
|
||||
binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber)
|
||||
.ensure();
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +98,10 @@ TEST(DB, binlog_encryption) {
|
||||
std::vector<string> v;
|
||||
LOG(INFO) << "RESTART";
|
||||
Binlog binlog;
|
||||
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, hello).ensure();
|
||||
binlog
|
||||
.init(
|
||||
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, hello)
|
||||
.ensure();
|
||||
CHECK(v == std::vector<string>({"AAAA", "BBBB", long_data, "CCCC"}));
|
||||
}
|
||||
|
||||
@ -102,7 +111,8 @@ TEST(DB, binlog_encryption) {
|
||||
std::vector<string> v;
|
||||
LOG(INFO) << "RESTART";
|
||||
Binlog binlog;
|
||||
auto status = binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber);
|
||||
auto status = binlog.init(
|
||||
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber);
|
||||
CHECK(status.is_error());
|
||||
}
|
||||
|
||||
@ -112,8 +122,8 @@ TEST(DB, binlog_encryption) {
|
||||
std::vector<string> v;
|
||||
LOG(INFO) << "RESTART";
|
||||
Binlog binlog;
|
||||
auto status =
|
||||
binlog.init(binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber, hello);
|
||||
auto status = binlog.init(
|
||||
binlog_name.str(), [&](const BinlogEvent &x) { v.push_back(x.data_.str()); }, cucumber, hello);
|
||||
CHECK(v == std::vector<string>({"AAAA", "BBBB", long_data, "CCCC"}));
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user