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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_service_unittest.cc
===================================================================
--- chrome/browser/metrics/metrics_service_unittest.cc (revision 0)
+++ chrome/browser/metrics/metrics_service_unittest.cc (revision 0)
@@ -0,0 +1,35 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/metrics/metrics_service.h"
+
+#include <string>
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if defined(OS_POSIX) && defined(LINUX2)
+TEST(MetricsServiceTest, ClientIdGeneratesAllZeroes) {
+ uint64 bytes[] = { 0, 0 };
+ std::string clientid = MetricsService::RandomBytesToGUIDString(bytes);
+ EXPECT_EQ("00000000-0000-0000-0000-000000000000", clientid);
+}
+TEST(MetricsServiceTest, ClientIdGeneratesCorrectly) {
+ uint64 bytes[] = { 0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL };
+ std::string clientid = MetricsService::RandomBytesToGUIDString(bytes);
+ EXPECT_EQ("01234567-89AB-CDEF-FEDC-BA9876543210", clientid);
+}
+
+TEST(MetricsServiceTest, ClientIdCorrectlyFormatted) {
+ std::string clientid = MetricsService::GenerateClientID();
+ EXPECT_EQ(36U, clientid.length());
+ std::string hexchars = "0123456789ABCDEF";
+ for (uint32 i = 0; i < clientid.length(); i++) {
+ char current = clientid.at(i);
+ if (i == 8 || i == 13 || i == 18 || i == 23) {
+ EXPECT_EQ('-', current);
+ } else {
+ EXPECT_TRUE(std::string::npos != hexchars.find(current));
+ }
+ }
+}
+#endif
Property changes on: chrome/browser/metrics/metrics_service_unittest.cc
___________________________________________________________________
Name: svn:eol-style
+ LF
« 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