Skip to content

Commit

Permalink
[core] add tests for lambda op name
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelKoch committed Aug 15, 2024
1 parent 4e574a9 commit 6e3f78d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions core/test/base/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,42 @@ TEST_F(ExecutorLogging, LogsOperation)
}


struct NameLogger : public gko::log::Logger {
protected:
void on_operation_launched(const gko::Executor* exec,
const gko::Operation* op) const override
{
op_name = op->get_name();
}

public:
mutable std::string op_name;
};


TEST(LambdaOperation, CanSetName)
{
auto name_logger = std::make_shared<NameLogger>();
auto exec = gko::ReferenceExecutor::create();
exec->add_logger(name_logger);

exec->run(
"name", [] {}, [] {}, [] {}, [] {});

ASSERT_EQ("name", name_logger->op_name);
}


TEST(LambdaOperation, HasDefaultName)
{
auto name_logger = std::make_shared<NameLogger>();
auto exec = gko::ReferenceExecutor::create();
exec->add_logger(name_logger);

exec->run([] {}, [] {}, [] {}, [] {});

ASSERT_EQ("unname", name_logger->op_name);
}


} // namespace

0 comments on commit 6e3f78d

Please sign in to comment.