bUUID: make it explicit the default constructor produces the nil value

The implicit default constructor zeroes all plain data fields, and now
this behaviour is explicit & tested for in a unit test.
This commit is contained in:
Sybren A. Stüvel
2021-09-23 18:27:15 +02:00
parent 18a4dc869d
commit 0a8a726014
2 changed files with 6 additions and 0 deletions

View File

@@ -78,6 +78,9 @@ namespace blender {
class bUUID : public ::bUUID {
public:
/**
* Default constructor, used with `bUUID value{};`, will initialise to the nil UUID.
*/
bUUID() = default;
/** Initialise from the bUUID DNA struct. */

View File

@@ -54,9 +54,12 @@ TEST(BLI_uuid, nil_value)
{
const bUUID nil_uuid = BLI_uuid_nil();
const bUUID zeroes_uuid{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const bUUID default_constructed{};
EXPECT_EQ(nil_uuid, zeroes_uuid);
EXPECT_TRUE(BLI_uuid_is_nil(nil_uuid));
EXPECT_TRUE(BLI_uuid_is_nil(default_constructed))
<< "Default constructor should produce the nil value.";
std::string buffer(36, '\0');
BLI_uuid_format(buffer.data(), nil_uuid);