summaryrefslogtreecommitdiff
path: root/yapf/unittest/test_blob.h
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2006-05-27 16:12:16 +0000
committerKUDr <kudr@openttd.org>2006-05-27 16:12:16 +0000
commit5e73dce0e71791b87e5b096a890578eefcc26639 (patch)
treee4580db6e03032a997fce1392929b7190dc3b03d /yapf/unittest/test_blob.h
parent3d01010440440cfbffd1e5d3b0cf1f23f0503a76 (diff)
downloadopenttd-5e73dce0e71791b87e5b096a890578eefcc26639.tar.xz
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
Diffstat (limited to 'yapf/unittest/test_blob.h')
-rw-r--r--yapf/unittest/test_blob.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/yapf/unittest/test_blob.h b/yapf/unittest/test_blob.h
new file mode 100644
index 000000000..5f266b0f7
--- /dev/null
+++ b/yapf/unittest/test_blob.h
@@ -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;
+}