mirror of
https://github.com/fmang/opustags.git
synced 2025-03-14 08:30:08 +01:00
Handlers: implement export tags handler
This commit is contained in:
parent
84a8d14ae0
commit
a3daa0f108
@ -7,21 +7,25 @@ ExportTagsHandler::ExportTagsHandler(std::ostream &output_stream)
|
||||
{
|
||||
}
|
||||
|
||||
bool ExportTagsHandler::relevant(const int streamno)
|
||||
bool ExportTagsHandler::relevant(const int)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ExportTagsHandler::list(const int streamno, const Tags &)
|
||||
void ExportTagsHandler::list(const int streamno, const Tags &tags)
|
||||
{
|
||||
output_stream << "[Stream " << streamno << "]\n";
|
||||
for (const auto tag : tags.get_all())
|
||||
output_stream << tag.key << "=" << tag.value << "\n";
|
||||
output_stream << "\n";
|
||||
}
|
||||
|
||||
bool ExportTagsHandler::edit(const int streamno, Tags &)
|
||||
bool ExportTagsHandler::edit(const int, Tags &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExportTagsHandler::done()
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
23
tests/tags_handlers/export_tags_handler_test.cc
Normal file
23
tests/tags_handlers/export_tags_handler_test.cc
Normal file
@ -0,0 +1,23 @@
|
||||
#include "tags_handlers/export_tags_handler.h"
|
||||
#include "catch.h"
|
||||
#include <sstream>
|
||||
|
||||
using namespace opustags;
|
||||
|
||||
TEST_CASE("export tags handler", "[tags_handlers]")
|
||||
{
|
||||
std::stringstream ss;
|
||||
ExportTagsHandler handler(ss);
|
||||
handler.list(1, {{{"a", "value1"}, {"b", "value2"}}});
|
||||
handler.list(2, {{{"c", "value3"}, {"d", "value4"}}});
|
||||
|
||||
REQUIRE(ss.str() == R"([Stream 1]
|
||||
a=value1
|
||||
b=value2
|
||||
|
||||
[Stream 2]
|
||||
c=value3
|
||||
d=value4
|
||||
|
||||
)");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user