diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 20:34:59 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 20:34:59 +0000 |
commit | 3469e7e544aeea3a5cee8aee9a8891a29c61a17d (patch) | |
tree | 4d9d1056f06f90f724ba702e94aa2b4d47da7fa6 /base/rand_util_unittest.cc | |
parent | 94e9666e60bf1d5e3559bfe216845a2cb054b204 (diff) | |
download | chromium_src-3469e7e544aeea3a5cee8aee9a8891a29c61a17d.zip chromium_src-3469e7e544aeea3a5cee8aee9a8891a29c61a17d.tar.gz chromium_src-3469e7e544aeea3a5cee8aee9a8891a29c61a17d.tar.bz2 |
Moving GUID generation from base to chrome/browser/guid*
Moves GUID generation into chrome/browser/guid*. GUID generation is used only within chrome/browser. So am moving it there.
BUG=58813
TEST=GUIDTest.GUIDGeneratesAllZeroes, GUIDTest.GUIDGeneratesCorrectly, GUIDTest.GUIDCorrectlyFormatted, MetricsServiceTest.ClientIdCorrectlyFormatted
Review URL: http://codereview.chromium.org/3800003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62639 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/rand_util_unittest.cc')
-rw-r--r-- | base/rand_util_unittest.cc | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/base/rand_util_unittest.cc b/base/rand_util_unittest.cc index 112099f..cbc338a 100644 --- a/base/rand_util_unittest.cc +++ b/base/rand_util_unittest.cc @@ -35,50 +35,3 @@ TEST(RandUtilTest, RandGeneratorForRandomShuffle) { EXPECT_LE(std::numeric_limits<ptrdiff_t>::max(), std::numeric_limits<int64>::max()); } - -#if defined(OS_POSIX) -// For unit testing purposes only. Do not use outside of tests. -namespace base { -extern std::string RandomBytesToGUIDString(const uint64 bytes[2]); -} // base - -TEST(RandUtilTest, GUIDGeneratesAllZeroes) { - uint64 bytes[] = { 0, 0 }; - std::string clientid = base::RandomBytesToGUIDString(bytes); - EXPECT_EQ("00000000-0000-0000-0000-000000000000", clientid); -} - -TEST(RandUtilTest, GUIDGeneratesCorrectly) { - uint64 bytes[] = { 0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL }; - std::string clientid = base::RandomBytesToGUIDString(bytes); - EXPECT_EQ("01234567-89AB-CDEF-FEDC-BA9876543210", clientid); -} -#endif - -TEST(RandUtilTest, GUIDCorrectlyFormatted) { - const int kIterations = 10; - for (int it = 0; it < kIterations; ++it) { - std::string guid = base::GenerateGUID(); - EXPECT_EQ(36U, guid.length()); - std::string hexchars = "0123456789ABCDEF"; - for (uint32 i = 0; i < guid.length(); ++i) { - char current = guid.at(i); - if (i == 8 || i == 13 || i == 18 || i == 23) { - EXPECT_EQ('-', current); - } else { - EXPECT_TRUE(std::string::npos != hexchars.find(current)); - } - } - } -} - -TEST(RandUtilTest, GUIDBasicUniqueness) { - const int kIterations = 10; - for (int it = 0; it < kIterations; ++it) { - std::string guid1 = base::GenerateGUID(); - std::string guid2 = base::GenerateGUID(); - EXPECT_EQ(36U, guid1.length()); - EXPECT_EQ(36U, guid2.length()); - EXPECT_NE(guid1, guid2); - } -} |