Removed Boost dependency in unit tests.
Some of the unit tests depended on Boost’s null_sink to redirect the unwanted test output to /dev/null. This commit adds a simple NullOutputStream as a replacement and removes the obsolete Boost includes.
This commit is contained in:
parent
72fc7493b2
commit
ca7ae883ee
44
tests/NullOutputStream.h
Normal file
44
tests/NullOutputStream.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef __PLASP__TESTS__NULL_OUTPUT_STREAM_H
|
||||
#define __PLASP__TESTS__NULL_OUTPUT_STREAM_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NullOutputStream
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class NullStreamBuffer : public std::streambuf
|
||||
{
|
||||
private:
|
||||
char dummyBuffer[64];
|
||||
|
||||
protected:
|
||||
virtual int overflow(int c)
|
||||
{
|
||||
setp(dummyBuffer, dummyBuffer + sizeof(dummyBuffer));
|
||||
return (c == traits_type::eof()) ? '\0' : c;
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class NullOutputStream : public std::ostream
|
||||
{
|
||||
public:
|
||||
NullOutputStream()
|
||||
: std::ostream(&m_nullStreamBuffer)
|
||||
{
|
||||
}
|
||||
|
||||
NullStreamBuffer *rdbuf() const
|
||||
{
|
||||
return &m_nullStreamBuffer;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable NullStreamBuffer m_nullStreamBuffer;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,7 +1,6 @@
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
#include <boost/iostreams/device/null.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include <colorlog/Logger.h>
|
||||
|
||||
@ -11,15 +10,17 @@
|
||||
|
||||
#include <plasp/pddl/TranslatorASP.h>
|
||||
|
||||
boost::iostreams::stream<boost::iostreams::null_sink> nullStream((boost::iostreams::null_sink()));
|
||||
#include "NullOutputStream.h"
|
||||
|
||||
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_CASE("[PDDL translation] Former issues are fixed", "[PDDL translation]")
|
||||
{
|
||||
// TODO: refactor
|
||||
colorlog::Logger logger(nullStream, nullStream);
|
||||
NullOutputStream nullOutputStream;
|
||||
|
||||
colorlog::Logger logger(nullOutputStream, nullOutputStream);
|
||||
pddl::Tokenizer tokenizer;
|
||||
pddl::Context context(std::move(tokenizer), ignoreWarnings);
|
||||
|
||||
|
Reference in New Issue
Block a user