PackedList iterator bugfix

- compare iteratorBase == iteratorBase by value, not position
  thus this works
      list[a] == list[b] ...

- compare iterator == iteratorBase and const_iterator == iteratorBase
  by position, not value. The inheritance rules means that this works:
      iter == list.end() ...
  this will compare positions:
      iter == list[5];
  Of course, this will still compare values:
      *iter == list[5];
This commit is contained in:
Mark Olesen
2009-02-27 13:43:43 +01:00
parent 576d9388f0
commit dbc9b7427a
3 changed files with 99 additions and 5 deletions

View File

@ -73,6 +73,50 @@ int main(int argc, char *argv[])
list1[1] = list1[8] = list1[10] = list1[14] = 2;
list1.print(Info);
Info<< "\ntest operator== between references\n";
if (list1[1] == list1[8])
{
Info<< "[1] == [8] (expected)\n";
}
else
{
Info<< "[1] != [8] (unexpected)\n";
}
if (list1[0] != list1[1])
{
Info<< "[0] != [1] (expected)\n";
}
else
{
Info<< "[0] == [1] (unexpected)\n";
}
Info<< "\ntest operator== with iterator\n";
{
PackedList<3>::iterator iter = list1[1];
if (iter != list1[8])
{
Info<< "iter != [8] (expected)\n";
}
else
{
Info<< "iter == [8] (unexpected)\n";
}
if (*iter != list1[8])
{
Info<< "*iter != [8] (unexpected)\n";
}
else
{
Info<< "*iter == [8] (expected)\n";
}
}
{
const PackedList<3>& constLst = list1;
Info<< "\ntest operator[] const with out-of-range index\n";