Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1167)

Side by Side Diff: base/win/scoped_variant_unittest.cc

Issue 1550493002: Switch to standard integer types in base/win/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/win/scoped_variant.cc ('k') | base/win/shortcut.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h>
6
5 #include "base/win/scoped_variant.h" 7 #include "base/win/scoped_variant.h"
6 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
7 9
8 namespace base { 10 namespace base {
9 namespace win { 11 namespace win {
10 12
11 namespace { 13 namespace {
12 14
13 static const wchar_t kTestString1[] = L"Used to create BSTRs"; 15 static const wchar_t kTestString1[] = L"Used to create BSTRs";
14 static const wchar_t kTestString2[] = L"Also used to create BSTRs"; 16 static const wchar_t kTestString2[] = L"Also used to create BSTRs";
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 var.Reset(); 121 var.Reset();
120 var.SetDate(date); 122 var.SetDate(date);
121 EXPECT_EQ(VT_DATE, var.type()); 123 EXPECT_EQ(VT_DATE, var.type());
122 EXPECT_EQ(date, V_DATE(var.ptr())); 124 EXPECT_EQ(date, V_DATE(var.ptr()));
123 125
124 // Simple setter tests. These do not require resetting the variant 126 // Simple setter tests. These do not require resetting the variant
125 // after each test since the variant type is not "leakable" (i.e. doesn't 127 // after each test since the variant type is not "leakable" (i.e. doesn't
126 // need to be freed explicitly). 128 // need to be freed explicitly).
127 129
128 // We need static cast here since char defaults to int (!?). 130 // We need static cast here since char defaults to int (!?).
129 var.Set(static_cast<int8>('v')); 131 var.Set(static_cast<int8_t>('v'));
130 EXPECT_EQ(VT_I1, var.type()); 132 EXPECT_EQ(VT_I1, var.type());
131 EXPECT_EQ('v', V_I1(var.ptr())); 133 EXPECT_EQ('v', V_I1(var.ptr()));
132 134
133 var.Set(static_cast<short>(123)); 135 var.Set(static_cast<short>(123));
134 EXPECT_EQ(VT_I2, var.type()); 136 EXPECT_EQ(VT_I2, var.type());
135 EXPECT_EQ(123, V_I2(var.ptr())); 137 EXPECT_EQ(123, V_I2(var.ptr()));
136 138
137 var.Set(static_cast<int32>(123)); 139 var.Set(static_cast<int32_t>(123));
138 EXPECT_EQ(VT_I4, var.type()); 140 EXPECT_EQ(VT_I4, var.type());
139 EXPECT_EQ(123, V_I4(var.ptr())); 141 EXPECT_EQ(123, V_I4(var.ptr()));
140 142
141 var.Set(static_cast<int64>(123)); 143 var.Set(static_cast<int64_t>(123));
142 EXPECT_EQ(VT_I8, var.type()); 144 EXPECT_EQ(VT_I8, var.type());
143 EXPECT_EQ(123, V_I8(var.ptr())); 145 EXPECT_EQ(123, V_I8(var.ptr()));
144 146
145 var.Set(static_cast<uint8>(123)); 147 var.Set(static_cast<uint8_t>(123));
146 EXPECT_EQ(VT_UI1, var.type()); 148 EXPECT_EQ(VT_UI1, var.type());
147 EXPECT_EQ(123u, V_UI1(var.ptr())); 149 EXPECT_EQ(123u, V_UI1(var.ptr()));
148 150
149 var.Set(static_cast<unsigned short>(123)); 151 var.Set(static_cast<unsigned short>(123));
150 EXPECT_EQ(VT_UI2, var.type()); 152 EXPECT_EQ(VT_UI2, var.type());
151 EXPECT_EQ(123u, V_UI2(var.ptr())); 153 EXPECT_EQ(123u, V_UI2(var.ptr()));
152 154
153 var.Set(static_cast<uint32>(123)); 155 var.Set(static_cast<uint32_t>(123));
154 EXPECT_EQ(VT_UI4, var.type()); 156 EXPECT_EQ(VT_UI4, var.type());
155 EXPECT_EQ(123u, V_UI4(var.ptr())); 157 EXPECT_EQ(123u, V_UI4(var.ptr()));
156 158
157 var.Set(static_cast<uint64>(123)); 159 var.Set(static_cast<uint64_t>(123));
158 EXPECT_EQ(VT_UI8, var.type()); 160 EXPECT_EQ(VT_UI8, var.type());
159 EXPECT_EQ(123u, V_UI8(var.ptr())); 161 EXPECT_EQ(123u, V_UI8(var.ptr()));
160 162
161 var.Set(123.123f); 163 var.Set(123.123f);
162 EXPECT_EQ(VT_R4, var.type()); 164 EXPECT_EQ(VT_R4, var.type());
163 EXPECT_EQ(123.123f, V_R4(var.ptr())); 165 EXPECT_EQ(123.123f, V_R4(var.ptr()));
164 166
165 var.Set(static_cast<double>(123.123)); 167 var.Set(static_cast<double>(123.123));
166 EXPECT_EQ(VT_R8, var.type()); 168 EXPECT_EQ(VT_R8, var.type());
167 EXPECT_EQ(123.123, V_R8(var.ptr())); 169 EXPECT_EQ(123.123, V_R8(var.ptr()));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 254
253 var.Set(sa); 255 var.Set(sa);
254 EXPECT_TRUE(ScopedVariant::IsLeakableVarType(var.type())); 256 EXPECT_TRUE(ScopedVariant::IsLeakableVarType(var.type()));
255 EXPECT_EQ(VT_ARRAY | VT_UI1, var.type()); 257 EXPECT_EQ(VT_ARRAY | VT_UI1, var.type());
256 EXPECT_EQ(sa, V_ARRAY(var.ptr())); 258 EXPECT_EQ(sa, V_ARRAY(var.ptr()));
257 // The array is destroyed in the destructor of var. 259 // The array is destroyed in the destructor of var.
258 } 260 }
259 261
260 } // namespace win 262 } // namespace win
261 } // namespace base 263 } // namespace base
OLDNEW
« no previous file with comments | « base/win/scoped_variant.cc ('k') | base/win/shortcut.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698