Skip to content

Commit

Permalink
More tests and a little doc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aslze committed Jun 9, 2024
1 parent 17afe05 commit 0ed8190
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions include/asl/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ class Array
int length() const {return d().n;}

/**
Reserves space for m elements without increasing actual length (to make appending faster),
but decreases length if m is less than current size
Reserves space for m elements without increasing actual length (to make appending faster)
*/
Array& reserve(int m);
/**
Expand Down
23 changes: 23 additions & 0 deletions tests/unittests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,29 @@ ASL_TEST(Array)
}
ASL_ASSERT(s == 26);
#endif

for (int i = 1, n = 1; i < 10; i++, n*=4)
{
int s = 0;
Array<int> a;
for (int j = 0; j < n; j++)
{
if (i % 2 == 0)
{
a.resize(a.length() + 1);
a.last() = j;
}
else
a << j;
s += j;
}
Array<int> b = a.clone();
int s2 = 0;
foreach (int x, b)
s2 += x;

ASL_EXPECT(s2, ==, s);
}
}


Expand Down

0 comments on commit 0ed8190

Please sign in to comment.