diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-10-12 12:22:48 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-10-12 12:25:24 +0300 |
commit | ac657bee0142f96fcd3fa5d56455658834a19b19 (patch) | |
tree | c42d64080a0fa651a8f654c3fff78172282fc796 /source/blender/blenkernel/intern/asset_catalog_path.cc | |
parent | 29e5dc1b197908e09d0872267500b79c8f41c317 (diff) |
Tests: simplify asset catalog tree testing code
Simplify the testing code that verifies the asset catalog tree. It now
prints clearer error messages when things go wrong, and it gets simpler
data to test (instead of having to explicitly pass the parent count, it
just counts the number of separators in the expected path).
No functional changes to Blender.
Diffstat (limited to 'source/blender/blenkernel/intern/asset_catalog_path.cc')
-rw-r--r-- | source/blender/blenkernel/intern/asset_catalog_path.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/asset_catalog_path.cc b/source/blender/blenkernel/intern/asset_catalog_path.cc index 85b8969cb8c..fec2b76e7a1 100644 --- a/source/blender/blenkernel/intern/asset_catalog_path.cc +++ b/source/blender/blenkernel/intern/asset_catalog_path.cc @@ -64,6 +64,16 @@ const std::string &AssetCatalogPath::str() const return this->path_; } +StringRefNull AssetCatalogPath::name() const +{ + const size_t last_sep_index = this->path_.rfind(SEPARATOR); + if (last_sep_index == std::string::npos) { + return StringRefNull(this->path_); + } + + return StringRefNull(this->path_.c_str() + last_sep_index + 1); +} + /* In-class operators, because of the implicit `AssetCatalogPath(StringRef)` constructor. * Otherwise `string == string` could cast both sides to `AssetCatalogPath`. */ bool AssetCatalogPath::operator==(const AssetCatalogPath &other_path) const |