diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-09-24 13:55:26 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-09-24 15:42:48 +0300 |
commit | ab9644382d14eb1254ce33e38227c874fd80a08f (patch) | |
tree | 935086c54a7b60d0597fb99330ec292ff118d8eb /source/blender/blenlib/tests/BLI_uuid_test.cc | |
parent | 2b9ca0f112ad41e9402d272cc0c691bd5e1c5956 (diff) |
UUID: add less-than operator
Add `operator<` to C++ class to allow lexicographic ordering of UUIDs.
This will be necessary when writing asset catalogs to disk in a predictable
(i.e. ordered) manner.
Diffstat (limited to 'source/blender/blenlib/tests/BLI_uuid_test.cc')
-rw-r--r-- | source/blender/blenlib/tests/BLI_uuid_test.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_uuid_test.cc b/source/blender/blenlib/tests/BLI_uuid_test.cc index f2160f614ba..b406a0521a1 100644 --- a/source/blender/blenlib/tests/BLI_uuid_test.cc +++ b/source/blender/blenlib/tests/BLI_uuid_test.cc @@ -75,6 +75,29 @@ TEST(BLI_uuid, equality) EXPECT_NE(uuid1, uuid2); } +TEST(BLI_uuid, comparison_trivial) +{ + const bUUID uuid0{}; + const bUUID uuid1("11111111-1111-1111-1111-111111111111"); + const bUUID uuid2("22222222-2222-2222-2222-222222222222"); + + EXPECT_LT(uuid0, uuid1); + EXPECT_LT(uuid0, uuid2); + EXPECT_LT(uuid1, uuid2); +} + +TEST(BLI_uuid, comparison_byte_order_check) +{ + const bUUID uuid0{}; + /* Chosen to test byte ordering is taken into account correctly when comparing. */ + const bUUID uuid12("12222222-2222-2222-2222-222222222222"); + const bUUID uuid21("21111111-1111-1111-1111-111111111111"); + + EXPECT_LT(uuid0, uuid12); + EXPECT_LT(uuid0, uuid21); + EXPECT_LT(uuid12, uuid21); +} + TEST(BLI_uuid, string_formatting) { bUUID uuid; |