[M108 Migration][VD] Support set time and time zone offset
[platform/framework/web/chromium-efl.git] / base / check_op.cc
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.
4
5 #include "base/check_op.h"
6
7 #include <string.h>
8
9 #include <cstdio>
10 #include <sstream>
11
12 namespace logging {
13
14 char* CheckOpValueStr(int v) {
15   char buf[50];
16   snprintf(buf, sizeof(buf), "%d", v);
17   return strdup(buf);
18 }
19
20 char* CheckOpValueStr(unsigned v) {
21   char buf[50];
22   snprintf(buf, sizeof(buf), "%u", v);
23   return strdup(buf);
24 }
25
26 char* CheckOpValueStr(long v) {
27   char buf[50];
28   snprintf(buf, sizeof(buf), "%ld", v);
29   return strdup(buf);
30 }
31
32 char* CheckOpValueStr(unsigned long v) {
33   char buf[50];
34   snprintf(buf, sizeof(buf), "%lu", v);
35   return strdup(buf);
36 }
37
38 char* CheckOpValueStr(long long v) {
39   char buf[50];
40   snprintf(buf, sizeof(buf), "%lld", v);
41   return strdup(buf);
42 }
43
44 char* CheckOpValueStr(unsigned long long v) {
45   char buf[50];
46   snprintf(buf, sizeof(buf), "%llu", v);
47   return strdup(buf);
48 }
49
50 char* CheckOpValueStr(const void* v) {
51   char buf[50];
52   snprintf(buf, sizeof(buf), "%p", v);
53   return strdup(buf);
54 }
55
56 char* CheckOpValueStr(std::nullptr_t v) {
57   return strdup("nullptr");
58 }
59
60 char* CheckOpValueStr(const std::string& v) {
61   return strdup(v.c_str());
62 }
63
64 char* CheckOpValueStr(double v) {
65   char buf[50];
66   snprintf(buf, sizeof(buf), "%.6lf", v);
67   return strdup(buf);
68 }
69
70 char* StreamValToStr(const void* v,
71                      void (*stream_func)(std::ostream&, const void*)) {
72   std::stringstream ss;
73   stream_func(ss, v);
74   return strdup(ss.str().c_str());
75 }
76
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());
81   free(v1_str);
82   free(v2_str);
83 }
84
85 }  // namespace logging