mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-25 15:39:09 +00:00
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
This commit is contained in:
61
yapf/unittest/test_blob.h
Normal file
61
yapf/unittest/test_blob.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $Id$ */
|
||||
|
||||
static int TestBlob1(bool silent)
|
||||
{
|
||||
typedef CBlobT<int64> Blob;
|
||||
int res = 0;
|
||||
{
|
||||
Blob a;
|
||||
Blob b;
|
||||
CHECK_INT(0, a.IsEmpty(), true);
|
||||
CHECK_INT(1, a.Size(), 0);
|
||||
|
||||
const int nItems = 10;
|
||||
|
||||
{
|
||||
for (int i = 1; i <= nItems; i++) {
|
||||
a.Append(i);
|
||||
CHECK_INT(2, a.IsEmpty(), false);
|
||||
CHECK_INT(3, a.Size(), i);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (int i = 1; i <= nItems; i++) {
|
||||
CHECK_INT(4, *a.Data(i - 1), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static int TestBlob2(bool silent)
|
||||
{
|
||||
typedef CBlobT<CFsaItem> Blob;
|
||||
int res = 0;
|
||||
{
|
||||
Blob a;
|
||||
Blob b;
|
||||
CHECK_INT(0, a.IsEmpty(), true);
|
||||
CHECK_INT(1, a.Size(), 0);
|
||||
|
||||
const int nItems = 10;
|
||||
|
||||
{
|
||||
for (int i = 1; i <= nItems; i++) {
|
||||
a.Append(CFsaItem(i));
|
||||
CHECK_INT(2, a.IsEmpty(), false);
|
||||
CHECK_INT(3, a.Size(), i);
|
||||
}
|
||||
}
|
||||
{
|
||||
for (int i = 1; i <= nItems; i++) {
|
||||
CHECK_INT(4, a.Data(i - 1)->i, i);
|
||||
}
|
||||
}
|
||||
CHECK_INT(15, CFsaItem::NumInstances(), nItems);
|
||||
}
|
||||
CHECK_INT(16, CFsaItem::NumInstances(), 0);
|
||||
|
||||
return res;
|
||||
}
|
Reference in New Issue
Block a user