Skip to content

Commit

Permalink
Some missing test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Jan 16, 2024
1 parent 387654f commit f745a0d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/takane/_height.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ inline auto default_registry() {
* For vectors or other 1-dimensional objects, the height is usually just the length of the object (for some object-specific definition of "length").
* For higher-dimensional objects, the height is usually the extent of the first dimension.
*
* Applications can supply custom height functions for a given type via the `Options::custom_height`.
* Applications can supply custom height functions for a given type via `Options::custom_height`.
* If available, the supplied custom function will be used instead of the default.
*
* @param path Path to a directory representing an object.
Expand Down
6 changes: 1 addition & 5 deletions include/takane/_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,14 @@ inline auto default_registry() {
/**
* Validate an object in a subdirectory, based on the supplied object type.
*
* Applications can supply custom validation functions for a given type via the `Options::custom_validate`.
* Applications can supply custom validation functions for a given type via `Options::custom_validate`.
* If available, the supplied custom function will be used instead of the default.
*
* @param path Path to a directory representing an object.
* @param metadata Metadata for the object, typically determined from its `OBJECT` file.
* @param options Validation options.
*/
inline void validate(const std::filesystem::path& path, const ObjectMetadata& metadata, Options& options) {
if (!std::filesystem::exists(path) || std::filesystem::status(path).type() != std::filesystem::file_type::directory) {
throw std::runtime_error("expected '" + path.string() + "' to be a directory");
}

auto cIt = options.custom_validate.find(metadata.type);
if (cIt != options.custom_validate.end()) {
try {
Expand Down
3 changes: 3 additions & 0 deletions tests/src/dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ TEST(GenericDispatch, Validate) {

opts.custom_validate["foobar"] = [](const std::filesystem::path&, const takane::ObjectMetadata&, const takane::Options&) -> void {};
test_validate(dir, opts);

opts.custom_validate["foobar"] = [](const std::filesystem::path&, const takane::ObjectMetadata&, const takane::Options&) -> void { throw std::runtime_error("YAY"); };
expect_validation_error(dir, "YAY", opts);
}

template<typename ... Args_>
Expand Down

0 comments on commit f745a0d

Please sign in to comment.