UUID: add !=
operator for comparing UUIDs
Make it possible to unit test with `EXPECT_NE(uuid1, uuid2)`.
This commit is contained in:
@@ -93,6 +93,7 @@ class bUUID : public ::bUUID {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(bUUID uuid1, bUUID uuid2);
|
bool operator==(bUUID uuid1, bUUID uuid2);
|
||||||
|
bool operator!=(bUUID uuid1, bUUID uuid2);
|
||||||
|
|
||||||
} // namespace blender
|
} // namespace blender
|
||||||
|
|
||||||
|
@@ -184,4 +184,9 @@ bool operator==(const bUUID uuid1, const bUUID uuid2)
|
|||||||
return BLI_uuid_equal(uuid1, uuid2);
|
return BLI_uuid_equal(uuid1, uuid2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!=(const bUUID uuid1, const bUUID uuid2)
|
||||||
|
{
|
||||||
|
return !(uuid1 == uuid2);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace blender
|
} // namespace blender
|
||||||
|
@@ -40,7 +40,7 @@ TEST(BLI_uuid, generate_many_random)
|
|||||||
/* Generate lots of UUIDs to get some indication that the randomness is okay. */
|
/* Generate lots of UUIDs to get some indication that the randomness is okay. */
|
||||||
for (int i = 0; i < 1000000; ++i) {
|
for (int i = 0; i < 1000000; ++i) {
|
||||||
const bUUID uuid = BLI_uuid_generate_random();
|
const bUUID uuid = BLI_uuid_generate_random();
|
||||||
EXPECT_FALSE(BLI_uuid_equal(first_uuid, uuid));
|
EXPECT_NE(first_uuid, uuid);
|
||||||
|
|
||||||
// Check that the non-random bits are set according to RFC4122.
|
// Check that the non-random bits are set according to RFC4122.
|
||||||
const uint16_t version = uuid.time_hi_and_version >> 12;
|
const uint16_t version = uuid.time_hi_and_version >> 12;
|
||||||
@@ -55,7 +55,7 @@ TEST(BLI_uuid, nil_value)
|
|||||||
const bUUID nil_uuid = BLI_uuid_nil();
|
const bUUID nil_uuid = BLI_uuid_nil();
|
||||||
const bUUID zeroes_uuid{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
const bUUID zeroes_uuid{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
EXPECT_TRUE(BLI_uuid_equal(nil_uuid, zeroes_uuid));
|
EXPECT_EQ(nil_uuid, zeroes_uuid);
|
||||||
EXPECT_TRUE(BLI_uuid_is_nil(nil_uuid));
|
EXPECT_TRUE(BLI_uuid_is_nil(nil_uuid));
|
||||||
|
|
||||||
std::string buffer(36, '\0');
|
std::string buffer(36, '\0');
|
||||||
@@ -68,8 +68,8 @@ TEST(BLI_uuid, equality)
|
|||||||
const bUUID uuid1 = BLI_uuid_generate_random();
|
const bUUID uuid1 = BLI_uuid_generate_random();
|
||||||
const bUUID uuid2 = BLI_uuid_generate_random();
|
const bUUID uuid2 = BLI_uuid_generate_random();
|
||||||
|
|
||||||
EXPECT_TRUE(BLI_uuid_equal(uuid1, uuid1));
|
EXPECT_EQ(uuid1, uuid1);
|
||||||
EXPECT_FALSE(BLI_uuid_equal(uuid1, uuid2));
|
EXPECT_NE(uuid1, uuid2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(BLI_uuid, string_formatting)
|
TEST(BLI_uuid, string_formatting)
|
||||||
|
Reference in New Issue
Block a user