1 // Copyright 2020 The Chromium Authors
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"
14 char* CheckOpValueStr(int v) {
16 snprintf(buf, sizeof(buf), "%d", v);
20 char* CheckOpValueStr(unsigned v) {
22 snprintf(buf, sizeof(buf), "%u", v);
26 char* CheckOpValueStr(long v) {
28 snprintf(buf, sizeof(buf), "%ld", v);
32 char* CheckOpValueStr(unsigned long v) {
34 snprintf(buf, sizeof(buf), "%lu", v);
38 char* CheckOpValueStr(long long v) {
40 snprintf(buf, sizeof(buf), "%lld", v);
44 char* CheckOpValueStr(unsigned long long v) {
46 snprintf(buf, sizeof(buf), "%llu", v);
50 char* CheckOpValueStr(const void* v) {
52 snprintf(buf, sizeof(buf), "%p", v);
56 char* CheckOpValueStr(std::nullptr_t v) {
57 return strdup("nullptr");
60 char* CheckOpValueStr(const std::string& v) {
61 return strdup(v.c_str());
64 char* CheckOpValueStr(double v) {
66 snprintf(buf, sizeof(buf), "%.6lf", v);
70 char* StreamValToStr(const void* v,
71 void (*stream_func)(std::ostream&, const void*)) {
74 return strdup(ss.str().c_str());
77 CheckOpResult::CheckOpResult(const char* expr_str, char* v1_str, char* v2_str) {
78 std::ostringstream ss;
79 ss << expr_str << " (" << v1_str << " vs. " << v2_str << ")";
80 message_ = strdup(ss.str().c_str());
85 } // namespace logging