From 0a8a726014fb4135414eedbe98170790fe09c2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 23 Sep 2021 18:27:15 +0200 Subject: 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. --- source/blender/blenlib/BLI_uuid.h | 3 +++ source/blender/blenlib/tests/BLI_uuid_test.cc | 3 +++ 2 files changed, 6 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_uuid.h b/source/blender/blenlib/BLI_uuid.h index eef37841d15..7ac676b7617 100644 --- a/source/blender/blenlib/BLI_uuid.h +++ b/source/blender/blenlib/BLI_uuid.h @@ -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. */ diff --git a/source/blender/blenlib/tests/BLI_uuid_test.cc b/source/blender/blenlib/tests/BLI_uuid_test.cc index b5d636ed1c3..f2160f614ba 100644 --- a/source/blender/blenlib/tests/BLI_uuid_test.cc +++ b/source/blender/blenlib/tests/BLI_uuid_test.cc @@ -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); -- cgit v1.2.3