Index: util/misc/uuid_test.cc |
diff --git a/util/misc/uuid_test.cc b/util/misc/uuid_test.cc |
index 2e3bea32344a2dea24c980468987cfb2c62ef6b1..5d515cc6dc0fcbde463039ebe1f2776778407531 100644 |
--- a/util/misc/uuid_test.cc |
+++ b/util/misc/uuid_test.cc |
@@ -70,6 +70,39 @@ TEST(UUID, UUID) { |
EXPECT_EQ(0x0fu, uuid.data_5[5]); |
EXPECT_EQ("00010203-0405-0607-0809-0a0b0c0d0e0f", uuid.ToString()); |
+ // Test both operator== and operator!=. |
+ EXPECT_FALSE(uuid == uuid_zero); |
+ EXPECT_NE(uuid, uuid_zero); |
+ |
+ UUID uuid_2(kBytes); |
+ EXPECT_EQ(uuid, uuid_2); |
+ EXPECT_FALSE(uuid != uuid_2); |
+ |
+ // Make sure that operator== and operator!= check the entire UUID. |
+ ++uuid.data_1; |
+ EXPECT_NE(uuid, uuid_2); |
+ --uuid.data_1; |
+ ++uuid.data_2; |
+ EXPECT_NE(uuid, uuid_2); |
+ --uuid.data_2; |
+ ++uuid.data_3; |
+ EXPECT_NE(uuid, uuid_2); |
+ --uuid.data_3; |
+ for (size_t index = 0; index < arraysize(uuid.data_4); ++index) { |
+ ++uuid.data_4[index]; |
+ EXPECT_NE(uuid, uuid_2); |
+ --uuid.data_4[index]; |
+ } |
+ for (size_t index = 0; index < arraysize(uuid.data_5); ++index) { |
+ ++uuid.data_5[index]; |
+ EXPECT_NE(uuid, uuid_2); |
+ --uuid.data_5[index]; |
+ } |
+ |
+ // Make sure that the UUIDs are equal again, otherwise the test above may not |
+ // have been valid. |
+ EXPECT_EQ(uuid, uuid_2); |
+ |
const uint8_t kMoreBytes[16] = {0xff, |
0xee, |
0xdd, |
@@ -100,6 +133,9 @@ TEST(UUID, UUID) { |
EXPECT_EQ(0x00u, uuid.data_5[5]); |
EXPECT_EQ("ffeeddcc-bbaa-9988-7766-554433221100", uuid.ToString()); |
+ EXPECT_NE(uuid, uuid_2); |
+ EXPECT_NE(uuid, uuid_zero); |
+ |
// Test that UUID is standard layout. |
memset(&uuid, 0x45, 16); |
EXPECT_EQ(0x45454545u, uuid.data_1); |