1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/check_op.h"
7 // check_op.h is a widely included header and its size has significant impact on
8 // build time. Try not to raise this limit unless absolutely necessary. See
9 // https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
11 #pragma clang max_tokens_here 244000
21 char* CheckOpValueStr(int v) {
23 snprintf(buf, sizeof(buf), "%d", v);
27 char* CheckOpValueStr(unsigned v) {
29 snprintf(buf, sizeof(buf), "%u", v);
33 char* CheckOpValueStr(long v) {
35 snprintf(buf, sizeof(buf), "%ld", v);
39 char* CheckOpValueStr(unsigned long v) {
41 snprintf(buf, sizeof(buf), "%lu", v);
45 char* CheckOpValueStr(long long v) {
47 snprintf(buf, sizeof(buf), "%lld", v);
51 char* CheckOpValueStr(unsigned long long v) {
53 snprintf(buf, sizeof(buf), "%llu", v);
57 char* CheckOpValueStr(const void* v) {
59 snprintf(buf, sizeof(buf), "%p", v);
63 char* CheckOpValueStr(std::nullptr_t v) {
64 return strdup("nullptr");
67 char* CheckOpValueStr(double v) {
69 snprintf(buf, sizeof(buf), "%.6lf", v);
73 char* StreamValToStr(const void* v,
74 void (*stream_func)(std::ostream&, const void*)) {
77 return strdup(ss.str().c_str());
80 CheckOpResult::CheckOpResult(const char* expr_str, char* v1_str, char* v2_str) {
81 std::ostringstream ss;
82 ss << expr_str << " (" << v1_str << " vs. " << v2_str << ")";
83 message_ = strdup(ss.str().c_str());
88 } // namespace logging