summaryrefslogtreecommitdiff
path: root/tests/test_tools_5.cc
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-12-10 22:30:12 +0100
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-12-10 22:30:12 +0100
commit429d5f88b94ff28416cbfc6420b6389fa284df97 (patch)
treefb6fdaf7731de1ef396f98b748c56f3149801c84 /tests/test_tools_5.cc
Import RTFL 0.1.1v0.1.1
Diffstat (limited to 'tests/test_tools_5.cc')
-rw-r--r--tests/test_tools_5.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_tools_5.cc b/tests/test_tools_5.cc
new file mode 100644
index 0000000..9f5f957
--- /dev/null
+++ b/tests/test_tools_5.cc
@@ -0,0 +1,37 @@
+#include "simple_sink.hh"
+#include "testtools.hh"
+
+using namespace rtfl::tools;
+using namespace rtfl::tests;
+
+class NotSoSimpleSink: public SimpleSink
+{
+private:
+ LinesSource *source;
+
+public:
+ NotSoSimpleSink (LinesSource *source);
+ void processLine (char *line);
+};
+
+NotSoSimpleSink::NotSoSimpleSink (LinesSource *source)
+{
+ this->source = source;
+}
+
+void NotSoSimpleSink::processLine (char *line)
+{
+ SimpleSink::processLine (line);
+ if (strcmp (line, "create") == 0)
+ source->addTimeout (2, 0);
+}
+
+int main (int argc, char *argv[])
+{
+ int fd = openPipe ("echo create; echo msg; sleep 5");
+ BlockingLinesSource source (fd);
+ NotSoSimpleSink sink (&source);
+ source.setup (&sink);
+
+ return 0;
+}