Bugfix: irrArray should no longer crash when using other allocators. Corresponding test added. This was

caused because operator= and copy-constructor where not called because the the second template parameters 
was not used in those function declarations and so only functions for the default parameter had been 
created. 


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2949 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2009-11-30 14:51:59 +00:00
parent e7b200fef4
commit 09b4f29944
5 changed files with 54 additions and 5 deletions

View File

@ -1,5 +1,7 @@
Changes in 1.7
- Bugfix: irrArray should no longer crash when using other allocators.
- Add MaterialViewer example.
- Checkbox uses now disabled text color when disabled.

View File

@ -42,7 +42,7 @@ public:
//! Copy constructor
array(const array<T>& other) : data(0)
array(const array<T, TAlloc>& other) : data(0)
{
*this = other;
}
@ -247,7 +247,7 @@ public:
//! Assignment operator
void operator=(const array<T>& other)
void operator=(const array<T, TAlloc>& other)
{
strategy = other.strategy;
@ -271,7 +271,7 @@ public:
//! Equality operator
bool operator == (const array<T>& other) const
bool operator == (const array<T, TAlloc>& other) const
{
if (used != other.used)
return false;
@ -284,7 +284,7 @@ public:
//! Inequality operator
bool operator != (const array<T>& other) const
bool operator != (const array<T, TAlloc>& other) const
{
return !(*this==other);
}

View File

@ -52,6 +52,7 @@ int main(int argumentCount, char * arguments[])
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
// Now the simple tests without device
TEST(testArray);
TEST(exports);
TEST(irrCoreEquals);
TEST(testIrrString);

46
tests/testArray.cpp Normal file
View File

@ -0,0 +1,46 @@
// Copyright (C) 2008-2009 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include <irrlicht.h>
#include <assert.h>
using namespace irr;
using namespace core;
struct VarArray
{
core::array < int, core::irrAllocatorFast<int> > MyArray;
};
// this will (did once) simply crash when wrong, so no return value
void crashTestFastAlloc()
{
core::array < VarArray, core::irrAllocatorFast<VarArray> > ArrayArray;
ArrayArray.setAllocStrategy(core::ALLOC_STRATEGY_SAFE); // force more re-allocations
VarArray var;
var.MyArray.setAllocStrategy(core::ALLOC_STRATEGY_SAFE); // force more re-allocations
var.MyArray.push_back( 0 );
for ( int i=0; i< 100; ++i )
{
ArrayArray.push_back(var);
ArrayArray.push_back(var);
}
}
// Test the functionality of core::array
bool testArray(void)
{
bool allExpected = true;
logTestString("crashTestFastAlloc\n");
crashTestFastAlloc();
if(allExpected)
logTestString("\nAll tests passed\n");
else
logTestString("\nFAIL!\n");
return allExpected;
}

View File

@ -1,2 +1,2 @@
Test suite pass at GMT Mon Nov 30 14:06:12 2009
Test suite pass at GMT Mon Nov 30 14:42:09 2009