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

Side by Side Diff: chrome/browser/metrics/metrics_service_unittest.cc

Issue 149343: http://codereview.chromium.org/147084... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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.
4
5 #include "chrome/browser/metrics/metrics_service.h"
6
7 #include <string>
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 #if defined(OS_POSIX) && defined(LINUX2)
11 TEST(MetricsServiceTest, ClientIdGeneratesAllZeroes) {
12 uint64 bytes[] = { 0, 0 };
13 std::string clientid = MetricsService::RandomBytesToGUIDString(bytes);
14 EXPECT_EQ("00000000-0000-0000-0000-000000000000", clientid);
15 }
16 TEST(MetricsServiceTest, ClientIdGeneratesCorrectly) {
17 uint64 bytes[] = { 0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL };
18 std::string clientid = MetricsService::RandomBytesToGUIDString(bytes);
19 EXPECT_EQ("01234567-89AB-CDEF-FEDC-BA9876543210", clientid);
20 }
21
22 TEST(MetricsServiceTest, ClientIdCorrectlyFormatted) {
23 std::string clientid = MetricsService::GenerateClientID();
24 EXPECT_EQ(36U, clientid.length());
25 std::string hexchars = "0123456789ABCDEF";
26 for (uint32 i = 0; i < clientid.length(); i++) {
27 char current = clientid.at(i);
28 if (i == 8 || i == 13 || i == 18 || i == 23) {
29 EXPECT_EQ('-', current);
30 } else {
31 EXPECT_TRUE(std::string::npos != hexchars.find(current));
32 }
33 }
34 }
35 #endif
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698