mirror of
https://github.com/chromium/crashpad.git
synced 2025-01-14 01:08:01 +08:00
Put back the standard-layout checks lost in 5bbb7e8abbe0.
TEST=util_test UUID.UUID R=rsesek@chromium.org Review URL: https://codereview.chromium.org/440603002
This commit is contained in:
parent
9f6d86742d
commit
4ae57690fa
@ -19,9 +19,21 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/sys_byteorder.h"
|
||||
#include "util/stdlib/cxx.h"
|
||||
|
||||
#if CXX_LIBRARY_VERSION >= 2011
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
COMPILE_ASSERT(sizeof(UUID) == 16, UUID_must_be_16_bytes);
|
||||
|
||||
#if CXX_LIBRARY_VERSION >= 2011
|
||||
COMPILE_ASSERT(std::is_standard_layout<UUID>::value,
|
||||
UUID_must_be_standard_layout);
|
||||
#endif
|
||||
|
||||
UUID::UUID() : data_1(0), data_2(0), data_3(0), data_4(), data_5() {
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ namespace crashpad {
|
||||
//! primarily by Microsoft.
|
||||
//!
|
||||
//! A %UUID is a unique 128-bit number specified by RFC 4122.
|
||||
//!
|
||||
//! This is a standard-layout structure.
|
||||
struct UUID {
|
||||
//! \brief Initializes the %UUID to zero.
|
||||
UUID();
|
||||
|
@ -99,6 +99,21 @@ TEST(UUID, UUID) {
|
||||
EXPECT_EQ(0x11u, uuid.data_5[4]);
|
||||
EXPECT_EQ(0x00u, uuid.data_5[5]);
|
||||
EXPECT_EQ("ffeeddcc-bbaa-9988-7766-554433221100", uuid.ToString());
|
||||
|
||||
// Test that UUID is standard layout.
|
||||
memset(&uuid, 0x45, 16);
|
||||
EXPECT_EQ(0x45454545u, uuid.data_1);
|
||||
EXPECT_EQ(0x4545u, uuid.data_2);
|
||||
EXPECT_EQ(0x4545u, uuid.data_3);
|
||||
EXPECT_EQ(0x45u, uuid.data_4[0]);
|
||||
EXPECT_EQ(0x45u, uuid.data_4[1]);
|
||||
EXPECT_EQ(0x45u, uuid.data_5[0]);
|
||||
EXPECT_EQ(0x45u, uuid.data_5[1]);
|
||||
EXPECT_EQ(0x45u, uuid.data_5[2]);
|
||||
EXPECT_EQ(0x45u, uuid.data_5[3]);
|
||||
EXPECT_EQ(0x45u, uuid.data_5[4]);
|
||||
EXPECT_EQ(0x45u, uuid.data_5[5]);
|
||||
EXPECT_EQ("45454545-4545-4545-4545-454545454545", uuid.ToString());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user