SF items:

[1981125] std::swap_ranges overloading resolution failed
[1981130] pointless comparison of unsigned integer with zero
[1981139] initial value of reference to non-const must be an lvalue

Buffer test
FunctionDelegate comment spelling
This commit is contained in:
Aleksandar Fabijanic
2008-06-01 14:33:45 +00:00
parent 1d27e75989
commit 0a1c616368
5 changed files with 31 additions and 4 deletions

View File

@@ -102,14 +102,14 @@ public:
T& operator [] (std::size_t index) T& operator [] (std::size_t index)
{ {
poco_assert (index >= 0 && index < _size); poco_assert (index < _size);
return _ptr[index]; return _ptr[index];
} }
const T& operator [] (std::size_t index) const const T& operator [] (std::size_t index) const
{ {
poco_assert (index >= 0 && index < _size); poco_assert (index < _size);
return _ptr[index]; return _ptr[index];
} }

View File

@@ -49,7 +49,7 @@ namespace Poco {
template <class TArgs, bool hasSender = true, bool senderIsConst = true> template <class TArgs, bool hasSender = true, bool senderIsConst = true>
class FunctionDelegate: public AbstractDelegate<TArgs> class FunctionDelegate: public AbstractDelegate<TArgs>
/// Wraps a C style function (or a C++ static fucntion) to be used as /// Wraps a C style function (or a C++ static function) to be used as
/// a delegate /// a delegate
{ {
public: public:

View File

@@ -137,7 +137,7 @@ void UUID::swap(UUID& uuid)
std::swap(_timeMid, uuid._timeMid); std::swap(_timeMid, uuid._timeMid);
std::swap(_timeHiAndVersion, uuid._timeHiAndVersion); std::swap(_timeHiAndVersion, uuid._timeHiAndVersion);
std::swap(_clockSeq, uuid._clockSeq); std::swap(_clockSeq, uuid._clockSeq);
std::swap_ranges(_node, _node + 6, uuid._node); std::swap_ranges(_node, _node + 6, &uuid._node[0]);
} }

View File

@@ -37,13 +37,17 @@
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/Environment.h" #include "Poco/Environment.h"
#include "Poco/Thread.h" #include "Poco/Thread.h"
#include "Poco/Buffer.h"
#include <iostream> #include <iostream>
#include <vector>
#include <memory.h>
using Poco::Bugcheck; using Poco::Bugcheck;
using Poco::Exception; using Poco::Exception;
using Poco::Environment; using Poco::Environment;
using Poco::Thread; using Poco::Thread;
using Poco::Buffer;
// //
@@ -142,6 +146,27 @@ void CoreTest::testEnvironment()
} }
void CoreTest::testBuffer()
{
std::size_t s = 10;
Buffer<int> b(s);
std::vector<int> v;
for (int i = 0; i < s; ++i)
v.push_back(i);
std::memcpy(b.begin(), &v[0], sizeof(int) * v.size());
assert (s == b.size());
for (int i = 0; i < s; ++i)
assert (b[i] == i);
#if ENABLE_BUGCHECK_TEST
try { int i = b[s]; fail ("must fail"); }
catch (Exception&) { }
#endif
}
void CoreTest::setUp() void CoreTest::setUp()
{ {
} }
@@ -160,6 +185,7 @@ CppUnit::Test* CoreTest::suite()
CppUnit_addTest(pSuite, CoreTest, testFixedLength); CppUnit_addTest(pSuite, CoreTest, testFixedLength);
CppUnit_addTest(pSuite, CoreTest, testBugcheck); CppUnit_addTest(pSuite, CoreTest, testBugcheck);
CppUnit_addTest(pSuite, CoreTest, testEnvironment); CppUnit_addTest(pSuite, CoreTest, testEnvironment);
CppUnit_addTest(pSuite, CoreTest, testBuffer);
return pSuite; return pSuite;
} }

View File

@@ -51,6 +51,7 @@ public:
void testBugcheck(); void testBugcheck();
void testFPE(); void testFPE();
void testEnvironment(); void testEnvironment();
void testBuffer();
void setUp(); void setUp();
void tearDown(); void tearDown();