Skip to content

Commit

Permalink
termbench: Add crafted test case
Browse files Browse the repository at this point in the history
  • Loading branch information
christianparpart committed Mar 18, 2024
1 parent 869f12f commit ce187cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions libtermbench/termbench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@ namespace
writeChar(_sink, 'm');
}

class CraftedTest: public Test
{
public:
explicit CraftedTest(std::string name, std::string description, std::string text) noexcept:
Test(std::move(name), std::move(description)), _text { std::move(text) }
{
}

void fill(Buffer& _sink) noexcept override { _sink.write(_text); }

private:
std::string _text;
};

class ManyLines: public Test
{
public:
Expand Down Expand Up @@ -386,4 +400,9 @@ std::unique_ptr<Test> sgrbg_line(size_t N)
return std::make_unique<Line>(name, text);
}

std::unique_ptr<Test> crafted(std::string name, std::string description, std::string text)
{
return std::make_unique<CraftedTest>(std::move(name), std::move(description), std::move(text));
}

} // namespace termbench::tests
1 change: 1 addition & 0 deletions libtermbench/termbench.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ std::unique_ptr<Test> binary();
std::unique_ptr<Test> ascii_line(size_t);
std::unique_ptr<Test> sgr_line(size_t);
std::unique_ptr<Test> sgrbg_line(size_t);
std::unique_ptr<Test> crafted(std::string name, std::string description, std::string text);
} // namespace termbench::tests

0 comments on commit ce187cb

Please sign in to comment.