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

Side by Side Diff: util/misc/uuid_test.cc

Issue 1004913004: win: Add UUID::InitializeFromSystemUUID() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Rebase Created 5 years, 9 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 | « util/misc/uuid.cc ('k') | util/util.gyp » ('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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/misc/uuid.h" 15 #include "util/misc/uuid.h"
16 16
17 #include <stdint.h> 17 #include <stdint.h>
18 18
19 #include <string> 19 #include <string>
20 20
21 #include "base/basictypes.h" 21 #include "base/basictypes.h"
22 #include "base/format_macros.h" 22 #include "base/format_macros.h"
23 #include "base/scoped_generic.h"
23 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
24 #include "gtest/gtest.h" 25 #include "gtest/gtest.h"
25 26
26 namespace crashpad { 27 namespace crashpad {
27 namespace test { 28 namespace test {
28 namespace { 29 namespace {
29 30
30 TEST(UUID, UUID) { 31 TEST(UUID, UUID) {
31 UUID uuid_zero; 32 UUID uuid_zero;
32 EXPECT_EQ(0u, uuid_zero.data_1); 33 EXPECT_EQ(0u, uuid_zero.data_1);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // Test for case insensitivty. 198 // Test for case insensitivty.
198 UUID uuid; 199 UUID uuid;
199 uuid.InitializeFromString("F32E5BDC-2681-4C73-A4E6-911FFD89B846"); 200 uuid.InitializeFromString("F32E5BDC-2681-4C73-A4E6-911FFD89B846");
200 EXPECT_EQ("f32e5bdc-2681-4c73-a4e6-911ffd89b846", uuid.ToString()); 201 EXPECT_EQ("f32e5bdc-2681-4c73-a4e6-911ffd89b846", uuid.ToString());
201 202
202 // Mixed case. 203 // Mixed case.
203 uuid.InitializeFromString("5762C15D-50b5-4171-a2e9-7429C9EC6CAB"); 204 uuid.InitializeFromString("5762C15D-50b5-4171-a2e9-7429C9EC6CAB");
204 EXPECT_EQ("5762c15d-50b5-4171-a2e9-7429c9ec6cab", uuid.ToString()); 205 EXPECT_EQ("5762c15d-50b5-4171-a2e9-7429c9ec6cab", uuid.ToString());
205 } 206 }
206 207
208 #if defined(OS_WIN)
209
210 TEST(UUID, FromSystem) {
211 ::GUID system_uuid;
212 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid));
213
214 UUID uuid;
215 uuid.InitializeFromSystemUUID(&system_uuid);
216
217 RPC_WSTR system_string;
218 ASSERT_EQ(RPC_S_OK, UuidToString(&system_uuid, &system_string));
219
220 struct ScopedRpcStringFreeTraits {
221 static RPC_WSTR* InvalidValue() { return nullptr; }
222 static void Free(RPC_WSTR* rpc_string) {
223 EXPECT_EQ(RPC_S_OK, RpcStringFree(rpc_string));
224 }
225 };
226 using ScopedRpcString =
227 base::ScopedGeneric<RPC_WSTR*, ScopedRpcStringFreeTraits>;
228 ScopedRpcString scoped_system_string(&system_string);
229
230 EXPECT_EQ(reinterpret_cast<wchar_t*>(system_string), uuid.ToString16());
231 }
232
233 #endif // OS_WIN
234
207 } // namespace 235 } // namespace
208 } // namespace test 236 } // namespace test
209 } // namespace crashpad 237 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/misc/uuid.cc ('k') | util/util.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698