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

Unified Diff: util/misc/uuid_test.cc

Issue 430003003: Add UUID, strlcpy, and their tests to util (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 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
Index: util/misc/uuid_test.cc
diff --git a/util/misc/uuid_test.cc b/util/misc/uuid_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d56a40a29b94dc299d27dba90c46612488e03c2b
--- /dev/null
+++ b/util/misc/uuid_test.cc
@@ -0,0 +1,59 @@
+// Copyright 2014 The Crashpad Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "util/misc/uuid.h"
+
+#include <stdint.h>
+
+#include "gtest/gtest.h"
+
+namespace {
+
+using namespace crashpad;
+
+TEST(UUID, InitializeFromBytes) {
+ const uint8_t kBytes[16] = {0x00,
+ 0x01,
+ 0x02,
+ 0x03,
+ 0x04,
+ 0x05,
+ 0x06,
+ 0x07,
+ 0x08,
+ 0x09,
+ 0x0a,
+ 0x0b,
+ 0x0c,
+ 0x0d,
+ 0x0e,
+ 0x0f};
+
+ UUID uuid;
+ uuid.InitializeFromBytes(kBytes);
+
+ EXPECT_EQ(0x00010203u, uuid.data_1);
+ EXPECT_EQ(0x0405u, uuid.data_2);
+ EXPECT_EQ(0x0607u, uuid.data_3);
+ EXPECT_EQ(0x08u, uuid.data_4[0]);
+ EXPECT_EQ(0x09u, uuid.data_4[1]);
+ EXPECT_EQ(0x0au, uuid.data_4[2]);
+ EXPECT_EQ(0x0bu, uuid.data_4[3]);
+ EXPECT_EQ(0x0cu, uuid.data_4[4]);
+ EXPECT_EQ(0x0du, uuid.data_4[5]);
+ EXPECT_EQ(0x0eu, uuid.data_4[6]);
+ EXPECT_EQ(0x0fu, uuid.data_4[7]);
+}
+
+} // namespace
« util/misc/uuid.h ('K') | « util/misc/uuid.cc ('k') | util/stdlib/strlcpy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698