6 #include "knowrob/queries/TokenBuffer.h"
7 #include "knowrob/queries/TokenQueue.h"
8 #include "knowrob/Logger.h"
9 #include "knowrob/integration/python/utils.h"
10 #include "knowrob/queries/AnswerDontKnow.h"
11 #include <gtest/gtest.h>
40 auto queue = std::make_shared<TokenQueue>();
61 class_<TokenBuffer, std::shared_ptr<TokenBuffer>, bases<TokenBroadcaster>, boost::noncopyable>
62 (
"TokenBuffer", init<>())
69 auto out = std::make_shared<TokenBuffer>();
71 auto dontKnow = std::make_shared<AnswerDontKnow>();
72 channel->push(dontKnow);
74 auto queue = out->createQueue();
75 std::vector<TokenPtr> tokens;
76 while (!queue->empty()) {
77 auto tok = queue->pop_front();
78 tokens.push_back(tok);
80 ASSERT_EQ(tokens.size(), 2);
81 ASSERT_EQ(tokens[0], dontKnow);
TEST(TokenBuffer, twoTokens)
void addSubscriber(const std::shared_ptr< Channel > &subscriber)
void push(const TokenPtr &tok) override
void push(const TokenPtr &tok) override
std::list< TokenPtr > buffer_
std::atomic< bool > isBuffering_
std::shared_ptr< TokenQueue > createQueue()
static std::shared_ptr< Channel > create(const std::shared_ptr< TokenStream > &stream)
void createType< TokenBuffer >()
std::shared_ptr< const Token > TokenPtr