diff options
author | 2022-12-19 07:43:33 -0800 | |
---|---|---|
committer | 2022-12-19 07:45:02 -0800 | |
commit | b1f792822b8d25e2f954b32dbcee0ddb89631fa9 (patch) | |
tree | 3943ae69194ad51f885adb08d9c257248d8209aa /absl/log/log_format_test.cc | |
parent | 95505fbfbabc5240b623017d44093bb82f4912a9 (diff) |
Fix a -Wsign-conversion and some -Wshorten-64-to-32.
PiperOrigin-RevId: 496397075
Change-Id: Ib44467cf5704b9147c7fd197e8343a666fada1c3
Diffstat (limited to 'absl/log/log_format_test.cc')
-rw-r--r-- | absl/log/log_format_test.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc index 5ff6f159..69bdf8d8 100644 --- a/absl/log/log_format_test.cc +++ b/absl/log/log_format_test.cc @@ -36,6 +36,7 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" +#include "absl/types/optional.h" namespace { using ::absl::log_internal::AsString; @@ -1702,18 +1703,18 @@ size_t MaxLogFieldLengthNoPrefix() { class StringLengthExtractorSink : public absl::LogSink { public: void Send(const absl::LogEntry& entry) override { - CHECK_EQ(size_, -1); + CHECK(!size_.has_value()); CHECK_EQ(entry.text_message().find_first_not_of('x'), absl::string_view::npos); - size_ = entry.text_message().size(); + size_.emplace(entry.text_message().size()); } size_t size() const { - CHECK_GT(size_, 0); - return size_; + CHECK(size_.has_value()); + return *size_; } private: - size_t size_ = -1; + absl::optional<size_t> size_; } extractor_sink; LOG(INFO).NoPrefix().ToSinkOnly(&extractor_sink) << std::string(2 * absl::log_internal::kLogMessageBufferSize, 'x'); |