summaryrefslogtreecommitdiffstats
path: root/chrome/browser/guid_unittest.cc
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-11-01 12:19:54 +0000
committerIain Merrick <husky@google.com>2010-11-03 10:21:10 +0000
commit731df977c0511bca2206b5f333555b1205ff1f43 (patch)
tree0e750b949b3f00a1ac11fda25d3c2de512f2b465 /chrome/browser/guid_unittest.cc
parent5add15e10e7bb80512f2c597ca57221314abe577 (diff)
downloadexternal_chromium-731df977c0511bca2206b5f333555b1205ff1f43.zip
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.gz
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.bz2
Merge Chromium at r63472 : Initial merge by git.
Change-Id: Ifb9ee821af006a5f2211e81471be93ae440a1f5a
Diffstat (limited to 'chrome/browser/guid_unittest.cc')
-rw-r--r--chrome/browser/guid_unittest.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/chrome/browser/guid_unittest.cc b/chrome/browser/guid_unittest.cc
new file mode 100644
index 0000000..1951ca1
--- /dev/null
+++ b/chrome/browser/guid_unittest.cc
@@ -0,0 +1,42 @@
+// Copyright (c) 2010 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/guid.h"
+
+#include <limits>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if defined(OS_POSIX)
+TEST(GUIDTest, GUIDGeneratesAllZeroes) {
+ uint64 bytes[] = { 0, 0 };
+ std::string clientid = guid::RandomDataToGUIDString(bytes);
+ EXPECT_EQ("00000000-0000-0000-0000-000000000000", clientid);
+}
+
+TEST(GUIDTest, GUIDGeneratesCorrectly) {
+ uint64 bytes[] = { 0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL };
+ std::string clientid = guid::RandomDataToGUIDString(bytes);
+ EXPECT_EQ("01234567-89AB-CDEF-FEDC-BA9876543210", clientid);
+}
+#endif
+
+TEST(GUIDTest, GUIDCorrectlyFormatted) {
+ const int kIterations = 10;
+ for (int it = 0; it < kIterations; ++it) {
+ std::string guid = guid::GenerateGUID();
+ EXPECT_TRUE(guid::IsValidGUID(guid));
+ }
+}
+
+TEST(GUIDTest, GUIDBasicUniqueness) {
+ const int kIterations = 10;
+ for (int it = 0; it < kIterations; ++it) {
+ std::string guid1 = guid::GenerateGUID();
+ std::string guid2 = guid::GenerateGUID();
+ EXPECT_EQ(36U, guid1.length());
+ EXPECT_EQ(36U, guid2.length());
+ EXPECT_NE(guid1, guid2);
+ }
+}