mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
Added in test suite for BasicFIFOBuffer
This commit is contained in:
85
Foundation/testsuite/src/BasicFIFOBufferTest.cpp
Normal file
85
Foundation/testsuite/src/BasicFIFOBufferTest.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// BasicFIFOBufferTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/BasicFIFOBufferTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "BasicFIFOBufferTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/FIFOBuffer.h"
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
// NOTE: using for certain namespace
|
||||
using Poco::BasicFIFOBuffer;
|
||||
using std::memcpy;
|
||||
|
||||
BasicFIFOBufferTest::BasicFIFOBufferTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BasicFIFOBufferTest::~BasicFIFOBufferTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BasicFIFOBufferTest::testNextWrite()
|
||||
{
|
||||
// String length is 88 characters.
|
||||
std::string text("The Quick Brown Dog Jumps Over The Lazy Fox.");
|
||||
BasicFIFOBuffer<char> buffer(128);
|
||||
buffer.write(text.data(), text.size());
|
||||
char c_buffer[buffer.size()];
|
||||
|
||||
buffer.read(c_buffer, 4);
|
||||
|
||||
assert(std::string(c_buffer, 4) == std::string("The "));
|
||||
|
||||
buffer.peek(c_buffer, buffer.used());
|
||||
assert(std::string(c_buffer, buffer.used()) ==
|
||||
std::string("Quick Brown Dog Jumps Over The Lazy Fox."));
|
||||
|
||||
memcpy(buffer.next(), "The ", 4);
|
||||
buffer.advance(4);
|
||||
|
||||
buffer.peek(c_buffer, buffer.used());
|
||||
|
||||
assert(std::string("Quick Brown Dog Jumps Over The Lazy Fox.The ") == std::string(c_buffer, buffer.used()));
|
||||
|
||||
/*
|
||||
std::istringstream istr("foo");
|
||||
std::ostringstream ostr;
|
||||
TeeInputStream tis(istr);
|
||||
tis.addStream(ostr);
|
||||
std::string s;
|
||||
tis >> s;
|
||||
assert (ostr.str() == "foo");
|
||||
*/
|
||||
}
|
||||
|
||||
void BasicFIFOBufferTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BasicFIFOBufferTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* BasicFIFOBufferTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("BasicFIFOBufferTest");
|
||||
|
||||
CppUnit_addTest(pSuite, BasicFIFOBufferTest, testNextWrite);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
40
Foundation/testsuite/src/BasicFIFOBufferTest.h
Normal file
40
Foundation/testsuite/src/BasicFIFOBufferTest.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// BasicFIFOBufferTest.h
|
||||
//
|
||||
// $Id: //poco/1.6/Foundation/testsuite/src/BasicFIFOBufferTest.h#1 $
|
||||
//
|
||||
// Definition of the BasicFIFOBufferTest class.
|
||||
//
|
||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef BasicFIFOBufferTest_INCLUDED
|
||||
#define BasicFIFOBufferTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class BasicFIFOBufferTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
BasicFIFOBufferTest(const std::string& name);
|
||||
~BasicFIFOBufferTest();
|
||||
|
||||
void testNextWrite();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // BasicFIFOBufferTest_INCLUDED
|
||||
24
Foundation/testsuite/src/BufferTestSuite.cpp
Normal file
24
Foundation/testsuite/src/BufferTestSuite.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// BufferTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/BufferTestSuite.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "BufferTestSuite.h"
|
||||
#include "BasicFIFOBufferTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* BufferTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("BufferTestSuite");
|
||||
|
||||
pSuite->addTest(BasicFIFOBufferTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
29
Foundation/testsuite/src/BufferTestSuite.h
Normal file
29
Foundation/testsuite/src/BufferTestSuite.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// BufferTestSuite.h
|
||||
//
|
||||
// $Id: //poco/1.6/Foundation/testsuite/src/BufferTestSuite.h#1 $
|
||||
//
|
||||
// Definition of the BufferTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef BufferTestSuite_INCLUDED
|
||||
#define BufferTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class BufferTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // BufferTestSuite_INCLUDED
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "EventTestSuite.h"
|
||||
#include "CacheTestSuite.h"
|
||||
#include "HashingTestSuite.h"
|
||||
#include "BufferTestSuite.h"
|
||||
|
||||
|
||||
CppUnit::Test* FoundationTestSuite::suite()
|
||||
@@ -39,6 +40,7 @@ CppUnit::Test* FoundationTestSuite::suite()
|
||||
pSuite->addTest(CoreTestSuite::suite());
|
||||
pSuite->addTest(DateTimeTestSuite::suite());
|
||||
pSuite->addTest(StreamsTestSuite::suite());
|
||||
pSuite->addTest(BufferTestSuite::suite());
|
||||
pSuite->addTest(CryptTestSuite::suite());
|
||||
pSuite->addTest(NotificationsTestSuite::suite());
|
||||
pSuite->addTest(ThreadingTestSuite::suite());
|
||||
|
||||
Reference in New Issue
Block a user