Explorar el Código

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

Aleksandar Fabijanic hace 18 años
padre
commit
0a1c616368

+ 2 - 2
Foundation/include/Poco/Buffer.h

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

+ 1 - 1
Foundation/include/Poco/FunctionDelegate.h

@@ -49,7 +49,7 @@ namespace Poco {
 
 template <class TArgs, bool hasSender = true, bool senderIsConst = true> 
 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
 {
 public:

+ 1 - 1
Foundation/src/UUID.cpp

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

+ 26 - 0
Foundation/testsuite/src/CoreTest.cpp

@@ -37,13 +37,17 @@
 #include "Poco/Exception.h"
 #include "Poco/Environment.h"
 #include "Poco/Thread.h"
+#include "Poco/Buffer.h"
 #include <iostream>
+#include <vector>
+#include <memory.h>
 
 
 using Poco::Bugcheck;
 using Poco::Exception;
 using Poco::Environment;
 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()
 {
 }
@@ -160,6 +185,7 @@ CppUnit::Test* CoreTest::suite()
 	CppUnit_addTest(pSuite, CoreTest, testFixedLength);
 	CppUnit_addTest(pSuite, CoreTest, testBugcheck);
 	CppUnit_addTest(pSuite, CoreTest, testEnvironment);
+	CppUnit_addTest(pSuite, CoreTest, testBuffer);
 
 	return pSuite;
 }

+ 1 - 0
Foundation/testsuite/src/CoreTest.h

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